January 7th, 2009
Timing C# function performance with the Stopwatch class - 1
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

Occasionally you need to time the performance of a C# function to see if its as fast, or as slow, as you think it is. You could of course run your code through a profiler. But in situations that that would be overkill there exists a quick solution. Originally I looked at the standard DateTime class, but NET 2.0 introduced the Stopwatch class which is much more suitable. In this post I look at how you can measure your functions performance down to the last fraction of a millisecond.



Except where otherwise noted, content on this site is