public void WindowsPerformanceFacadeTest_VerifyWeCanSeeWellKnownCategoryTest()
        {
            int   counterId = WindowsPerformanceFacade.GetPerformanceCounterId("cache", null, "Dirty Pages");
            float value     = WindowsPerformanceFacade.NextValue(counterId);

            Assert.AreNotEqual(0.0f, value, 0.1f, "dirty pages should not be 0.0");
        }
        public void WindowsPerformanceFacadeTest_VerifyIncrementBySimple64()
        {
            int   counterId    = WindowsPerformanceFacade.GetPerformanceCounterId(CounterTestUtilities.TestCategoryName, null, CounterTestUtilities.TestCounterNumberOfItems64Name);
            float initialValue = WindowsPerformanceFacade.NextValue(counterId);

            WindowsPerformanceFacade.IncrementBy(counterId, 3);
            float finalValue = WindowsPerformanceFacade.NextValue(counterId);

            Assert.AreEqual(initialValue + 3, finalValue);
        }
        public void WindowsPerformanceFacadeTest_VerifyIncrementAverageTimer32()
        {
            int counterId = WindowsPerformanceFacade.GetPerformanceCounterId(CounterTestUtilities.TestCategoryName, null, CounterTestUtilities.TestAverageTimer32Name);

            WindowsPerformanceFacade.Increment(counterId);
            WindowsPerformanceFacade.Increment(counterId);
            float finalValue = WindowsPerformanceFacade.NextValue(counterId);
            //// ((N1 - N0) / F) / (B1 - B0)
            //// how fast is our clock
            float freq        = Stopwatch.Frequency;
            float numerator   = ((float)(2 - 1)) / freq;
            float denominator = 2 - 1;

            Assert.AreEqual(numerator / denominator, finalValue, .002, "Freq: " + freq);
        }
        public void WindowsPerformanceFacadeTest_VerifyDecrementAverageTimer32()
        {
            int counterId = WindowsPerformanceFacade.GetPerformanceCounterId(CounterTestUtilities.TestCategoryName, null, CounterTestUtilities.TestAverageTimer32Name);

            WindowsPerformanceFacade.Increment(counterId);
            WindowsPerformanceFacade.Increment(counterId);
            WindowsPerformanceFacade.Decrement(counterId);
            float finalValue = WindowsPerformanceFacade.NextValue(counterId);
            //// ((N1 - N0) / F) / (B1 - B0)
            //// how fast is our clock
            float freq = Stopwatch.Frequency;
            //// ((N1 - N0) / F)
            float numerator   = (1 - 2) / freq;
            float denominator = 3 - 2;

            Assert.AreEqual(numerator / denominator, finalValue, .002, "Freq: " + freq);
            //// the final value is actually 0 here and our calculatd value is very small, almost -0
        }
        public void WindowsPerformanceFacadeTest_VerifyIncrementByAverageTimer32()
        {
            //// The spans need to be ever increasing number like if you used a global stopwatch
            long span1 = 1000;
            long span2 = 2000;

            int counterId = WindowsPerformanceFacade.GetPerformanceCounterId(CounterTestUtilities.TestCategoryName, null, CounterTestUtilities.TestAverageTimer32Name);

            //// average (time) of all measurements performed.  lets assume it was clear before we ran the test
            WindowsPerformanceFacade.IncrementBy(counterId, span1);
            WindowsPerformanceFacade.IncrementBy(counterId, span2);
            //// average (time) of all measurements performed.
            float finalValue = WindowsPerformanceFacade.NextValue(counterId);
            //// ((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);
        }