aspose file troubles
The moose likes Java in General and the fly likes New JavaRanch Journal article: Supercharging your HashMaps The Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "New JavaRanch Journal article: Supercharging your HashMaps" Watch "New JavaRanch Journal article: Supercharging your HashMaps" New topic
Author

New JavaRanch Journal article: Supercharging your HashMaps

Ulf Dittmer
Sheriff

Joined: Mar 22, 2005
Posts: 28826
The latest issue of the JavaRanch Journal contains an article by David O'Meara on Supercharging your HashMaps. Go read it while it's fresh, and discuss it in this thread.

cewolf - Java web chartsMy Android appsImageJ Plugins
David O'Meara
Sheriff

Joined: Mar 06, 2001
Posts: 12332
Not particularly ground breaking I admit, but if anyone has any comments on the "Unusual Iteration Times" mentioned in the after thoughts, I haven't had a chance to dig deeper and would appreciate opinions.


Some people, when confronted with a problem, think "I know, I’ll use regular expressions." Now they have two problems. Jamie Zawinski
[JavaRanch FAQ] [Book Promotions] [DbTamer]
Manuel Laflamme
Greenhorn

Joined: Jul 31, 2008
Posts: 1
Map iteration is traversing the whole map entry table. If your initial capacity is 1,000,000 the iterator have to traverse all the 1,000,000 entries (2^20 actually) even if only a small subset of them contain values. So your test with initial capacity of 1,000,000 and 1,000 keys is actually doing 10,000 iteration x 1,000,000 entries rather than 10,000 x 1,000.
[ July 31, 2008: Message edited by: Manuel Laflamme ]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 17075
. . . and welcome to JavaRanch, Manuel Laflamme
David O'Meara
Sheriff

Joined: Mar 06, 2001
Posts: 12332
Welcome also

Understood, but if you look at Table 5, we expect the iteration time to increase when increasing the initial capacity, what I wasn't expecting was the iteration time to decrease for a given capacity when the Map contains more items

ie


In the above, the actual capacity should be the same in each case (2^20) but the iteration time decreases with the increasing size of data held in the HashMap, or so it would appear.
 
Java Business RIA redefined!
 
subject: New JavaRanch Journal article: Supercharging your HashMaps
 
JProfiler
Get rid of your performance problems and memory leaks!

.