C# StopWatch

프로그램 2014.04.29 22:15 Posted by soulfree >동네청년<
using System.Diagnostics;

 

... 

  
 
Stopwatch stwatch = new Stopwatch();
  
stwatch.Reset();

 

stwatch.Start();
  
// 코드

 

stwatch.Stop();

 

 

*실버라이트의 경우

 

long before = DateTime.Now.Ticks;
DoTheTaskThatNeedsMeasurement();
long after = DateTime.Now.Ticks;

TimeSpan elapsedTime = new TimeSpan(after - before);
MessageBox.Show(string.Format("Task took {0} milliseconds",
    elapsedTime
.TotalMilliseconds));