public void WindowsPerformanceLiasonTest_VerifyIncrementAverageTimer32() { WindowsPerformanceLiason underTest = new WindowsPerformanceLiason(); underTest.Increment(CounterTestUtilities.TestCategoryName, CounterTestUtilities.TestAverageTimer32Name); underTest.Increment(CounterTestUtilities.TestCategoryName, CounterTestUtilities.TestAverageTimer32Name); 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)(2 - 1)) / freq; float denominator = 2 - 1; Assert.AreEqual(numerator / denominator, finalValue, .002, "Freq: " + freq); }
public void WindowsPerformanceLiasonTest_VerifyDecrementAverageTimer32() { WindowsPerformanceLiason underTest = new WindowsPerformanceLiason(); underTest.Increment(CounterTestUtilities.TestCategoryName, CounterTestUtilities.TestAverageTimer32Name); underTest.Increment(CounterTestUtilities.TestCategoryName, CounterTestUtilities.TestAverageTimer32Name); underTest.Decrement(CounterTestUtilities.TestCategoryName, CounterTestUtilities.TestAverageTimer32Name); float finalValue = underTest.NextValue(CounterTestUtilities.TestCategoryName, CounterTestUtilities.TestAverageTimer32Name); //// ((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 WindowsPerformanceLiasonTest_VerifyIncrementSimple64() { WindowsPerformanceLiason underTest = new WindowsPerformanceLiason(); float initialValue = underTest.NextValue(CounterTestUtilities.TestCategoryName, CounterTestUtilities.TestCounterNumberOfItems64Name); underTest.Increment(CounterTestUtilities.TestCategoryName, CounterTestUtilities.TestCounterNumberOfItems64Name); float finalValue = underTest.NextValue(CounterTestUtilities.TestCategoryName, CounterTestUtilities.TestCounterNumberOfItems64Name); Assert.AreEqual(initialValue + 1, finalValue); }
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'"); }
public void WindowsPerformanceLiasonBoundsTest_VerifyIncrementEmptyCounterCheck() { WindowsPerformanceLiason underTest = new WindowsPerformanceLiason(); underTest.Increment(CounterTestUtilities.TestCategoryName, string.Empty); }
public void WindowsPerformanceLiasonBoundsTest_VerifyIncrementEmptyCategoryCheck() { WindowsPerformanceLiason underTest = new WindowsPerformanceLiason(); underTest.Increment(string.Empty, CounterTestUtilities.TestCounterNumberOfItems64Name); }