170 likes | 421 Views
Use of Profile Tool in Java. 이준표 walker@altair.snu.ac.kr. Overview. What is profile? Default profiler of JDK Other profile tool. What is profile?. A report on the amounts of time spent in each routine of a program, used to find and tune away the hotspots in it .
E N D
Use of Profile Tool in Java 이준표 walker@altair.snu.ac.kr
Overview • What is profile? • Default profiler of JDK • Other profile tool
What is profile? • A report on the amounts of time spent in each routine of a program, used to find and tune away the hotspots in it. • Some profiling modes reports units other than time(such as call counts) and/or report at granularities other than per-routine, but the idea is similar.
JDK1.1 style profile • How to get profile information? • java -prof class_file • java -Xrunhprof:cpu=old class_file(Java 2) • Output(java.prof) format • count: how many callee is called by caller • callee: called method • caller: calling method • time(msec): spent in callee when called in caller
Considerations on output • The output is initially sorted by count. • Both count and time are important to find hot-spot. • If JIT-compilation is enabled in JDK1.2, the profile information is not correct.
Output example count callee caller time 811063 BitSet.clear(I)V SieveBits.sieve()V 1994 499998 BitSet.set(I)V SieveBits.sieve()V 1223 499998 BitSet.get(I)Z SieveBits.main([Ljava/lang/String;)V 1205 5808 java/lang/String.charAt(I)C java/lang/Character.<clinit>()V 11 1774 sun/io/CharToByteDoubleByte.convSingleByte(C[B)I sun/io/CharToByteDoubleByte.convert([CII[BII)I 4 ......... 1 SieveBits.main(Ljava/lang/String;)V Unknown caller 8955 1 SieveBits.sieve()V SieveBits.main(Ljava/lang/String;)V 6538
ProfileViewer • Read profiling information of JDK1.1 style, and displays it for easy interpretation • Location http://www.capital.net/~dittmer/profileviewer.html • Requirement • swing : http://java.sun.com/products/jfc/index.html • collection : http://java.sun.com/beans/infobus
JDK 1.2 style profile • How to get profile information? • java -Xrunhprof:cpu=[times|samples] class_file • Output(java.hprof.txt) format • rank : according to self value • self : % of total samples where this method is included in the trace • accum : % of total samples where the methods from rank 1 to this are
Output example rank self accum method 1 93.12% 10.51% SieveBits.main ([Ljava/lang/String;)V 2 67.75% 39.13% SieveBits.sieve ()V 3 27.54% 66.67% BitSet.clear (I)V 4 14.49% 81.16% BitSet.get (I)Z 5 11.59% 92.75% BitSet.set (I)V
JProbe • Location • http://www.klgroup.com/jprobe • Evaluation version is available(Window, Sparc) • Install • run ‘java profiler25’ • set install directory to INSTALL • Run • run ‘$INSTALL/profiler/jpprofiler’
Limitation • Granulariry • routine(method) • time sample • JIT • compiler optimization(e.g., inlining)
Summary • For most profile tools, method count, execution time, call graph are provided. • Graphical tool can give you an insight about entire execution easily.