日期:2014-05-17 浏览次数:20762 次
TimeSpan tempTimeSpan = myPrc.TotalProcessorTime; outPrcTime = tempTimeSpan.ToString().Remove(8); newTime = (long)tempTimeSpan.TotalMilliseconds;
outPrcTime = myPrc.TotalProcessorTime.ToString().Remove(8); newTime = (long)myPrc.TotalProcessorTime.TotalMilliseconds;
DateTime dt = DateTime.Now; for (int i = 0; i < 100000; i++) //调整最大值 { //你的代码复制到这里 } TimeSpan ts = new TimeSpan(DateTime.Now.Ticks - dt.Ticks); MessageBox.Show(ts.ToString()); //看看哪个耗时长
------解决方案--------------------
不动手测试你永远都会空耗时间的。
------解决方案--------------------