performance between hashtable and ListDictionary

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hi

If you intend to use a Hashtable and the number of element are 10 or less
this has some impact on the performance according to MSDN. So in this case
you should use ListDictionary instead.

This is perhaps true but assume the average time to access some element in
Hashtable is 0.3 sec and if you instead use
a ListDictionary you have 0.2 sek but who cares about 0.1 sec even though
the performance improvement was 33 %

I do would have agreed if the perfomnace improvement was from 5 sec to 2 sec
or someing similar.

//Tony
 
Tony said:
Hi

If you intend to use a Hashtable and the number of element are 10 or less
this has some impact on the performance according to MSDN. So in this case
you should use ListDictionary instead.

This is perhaps true but assume the average time to access some element in
Hashtable is 0.3 sec and if you instead use
a ListDictionary you have 0.2 sek but who cares about 0.1 sec even though
the performance improvement was 33 %

And have you actually measured what the difference is? Assuming it's a
difference if 0.1 second is just that: An assumption. Maybe it's bigger,
maybe it's smaller, but without profiling it, you won't know.
I do would have agreed if the perfomnace improvement was from 5 sec to 2 sec
or someing similar.

If the number of iterations involved is big enough, a 0.1 second
performance improvement can have a huge impact. If you have knowledge of
the data to be processed beforehand, you can make some decisions whether
a ListDictionary or a Hashtable is more appropriate.

If you don't, then worrying about which one to choose is meaningless,
and would fall in the category of premature optimization. Only profiling
afterwards can tell you whether it will make a (significant) difference.
 
Tony said:
Hi

If you intend to use a Hashtable and the number of element are 10 or less
this has some impact on the performance according to MSDN. So in this case
you should use ListDictionary instead.

This is perhaps true but assume the average time to access some element in
Hashtable is 0.3 sec and if you instead use
a ListDictionary you have 0.2 sek but who cares about 0.1 sec even though
the performance improvement was 33 %

It's more like 0,000000055 seconds and 0,000000047 seconds... (Actual
measurements.)
I do would have agreed if the perfomnace improvement was from 5 sec to 2 sec
or someing similar.

The performance impact of course only has any significance if you access
the collection a lot of times.
 
Back
Top