private ExecuteResult Execute(Process process, Benchmark benchmark, SynchronousProcessOutputLoggerWithDiagnoser loggerWithDiagnoser, IDiagnoser compositeDiagnoser, ILogger logger) { consoleHandler.SetProcess(process); process.Start(); compositeDiagnoser?.ProcessStarted(process); process.EnsureHighPriority(logger); if (!benchmark.Job.Affinity.IsAuto) { process.EnsureProcessorAffinity(benchmark.Job.Affinity.Value); } loggerWithDiagnoser.ProcessInput(); process.WaitForExit(); // should we add timeout here? compositeDiagnoser?.ProcessStopped(process); if (process.ExitCode == 0) { return new ExecuteResult(true, loggerWithDiagnoser.Lines); } return new ExecuteResult(true, new string[0]); }
private ExecuteResult Execute(Benchmark benchmark, ILogger logger, string exeName, string workingDirectory, string args, IDiagnoser diagnoser) { if (consoleHandler == null) { consoleHandler = new ConsoleHandler(logger); Console.CancelKeyPress += consoleHandler.EventHandler; } try { using (var process = new Process { StartInfo = CreateStartInfo(benchmark, exeName, args, workingDirectory) }) { var loggerWithDiagnoser = new SynchronousProcessOutputLoggerWithDiagnoser(logger, process, diagnoser, benchmark); return Execute(process, benchmark, loggerWithDiagnoser, diagnoser, logger); } } finally { consoleHandler.ClearProcess(); } }
private ExecuteResult Execute(Process process, Benchmark benchmark, SynchronousProcessOutputLoggerWithDiagnoser loggerWithDiagnoser, IDiagnoser compositeDiagnoser, ILogger logger) { consoleHandler.SetProcess(process); process.Start(); process.EnsureHighPriority(logger); if (benchmark.Job.Env.HasValue(EnvMode.AffinityCharacteristic)) { process.EnsureProcessorAffinity(benchmark.Job.Env.Affinity); } loggerWithDiagnoser.ProcessInput(); process.WaitForExit(); // should we add timeout here? if (process.ExitCode == 0) { return new ExecuteResult(true, process.ExitCode, loggerWithDiagnoser.LinesWithResults, loggerWithDiagnoser.LinesWithExtraOutput); } return new ExecuteResult(true, process.ExitCode, new string[0], new string[0]); }