Timing your C# code

I've gotten a couple of emails on my recent column telling me that they couldn't replicate my timings.

My first reaction was a sinking feeling in my stomach that I'd messed up the timings, but then a more rational idea occurred to me.

They were running from inside the IDE.

You see, whenever you do an F5 from inside the IDE, the IDE figures that you want to be able to debug your code, and therefore the JIT is put into debug mode, and you don't get the fully optimized path.

This happens even if you are building in a release comparison.

IIRC, if you do a CTRL-F5, you don't get this behavior, but it's generally a better idea to do any timings outside the IDE, as the IDE may have other impact on your timings.