zhshlimi
/// <summary>
    /// 方法帮助类
    /// </summary>
    public class ActionHelper
    {
        /// <summary>
        /// 统一计算执行时间
        /// </summary>
        /// <param name="action">执行方法</param>
        /// <returns></returns>
        public static int ComputeMethodCostMilliseconds(Action action)
        {
            var stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Start(); //  开始监视
            action();
            stopwatch.Stop(); //  停止监视
            var timeSpan = stopwatch.Elapsed; //  获取总时间

            return (int)timeSpan.TotalMilliseconds;
        }
    }

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-10
  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
  • 2021-07-15
猜你喜欢
  • 2021-12-27
  • 2021-09-12
  • 2021-12-27
  • 2021-11-07
  • 2021-12-07
  • 2022-01-08
  • 2022-12-23
相关资源
相似解决方案