public void PrecaclTimeTest(int size, int expectedTimeMs) { var res = new PrimeReductionWithCount[size]; var sw = Stopwatch.StartNew(); for (uint i = 5; i < res.Length; i++) { res[i] = PrimeFunctions.Reduce(i); } sw.Stop(); Assert.Less(sw.ElapsedMilliseconds, expectedTimeMs, $"Execution took {sw.ElapsedMilliseconds}ms"); }
public void BigInputTest() { var rnd = new Random(42); var source = Enumerable.Repeat(1, 1000) .Select(n => (uint)rnd.Next(100000001, 1000000000)) .ToArray(); var res = new PrimeReductionWithCount[source.Length]; var sw = Stopwatch.StartNew(); for (int i = 0; i < res.Length; i++) { res[i] = PrimeFunctions.Reduce(source[i]); } sw.Stop(); Assert.Less(sw.ElapsedMilliseconds, 4000); }