Reputation: 17782
I hope with this question that we can assemble a bunch of good advices to measure performance of .Net applications.
Personally, I'm in a situation where I want to test an algorithm, and I want to be sure the measurements are reasonable precise. Therefore I do the following:
(*1) If the input isn't always the same, it may make sense to do an average of the running time. Also, see Accurately measure elapsed wall clock time in .NET
So the question is really:
Is there anything I (or others) have missed in the above list? And elaborating of why the recommendations (in the list or new ones) works will be appreciated.
Update: Is anyone using ngen
before benchmarking? If yes, why?
Thanks, Lasse Espeholt
Upvotes: 2
Views: 1097
Reputation: 5037
If you are testing one algorithm, then you can also write a small test app (simple DIY solution), shove in a bunch of inputs, and run for one million iterations, then take the average. If you need to test multiple algorithms, then you can extend the small test app into a small test harness, and get results for all test algorithms. If you use Continuous Integration, then this test harness can give you frequent feedback on the performance of these algorithms.
Or, you use the profiling tools that come with Visual Studio team edition.
Regarding your #2 comment, the System.Diagnostics.Stopwatch
class is about as good as it gets on a general-purpose OS such as windows.
Upvotes: 1
Reputation: 27441
These links may help..
Monitoring ASP.NET Application Performance
PerfMon – Your debugging buddy
Upvotes: 1