怎样统计“执行一个过程”所用的时间??? 用毫秒计算。
怎样统计“执行一个过程”所用的时间??? 用毫秒计算。在C#中怎样统计,让它显示出来呢? --------------------编程问答-------------------- http://www.cnblogs.com/acoll/articles/2452084.html --------------------编程问答--------------------
Stopwatch stopWatch = new Stopwatch();--------------------编程问答-------------------- string begin=datetime.now.tostring("ssfff");//开始时间
stopWatch.Start();
Thread.Sleep(10000);
stopWatch.Stop();
long runTime = stopWatch.ElapsedMilliseconds;//获取总运行时间,毫秒为单位
//过程代码
string end=datetime.now.tostring("ssfff");
int result = Convert.Toint32(end)-Convert.ToInt32(begin);//结果 --------------------编程问答-------------------- DateTime dtStart = Date.Now;
//过程代码
TimeSpan ts = DateTime.Now.Subtract(dtStart);
double result = ts.TotalMilliseconds; //结果 --------------------编程问答-------------------- 用StopWatcher --------------------编程问答-------------------- Stopwatch 秒表 --------------------编程问答--------------------
正解 --------------------编程问答-------------------- 不行就用个Timer控件计时吧
--------------------编程问答--------------------
补充:.NET技术 , C#