Note that there are some explanatory texts on larger screens.

plurals
  1. POJMX: CPU + Blocked + Wait time = Wall time?
    primarykey
    data
    text
    <p>I'm trying to use JMX for measuring how long a method call took and how much of that was CPU time, how much was the thread being blocked and how much was waiting. Ideally, I would expect that <strong>CPU time + Block time + Wait time = Wall time</strong>, but I've noticed that it's not the case - and it's not just slightly inaccurate timer. For example:</p> <pre><code>Wall time: 5657.305 ms CPU time: 4060.000 ms (71.77%) User time: 3840.000 ms (67.88%) Block time: 0.000 ms (0.00%) Wait time: 0.000 ms (0.00%) </code></pre> <p>So, the question is ... <strong>is my presumption</strong> that the sum of these times (not User time, that's included in CPU time) should give Wall time <strong>wrong?</strong> Am I missing something?</p> <p>Some more details:</p> <ul> <li><p>Wall time: difference of <code>System.currentTimeMillis()</code> at the method entry and exit</p></li> <li><p>CPU time: difference of <code>ManagementFactory.getThreadMXBean().getCurrentThreadCpuTime()</code> at the method entry and exit</p></li> <li><p>Block and Wait time: analogically to CPU, with <code>ManagementFactory.getThreadMXBean().getThreadInfo(Thread.currentThread().getId()).getBlockedTime()</code> and <code>getWaitedTime()</code></p></li> <li><p>Yes, I do know that these methods return time in different units (ns/ms), I take that into account.</p></li> <li><p>The application is highly hyperthreaded (4000+ threads), but I store all the info per thread, so there <em>shouldn't</em> be any interference between calls from different threads.</p></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload