How to calculate the time consumed on a block of souce code.


     System.Diagnostics.Stopwatch stopWatch2= new System.Diagnostics.Stopwatch();
     stopWatch2.Start();

     // the code that you want to know the time being comsumed.

     stopWatch2.Stop();

     string resTotal = stopWatch2.Elapsed.TotalMilliseconds.ToString();

posted @ 2011-07-06 13:54  withsoso  阅读(126)  评论(0编辑  收藏  举报