29. August 2011 14:06
Did you know that C# has a high resolution timer in the System.Diagnostics namespace which is very useful for benchmarking / fine tunning small parts of code that run regularly. Here is a short example on how to use it.
class Program
{
static void Main(string[] args)
{
System.Diagnostics.Stopwatch SW = new Stopwatch();
SW.Start();
Console.WriteLine("Starting");
for (int i = 0; i < 1000; i++)
Console.WriteLine("Test");
SW.Stop();
Console.WriteLine("Time Taken: {0}", SW.ElapsedMilliseconds);
Console.ReadLine();
}
}
df1ea05d-9b3c-4c3d-8cd8-2f5b3c3afd11|0|.0