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_VerifyGetPerformanceCounterMatch() { int returnedId = WindowsPerformanceFacade.GetPerformanceCounterId("a", "b", "c"); PerformanceCounterKey foo = WindowsPerformanceFacade.GetPerformanceCounterKey(returnedId); Assert.AreEqual("a", foo.CategoryName); Assert.AreEqual("b", foo.InstanceName); Assert.AreEqual("c", foo.CounterName); }
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_GetTicks() { long firstTick = WindowsPerformanceFacade.StopwatchTimestamp(); Thread.Sleep(100); long secondTick = WindowsPerformanceFacade.StopwatchTimestamp(); long elapsedTicks = secondTick - firstTick; //// Dividing by Frequency gives you seconds but we want milliseconds //// Assume we're not off by more than 10 msec on a 100msec wait Assert.AreEqual(100, (1000 * elapsedTicks) / Stopwatch.Frequency, 10); }
public void WindowsPerformanceFacadeTest_VerifySetGetNextValue() { int counterId = WindowsPerformanceFacade.GetPerformanceCounterId(CounterTestUtilities.TestCategoryName, null, CounterTestUtilities.TestCounterNumberOfItems64Name); WindowsPerformanceFacade.SetRawValue(counterId, 0); float initialValue = WindowsPerformanceFacade.GetRawValue(counterId); Assert.AreEqual(0.0, initialValue, 0.001); // shouldn't need delta... WindowsPerformanceFacade.SetRawValue(counterId, 10); float finalValue = WindowsPerformanceFacade.GetRawValue(counterId); Assert.AreEqual(10.0, finalValue, 0.001); // shouldn't need delta }
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); }
public void WindowsPerformanceFacadeTest_VerifyFailsNonExistentCategoryNameTest() { int counterId = WindowsPerformanceFacade.GetPerformanceCounterId("dogfood", null, "catfood"); WindowsPerformanceFacade.Increment(counterId); }
public void WindowsPerformanceFacadeTest_VerifyFailsNoCategoryNameTest() { WindowsPerformanceFacade.CacheCounters(string.Empty, null); }
public void WindowsPerformanceFacadeTest_VerifyGetPerformanceCounterNotCreated() { WindowsPerformanceFacade.GetPerformanceCounterKey(12); }