Use of C # StopWatch

Use StopWatch class, the timing may need to be introduced System.Diagnostics namespace.

        static  void the Main ( String [] args) 
        { 
            Console.WriteLine ( " the Main the Start .... " ); 
            The Stopwatch SW = new new The Stopwatch (); 
            sw.Start (); 
            the Thread.Sleep ( 3000 ); 
            sw.Stop () ; 
            Console.WriteLine ( " Time the Elapsed " + sw.ElapsedMilliseconds); 
            sw.Restart ();                             // set to 0, and re-start time, if the direct use of start (), must call Reset () set to 0 
            Thread.Sleep ( 3000  );
            sw.Stop ();
            Console.WriteLine("Main end...." + sw.Elapsed);
            Console.ReadLine();
        }

operation result:

Main Start....
time elapsed 3004
Main end....00:00:03.0093181

Guess you like

Origin www.cnblogs.com/change-myself/p/11130381.html