0
点赞
收藏
分享

微信扫一扫

C#之时间统计

一点读书 2022-07-18 阅读 63
  1. DateTime beforDT = System.DateTime.Now;

  2. //耗时巨大的代码

  3. DateTime afterDT = System.DateTime.Now;
  4. TimeSpan ts = afterDT.Subtract(beforDT);
  5. "DateTime总共花费{0}ms.", ts.TotalMilliseconds);

 

  1. new Stopwatch();
  2. sw.Start();

  3. //耗时巨大的代码

  4. sw.Stop();
  5. TimeSpan ts2 = sw.Elapsed;
  6. "Stopwatch总共花费{0}ms.", ts2.TotalMilliseconds);

黄世宇/Shiyu Huang's Personal Page:​​https://huangshiyu13.github.io/​​



举报

相关推荐

0 条评论