I had some unexpected benchmark results with the following snippet of Groovy Code:
class A{
def n(){
return 1
}
}
class B{
def n(){
return 2
}
}
class C{
def n(){
return 3
}
}
class D{
def n(){
return 4
}
}
def bench(loops){
def a = new A()
def b = new B()
def c = new C()
def d = new D()
def ret=0
for(i=0; i<loops; i++){
ret = ret + getN(a) + getN(b) + getN(c) + getN(d)
}
return ret
}
def getN(clazz){
return clazz.n()
}
I have to say that I used the compiled class files and invoked it with the Reflection API. Long story to tell (dont ask ;). For the first impressions I used 10 rounds + 5 warmup with 10000 loops. (junit-benchmark framework) My JDK is Verison 1.7.0_09 and I used Groovy 2.1. I compiled the code 2 times with and without invokedynamic support. The point is, that the benchmark with invokedynamic took very much longer than the normal compiled one. I also did other benchmarks with fibonacci numbers, which behaved like expected (indy took about half of the time).
Does anybody know what's going wrong here?
Thanks.