C# 计算程序的运行时间

//用Stopwatch类(System.Diagnostics)计算耗时
static
void SubTest() { Stopwatch sw = new Stopwatch(); sw.Start(); //耗时巨大的代码 sw.Stop(); TimeSpan ts2 = sw.Elapsed; Console.WriteLine("Stopwatch总共花费{0}ms.", ts2.TotalMilliseconds); }

猜你喜欢

转载自www.cnblogs.com/ashbur/p/12035433.html