System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
stopwatch.Start(); // 开始监视代码运行时间

//需要监测的代码

stopwatch.Stop(); // 停止监视
TimeSpan timespan = stopwatch.Elapsed; // 获取当前实例测量得出的总时间

string hours = timespan.TotalHours.ToString("#0.00000000 "); // 总小时
string minutes = timespan.TotalMinutes.ToString("#0.00000000 "); // 总分钟
string seconds = timespan.TotalSeconds.ToString("#0.00000000 "); // 总秒数
string milliseconds = timespan.TotalMilliseconds.ToString("#0.00000000 "); // 总毫秒数

  

相关文章:

  • 2021-12-13
  • 2021-07-04
  • 2022-12-23
  • 2021-05-23
  • 2021-08-21
  • 2021-12-16
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-23
  • 2021-08-02
  • 2021-09-10
  • 2021-07-29
  • 2022-12-23
相关资源
相似解决方案