public static void RunParse(ProfileSet set) { var runner = ProfileTools.GetSet(set); var reportTime = set switch { ProfileSet.Primitives => 10000, ProfileSet.Middle => 5000, ProfileSet.Complex => 1000, ProfileSet.All => 2000, _ => throw new ArgumentOutOfRangeException(nameof(set), set, null) }; var parseBench = new ProfileParserSet(); for (int i = 0; i < 3; i++) { runner(parseBench); } int measurementsCount = 0; int historyCount = 10; var parseStopWatch = new Stopwatch(); var parseHistory = new LinkedList <double>(); for (int iterations = 1; !Console.KeyAvailable || Console.ReadKey().Key != ConsoleKey.Escape; iterations++) { parseStopWatch.Start(); runner(parseBench); parseStopWatch.Stop(); if (iterations >= reportTime) { measurementsCount++; parseHistory.AddAndTruncate(parseStopWatch.Elapsed.TotalMilliseconds, historyCount); PrintHeader("PARSE", set, measurementsCount, parseStopWatch.Elapsed); PrintResults("parse ", parseStopWatch.Elapsed, parseHistory, iterations); PrintFooter(); parseStopWatch.Reset(); iterations = 1; } } }
public static void RunAll(ProfileSet set) { var runner = ProfileTools.GetSet(set); var reportTime = set switch { ProfileSet.Primitives => 4000, ProfileSet.Middle => 1500, ProfileSet.Complex => 500, ProfileSet.All => 500, _ => throw new ArgumentOutOfRangeException(nameof(set), set, null) }; var buildBench = new ProfileBuildAllSet(); var parseBench = new ProfileParserSet(); var updateBench = new ProfileUpdateSet(); var calculateBench = new ProfileCalculateSet(); for (int i = 0; i < 3; i++) { runner(parseBench); runner(buildBench); runner(updateBench); runner(calculateBench); } int measurementsCount = 0; int historyCount = 10; var parseStopWatch = new Stopwatch(); var parseHistory = new LinkedList <double>(); var buildStopWatch = new Stopwatch(); var buildHistory = new LinkedList <double>(); var interpritateHistory = new LinkedList <double>(); var updateStopWatch = new Stopwatch(); var updateHistory = new LinkedList <double>(); var calcStopWatch = new Stopwatch(); var calcHistory = new LinkedList <double>(); for (int iterations = 1; !Console.KeyAvailable || Console.ReadKey().Key != ConsoleKey.Escape; iterations++) { parseStopWatch.Start(); runner(parseBench); parseStopWatch.Stop(); buildStopWatch.Start(); runner(buildBench); buildStopWatch.Stop(); updateStopWatch.Start(); runner(updateBench); updateStopWatch.Stop(); calcStopWatch.Start(); runner(calculateBench); calcStopWatch.Stop(); if (iterations >= reportTime) { measurementsCount++; parseHistory.AddAndTruncate(parseStopWatch.Elapsed.TotalMilliseconds, historyCount); buildHistory.AddAndTruncate(buildStopWatch.Elapsed.TotalMilliseconds, historyCount); interpritateHistory.AddAndTruncate(buildStopWatch.Elapsed.TotalMilliseconds - parseStopWatch.Elapsed.TotalMilliseconds, historyCount); updateHistory.AddAndTruncate(updateStopWatch.Elapsed.TotalMilliseconds, historyCount); calcHistory.AddAndTruncate(calcStopWatch.Elapsed.TotalMilliseconds, historyCount); var total = parseStopWatch.Elapsed + buildStopWatch.Elapsed + updateStopWatch.Elapsed + calcStopWatch.Elapsed; var buildAndRunTime = buildStopWatch.Elapsed + calcStopWatch.Elapsed; parseStopWatch.Reset(); buildStopWatch.Reset(); updateStopWatch.Reset(); calcStopWatch.Reset(); PrintHeader("everything", set, measurementsCount, total); PrintResults("parse ", buildAndRunTime, parseHistory, iterations); PrintResults("interprt ", buildAndRunTime, interpritateHistory, iterations); PrintResults("calculate", buildAndRunTime, calcHistory, iterations); PrintResults("update ", buildAndRunTime, updateHistory, iterations); PrintFooter(); iterations = 1; } } }