When using a Guid as an index for a Dictionary, is it better to use the Guid object, or the string representation of the Guid?
I just refactored some code which was using string to use the object, because there were new Guid() calls all over the place. But that left me wondering what the performance issues might be. (The collections are fairly small, but they get iterated lots of times.)
The
Guidshould be quicker, as the comparison is simpler – just a few direct bytes. The string involves a dereference and lots more work.Of course – you could profile ;-p
Evidence:
based on: