使用Stopwatch测量运行时间
Stopwatch Watch = new Stopwatch();
//启动计时器
Watch.Start();
log.Debug($"开始调用GetDimensionErrorPage_4:{Watch.ElapsedMilliseconds} ms");
//这里做一些耗时的事情
//这里做一些耗时的事情
//这里做一些耗时的事情
log.Debug($"调用完成 GetDimensionErrorPage_4:{Watch.ElapsedMilliseconds} ms");
Watch.Stop();
Watch = null;
本文介绍了一种使用Stopwatch类测量代码运行时间的方法,通过实例演示了如何在代码中启动、停止计时器,并记录调用特定函数的耗时。
37

被折叠的 条评论
为什么被折叠?



