Ejemplo n.º 1
0
 public DiagnoserActionParameters(Process process, Benchmark benchmark, BenchmarkId benchmarkId, IConfig config)
 {
     Process     = process;
     Benchmark   = benchmark;
     BenchmarkId = benchmarkId;
     Config      = config;
 }
Ejemplo n.º 2
0
        private ExecuteResult Execute(BenchmarkCase benchmarkCase, BenchmarkId benchmarkId, ILogger logger, string exePath, string workingDirectory, string args, IDiagnoser diagnoser, IResolver resolver)
        {
            ConsoleExitHandler.Instance.Logger = logger;

            try
            {
                using (var process = new Process {
                    StartInfo = CreateStartInfo(benchmarkCase, exePath, args, workingDirectory, resolver)
                })
                {
                    var loggerWithDiagnoser = new SynchronousProcessOutputLoggerWithDiagnoser(logger, process, diagnoser, benchmarkCase, benchmarkId);

                    diagnoser?.Handle(HostSignal.BeforeProcessStart, new DiagnoserActionParameters(process, benchmarkCase, benchmarkId));

                    return(Execute(process, benchmarkCase, loggerWithDiagnoser, logger));
                }
            }
            finally
            {
                ConsoleExitHandler.Instance.Process = null;
                ConsoleExitHandler.Instance.Logger  = null;

                diagnoser?.Handle(HostSignal.AfterProcessExit, new DiagnoserActionParameters(null, benchmarkCase, benchmarkId));
            }
        }
Ejemplo n.º 3
0
 public ExecuteParameters(BuildResult buildResult, BenchmarkCase benchmarkCase, BenchmarkId benchmarkId, ILogger logger, IResolver resolver, IDiagnoser diagnoser = null)
 {
     BuildResult   = buildResult;
     BenchmarkCase = benchmarkCase;
     BenchmarkId   = benchmarkId;
     Logger        = logger;
     Resolver      = resolver;
     Diagnoser     = diagnoser;
 }
Ejemplo n.º 4
0
        private static MethodInfo GetRunCallback(
            BenchmarkId benchmarkId, Assembly partitionAssembly)
        {
            var runnableType = partitionAssembly.GetType(GetRunnableTypeName(benchmarkId));

            var runnableMethod = runnableType.GetMethod(RunMethodName, BindingFlagsPublicStatic);

            return(runnableMethod);
        }
Ejemplo n.º 5
0
 public ExecuteParameters(BuildResult buildResult, Benchmark benchmark, BenchmarkId benchmarkId, ILogger logger, IResolver resolver, IConfig config, IDiagnoser diagnoser = null)
 {
     BuildResult = buildResult;
     Benchmark   = benchmark;
     BenchmarkId = benchmarkId;
     Logger      = logger;
     Resolver    = resolver;
     Config      = config;
     Diagnoser   = diagnoser;
 }
Ejemplo n.º 6
0
        private ExecuteResult Execute(Benchmark benchmark, BenchmarkId benchmarkId, ILogger logger, string exePath, string workingDirectory, string args, IDiagnoser diagnoser, IResolver resolver, IConfig config)
        {
            ConsoleHandler.EnsureInitialized(logger);

            try
            {
                using (var process = new Process {
                    StartInfo = CreateStartInfo(benchmark, exePath, args, workingDirectory, resolver)
                })
                {
                    var loggerWithDiagnoser = new SynchronousProcessOutputLoggerWithDiagnoser(logger, process, diagnoser, benchmark, benchmarkId, config);

                    return(Execute(process, benchmark, loggerWithDiagnoser, logger));
                }
            }
            finally
            {
                ConsoleHandler.Instance.ClearProcess();
            }
        }
