这里有一些基准(虽然很难看到发生了什么)
但是,Fib从页面底部获取Groovy 1.8.2 源代码,并在groovy 2.0中运行它可以为您提供:
Groovy(static ternary): 1623ms
Groovy(static if): 1583ms
Groovy(instance ternary): 1744ms
Groovy(instance if): 1694ms
Run Code Online (Sandbox Code Playgroud)
把@groovy.transform.CompileStatic在脚本的顶部为您提供:
Groovy(static ternary): 819ms
Groovy(static if): 799ms
Groovy(instance ternary): 816ms
Groovy(instance if): 811ms
Run Code Online (Sandbox Code Playgroud)
显然,这不是一个完整的基准测试(它只测试一件事),它不包括热身或任何东西,而Groovy 2.0只出现了一周,但它确实暗示了在这种情况下良好的速度提升......