private void TestDivisibilityChecker(ICheckDivisibilityBySeven divisibilityChecker) { for (uint i = 0; i <= MaxTestValue; ++i) { Assert.AreEqual(_modChecker.IsDivisibleBySeven(i), divisibilityChecker.IsDivisibleBySeven(i)); } }
private long TimeTakenInMilliseconds(ICheckDivisibilityBySeven checker) { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); for (uint i = 0; i <= TestValueCount; ++i) { checker.IsDivisibleBySeven(i); } stopWatch.Stop(); return stopWatch.ElapsedMilliseconds; }
private void PerformanceTestBitShiftAlgorithm(ICheckDivisibilityBySeven standardChecker, double acceptableFactor) { // Code to prime the jitter. _bitShiftChecker.IsDivisibleBySeven(1337); standardChecker.IsDivisibleBySeven(1337); long bitShiftMilliseconds = TimeTakenInMilliseconds(_bitShiftChecker); long typicalMethodMilliseconds = TimeTakenInMilliseconds(standardChecker); var speedUpFactor = typicalMethodMilliseconds/(double) bitShiftMilliseconds; Assert.GreaterOrEqual(speedUpFactor, acceptableFactor); }
private long TimeTakenInMilliseconds(ICheckDivisibilityBySeven checker) { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); for (uint i = 0; i <= TestValueCount; ++i) { checker.IsDivisibleBySeven(i); } stopWatch.Stop(); return(stopWatch.ElapsedMilliseconds); }
private void PerformanceTestBitShiftAlgorithm(ICheckDivisibilityBySeven standardChecker, double acceptableFactor) { // Code to prime the jitter. _bitShiftChecker.IsDivisibleBySeven(1337); standardChecker.IsDivisibleBySeven(1337); long bitShiftMilliseconds = TimeTakenInMilliseconds(_bitShiftChecker); long typicalMethodMilliseconds = TimeTakenInMilliseconds(standardChecker); var speedUpFactor = typicalMethodMilliseconds / (double)bitShiftMilliseconds; Assert.GreaterOrEqual(speedUpFactor, acceptableFactor); }
private void TestDivisibilityChecker(ICheckDivisibilityBySeven divisibilityChecker) { for (uint i = 0; i <= MaxTestValue; ++i) Assert.AreEqual(_modChecker.IsDivisibleBySeven(i), divisibilityChecker.IsDivisibleBySeven(i)); }