public void WindowsPerformanceFacadeTest_VerifyIncrementSimple64() { int counterId = WindowsPerformanceFacade.GetPerformanceCounterId(CounterTestUtilities.TestCategoryName, null, CounterTestUtilities.TestCounterNumberOfItems64Name); float initialValue = WindowsPerformanceFacade.NextValue(counterId); WindowsPerformanceFacade.Increment(counterId); float finalValue = WindowsPerformanceFacade.NextValue(counterId); Assert.AreEqual(initialValue + 1, 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_VerifyFailsNonExistentCategoryNameTest() { int counterId = WindowsPerformanceFacade.GetPerformanceCounterId("dogfood", null, "catfood"); WindowsPerformanceFacade.Increment(counterId); }