Stopwatch t1 = new Stopwatch(); //需要引入相应的命名空间
t1.Start(); //开始计时
t1.Stop(); //结束计时
Console.WriteLine(t1.ElapsedMilliseconds); //输出时间,单位为毫秒ms
记得把Debug 改成Release再来测试。