Friday, October 4, 2013

Performance of Java Collections


I’m in the midst of teaching an Introduction to Java class. Like most courses of this type, when I introduce the standard JVM collections I intend to provide guidance on which type of collection to use when.

I wanted to show the real-world effects of making the correct or incorrect decision, so I put together an example. I used the excellent Caliper library to create a class that benchmarks pulling data from existing collections. Caliper is nice for this kind of thing because it does the measurement for you, and automatically handles some things like garbage collection coming in and messing up your test. It also publishes the results to a webapp, with a useful table that I’ll be able to use in my slides. Caliper is undergoing a change to its API at the moment, so I used the old API since that’s the version that’s available in Maven. Both APIs look a lot like JUnit; the old API looks like JUnit 3 and the new API looks like JUnit 4.

Read more here

One Response so far.

tuolumne said...

Please evaluate AirConcurrentMap. It's a ConcurrentNavigableMap with internal threading for forEach() and streams and is 2 to 6 times faster in general. It's about 50% to 90% more memory efficient.

Leave a Reply

All Tech News IN © 2011 & Main Blogger .