码迷,mamicode.com
首页 > 其他好文 > 详细

测量程序运行时间

时间:2017-02-10 22:58:37      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:string   lin   watch   测量   tar   结束   stopwatch   运行时间   new   

1            string a = string.Empty;
2             Stopwatch sp = new Stopwatch();//using System.Diagnostics;
3             sp.Start();//开始
4             for (int i = 0; i < 100000; i++)
5             {
6                 a += i;
7             }
8             sp.Stop();//结束
9             Console.WriteLine(sp.Elapsed);//sp.Elapsed为时间间隔

 

测量程序运行时间

标签:string   lin   watch   测量   tar   结束   stopwatch   运行时间   new   

原文地址:http://www.cnblogs.com/wwz-wwz/p/6388029.html

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