Valhalla Legends Forums Archive | Java Programming | Map implementation Performance Comparison

AuthorMessageTime
Orillion
I'm doing some comparison's between various implementations of Java's map interface, mainly between a SortedArray Map and a Binary Search Tree Map and my timings have produced nothing very conclusive in terms of which proves a better implementation overall.

The tests I've run involve the creation of a banking system (eg creation of Accounts, deposits,. withdraws and closing of accounts). I've run the test on some large numbers (eg 10,000+ transactions).

Any suggestions on what implementation should have the best performance?
September 27, 2003, 3:17 AM
Grok
You should also consider comparison tests under different loads. Not all clients will have equal numbers of processes, CPU availability, and memory constraints. MSDN has Windows stress loading tools, and I'm sure *nix has them too, because *nix has everything.
September 27, 2003, 4:47 AM
St0rm.iD
HashMap should, in theory.

There's several other considerations though. For example, synchronization may be a factor (Collections.synchronizedMap(new HashMap()).

Also, to get an accurate benchmark, run your program a few times so it gets cached in RAM. Also, within each run, run it several hundred times, because if you're using Sun's VM, hotspot will do some JIT optimizing on the hashing/sorting/whatever algorithm. Finally, different Java implementations may implement it differently. GNU Classpath+gcj may be faster, but I don't know.

As always, you should be using jikes as your compiler for everything.
September 27, 2003, 10:28 PM
Orillion
Yes an OpenHashMap is definately the most efficent. And yes I do use jikes
September 28, 2003, 1:41 AM
MrRaza
Here is a link to a Java site that you might find useful.

Annotated Outline of Collections Framework
September 29, 2003, 2:14 AM

Search