コード例 #1
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();
            }
        }
コード例 #2
0
        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.Affinity.IsDefault)
            {
                process.EnsureProcessorAffinity(benchmark.Job.Env.Affinity.SpecifiedValue);
            }

            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]));
        }