Exemple #1
0
        /// <summary>
        /// See if tracing is allowed.  If tracing is allowed, tracing will not be allowed to occur
        /// again until the allotted time (1/qps) has passed.
        /// </summary>
        /// <returns>True if tracing is allowed.</returns>
        public bool CanTrace()
        {
            var nowMillis      = _timer.GetElapsedMilliseconds();
            var lastCallMillis = _lastCallMillis;

            return((nowMillis - lastCallMillis >= _fixedDelayMillis) &&
                   Interlocked.CompareExchange(ref _lastCallMillis, nowMillis, lastCallMillis) == lastCallMillis);
        }
Exemple #2
0
        public void TimerTracksTimeAccordingToTimer()
        {
            mTimer.GetElapsedMilliseconds().Returns(TIME_PER_STEP);
            mAnalyticsTimerUnderTest.Start();
            mAnalyticsTimerUnderTest.StepComplete(STEP_1);
            mAnalyticsTimerUnderTest.StepComplete(STEP_2);
            mAnalyticsTimerUnderTest.StopAndSendAnalytic();

            Assert.AreEqual(TIME_PER_STEP, mAnalyticsTimerUnderTest.StepData[STEP_1]);
            Assert.AreEqual(TIME_PER_STEP, mAnalyticsTimerUnderTest.StepData[STEP_2]);
            Assert.AreEqual(TIME_PER_STEP * 3, mAnalyticsTimerUnderTest.TotalTime);
        }
Exemple #3
0
        /// <summary>
        /// See if tracing is allowed.  If tracing is allowed, tracing will not be allowed to occur
        /// again until the allotted time (1/qps) has passed.
        /// </summary>
        /// <returns>True if tracing is allowed.</returns>
        public bool CanTrace()
        {
            if (_fixedDelayMillis == 0)
            {
                return(true);
            }

            lock (_lastCallMutex)
            {
                var nowMillis = _timer.GetElapsedMilliseconds();
                if (nowMillis - _lastCallMillis >= _fixedDelayMillis)
                {
                    _lastCallMillis = nowMillis;
                    return(true);
                }

                return(false);
            }
        }
Exemple #4
0
 private void AddStepToEventData(string i_stepName)
 {
     mStepData.Add(i_stepName, mTimer.GetElapsedMilliseconds());
 }