当前位置:编程学习 > C#/ASP.NET >>

怎样统计“执行一个过程”所用的时间??? 用毫秒计算。

怎样统计“执行一个过程”所用的时间???    用毫秒计算。

在C#中怎样统计,让它显示出来呢? --------------------编程问答-------------------- http://www.cnblogs.com/acoll/articles/2452084.html --------------------编程问答--------------------
Stopwatch stopWatch = new Stopwatch();
                stopWatch.Start();
                Thread.Sleep(10000);
                stopWatch.Stop();
                long runTime = stopWatch.ElapsedMilliseconds;//获取总运行时间,毫秒为单位
--------------------编程问答-------------------- string begin=datetime.now.tostring("ssfff");//开始时间
//过程代码
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 秒表 --------------------编程问答--------------------
引用 2 楼 Return_false 的回复:
C# code12345Stopwatch stopWatch = new Stopwatch();                stopWatch.Start();                Thread.Sleep(10000);                stopWatch.Stop();                long runTime = sto……

正解 --------------------编程问答-------------------- 不行就用个Timer控件计时吧
--------------------编程问答--------------------
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,