This post originated from an RSS feed registered with .NET Buzz
by Eric Gunnerson.
Original Post: Timing your C# code
Feed Title: Eric Gunnerson's C# Compendium
Feed URL: /msdnerror.htm?aspxerrorpath=/ericgu/Rss.aspx
Feed Description: Eric comments on C#, programming and dotnet in general, and the aerodynamic characteristics of the red-nosed flying squirrel of the Lesser Antilles
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.