public BenchmarkExecResult Execute(BenchmarkBuildResult buildResult, BenchmarkParameters parameters, IBenchmarkDiagnoser diagnoser) { var exeName = Path.Combine(buildResult.DirectoryPath, "Program.exe"); var args = parameters == null ? string.Empty : parameters.ToArgs(); if (File.Exists(exeName)) { try { var startInfo = CreateStartInfo(exeName, args); using (var process = Process.Start(startInfo)) { if (process != null) { consoleHandler.SetProcess(process); return ExecuteImpl(process, diagnoser, exeName); } } } finally { if (consoleHandler != null) { consoleHandler.ClearProcess(); } } } return new BenchmarkExecResult(false, new string[0]); }
private BenchmarkExecResult ExecuteImpl(Process process, IBenchmarkDiagnoser diagnoser, string exeName) { process.PriorityClass = ProcessPriorityClass.High; process.ProcessorAffinity = new IntPtr(2); var lines = new List<string>(); string line; while ((line = process.StandardOutput.ReadLine()) != null) { logger?.WriteLine(line); if (!line.StartsWith("//") && !string.IsNullOrEmpty(line)) lines.Add(line); // Wait until we know "Warmup" is happening, and then dissassemble the process if (codeAlreadyExtracted == false && line.StartsWith("// Warmup") && !line.StartsWith("// Warmup (idle)")) { try { diagnoser.Print(benchmark, process, logger); } finally { // Always set this, even if something went wrong, otherwise we will try on every run of a benchmark batch codeAlreadyExtracted = true; } } } if (process.HasExited && process.ExitCode != 0) { if (logger != null) { logger.WriteError( $"Something bad happened during the execution of {exeName}. Try to run the benchmark again using an AnyCPU application\n"); } else { if (exeName.ToLowerInvariant() == "msbuild") Console.WriteLine("Build failed"); } return new BenchmarkExecResult(true, new string[0]); } return new BenchmarkExecResult(true, lines); }
public BenchmarkExecResult Execute(BenchmarkBuildResult buildResult, BenchmarkParameters parameters, IBenchmarkDiagnoser diagnoser) { Done = true; return new BenchmarkExecResult(true, new string[0]); }
public BenchmarkExecResult Execute(BenchmarkBuildResult buildResult, BenchmarkParameters parameters, IBenchmarkDiagnoser diagnoser) { return executor.Execute(buildResult, parameters, diagnoser); }
public BenchmarkExecResult Execute(BenchmarkBuildResult buildResult, BenchmarkParameters parameters, IBenchmarkDiagnoser diagnoser) { Done = true; return(new BenchmarkExecResult(true, new string[0])); }
public BenchmarkExecResult Execute(BenchmarkBuildResult buildResult, BenchmarkParameters parameters, IBenchmarkDiagnoser diagnoser) { var exeName = Path.Combine(buildResult.DirectoryPath, "Program.exe"); var args = parameters == null ? string.Empty : parameters.ToArgs(); if (File.Exists(exeName)) { var lines = new List <string>(); var startInfo = CreateStartInfo(exeName, args); using (var process = Process.Start(startInfo)) { if (process != null) { process.PriorityClass = ProcessPriorityClass.High; process.ProcessorAffinity = new IntPtr(2); string line; while ((line = process.StandardOutput.ReadLine()) != null) { logger?.WriteLine(line); if (!line.StartsWith("//") && !string.IsNullOrEmpty(line)) { lines.Add(line); } // Wait until we know "Warmup" is happening, and then dissassemble the process if (codeAlreadyExtracted == false && line.StartsWith("// Warmup") && !line.StartsWith("// Warmup (idle)")) { try { diagnoser.Print(benchmark, process, logger); } finally { // Always set this, even if something went wrong, otherwise we will try on every run of a benchmark batch codeAlreadyExtracted = true; } } } if (process.HasExited && process.ExitCode != 0) { if (logger != null) { logger.WriteError( $"Something bad happened during the execution of {exeName}. Try to run the benchmark again using an AnyCPU application\n"); } else { if (exeName.ToLowerInvariant() == "msbuild") { Console.WriteLine("Build failed"); } } return(new BenchmarkExecResult(true, new string[0])); } } } return(new BenchmarkExecResult(true, lines)); } return(new BenchmarkExecResult(false, new string[0])); }
public IBenchmarkPluginBuilder AddDiagnoser(IBenchmarkDiagnoser diagnoser) { diagnosers.Add(diagnoser); return(this); }
public BenchmarkExecResult Execute(BenchmarkBuildResult buildResult, BenchmarkParameters parameters, IBenchmarkDiagnoser diagnoser) { return(executor.Execute(buildResult, parameters, diagnoser)); }