Performance of Case Insensitive Hashtables

I wrote a small test, comparing the performance of case sensitive and case insensitive hashtables in .NET. The result is, that the case sensitive hastable is 3 times faster than the case insensitive hashtable …mmmh, quite a difference!

Case sensitive – 527 ms:
new Dictionary<string, string>()

Case insensitive – 1297 ms:
new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase)

Source Code

2 thoughts on “Performance of Case Insensitive Hashtables

  1. Dave T

    Although, if you use “StringComparer.OrdinalIgnoreCase” as the comparer instead of “StringComparer.InvariantCultureIgnoreCase” the performance is only marginally less.

    I get these results for your test
    277 ms for Default
    349 ms for OrdinalIgnoreCase
    714 ms for InvariantCultureIgnoreCase

Comments are closed.