Stowatch Articles

Using the .NET Stopwatch class to Profile Your Code

The Stopwatch class in the System.Diagnostics namespace can be used a as a basic tool to profile blocks of .NET code. System.Diagnostics.Stopwatch timerObj = new System.Diagnostics.Stopwatch(); timer.Start(); Decimal totalDec = 0; int limit = 1000000; for (int i = 0; i < limit; ++i) { totalDec = totalDec + (Decimal)Math.Sqrt(i); } timerObj.Stop(); Console.WriteLine(“Sum of square […]

Read more