Forum Navigation
Container benchmarks
Posted: 06/30/08 11:45:52 Modified: 06/30/08 11:49:52I've been playing around with benchmarking the old and new "map" containers and the built-in associative arrays, for myself and anyone interested. It only tests insertion and lookup of the maps. My code.
Here's some results (expect some variance of results). Note that the number of elements inserted ("init") and looked up ("find") vary.
No particular selection of allocator, etc:
Starting warmup... (16384 elements) Starting tests... (init 1048576 elements and find 1048576 elements) Initializations finished Did all find runs get the same results: yes Results: Init time Find time (sec) Old TreeMap 5.68 1.60 New SortedMap 5.16 1.28 AssocArray 7.15 0.30 Old HashMap 9.47 0.38 New HashMap 7.11 0.28 New StackMap 11.19 0.42 Starting warmup... (16384 elements) Starting tests... (init 131072 elements and find 1048576 elements) Did all find runs get the same results: yes Results: Init time Find time (sec) Old TreeMap 0.52 1.10 New SortedMap 0.14 0.79 AssocArray 0.17 0.26 Old HashMap 0.25 0.33 New HashMap 0.25 0.23 New StackMap 0.05 0.35Using the chunk allocator seems to make a big difference to the new HashMap? insertions:
Starting warmup... (16384 elements) Starting tests... (init 131072 elements and find 1048576 elements) Did all find runs get the same results: yes Results: Init time Find time (sec) Old TreeMap 0.83 1.06 New SortedMap 0.12 0.77 AssocArray 0.20 0.26 Old HashMap 0.20 0.32 New HashMap 0.05 0.23 New StackMap 0.04 0.35Calling allocator.config (1000, 1000) for the new hash and stack maps, and setting the number of buckets for the hash map initially makes it really fast to insert elements - compare with the builtin AA!
Starting warmup... (16384 elements) Starting tests... (init 131072 elements and find 1048576 elements) Did all find runs get the same results: yes Results: Init time Find time (sec) Old TreeMap 0.64 1.07 New SortedMap 0.12 0.74 AssocArray 0.21 0.25 Old HashMap 0.20 0.31 New HashMap 0.02 0.22 New StackMap 0.04 0.34 Starting warmup... (16384 elements) Starting tests... (init 1048576 elements and find 1048576 elements) Did all find runs get the same results: yes Results: Init time Find time (sec) Old TreeMap 5.53 1.62 New SortedMap 1.74 1.40 AssocArray 3.88 0.31 Old HashMap 6.13 0.38 New HashMap 0.26 0.30 New StackMap 0.42 0.42Including the old LinkMap? (using far less elements):
Starting warmup... (8192 elements) Starting tests... (init 16384 elements and find 16384 elements) Initializations finished Did all find runs get the same results: yes Results: Init time Find time (sec) Old LinkMap 3.36 3.31 Old TreeMap 0.02 0.01 New SortedMap 0.00 0.00 AssocArray 0.00 0.00 Old HashMap 0.00 0.00 New HashMap 0.00 0.00 New StackMap 0.00 0.00