What is the performance of Groovy 2.0 with static compilation
Asked Answered
G

2

11

I see that the recent release of Groovy 2.0 includes optional static compilation along with several other added benefits, like optional static type checking. After doing a bit of a search, I haven't been able to find any extensive benchmarks comparing Groovy's performance (with static compilation) to Java and perhaps Scala. Does anyone know of any such performance comparisons? Can we assume that it is the same as Groovy++ was before it died? If it's performance is comparable, would Groovy be a viable alternative for a large, performance-critical application?

Giana answered 5/7, 2012 at 12:32 Comment(0)
R
6

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...

Rheumy answered 5/7, 2012 at 13:9 Comment(5)
Nice. That's a pretty dramatic improvement.Dane
Thanks Tim, this was exactly the type of link that I was looking for although it would be nice to see more of a comparison between Groovy 2.0 (static) and Java/Scala performance. I think you're right though that we may have to wait as it's only been out for a week.Giana
I believe java runs those tests in around 550msRheumy
@Giana you could always take a couple of minutes to fire up a compiler and run all 3 to see what results you get? Probably easier and quicker than trying to get people to do it for you?Rheumy
@Rheumy This last comment seemed needlessly snippy. I'm hoping to get programmers experience with Groovy 2.0 performance in real-life applications. Take a look at the last part of the question.Giana
D
5

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.

Dyann answered 26/8, 2012 at 10:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.