示例#1
0
        private static Benchmark[] MakeBenchmarks(string slnDir, EndToEndRoslynConfig config, string[] commits)
        {
            var benchmarks = new Benchmark[commits.Length];

            for (int i = 0; i < commits.Length; i++)
            {
                benchmarks[i] = new ExternalProcessBenchmark(
                    Path.Combine(slnDir, "Binaries/CodeAnalysisRepro"),
                    "-noconfig @repro.rsp",
                    BuildRoslyn(slnDir),
                    config.GetJobs().Single(),
                    MakeParameterInstances(commits[i]));
            }
            return(benchmarks);
        }
示例#2
0
        private ProcessStartInfo CreateStartInfo(string exePath, ExternalProcessBenchmark benchmark)
        {
            var startInfo = new ProcessStartInfo
            {
                WorkingDirectory       = benchmark.WorkingDirectory,
                RedirectStandardError  = true,
                RedirectStandardOutput = true,
            };

            var runtime = benchmark.Job.Env.HasValue(EnvMode.RuntimeCharacteristic)
                ? benchmark.Job.Env.Runtime
                : Runtime.Core;

            var args = benchmark.Arguments;

            switch (runtime)
            {
            case ClrRuntime clr:
                startInfo.FileName  = exePath;
                startInfo.Arguments = args;
                break;

            case CoreRuntime core:
                startInfo.FileName  = "dotnet";
                startInfo.Arguments = $"\"{exePath}\" {args}";
                break;

            case MonoRuntime mono:
                startInfo.FileName  = mono.CustomPath ?? "mono";
                startInfo.Arguments = $"\"{exePath}\" {args}";
                break;

            default:
                throw new NotSupportedException("Runtime = " + runtime);
            }

            return(startInfo);
        }
示例#3
0
        private ExecuteResult Execute(Process proc, ExternalProcessBenchmark benchmark, ILogger logger)
        {
            logger.WriteLineInfo($"// Execute: {proc.StartInfo.FileName} {proc.StartInfo.Arguments}");

            var invokeCount  = benchmark.Job.Run.TargetCount;
            var measurements = new string[invokeCount];

            for (int i = 0; i < invokeCount; i++)
            {
                var clock = Chronometer.BestClock;
                var start = clock.Start();

                proc.Start();
                proc.WaitForExit();

                var span = start.Stop();

                var measurement = new Measurement(0, IterationMode.Result, i, 1, span.GetNanoseconds()).ToOutputLine();
                Console.WriteLine(measurement);
                measurements[i] = measurement;
            }

            return(new ExecuteResult(true, proc.ExitCode, measurements, Array.Empty <string>()));
        }