GProf, the Groovy Profiler supports Groovy 2.4 in the new release version 0.3.1.
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.1-groovy-2.4') // v0.3.1 for Groovy 2.4
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
46.8 0.82 0.82 2 411.11 875.84 366.64 786.45 455.58 965.22 Prof.fib
35.1 1.43 0.61 21890 0.02 0.02 0.00 0.00 3.76 3.76 java.lang.Integer.minus
17.9 1.75 0.31 10945 0.02 0.02 0.00 0.00 1.79 1.79 java.lang.Integer.plus
0.0 1.75 0.00 1 0.74 1753.00 0.74 1753.00 0.74 1753.00 Prof$_run_closure1.fib
0.0 1.75 0.00 1 0.14 1753.15 0.14 1753.15 0.14 1753.15 Prof$_run_closure1.doCall
Call graph:
index % time self children calls name
0.00 1.75 1/1
[1] 100.0 0.00 1.75 1 Prof$_run_closure1.doCall [1]
0.00 1.75 1/1 Prof$_run_closure1.fib [2]
-----------------------------------------------------------------------------
0.00 1.75 1/1 Prof$_run_closure1.doCall [1]
[2] 99.9 0.00 1.75 1 Prof$_run_closure1.fib [2]
0.82 0.92 2/2 Prof.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.82 0.92 2/2 Prof$_run_closure1.fib [2]
[3] 99.9 0.82 0.92 2+21888 Prof.fib [3]
0.61 0.00 21888/21890 java.lang.Integer.minus [4]
0.31 0.00 10944/10945 java.lang.Integer.plus [5]
-----------------------------------------------------------------------------
0.00 0.00 2/21890 Prof$_run_closure1.fib [2]
0.61 0.00 21888/21890 Prof.fib [3]
[4] 35.1 0.61 0.00 21890 java.lang.Integer.minus [4]
-----------------------------------------------------------------------------
0.00 0.00 1/10945 Prof$_run_closure1.fib [2]
0.31 0.00 10944/10945 Prof.fib [3]
[5] 17.9 0.31 0.00 10945 java.lang.Integer.plus [5]
-----------------------------------------------------------------------------
Last of all,
I'm sorry for the late release and thanks for kicking my butt!
