性能监视Stopwatch使用

代码
   
     
Stopwatch watch = new Stopwatch();
watch.Start();
ArrayList al
= new ArrayList();
for ( long i = 0 ; i < 1000000 ; i ++ )
{
al.Add(i);
}
watch.Stop();
Console.WriteLine(watch.ElapsedMilliseconds);

watch.Reset();

watch.Start();
List
< int > list = new List < int > ();
for ( int i = 0 ; i < 1000000 ; i ++ )
{
list.Add(i);
}
watch.Stop();
Console.WriteLine(watch.ElapsedMilliseconds);

 

你可能感兴趣的:(Stop)