Processed detection code C #

static  void subTest () 
{ 
    The Stopwatch SW = new new The Stopwatch (); 
    sw.Start (); 
  
    // time consuming code 
    
    sw.Stop (); 
    the TimeSpan TS2 = sw.Elapsed; 
    Console.WriteLine ( " The Stopwatch spent a total of {0 MS}. " , ts2.TotalMilliseconds); 
} 
the first method uses System.DateTime.Now 
static  void subTest () 
{ 
    the DateTime beforDT = System.DateTime.Now;   

    // time consuming code 
    
    the DateTime afterDT = System.DateTime. now; 
    the TimeSpan TS =afterDT.Subtract (beforDT); 
    Console.WriteLine ( " . spent a total of the DateTime 0} MS { " , ts.TotalMilliseconds); 
}

// Source forgotten. . .

Guess you like

Origin www.cnblogs.com/enych/p/11901439.html