C#程序运行计时

var stp = new System.Diagnostics.Stopwatch();
stp.Start();//计时启动


..........程序代码...........


stp.Stop();//停止计时
Classlog.WriterLog(string.Format("耗时:{0}毫秒",stp.ElapsedMilliseconds), "caltm");
stp.Restart();// 停止时间间隔测量,将运行时间重置为零,然后开始测量运行时间。


..........程序代码.................


Classlog.WriterLog(string.Format("耗时:{0}毫秒",stp.ElapsedMilliseconds), "caltm");
stp.Stop();

posted @ 2018-03-12 16:09  小痞子Yang  阅读(339)  评论(0编辑  收藏  举报