Ejemplo n.º 7
0
        private ExecuteResult Execute(BenchmarkCase benchmarkCase, BenchmarkId benchmarkId, ILogger logger, ArtifactsPaths artifactsPaths,
                                      string args, IDiagnoser diagnoser, IResolver resolver, int launchIndex)
        {
            try
            {
                using (var process = new Process {
                    StartInfo = CreateStartInfo(benchmarkCase, artifactsPaths, args, resolver)
                })
                    using (var consoleExitHandler = new ConsoleExitHandler(process, logger))
                    {
                        var loggerWithDiagnoser = new SynchronousProcessOutputLoggerWithDiagnoser(logger, process, diagnoser, benchmarkCase, benchmarkId);

                        diagnoser?.Handle(HostSignal.BeforeProcessStart, new DiagnoserActionParameters(process, benchmarkCase, benchmarkId));

                        return(Execute(process, benchmarkCase, loggerWithDiagnoser, logger, consoleExitHandler, launchIndex));
                    }
            }
            finally
            {
                diagnoser?.Handle(HostSignal.AfterProcessExit, new DiagnoserActionParameters(null, benchmarkCase, benchmarkId));
            }
        }
Ejemplo n.º 8
0
        public static int Run(
            BenchmarkId benchmarkId,
            Assembly partitionAssembly,
            BenchmarkCase benchmarkCase,
            IHost host)
        {
            // the first thing to do is to let diagnosers hook in before anything happens
            // so all jit-related diagnosers can catch first jit compilation!
            host.BeforeAnythingElse();

            try
            {
                // we are not using Runnable here in any direct way in order to avoid strong dependency Main<=>Runnable
                // which could cause the jitting/assembly loading to happen before we do anything
                // we have some jitting diagnosers and we want them to catch all the informations!!

                var runCallback = GetRunCallback(benchmarkId, partitionAssembly);

                runCallback.Invoke(null, new object[] { benchmarkCase, host });
                return(0);
            }
            catch (Exception oom) when(
                oom is OutOfMemoryException ||
                oom is TargetInvocationException reflection && reflection.InnerException is OutOfMemoryException)
            {
                DumpOutOfMemory(host, oom);
                return(-1);
            }
            catch (Exception ex)
            {
                DumpError(host, ex);
                return(-1);
            }
            finally
            {
                host.AfterAll();
            }
        }
        public SynchronousProcessOutputLoggerWithDiagnoser(ILogger logger, Process process, IDiagnoser diagnoser, BenchmarkCase benchmarkCase, BenchmarkId benchmarkId, IConfig config)
        {
            if (!process.StartInfo.RedirectStandardOutput)
            {
                throw new NotSupportedException("set RedirectStandardOutput to true first");
            }
            if (!process.StartInfo.RedirectStandardInput)
            {
                throw new NotSupportedException("set RedirectStandardInput to true first");
            }

            this.logger               = logger;
            this.process              = process;
            this.diagnoser            = diagnoser;
            diagnoserActionParameters = new DiagnoserActionParameters(process, benchmarkCase, benchmarkId, config);

            LinesWithResults     = new List <string>();
            LinesWithExtraOutput = new List <string>();
        }
Ejemplo n.º 10
0
 private static string GetRunnableTypeName(BenchmarkId benchmarkId)
 {
     return(EmittedTypePrefix + benchmarkId);
 }
        public SynchronousProcessOutputLoggerWithDiagnoser(ILogger logger, Process process, IDiagnoser diagnoser,
                                                           BenchmarkCase benchmarkCase, BenchmarkId benchmarkId, bool noAcknowledgments)
        {
            if (!process.StartInfo.RedirectStandardOutput)
            {
                throw new NotSupportedException("set RedirectStandardOutput to true first");
            }
            if (!(process.StartInfo.RedirectStandardInput || benchmarkCase.GetRuntime() is WasmRuntime || noAcknowledgments))
            {
                throw new NotSupportedException("set RedirectStandardInput to true first");
            }

            this.logger               = logger;
            this.process              = process;
            this.diagnoser            = diagnoser;
            diagnoserActionParameters = new DiagnoserActionParameters(process, benchmarkCase, benchmarkId);

            LinesWithResults     = new List <string>();
            LinesWithExtraOutput = new List <string>();
        }
Ejemplo n.º 12
0
 public DiagnoserActionParameters(Process process, BenchmarkCase benchmarkCase, BenchmarkId benchmarkId)
 {
     Process       = process;
     BenchmarkCase = benchmarkCase;
     BenchmarkId   = benchmarkId;
 }