[Dcmlib] std::map vs std::hash_map
Jean-Pierre Roux
jpr at creatis.insa-lyon.fr
Wed Jul 6 16:43:08 CEST 2005
Mathieu Malaterre wrote:
> Sean,
>
> Good catch ! the problem was indeed the hash function. I replaced
> my hash function with a sscanf on a TagKey to retrieve the DICOM
> group/element. But then most of the time was spent in the sscanf (this
> function is soooo slow). So I change the typedef TagKey to be a:
>
> union {
> uint32_t tagkey
> uint16_t tab;
> }
>
Hi, Mathieu.
I didn't catch exactly what you did with the union.
I suppose the uint32_t tagkey is the 'concatenation' of Dicom Group
number and Dicom Element number.
What is uint16_t tab used for ?
In the original version, we did something stupid : transform the tag
(e.g 0x0018,0x0050) into a TagKey ( e.g "0018|0050")
We can save time removing the transformation tag -> TagKey.
But we don't know (maybe Sean knows) the way the hash function should act.
(in the very late 70's -there was no stl ...- we splitted the 'key'
into 4 bytes pieces, Xor'ed the pieces to get a 'random like' int32, and
divide it by the number of blocks, to get the target block number, and
perform a chain when collision occurs)
I think (I'm not sure), nowadays Htable methods that use 'tries' look at
the first bits of the number to know whether they have to split the
target block or not, right ?
The first uint16 of the tag has no more than 100 distinct values (65 in
the Dicom V3 directory, + a few 'shadow groups'),
The second uint16 of the tag has more than 1250 distinct values, the
Dicom V3 directory.
Maybe we could have something more efficent if we describe the key as
'Element number Group number' instead of 'Group number Element number '.
Or maybe my idea is meaningless :-(
Jean-Pierre Roux
> There are still some glitch, but the improvement now is 23% (in fact
> most of the improvement is due to the union vs std::string).
>
> Thanks for your comments,
> Mathieu
> Ps: I'll keep investigating
>
> Sean McInerney wrote:
>
>> Hi Mathieu,
>>
>>
[...]
>> 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.
>
I hope we'll act together to fix it up...
Ten more days to wait for the Bastille Day.
Mathieu, don't forget to bring some fire crakers, at Kitware's.
;-)
>>
>> -Sean
>>
>> Mathieu Malaterre wrote:
>
>
More information about the Dcmlib
mailing list