Search code examples
javaprofilerjprofiler

Understanding JProfiler CPU Profiling


I am trying to understand how CPU profiling works in JProfiler and for that I created a very simple Rest Service as shown below:

@RestController
public class AlertsService {
private static final Logger log = LoggerFactory.getLogger(AlertsService.class);

@GetMapping("/hello")
public String sayHello() throws InterruptedException {
    log.info("inside hello...");
    Thread.sleep(5000);
    return "hello world";
}
}

I started the App and then opened JProfiler and I clicked on "Attach" to attach to that service and selected following settings:

enter image description here

Next I went to CPU views and clicked on "record CPU data" enter image description here

After that I triggered a request to the endpoint and I got following results:

enter image description here enter image description here

As we can see we have the com.ramos.loadtest.service.AlertsService.sayHello method being displayed but for some reason it is showing 420 micro seconds in Call Tree View and 12 micro seconds in HotSpot View, what I don't understand is why is not showing at least 5000 milliseconds if that is what was specified in the service call (trying so simulate a long running process). Please help me understand, thank you.


Solution

  • By default, CPU views in JProfiler show the "Runnable" thread state. This is the time that threads can be scheduled to perform method calls. It excludes waiting and blocking on monitors as well as waiting on network input or output.

    To see the wall clock times, switch the thread state selector in the top left corner of the view to "All states".