Stopwatch
static void Main(string[] args) ???{ ???????Stopwatch stopWatch = new Stopwatch(); ???????stopWatch.Start(); ???????Thread.Sleep(10000); ???????stopWatch.Stop(); ???????// Get the elapsed time as a TimeSpan value. ???????TimeSpan ts = stopWatch.Elapsed; ???????// Format and display the TimeSpan value. ???????string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ???????????ts.Hours, ts.Minutes, ts.Seconds, ???????????ts.Milliseconds / 10); ???????Console.WriteLine("RunTime " + elapsedTime); ???}
.net 代码计时
原文地址:http://www.cnblogs.com/sunlyk/p/7427438.html