Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best way to benchmark programs in Windows?

I need to do some performance benchmarks on .NET programs (C#) in Windows, but I haven't done benchmarking much in the Windows world. I've looked into using the Windows 2000/XP Performance monitor with custom counters for this, but I don't think this is quite what I want.

Are there any good system facilities for this in Windows XP, or do I need to just use System.Diagnostics.Stopwatch [edit] and write text logs for manual interpretation, or is there something else?

Edit: is there anything beyond System.Diagnostics.Stopwatch?

like image 525
Ben Collins Avatar asked Sep 28 '08 03:09

Ben Collins


1 Answers

using System.Diagnostics;
....

Stopwatch sw = new Stopwatch();

sw.Start();

// Code you want to time...

// Note: for averaged accuracy (without other OS effects), 
//       run timed code multiple times in a loop 
//       and then divide by the number of runs.

sw.Stop();

Console.WriteLine("Took " + sw.ElapsedTicks + " Ticks");
like image 138
Mitch Wheat Avatar answered Oct 05 '22 03:10

Mitch Wheat