private static int Main(string[] args) { var inputFilePathPrefix = args.FirstOrDefault(arg => arg.StartsWith("/inPrefix="))?.Substring(10); // ?? @"C:\tmp\aggregated_"; var outputFilePath = args.FirstOrDefault(arg => arg.StartsWith("/out="))?.Substring(5); // ?? @"C:\tmp\aggregated-results.csv"; var numberOfInputFilesString = args.FirstOrDefault(arg => arg.StartsWith("/count="))?.Substring(7); // ?? "3"; int numberOfInputFiles; if (string.IsNullOrEmpty(inputFilePathPrefix) || string.IsNullOrEmpty(outputFilePath) || !int.TryParse(numberOfInputFilesString, NumberStyles.Integer, CultureInfo.InvariantCulture, out numberOfInputFiles) || numberOfInputFiles < 1) { Console.WriteLine($"Called with: {string.Join(" ", args)}"); PrintHelp(); return(-1); } Console.WriteLine($"Aggregating the ReportAnalyzer times from files {inputFilePathPrefix} 0-{numberOfInputFiles - 1}"); var filesProvider = new InputFilesProvider(inputFilePathPrefix, numberOfInputFiles, "txt"); var result = GetAggregatedAnalyzerExecutionTimes(filesProvider); Console.WriteLine($"Writing results to {outputFilePath}"); var csvExporter = new CsvResultsExporter(); csvExporter.Export(outputFilePath, result); Console.WriteLine($"Execution times aggregated in CSV format into {outputFilePath}"); return(0); }
private static IEnumerable <AnalyzerExecutionTimes> GetAggregatedAnalyzerExecutionTimes(InputFilesProvider filesProvider) { var aggregator = new ExecutionTimesAggregator(); var analyzerExecutionTimes = filesProvider .GetLinesOfFiles() .SelectMany(filesLines => filesLines.Select(fileLines => fileLines)) .Select(AnalyzerExecutionTime.FromString) .ToList(); analyzerExecutionTimes.ForEach(line => aggregator.AddAnalyzerExecutionTime(line)); return(aggregator.GetAggregatedResults()); }