views:

190

answers:

3
+3  Q: 

HashMap profiling

Are there any HashMap implementations that expose hook methods for profiling the performance of the Map (average chain length, best / worst / average access time, #rehashes, etc.).

It seems quite common to use HashMap and "hope for the best" with regards to ~O(1) access time, without analysing whether this is really the case but I'd like to measure the performance at runtime (at least during development), so anything that hooks into JMX or profiling software would also be good.

Also, Is anyone aware of HashMap implementations where the chains are based on binary trees instead of linked lists?

Thanks in advance.

A: 
Carl Manaster
Which technically isn't a hashmap implementation, but we wouldn't want to get too pedantic.
skaffman
Thanks but I'm interesting in HashMaps where the individual chains are binary trees ... i.e. I'm interested in approximating O(1) access time.
Adamski
Carl Manaster
+1  A: 

On the second part of your question, if you're looking for a fast Hashmap implementation with some decent real-time guarantees have a look at Javolution. It's fast, reliable and goes into a decent amount of detail on performance.

GaryF
+1  A: 

There's a new Java profiler that goes some way towards doing what you're after. CollectionSpy (www.collectionspy.com) tracks the number of internal rehashes of any hashing container, and also has a graph visualization of the bucket list lenghts. Doesn't (yet) provide any timing info though.

Laurence Vanhelsuwe
Thanks - I'll definitely check it out.
Adamski