Beispiel #1
0
 /// <summary>
 /// 性能计数结束
 /// <remarks>性能计数本身会消耗性能,在想统计性能的方法段的开始调用该方法,在末尾调用PerformanceStop()方法可输出日志,两者必须匹配</remarks>
 /// </summary>
 public static void PerformanceStop(object key)
 {
     if (key != null && !string.IsNullOrEmpty(key.ToString()))
     {
         PerformanceHelper.StopPerformance(key.ToString());
     }
 }
        /// <summary>
        /// 性能计数结束
        /// <remarks>性能计数本身会消耗性能,在想统计性能的方法段的开始调用该方法,在末尾调用PerformanceStop()方法可输出日志,两者必须匹配</remarks>
        /// </summary>
        public static void PerformanceStop()
        {
            var stopWatch = new Stopwatch();

            stopWatch.Start();

            var stackFrame = new StackFrame(1, true);
            var fileName   = stackFrame.GetFileName();
            var methodName = stackFrame.GetMethod().Name;

            stopWatch.Stop();

            PerformanceHelper.StopPerformance(fileName, methodName, stopWatch.ElapsedTicks);
        }
Beispiel #3
0
 /// <summary>
 /// 性能计数结束
 /// <remarks>性能计数本身会消耗性能,在想统计性能的方法段的开始调用该方法,在末尾调用PerformanceStop()方法可输出日志,两者必须匹配</remarks>
 /// </summary>
 public static void PerformanceStop([CallerFilePath] string filePath = "", [CallerMemberName] string methodName = "")
 {
     PerformanceHelper.StopPerformance(filePath, methodName);
 }