There are many options for profiling. One free profiler that I used and which I would recommend is EQATEC . There are many more options, many of which are mentioned in this SO question .
As for the implementations, the first few that come to mind are Dictionary<TKey, TValue> , SortedDictionary<TKey, TValue> and SortedList<TKey, TValue> . Of course, I would be inclined to guess that Dictionary<TKey, TValue> is the fastest, since it is the simplest in terms of features. But I never tested them against each other for speed.
Note that the above classes are general, which should make them more efficient than HashTable in at least one sense: they do not require boxing / unpacking of keys and values ββlike System.Object , which leads to unnecessary memory allocation.
Something else you need to know about is that since you are using a multi-threaded script, you need to take care to somehow block your reads / writes. (The above classes, unlike HashTable , are not thread safe for multiple readers and the writer.) Locking on a shared object may be a better choice in most cases, whereas if you are doing more reads than writes, you might want to use ReaderWriterLock or ReaderWriterLockSlim (both of which allow you to switch between multiple simultaneous readers and one author). If you list a collection, you really should be blocked anyway - even with a HashTable .
source share