1

I'd like to measure how much time my test method spends; but when I enable time based profiling by using event type as wall I am not getting the flame graph (or call graph) appropriate time consumption.

Expectation: All waitX methods call with relative rectangle widths in Flame Graph or % in Call Tree tab.

Actual: Only wait50s is shown in flame graph and it's width remain same irrespective of sleep time i use.

Agent Options: event=wall,interval=1ms,event=alloc

Sample Code:

 public void wait1s() throws InterruptedException {
        Thread.sleep(1000);
    }

    public void wait10s() throws InterruptedException {
        Thread.sleep(10000);
    }

    public void wait50s() throws InterruptedException {
        Thread.sleep(50000);
    }

    public void testTemp() throws Exception {
        logger.info("Starting test");
        for(int i=0;i<1;i++) {
            this.wait1s();
            this.wait10s();
            this.wait50s();
        }
        logger.info("Finished test");
    }
  • I am pretty sure that I am messing up something in AgentOptions because wait50s shows 1.94% (time?) of total, which is definitely not true. – Suraj Singh Jan 03 '22 at 02:59
  • *"which is definitely not true"* - it's true, though. Keep in mind that besides the main application thread, JVM runs donzens of other threads, and async-profiler graph includes all of them by default. So that 1.94% is relative to the total time of *all* threads. In IDEA's Flame Graph viewer you can select only those threads you are interested in, then the percentage will scale to the total time of only those threads. – apangin Jan 03 '22 at 20:45

0 Answers0