How to quickly annotate a few lines of code in Java?

I want to test the runtime of some code blocks as follows:

start = System.currentTimeMillis();
{
   ...
   this.dosomething();
}
end = System.currentTimeMillis();
System.out.println(end - start);

When I optimize code blocks, how do I annotate code that calculates time quickly, as shown below?

//start = System.currentTimeMillis();
{
   ...
   this.dosomething();
}
//end = System.currentTimeMillis();
//System.out.println(end - start);

Solution

Just use the analyzer It will automatically adjust the code with the smallest floor area and display various statistics and hotspots View profiler build into jvisualvm, jpprofiler or yourkit

When you don't need it, you don't pay for anything

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>