Today I released the Groovy profiler, GProf 0.3.0. GProf is a profiling module for Groovy which is developed in GPerfUtils project at http://gperfutils.org. The release includes the GNU profiler compatible call graph report and many improvements. You can read all the changes at https://code.google.com/p/gprof/wiki/ReleaseNotes030).
The release already has been available on the Maven Central repository and it means that now you can install GProf by the following one line:
@Grab('org.gperfutils:gprof:0.3.0-groovy-2.1') // v0.3.0 for Groovy 2.1
Here is a demo:
// slow !!
def fib(n) {
if (n < 2) {
n
} else {
fib(n - 1) + fib(n - 2)
}
}
profile {
fib(20)
}.prettyPrint()
and the output will be like this:
Flat:
% cumulative self self total self total self total
time seconds seconds calls ms/call ms/call min ms min ms max ms max ms name
54.3 0.29 0.29 2 145.86 267.78 38.14 58.56 253.57 477.00 demo.fib
30.4 0.45 0.16 21890 0.00 0.00 0.00 0.00 0.80 0.80 java.lang.Integer.minus
15.0 0.53 0.08 10945 0.00 0.00 0.00 0.00 0.83 0.83 java.lang.Integer.plus
0.1 0.53 0.00 1 1.05 537.10 1.05 537.10 1.05 537.10 demo$_run_closure1.fib
0.0 0.53 0.00 1 0.13 537.23 0.13 537.23 0.13 537.23 demo$_run_closure1.doCall
Call graph:
index % time self children calls name
0.00 0.53 1/1
[1] 100.0 0.00 0.53 1 demo$_run_closure1.doCall [1]
0.00 0.53 1/1 demo$_run_closure1.fib [2]
-----------------------------------------------------------------------------
0.00 0.53 1/1 demo$_run_closure1.doCall [1]
[2] 99.9 0.00 0.53 1 demo$_run_closure1.fib [2]
0.29 0.24 2/2 demo.fib [3]
0.00 0.00 2/21890 java.lang.Integer.minus [4]
0.00 0.00 1/10945 java.lang.Integer.plus [5]
-----------------------------------------------------------------------------
0.29 0.24 2/2 demo$_run_closure1.fib [2]
[3] 99.6 0.29 0.24 2+21888 demo.fib [3]
0.16 0.00 21888/21890 java.lang.Integer.minus [4]
0.08 0.00 10944/10945 java.lang.Integer.plus [5]
-----------------------------------------------------------------------------
0.00 0.00 2/21890 demo$_run_closure1.fib [2]
0.16 0.00 21888/21890 demo.fib [3]
[4] 30.4 0.16 0.00 21890 java.lang.Integer.minus [4]
-----------------------------------------------------------------------------
0.00 0.00 1/10945 demo$_run_closure1.fib [2]
0.08 0.00 10944/10945 demo.fib [3]
[5] 15.0 0.08 0.00 10945 java.lang.Integer.plus [5]
-----------------------------------------------------------------------------
I welcome any requests or feedback.

It would be nice post the import for the profile closure.
ReplyDelete