public void WindowsPerformanceLiasonTest_VerifyIncrementByWithBaseAverageTimer32()
        {
            //// The spans need to be ever increasing number like if you used a global stopwatch
            long span1 = 1000;
            long span2 = 2000;

            WindowsPerformanceLiason underTest = new WindowsPerformanceLiason();
            //// average (time) of all measurements performed.  lets assume it was clear before we ran the test
            //// this value is probably 0 because we haven't run any in the past
            float initialValue =
                underTest.NextValue(CounterTestUtilities.TestCategoryName, CounterTestUtilities.TestAverageTimer32Name);

            //// increment the base counters by something other than the default
            underTest.IncrementBy(CounterTestUtilities.TestCategoryName, CounterTestUtilities.TestAverageTimer32Name, span1, 4);
            underTest.IncrementBy(CounterTestUtilities.TestCategoryName, CounterTestUtilities.TestAverageTimer32Name, span2, 4);
            //// average (time) of all measurements performed.
            float finalValue =
                underTest.NextValue(CounterTestUtilities.TestCategoryName, CounterTestUtilities.TestAverageTimer32Name);
            //// ((N1 - N0) / F) / (B1 - B0)
            //// how fast is our clock
            float freq        = Stopwatch.Frequency;
            float numerator   = ((float)(span2 - span1)) / freq;
            float denominator = 8 - 4;

            Assert.AreEqual(numerator / denominator, finalValue, .002, "Freq: " + freq);
        }
        public void WindowsPerformanceLiasonTest_VerifyIncrementBySimple64()
        {
            WindowsPerformanceLiason underTest = new WindowsPerformanceLiason();
            float initialValue =
                underTest.NextValue(CounterTestUtilities.TestCategoryName, CounterTestUtilities.TestCounterNumberOfItems64Name);

            underTest.IncrementBy(CounterTestUtilities.TestCategoryName, CounterTestUtilities.TestCounterNumberOfItems64Name, 3);
            float finalValue =
                underTest.NextValue(CounterTestUtilities.TestCategoryName, CounterTestUtilities.TestCounterNumberOfItems64Name);

            Assert.AreEqual(initialValue + 3, finalValue);
        }
        public void WindowsPerformanceLiasonTest_VerifyIncrementByAverageTimer32()
        {
            //// The spans need to be ever increasing number like if you used a global stopwatch
            long span1 = 1000;
            long span2 = 2000;

            WindowsPerformanceLiason underTest = new WindowsPerformanceLiason();

            //// average (time) of all measurements performed.  lets assume it was clear before we ran the test
            underTest.IncrementBy(CounterTestUtilities.TestCategoryName, CounterTestUtilities.TestAverageTimer32Name, span1);
            underTest.IncrementBy(CounterTestUtilities.TestCategoryName, CounterTestUtilities.TestAverageTimer32Name, span2);
            //// average (time) of all measurements performed.
            float finalValue =
                underTest.NextValue(CounterTestUtilities.TestCategoryName, CounterTestUtilities.TestAverageTimer32Name);
            //// ((N1 - N0) / F) / (B1 - B0)
            //// how fast is our clock
            float freq        = Stopwatch.Frequency;
            float numerator   = ((float)(span2 - span1)) / freq;
            float denominator = 2 - 1;

            Assert.AreEqual(numerator / denominator, finalValue, .002, "Freq: " + freq);
        }
예제 #4
0
        public void PerformanceCounterExplorerTest_TimeIncrementVsIncrementBy()
        {
            WindowsPerformanceLiason updatableCounters = new WindowsPerformanceLiason();
            Stopwatch incrementWatcher = new Stopwatch();

            incrementWatcher.Start();
            for (int i = 0; i < 100000; i++)
            {
                updatableCounters.Increment(CounterTestUtilities.TestCategoryName, CounterTestUtilities.TestCounterNumberOfItems64Name);
            }
            incrementWatcher.Stop();

            Stopwatch incrementByWatcher = new Stopwatch();

            incrementByWatcher.Start();
            for (int i = 0; i < 100000; i++)
            {
                updatableCounters.IncrementBy(CounterTestUtilities.TestCategoryName, CounterTestUtilities.TestCounterNumberOfItems64Name, 1);
            }
            incrementByWatcher.Stop();
            Assert.AreEqual(incrementWatcher.ElapsedMilliseconds, incrementByWatcher.ElapsedMilliseconds, " expected time is the 'increment', actual is 'incrementBy'");
        }
예제 #5
0
        public void WindowsPerformanceLiasonBoundsTest_VerifyIncrementByCounterWithoutBase()
        {
            WindowsPerformanceLiason underTest = new WindowsPerformanceLiason();

            underTest.IncrementBy(CounterTestUtilities.TestCategoryName, CounterTestUtilities.TestCounterNumberOfItems64Name, 3, 3);
        }
예제 #6
0
        public void WindowsPerformanceLiasonBoundsTest_VerifyIncrementByEmptyCounterCheck()
        {
            WindowsPerformanceLiason underTest = new WindowsPerformanceLiason();

            underTest.IncrementBy(CounterTestUtilities.TestCategoryName, string.Empty, 3);
        }
예제 #7
0
        public void WindowsPerformanceLiasonBoundsTest_VerifyIncrementByEmptyCategoryCheck()
        {
            WindowsPerformanceLiason underTest = new WindowsPerformanceLiason();

            underTest.IncrementBy(string.Empty, CounterTestUtilities.TestCounterNumberOfItems64Name, 3);
        }