示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DurationPerformanceResult"/> class.
 /// </summary>
 public DurationPerformanceResult(DurationPerformanceCalculator calculator, DateTime timestampKey, long sumAvgTicks, long sumMaxTicks, long sumMinTicks)
     : base(calculator, timestampKey)
 {
     this.SumAverageTicks = sumAvgTicks;
     this.SumMaxTicks     = sumMaxTicks;
     this.SumMinTicks     = sumMinTicks;
 }
示例#2
0
        /// <summary>
        /// Executes the given action and measures the time it took in total.
        /// </summary>
        /// <param name="activity">The Activity to report to.</param>
        /// <param name="actionToExecute">The action to be executed and measured.</param>
        public void ExecuteAndMeasureActivityDuration(string activity, Action actionToExecute)
        {
            DurationPerformanceCalculator kpiCalculator = GetKpiCalculator <DurationPerformanceCalculator>(activity);
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            try
            {
                actionToExecute();
            }
            finally
            {
                kpiCalculator.NotifyActivityDuration(stopwatch.ElapsedMilliseconds);
            }
        }
示例#3
0
        /// <summary>
        /// Notifies that the given activity took the given count of ticks.
        /// </summary>
        /// <param name="activity">The Activity to report to.</param>
        /// <param name="durationTicks">Total count of ticks to be notified.</param>
        public void NotifyActivityDuration(string activity, long durationTicks)
        {
            DurationPerformanceCalculator kpiCalculator = GetKpiCalculator <DurationPerformanceCalculator>(activity);

            kpiCalculator.NotifyActivityDuration(durationTicks);
        }