码迷,mamicode.com
首页 > Windows程序 > 详细

C# 测试代码段性能耗时

时间:2016-04-07 18:18:20      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:

?一:?

????????????DateTime BeginTime = System.DateTime.Now;
??????????? //
代码
??????????? DateTime EndTime = System.DateTime.Now;
??????????? TimeSpan ts = EndTime.Subtract(BeginTime);
??????????? MessageBox.Show(ts.TotalMilliseconds.ToString());

? ?

二:

??????????? System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
??????????? watch.Reset();
??????????? watch.Start();
??????????? //
代码
??????????? watch.Stop();
??????????? MessageBox.Show(watch.ElapsedMilliseconds.ToString());

C# 测试代码段性能耗时

标签:

原文地址:http://www.cnblogs.com/qq260250932/p/5364635.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!