I'm creating a library which I'm performance testing. In it I generate a Dictionary<Type, X>
once. The items are currently inserted in a random order. The dictionary remains unchanged during the application lifetime.
It's then frequently used to lookup items. The lookup is one of the larger bottlenecks in the library.
Yes, I'm micro-optimizing, but to learn. I'm wondering if there are a better way to get lookup performance?
Update
I've used dotTrace to measure the performance. The report + dotTrace is in my home computer, so I don't have the report here (could have uploaded it somewhere otherwise).
I used the tests found here: https://github.com/danielpalme/IocPerformance
The dictionary definition is found here: https://github.com/jgauffin/Griffin.Container/blob/master/Source/Griffin.Container/ContainerBase.cs
(I created the container last friday, don't expect too much)
Update2
Dictionary.TryGetValue
takes totally 101ms of Resolve
(total 251ms) which is 40,2% if I've interpreted the numbers correctly.