命名空间:using System.Diagnostics;
调用方法:
Stopwatch stopWatch = new Stopwatch();
//开始记录时间
stopWatch.Start();
……
//结束记录时间
stopWatch.Stop();
//输出运行时间
Console.WriteLine("运行时间:" + stopWatch.Elapsed);
调用方法:
Stopwatch stopWatch = new Stopwatch();
//开始记录时间
stopWatch.Start();
……
//结束记录时间
stopWatch.Stop();
//输出运行时间
Console.WriteLine("运行时间:" + stopWatch.Elapsed);