{ by david linsin }

January 30, 2007

Java 5 syntax and performance

Actually the article linked above is about a performance comparison of iterative and recurive operations in Java. The author compared an algorithm performed in an iterative and recursive manner, highlighting that recursion peforms way better.

He implemented the algorithm, for both iterative and recursive style, with and without Java 5 language features (e.g. for-each loop). I was struck by the fact that in both cases the implementation using Java 5 language features was significantly slower than using the "old" syntax.

On the other hand, it is also clear that it is easy to inadvertently "give away" performance by, for example, improving readability using Java 5 for-loop iteration. Elegant recursion uses over 1MB of heap space and runs almost as slowly as the fast iterative solution. The elegant iterative solution uses 160% of the fast solution's time, and uses roughly 40 times more heap space.

So I'm asking myself, when it comes to Java 5 language features like the for-each loop or autoboxing/unboxing is it really readability over performance?

1 comments:

Blogger said...

Need To Boost Your ClickBank Commissions And Traffic?

Bannerizer made it easy for you to promote ClickBank products by banners, simply visit Bannerizer, and grab the banner codes for your chosen ClickBank products or use the Universal ClickBank Banner Rotator to promote all of the ClickBank products.


com_channels

  • mail(dlinsin@gmail.com)
  • jabber(dlinsin@gmail.com)
  • skype(dlinsin)

recent_postings

loading...