OK, since your goal is to make the code run as fast as possible, let me suggest how to do it. I'm not a VisualVM specialist, but I can tell you what works. (Only a few profilers actually tell you what you need to know, namely: which lines of your code on the stack make up a healthy fraction of the wall clock time.)
The only measurement I've ever come across is a stopwatch in total time, or, alternatively, if the code has something like frame rate, frames per second. I do not need any further precision breakdown, because at best it is a remote key to what is wasting time (and most often completely inappropriate) when there is a very direct way to find it.
If you do not want to make a random pause , thatβs up to you, but it turned out to be effective, and here is an example of acceleration of 43 times .
Basically, the idea is that you get (small, like 10) the number of stack samples, which is taken randomly from a wall clock. Each sample consists (obviously) of a list of call sites and, possibly, a site without a call at the end. (If the sample is during I / O or sleep, it will end in a system call, which is very good. This is what you want to know.)
If there is a way to speed up your code (and there is almost certainly there), you will see it as a line of code that appears in at least one of the stack samples. The likelihood that he will appear on any one sample is exactly the same as the fraction of the time that she uses. Therefore, if there is a call site or another line of code using a healthy fraction of the time, and you can avoid its execution, the total time will decrease by this fraction.
I do not know every profiler, but I know that I can say that it is Zoom . Others can do it. They may be more flexible, but they do not work faster or better than the manual method when your goal is to maximize performance.