StopWatch的使用,计算程序运行时间

           Stopwatch sw = new Stopwatch();
            sw.Reset();
            sw.Start();
            //...运行的代码
            sw.Stop();
            TimeSpan tp = sw.Elapsed;
            double s = tp.TotalSeconds;//得到运行的时间,单位为秒
        Response.Write("绑定事件" + Math.Round(s, 2) + "</br>");//输出运行时间,两位小数                

 

posted @ 2013-11-29 16:50  国驰  阅读(124)  评论(0)    收藏  举报