Beispiel #1
0
        public PerformanceContainer(
            ITelemetryLogger logger,
            IPerformanceRecordFactory factory,
            IPerformanceSaver saver)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            if (factory == null)
            {
                throw new ArgumentNullException("factory");
            }
            if (saver == null)
            {
                throw new ArgumentNullException("saver");
            }

            _logger = logger;
            _factory = factory;
            _saver = saver;
            _activeRecordDict = new ConcurrentDictionary<int, IPerformanceRecord>();
        }
Beispiel #2
0
        public PerformanceRecord(
            string className,
            string methodName,
            IPerformanceRecordFactory recordFactory,
            IPerformanceTimerFactory timerFactory,
            IPerformanceRecord parent)
        {
            if (className == null)
            {
                throw new ArgumentNullException("className");
            }
            if (methodName == null)
            {
                throw new ArgumentNullException("methodName");
            }
            if (recordFactory == null)
            {
                throw new ArgumentNullException("recordFactory");
            }
            if (timerFactory == null)
            {
                throw new ArgumentNullException("timerFactory");
            }

            //parent allowed to be null


            _className = className;
            _methodName = methodName;
            _recordFactory = recordFactory;
            _parent = parent;

            Active = true;
            _diedChildren = new List<IPerformanceRecord>();

            var creationStack = new StackTrace(1, true).ToString(); //единица подобрана так, чтобы "служебные" фреймы перформанса не попадали в стек
            _creationStack = string.IsInterned(creationStack) ?? creationStack; //memory economy

            //Запоминаем время
            _startTime = timerFactory.GetCurrentTime();
            _timer = timerFactory.CreatePerformanceTimer();
        }