1 Stopwatch timer = new Stopwatch(); 2 timer.Start(); 3 //要测试的代码 4 timer.Stop(); 转载于:https://www.cnblogs.com/Jacob-Wu/p/11274191.html