System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
watch.Start();//开始计时
for(int i=0,i<=50,i++){
Console.WriteLine($"第{i}遍打印");
}
watch.Stop();//停止计时
var time = watch.ElapsedMilliseconds; //以毫秒为单位
System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
watch.Start();//开始计时
for(int i=0,i<=50,i++){
Console.WriteLine($"第{i}遍打印");
}
watch.Stop();//停止计时
var time = watch.ElapsedMilliseconds; //以毫秒为单位