Wednesday, May 6, 2009

Performence check in c# with Stopwatch

Hi,
System.Diagnostics has a very nice object called Stopwatch
i show here my very easy and simple example 4 making performence check:

Stopwatch oStopwatch = new Stopwatch();
oStopwatch.Start();
//@@@ Start of code to make the performence check
Thread.Sleep(3000);
//@@@ End of code to make the performence check
oStopwatch.Stop();
TimeSpan oTimeSpan = oStopwatch.Elapsed;
Console.WriteLine(oTimeSpan.ToString());


the output of this code was:

00:00:02.9994520

No comments: