Пример #1
0
        public IDisposable MeasureEventDuration(string componentName, string eventName)
        {
            if (!StateSynchronizationPerformanceParameters.EnablePerformanceReporting)
            {
                return(null);
            }

            var key = new StopWatchKey(componentName, eventName);

            if (!eventStopWatches.TryGetValue(key, out var stopwatch))
            {
                stopwatch = new Stopwatch();
                eventStopWatches.Add(key, stopwatch);
            }

            return(new TimeScope(stopwatch));
        }
Пример #2
0
        public void IncrementEventCount(string componentName, string eventName)
        {
            if (!StateSynchronizationPerformanceParameters.EnablePerformanceReporting)
            {
                return;
            }

            var key = new StopWatchKey(componentName, eventName);

            if (!eventCounts.ContainsKey(key))
            {
                eventCounts.Add(key, 1);
            }
            else
            {
                eventCounts[key]++;
            }
        }