I try to use wall clock time in intellij profiler instead of cpu time, and I change the config to wall according the post here. How to enable wall-clock profiling for Intellij Async Profiler? But it looks like doesnt' work. The following code is what I tested.
private static void f1(long mills) {
Random random = new Random();
long start = System.currentTimeMillis();
while ((System.currentTimeMillis() - start) < mills) {
Math.pow(random.nextDouble(), random.nextDouble());
}
}
private static void f2(long mills) {
long start = System.currentTimeMillis();
while ((System.currentTimeMillis() - start) < mills) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
public static void main(String[] args) throws IOException, InterruptedException {
f1(10000);
f2(10000);
}
And the following is the screenshot of frame graph of intellij async profiler. You can see that f1 take the majority of cpu time, but in wall clock time perspective, f1 and f2 should be close. Anyone know what is the right way? Thanks