测量程序运行时间

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为时间间隔

 

posted @ 2017-02-10 21:30  冲天小肥牛  阅读(119)  评论(0编辑  收藏  举报