Use Stopwatch : Stopwatch : Date Time C# Examples


C# Examples » Date Time » Stopwatch »

 

Use Stopwatch









    
using  System;
using  System.Collections.Generic;
using  System.Diagnostics;
using  System.Runtime.CompilerServices;
using  System.Threading;

public  class  MainClass
{
        public  static  void  Main()
        {
                Stopwatch  sw  =  new  Stopwatch();
                sw.Start();
                for  (int  i  =  0;  i  <  1000;  i++)
                {
                }
                sw.Stop();

                Console.WriteLine("Parse  pattern  took  {0}ms",  sw.ElapsedMilliseconds);
                sw.Reset();

                sw.Start();
                for  (int  i  =  0;  i  <  1000;  i++)
                {
                }
                sw.Stop();

                Console.WriteLine("TryParse  pattern  took  {0}ms",  sw.ElapsedMilliseconds);
        }
}
    
   
  
   



Output

Parse pattern took 0ms
TryParse pattern took 0ms


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Date Time
» Stopwatch