برای اینکار از کلاس stopwatch که در فضای نام System.Diagnostics قرار داره استفاده میکنیم:

مثال:
using System.Diagnostics;

// Create an instance of the new StopWatch class
            Stopwatch myWatch = new Stopwatch();

            // Start the timer
            myWatch.Start();

            //Code Here...
            for (int SA = 0; SA < 1000; SA++)
            {
                Console.WriteLine("SoftAfzar.Net | Share your computer science!");
            }

                // Now we can stop the timer and display the elapsed time along
                myWatch.Stop();
           MessageBox.Show(myWatch.ElapsedMilliseconds.ToString(),"elapsed time");
        }

این تیکه کد تو کامپیوتر من 8856 میلی ثانیه طول کشید