[Dcmlib] std::map vs std::hash_map

Sean McInerney seanm at nmr.mgh.harvard.edu
Sun Jul 3 21:34:00 CEST 2005


Hi Mathieu,

A 5% improvement is surprisingly weak, but may be due to the typical key
sizes found in a DICOM table as well as the size of the table. Depending
on the hash function used, you may have a lot of collisions and multiple
rehashing necessary for any given key. If you really *need* better
performance, you may want to investigate passing a different hash
function (functor) as a template parameter to std::hash_map tuned for
your specific distribution of input values (keys).

Or better yet, skip the enormous time sink of tweaking your hash
implementation and enjoy the handy lexicographic sorting offered by
std::map. By definition, hash maps have no such ordering.

Happy 4th of July to all ... especially the French members of the list.
We would not be here without you. Sorry to have made such a mess of the
place in the meantime, we'll try to fix it up in the near future.

-Sean

Mathieu Malaterre wrote:
> Ok guys,
> 
>     I did perform a few bench comparing in Release mode on linux debian,
> gcc 3.3. If I replace the TagKeyHT from a std::map to a
> std::hash_table.. I only get a ~5% improvement. But again to reach 5%
> improvement I was parsing (see TestAllPrint.cxx) all files from gdcmData
> and all files from gdcmSampleData (rsync serveur). Basically the
> difference between a map and a hash is extremely negligeable. You only
> notice it when you parse a lot of file and a lot of tags...
> 
>     Since this is not exactly what I expected I'll differ the merge with
> my local change until I found a more drastic change that affect the
> speed of gdcm.
> 
>     Unless of course people are interested in the patch right away...
> 
> -----------------------------
> 
>     My machine: CHIRON, which used to do the win32 part (bcc32, and
> vs7.1) died last week (I am guessing the power supply), so it will only
> be back middle of next week.
> 
> 
> Mathieu
> _______________________________________________
> Dcmlib mailing list
> Dcmlib at creatis.insa-lyon.fr
> http://www.creatis.insa-lyon.fr/mailman/listinfo/dcmlib
> 
> 
> 



More information about the Dcmlib mailing list