Beispiel #1
0
        private static async Task PerformTesting(
            int[] sizes,
            MatrixProvider provider,
            ResultsSaver saver,
            IEquationSolver solver,
            Action <Matrix> matrixAction = null)
        {
            Stopwatch stopwatch = new Stopwatch();

            foreach (int size in sizes)
            {
                Matrix matrix = provider.GetMatrix(size);

                if (matrixAction != null)
                {
                    matrixAction(matrix);
                }

                stopwatch.Start();
                CalculationResult result = solver.Solve(matrix);
                stopwatch.Stop();

                Console.WriteLine($"{size}x{size} ({result.Answers.Length}): {stopwatch.ElapsedMilliseconds}ms, {stopwatch.ElapsedTicks} ticks");
                stopwatch.Reset();

                string outputFile = string.Format(OutputFileTemplate, $"{size}x{size}", solver.GetType());
                await saver.SaveAsync(outputFile, result);
            }
        }