70

I've been searching all over for a consistent and clear explanation of what 'self time' actually refers to in the VisualVM context and how does it differ to 'self time (cpu)'. Also does 'self time [%]' refer to self time or self time cpu.

There doesn't appear to be much documentation on this or at least I haven't found it. So any thoughts/input will be appreciated.

AndyF
  • 1,074
  • 1
  • 12
  • 19

1 Answers1

97
  • Self Time is a wall-clock time spent in the method itself (includes time waiting/sleeping).
  • Self Time (CPU) is a time processor time, so it does NOT include time spent waiting, sleeping, etc.

  • Both columns do NOT include time spent in methods invoked from that method.
  • Both Self Time and Self Time (CPU) in the sampler are approximation of actual data.
  • Self Time [%] refers to one of the two selected Self Time [(CPU)] columns.
Andrei Damian-Fekete
  • 1,820
  • 21
  • 27
Tomas Hurka
  • 6,723
  • 29
  • 38
  • 18
    Adding to this even though it's an old question, in case it helps someone - it seems that 'self time [%]' will refer to whichever self time column you have sorted by. So if you sort by 'Self time (CPU)', the % will now be % of CPU time – Matt Nov 20 '13 at 17:01
  • 8
    Is it right to say that "self time" would be any time spent in sub-methods that are not instrumented to be profiled? So if method X calls method Y and Z, and method Z is not instrumented, any time spent in method Z will be the "self time" for method X? – Marquez Jun 05 '15 at 19:44
  • 7
    @Marquez I just verified this by running the profiling twice: With and without excluding java.* packages; It influences the results exactly as you suspect: CPU time spent in classes that are not instrumented are counted towards the CPU self time of the invoking instrumented class; – derwiwie Aug 14 '16 at 10:32