Share via


NameValueCollection vs. Hashtable performance considerations

We had a good discussion on the NameValueCollection internally not too long ago and I asked my friends on the BCL Team to post a summary of the things that were discussed.  Kim Hamilton delivered and how.  Great tidbits like:

For example, when doing 40,000 lookups on a collection size of 100,000, NameValueCollection is about 2.6x worse:

NameValueCollection time: 0.050 sec
Hashtable time: 0.019 sec

 Check out the full article here.

Comments

  • Anonymous
    September 14, 2006
    It strikes me as kinda funny, because FxCop goes out of its way to discourage use of the performance-oriented lists (like List and Hashtable) in favour of Collection and NameValueCollection.

    I can see its point, though.  It's a tradeoff between performance and breaking the ABI if you need to add an event model.