What is the performance of Groovy 2.0 with static compilation

随声附和 提交于 2019-12-01 15:23:05

There are some benchmarks here (though it's hard to see what's going on)

However, taking the Groovy 1.8.2 Fib source code from the bottom of the page, and running it in groovy 2.0 gives you:

Groovy(static ternary): 1623ms
Groovy(static if): 1583ms
Groovy(instance ternary): 1744ms
Groovy(instance if): 1694ms

Putting @groovy.transform.CompileStatic at the top of the script gives you:

Groovy(static ternary): 819ms
Groovy(static if): 799ms
Groovy(instance ternary): 816ms
Groovy(instance if): 811ms

Obviously, this is not a complete benchmark (it's only testing one thing), it doesn't include warmup or anything, and Groovy 2.0 has only been out a week, however it does hint towards a good speed improvement in this situation...

I believe java runs those tests in around 550ms

I did some performance comparison with Java. For "static ternary" and "static if" performance of Groovy with @CompileStatic is somewhat the same as with Java. For "instance ternary" and "instance if" it's almost a factor of 2. See my blog post.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!