0

I've been running the CPU Profiler in visualvm on my java process for 45 minutes, however the "Total Time" column shows only roughly 104,000ms elapsed (i.e. 104 seconds), and it grows but it grows slowly.

This clearly doesn't map to real physical time as I was expecting to see 45*60*1000 milliseconds elapsed (not 104*1000). What is it measuring?enter image description here

Naman
  • 27,789
  • 26
  • 218
  • 353
ABC
  • 693
  • 1
  • 10
  • 22
  • Can you provide a screen, so that we know, what you're asking for? – Andronicus Oct 09 '19 at 05:49
  • are you asking about [total method time in visualvm](https://stackoverflow.com/questions/1892038/total-method-time-in-java-visualvm) ? – Naman Oct 09 '19 at 05:52
  • @Andronicus I've included a picture and more info to the question – ABC Oct 09 '19 at 06:03
  • @Naman Yes that's what I'm talking about. I've been running the profiler for 45 minutes but the column `Total Time` is only showing 104 seconds accounted for. – ABC Oct 09 '19 at 06:04

1 Answers1

1

As the tooltip hover says "Time spent in all invocations on this method (including further method calls)". I.e. method specific wall-clock time, including calls done in the method.

You can compare it with the total CPU time, to see how efficiently the time is being used processor-wise.

Kayaman
  • 72,141
  • 5
  • 83
  • 121
  • Why does the column sum to 104 seconds when I've been running the profiler for 45 minutes? – ABC Oct 09 '19 at 06:03
  • @ABC because you have other programs running. You don't think the CPU is dedicated to your program, do you? Besides, unless you're really burning the CPU the times might not get too big, that's why hotspots are easier to detect and improve. – Kayaman Oct 09 '19 at 06:04
  • I have a busy while loop, I figured it would occupy the CPU 100% of the time? – ABC Oct 09 '19 at 06:06
  • @ABC You mean you have a single while(true) in a single thread in your program? That should saturate a single core yes. But still, the CPU doesn't give time to just your program, so it'll never match the wallclock time. – Kayaman Oct 09 '19 at 06:16
  • Yes, a I have a while(true). I have 32 physical cores on my machine (almost all are unused right now). I agree the CPU doesn't give time to just my program. But why _only_ 104 seconds when the time I've been profiling has been 27000 seconds? That's 0.38% of the time which seems extremely small (hence my question). – ABC Oct 09 '19 at 06:19
  • 1
    Hard to say. Try calculating hashes in that loop, and see if it makes a difference when you actually do something. – Kayaman Oct 09 '19 at 06:27
  • The 104 seconds randomly jumped up to 6300 seconds suddenly. The profiler seems buggy... – ABC Oct 09 '19 at 06:39
  • 1
    The sampler tends to be a more useful tool, at least in my experience. Doesn't have the overhead of the profiler, and still finds the hotspots efficiently. – Kayaman Oct 09 '19 at 06:41