static void Main(string[] args) { var comparer = new PrimeComparer(); var writer = new PrimeNumberWriter(); MyConsole.WriteLine("Hello World"); const int maxNumberToFind = (int)1e8; const int threadCount = 4; //do //{ // var workers = new BaseBenchmarkStrategy<List<int>>[] // { // // sieve // new SieveOfEratosthenesStrategy(maxNumberToFind), // new ParallelSieveNumberStrategy(maxNumberToFind, threadCount), // // basic // new BasicPrimeNumberStrategy(maxNumberToFind), // new ParallelPrimeNumberStrategy(maxNumberToFind, threadCount), // new FullyParrallelPrimeNumberStrategy(maxNumberToFind, threadCount), // }; // var benchmark = new Benchmark<List<int>>(workers, comparer, writer); // if (!benchmark.StartBenchmark().IsBechmarkSuccessful) // { // break; // } // MyConsole.WriteLine(); //} while (true); //MyConsole.WriteLine("Tests finished!! Press enter"); var averageBenchmark = new AverageBenchmark(); averageBenchmark.StartBenchmark(5, () => { var workers = new BaseBenchmarkStrategy<List<int>>[] { // basic new BasicPrimeNumberStrategy(maxNumberToFind), new ParallelPrimeNumberStrategy(maxNumberToFind, threadCount), //new FullyParrallelPrimeNumberStrategy(maxNumberToFind, threadCount), // sieve //new SieveOfEratosthenesStrategy(maxNumberToFind), //new ParallelSieveNumberStrategy(maxNumberToFind, threadCount), }; var benchmark = new Benchmark<List<int>>(workers, comparer, writer); return benchmark; }, result => { MyConsole.Write("AVG Time {0}/{1}: ", "Basic", "Parrallel"); MyConsole.WriteLine(result.GetAVGTimeComparing(0, 1).ToString()); }); MyConsole.ReadLine(); }
static void Main(string[] args) { MyConsole.WriteLine("Hello World"); WriteDebugInformation(); const int height = 407; const int width = 403; const int step = 1; const int colorsCount = 51; const int threadCount = 4; var averageBenchmark = new AverageBenchmark(); averageBenchmark.StartBenchmark(1, () => { var colors = _colorsGenerator.Generate(height, width, colorsCount, step); var workers = new BaseBenchmarkStrategy<List<Point>>[] { new BasicPointStrategy(colors, height, width), new LockPointStrategy(threadCount, colors, height, width), new ConcurrentPointStrategy(threadCount, colors, height, width) }; var benchmark = new Benchmark<List<Point>>(workers, _pointComparer, _pointWriter); return benchmark; }, result => { MyConsole.Write("AVG Time #{0}/#{1}: ", 1, 2); MyConsole.WriteLine(ConsoleColor.Yellow, result.GetAVGTimeComparing(0, 1).ToString()); MyConsole.Write("AVG Time #{0}/#{1}: ", 1, 3); MyConsole.WriteLine(ConsoleColor.Yellow, result.GetAVGTimeComparing(0, 2).ToString()); MyConsole.Write("AVG Time #{0}/#{1}: ", 2, 3); MyConsole.WriteLine(ConsoleColor.Yellow, result.GetAVGTimeComparing(1, 2).ToString()); }); MyConsole.ReadLine(); }