About Me

My photo
Author of Groovy modules: GBench, GProf, Co-author of a Java book パーフェクトJava, Game Developer at GREE

Friday, July 6, 2012

GBench 0.3.1 released!

Today I released GBench 0.3.1 with one bug fix for Groovy 2.0.

Release note: http://code.google.com/p/gbench/wiki/ReleaseNotes031.

Here is an example that compares execution time with and without @CompileStatic (new feature of Groovy 2.0) using GBench:
@Grab('com.googlecode.gbench:gbench:0.3.1-groovy-2.0') 
import gbench.BenchmarkBuilder 
import groovy.transform.CompileStatic 
 
int fib(int n) { 
    if (n < 2) return n 
    return fib(n - 1) + fib(n - 2)  
} 
 
@CompileStatic 
int fib2(int n) { 
    if (n < 2) return n 
    return fib2(n - 1) + fib2(n - 2)  
} 
 
new BenchmarkBuilder().run { 
    int n = 20  
    "Normal Version" { fib n } 
    "@CompileStatic Version" { fib2 n } 
}.prettyPrint() 
The output of the example:
Environment
===========
* Groovy: 2.0.0
* JVM: Java HotSpot(TM) 64-Bit Server VM (23.0-b21, Oracle Corporation)
    * JRE: 1.7.0_04
    * Total Memory: 98.25 MB
    * Maximum Memory: 1157.375 MB
* OS: Mac OS X (10.7.4, x86_64) 

Options
=======
* Warm Up: Auto 
* CPU Time Measurement: On

                         user  system    cpu   real

Normal Version          89945      14  89959  89961
@CompileStatic Version  39219       4  39223  39222