Tuesday, April 28, 2009

Measure a function's performance

Use the Stopwatch (in System.Diagnostics)

Stopwatch sw = Stopwatch.StartNew();
PerformWork();
sw.Stop();

Console.WriteLine("Time taken: {0}ms",
sw.Elapsed.TotalMilliseconds);

No comments:

Post a Comment