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

6 comments:

  1. Hi Nagai, we use GBench in us project, and we are looking it very useful.
    Thanks. Tom

    ReplyDelete
  2. Hi,
    Combining your two posts together and trying to run this gbench example with -indy is giving me an error. Have you successfully done this? (Sorry at work at the moment so I can't give the exact error but it is from the jvm saying the class file is an incorrect version and a digit 15 in there somewhere...)

    ReplyDelete
    Replies
    1. hi, sorry for late reply.
      i tried to run gbench 0.3.1 with groovy 2.0.0 indy but any error didn't occur.
      if you still have have the error, let me know more info.
      thanks :)

      Delete