public void StressTest() { var random = new Random(); for (int i = 0; i < 1; i++) { var points = GeneratePoints(r.Next(1, 50001)); var starts = GenerateStarts(r.Next(1, 50001)); var ends = GenerateEnds(starts); var naiveResult = Organize_Lottery.NaiveCountSegments(starts, ends, points); var stopwatch = new Stopwatch(); stopwatch.Start(); var fastResult = Organize_Lottery.FastCountSegments(starts, ends, points); stopwatch.Stop(); Assert.AreEqual(naiveResult.Count, fastResult.Count); Assert.IsTrue(stopwatch.ElapsedMilliseconds / 1000F < 5F); for (int x = 0; x < naiveResult.Count; x++) { int n = naiveResult[x]; int f = fastResult[x]; Assert.AreEqual(n, f, x + " " + i); } } }
public void StressTestDebug() { var random = new Random(); for (int i = 0; i < 100000; i++) { var points = GeneratePoints(r.Next(1, 51), -1000, 1001); var starts = GenerateStarts(r.Next(1, 51), -1000, 1001); var ends = GenerateEnds(starts, 1001); var naiveResult = Organize_Lottery.NaiveCountSegments(starts, ends, points); var fastResult = Organize_Lottery.FastCountSegments(starts, ends, points); Assert.AreEqual(naiveResult.Count, fastResult.Count); for (int x = 0; x < naiveResult.Count; x++) { int n = naiveResult[x]; int f = fastResult[x]; Assert.AreEqual(n, f, x + " " + i); } } }