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_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_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); }
public void WindowsPerformanceLiasonBoundsTest_VerifyNextValueEmptyCounterCheck() { WindowsPerformanceLiason underTest = new WindowsPerformanceLiason(); underTest.NextValue(CounterTestUtilities.TestCategoryName, string.Empty); }
public void WindowsPerformanceLiasonBoundsTest_VerifyNextValueEmptyCategoryCheck() { WindowsPerformanceLiason underTest = new WindowsPerformanceLiason(); underTest.NextValue(string.Empty, CounterTestUtilities.TestCounterNumberOfItems64Name); }