private void button21_Click(object sender, EventArgs e) { Test001 openCV = new Test001(); openCV.test001(); }
private static void Main(string[] args) { Random rand = new Random(); long remainingTests = 20000; var logIntervalStopwatch = new Stopwatch(); var testBatchStopwatch = new Stopwatch(); long testBatchSize; logIntervalStopwatch.Start(); testBatchStopwatch.Start(); while (true) { testBatchSize = remainingTests; var testRunsStopwatch = new Stopwatch(); while (remainingTests > 0) { if (logIntervalStopwatch.Elapsed.TotalSeconds >= 10) { Console.WriteLine("Number of remaining tests: " + remainingTests); if (testBatchSize - remainingTests != 0) { Console.WriteLine("Remaining time: " + (double)remainingTests / (testBatchSize - remainingTests) * testBatchStopwatch.Elapsed.TotalSeconds + " s"); } logIntervalStopwatch.Restart(); } remainingTests--; var test = new Test001(); test.Seed = rand.Next(int.MinValue, int.MaxValue); //Console.WriteLine("seed: {0}", test.Seed); try { Thread.Yield(); testRunsStopwatch.Start(); Thread.MemoryBarrier(); test.Main(args); Thread.MemoryBarrier(); testRunsStopwatch.Stop(); } catch { Console.WriteLine($"The test failed. The seed was: {test.Seed}."); throw; } } if (testBatchSize > 0) { Console.WriteLine($"Time per test: {testRunsStopwatch.Elapsed.TotalSeconds / testBatchSize} s."); } Console.Write("Enter 'r' or 'n', to restart the test. ?"); string input = Console.ReadLine(); Console.WriteLine(); if (input == "r") { remainingTests = 1; } else if (input == "n") { Console.Write("Enter number of restarts. ?"); long i; string text = Console.ReadLine(); if (long.TryParse(text, out i)) { remainingTests = i; } } if (remainingTests == 0) { break; } testBatchStopwatch.Restart(); logIntervalStopwatch.Restart(); } }