benchmark

4 posts

Quicksort in Groovy - can it be as fast as implemented in Java?

I started reading "Cracking the Coding Interview, 6th Edition" book recently and it inspired me to experiment a bit. It’s been a while since I implemented the quicksort algorithm the last time, and I did that in Haskell. I remember some old and imperative implementations in Java, but I never tried to implement it in Groovy. Let’s give it a try!

Groovy Trampoline Closure - a step into recursive closures

A few weeks ago an interesting question was asked on the StackOverflow. Someone experimented with a recursion in Groovy and stepped into Closure.trampoline() [1]. It quickly turned out that using TrampolineClosure makes a recursive execution slower. Is this a valid behavior, or do we do something wrong?

Groovy Regular Expressions - The Benchmark (Part 2)

In the second part of the "Groovy Regular Expression" blog post, I want to show you some benchmarks. And let me make one thing clear - the following results you are going to see are not scientific proof. I present those results only to give you a hint about the overall performance of some cool features you have seen before.

What is the most efficient way to iterate collection in Groovy? Let's play with JMH!

I guess you may heard about Groovy’s Collection.each(Closure cl) method - it was introduced 15 years ago [1] and it was a great alternative for a good old for-loop, for-each or even using an iterator approach. You may also heard, that you should not overuse it, because creating a closure to do such simple operation like collection iteration is an overhead. But what if I tell you that nothing could be further from the truth - Groovy’s each method may be faster than iterator or Java’s for-each. Sounds interesting? Enjoy the reading!