The following are examples of j_calltime.d.
This script traces the elapsed time of Java methods and prints a report of the
top ten in each category. This number is configurable with simple edit of
the DTrace script
Here it traces the example program, Code/Java/Func_abc
# j_calltime.d
Tracing... Hit Ctrl-C to end.
^C
Top 10 counts,
PID TYPE NAME COUNT
311358 method java/lang/String.equals 202
311358 method java/lang/Math.min 208
311358 method java/lang/String.hashCode 213
311358 method java/lang/String.indexOf 302
311358 method java/lang/System.arraycopy 360
311358 method java/lang/StringBuilder.append 533
311358 method java/lang/AbstractStringBuilder.append 549
311358 method java/lang/Object.<init> 823
311358 method java/lang/String.charAt 1960
0 total - 12020
Top 10 elapsed times (us),
PID TYPE NAME TOTAL
Top 10 exclusive method elapsed times (us),
PID TYPE NAME TOTAL
311358 method java/nio/ByteBuffer.<init> 5430
311358 method java/lang/String.charAt 6079
311358 method java/lang/String.<init> 7306
311358 method java/lang/StringBuilder.append 10240
311358 method java/util/StringTokenizer.scanToken 11075
311358 method java/net/URL.<clinit> 12519
311358 method java/io/UnixFileSystem.normalize 13218
311358 method sun/net/www/ParseUtil.decode 14208
311358 method java/lang/Thread.sleep 3016374
0 total - 3344993
Top 10 inclusive method elapsed times (us),
PID TYPE NAME TOTAL
311358 method sun/misc/Launcher.<clinit> 129120
311358 method java/lang/ClassLoader.initSystemClassLoader 129851
311358 method java/lang/ClassLoader.getSystemClassLoader 129897
311358 method java/lang/ClassLoader.loadClass 267404
311358 method java/security/AccessController.doPrivileged 278364
311358 method Func_abc.func_c 1009971
311358 method Func_abc.func_b 2019995
311358 method java/lang/Thread.sleep 3016374
311358 method Func_abc.func_a 3027043
311358 method Func_abc.main 3027068
Counts shows us how many times each different method was called, and how
many methods were called in total.
The exclusive method elapsed times show the time that each method spent
processing code - while not in other method.
The inclusive method elapsed times show the time that each method spent
processing code, including the time spent in other calls.
These elapsed times are the absolute time from when the method began to
when it completed - which includes off-CPU time due to other system events
such as I/O, scheduling, interrupts, etc.