Exemplo n.º 1
0
        /// <summary>Measures the rule execution time and adds this sample to performance counter.</summary>
        /// <param name="rule">Rule being measured.</param>
        /// <returns><see cref="IDisposable"/> that should be disposed after rule has finished it's execution.</returns>
        public IDisposable MeasureRuleExecutionTime(IConsensusRuleBase rule)
        {
            var stopwatch = new StopwatchDisposable(elapsedTicks =>
            {
                this.currentSnapshot.PerformanceInfo[rule].AddTicks(elapsedTicks);
            });

            return(stopwatch);
        }
Exemplo n.º 2
0
        /// <summary>Measures the rule execution time and adds this sample to performance counter.</summary>
        /// <param name="rule">Rule being measured.</param>
        /// <returns><see cref="IDisposable"/> that should be disposed after rule has finished it's execution.</returns>
        public IDisposable MeasureRuleExecutionTime(IConsensusRuleBase rule)
        {
            var stopwatch = new StopwatchDisposable(elapsedTicks =>
            {
                RulePerformance performance = this.currentSnapshot.PerformanceInfo[rule];

                Interlocked.Increment(ref performance.CalledTimes);
                Interlocked.Add(ref performance.ExecutionTimesTicks, elapsedTicks);
            });

            return(stopwatch);
        }