StopwatchHelper.cs 449 B

12345678910111213141516171819202122
  1. using System;
  2. using System.Diagnostics;
  3. namespace Masuit.Tools.Systems;
  4. /// <summary>
  5. /// 计数器帮助类
  6. /// </summary>
  7. public static class StopwatchHelper
  8. {
  9. /// <summary>
  10. /// 执行方法
  11. /// </summary>
  12. /// <param name="action"></param>
  13. /// <returns></returns>
  14. public static double Execute(Action action)
  15. {
  16. var sw = Stopwatch.StartNew();
  17. action();
  18. return sw.ElapsedMilliseconds;
  19. }
  20. }