StopwatchHelper.cs 518 B

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