• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

21. Java > Profile Your Code

Profile Your Code

To do code profiling in Java, you can run with the -prof option, like this:

 % java -prof MyClass.java

This profile is based on actual execution times, but doesn’t count the number of times any set of bytecode is used. The result is a profile file, which is not entirely human-readable. You can interpret the profile file with a number of free tools available on the Web, such as Hyperprof. This will tell you where your code is spending most of its time, and therefore, where you should concentrate your source code optimization efforts.

There is also the -hprof option to profile heap and CPU but it leads to 10 × inflation in time and code size. The -hprof option precludes use of JIT profiler.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint