Пример #1
0
        static void Main(string[] args)
        {
            var options = JitBenchHarnessOptions.Parse(args);

            s_temporaryDirectory = Path.Combine(options.IntermediateOutputDirectory, "JitBench");
            s_targetArchitecture = options.TargetArchitecture;
            if (string.IsNullOrWhiteSpace(s_targetArchitecture))
            {
                throw new ArgumentNullException("Unspecified target architecture.");
            }

            if (Directory.Exists(s_temporaryDirectory))
            {
                Directory.Delete(s_temporaryDirectory, true);
            }
            Directory.CreateDirectory(s_temporaryDirectory);

            s_jitBenchDevDirectory = Path.Combine(s_temporaryDirectory, "JitBench-dev");

            using (var h = new XunitPerformanceHarness(args))
            {
                ProcessStartInfo startInfo = Setup();
                h.RunScenario(startInfo, () => { PrintHeader("Running Benchmark Scenario"); }, PostIteration, PostProcessing, s_ScenarioConfiguration);
            }
        }
Пример #2
0
        private static void SetupStatics(JitBenchHarnessOptions options)
        {
            s_temporaryDirectory = options.IntermediateOutputDirectory;
            s_targetArchitecture = options.TargetArchitecture;
            if (string.IsNullOrWhiteSpace(s_targetArchitecture))
            {
                throw new ArgumentNullException("Unspecified target architecture.");
            }

            // J == JitBench folder. By reducing the length of the directory
            // name we attempt to reduce the chances of hitting PATH length
            // problems we have been hitting in the lab.
            // The changes we have done have reduced it in this way:
            // C:\Jenkins\workspace\perf_scenario---5b001a46\bin\sandbox\JitBench\JitBench-dev
            // C:\j\workspace\perf_scenario---5b001a46\bin\sandbox\JitBench\JitBench-dev
            // C:\j\w\perf_scenario---5b001a46\bin\sandbox\JitBench\JitBench-dev
            // C:\j\w\perf_scenario---5b001a46\bin\sandbox\J
            s_jitBenchDevDirectory  = Path.Combine(s_temporaryDirectory, "J");
            s_dotnetProcessFileName = Path.Combine(s_jitBenchDevDirectory, ".dotnet", "dotnet.exe");
            s_musicStoreDirectory   = Path.Combine(s_jitBenchDevDirectory, "src", "MusicStore");

            s_localJitBenchRepo = options.LocalJitBenchRepo;
            if (s_localJitBenchRepo != null && !Directory.Exists(s_localJitBenchRepo))
            {
                throw new Exception("Requested local JitBench repo " + s_localJitBenchRepo + " does not exist");
            }
        }
Пример #3
0
        private static void SetupStatics(JitBenchHarnessOptions options)
        {
            // Set variables we will need to store results.
            s_iterations       = options.Iterations;
            s_iteration        = 0;
            s_startupTimes     = new double[s_iterations];
            s_requestTimes     = new double[s_iterations];
            s_steadystateTimes = new double[s_iterations];

            s_temporaryDirectory = options.IntermediateOutputDirectory;
            s_targetArchitecture = options.TargetArchitecture;
            if (string.IsNullOrWhiteSpace(s_targetArchitecture))
            {
                throw new ArgumentNullException("Unspecified target architecture.");
            }

            // J == JitBench folder. By reducing the length of the directory
            // name we attempt to reduce the chances of hitting PATH length
            // problems we have been hitting in the lab.
            // The changes we have done have reduced it in this way:
            // C:\Jenkins\workspace\perf_scenario---5b001a46\bin\sandbox\JitBench\JitBench-dev
            // C:\j\workspace\perf_scenario---5b001a46\bin\sandbox\JitBench\JitBench-dev
            // C:\j\w\perf_scenario---5b001a46\bin\sandbox\JitBench\JitBench-dev
            // C:\j\w\perf_scenario---5b001a46\bin\sandbox\J
            s_jitBenchDevDirectory  = Path.Combine(s_temporaryDirectory, "J");
            s_dotnetProcessFileName = Path.Combine(s_jitBenchDevDirectory, ".dotnet", "dotnet.exe");
            s_musicStoreDirectory   = Path.Combine(s_jitBenchDevDirectory, "src", "MusicStore");
        }
Пример #4
0
        static void Main(string[] args)
        {
            var options = JitBenchHarnessOptions.Parse(args);

            s_temporaryDirectory = options.IntermediateOutputDirectory;
            s_targetArchitecture = options.TargetArchitecture;
            if (string.IsNullOrWhiteSpace(s_targetArchitecture))
            {
                throw new ArgumentNullException("Unspecified target architecture.");
            }

            // J == JitBench folder. By reducing the length of the directory
            // name we attempt to reduce the chances of hitting PATH length
            // problems we have been hitting in the lab.
            // The changes we have done have reduced it in this way:
            // C:\Jenkins\workspace\perf_scenario---5b001a46\bin\sandbox\JitBench\JitBench-dev
            // C:\j\workspace\perf_scenario---5b001a46\bin\sandbox\JitBench\JitBench-dev
            // C:\j\w\perf_scenario---5b001a46\bin\sandbox\JitBench\JitBench-dev
            // C:\j\w\perf_scenario---5b001a46\bin\sandbox\J
            s_jitBenchDevDirectory = Path.Combine(s_temporaryDirectory, "J");

            using (var h = new XunitPerformanceHarness(args))
            {
                ProcessStartInfo startInfo = Setup();
                h.RunScenario(startInfo, () => { PrintHeader("Running Benchmark Scenario"); }, PostIteration, PostProcessing, s_ScenarioConfiguration);
            }
        }
Пример #5
0
        public static JitBenchHarnessOptions Parse(string[] args)
        {
            using (var parser = new Parser((settings) => {
                settings.CaseInsensitiveEnumValues = true;
                settings.CaseSensitive = false;
                settings.HelpWriter = new StringWriter();
                settings.IgnoreUnknownArguments = true;
            }))
            {
                JitBenchHarnessOptions options = null;
                parser.ParseArguments <JitBenchHarnessOptions>(args)
                .WithParsed(parsed => options = parsed)
                .WithNotParsed(errors => {
                    foreach (Error error in errors)
                    {
                        switch (error.Tag)
                        {
                        case ErrorType.MissingValueOptionError:
                            throw new ArgumentException(
                                $"Missing value option for command line argument '{(error as MissingValueOptionError).NameInfo.NameText}'");

                        case ErrorType.HelpRequestedError:
                            Console.WriteLine(Usage());
                            Environment.Exit(0);
                            break;

                        case ErrorType.VersionRequestedError:
                            Console.WriteLine(new AssemblyName(typeof(JitBenchHarnessOptions).GetTypeInfo().Assembly.FullName).Version);
                            Environment.Exit(0);
                            break;

                        case ErrorType.BadFormatTokenError:
                        case ErrorType.UnknownOptionError:
                        case ErrorType.MissingRequiredOptionError:
                            throw new ArgumentException(
                                $"Missing required  command line argument '{(error as MissingRequiredOptionError).NameInfo.NameText}'");

                        case ErrorType.MutuallyExclusiveSetError:
                        case ErrorType.BadFormatConversionError:
                        case ErrorType.SequenceOutOfRangeError:
                        case ErrorType.RepeatedOptionError:
                        case ErrorType.NoVerbSelectedError:
                        case ErrorType.BadVerbSelectedError:
                        case ErrorType.HelpVerbRequestedError:
                            break;
                        }
                    }
                });
                return(options);
            }
        }
Пример #6
0
        static void Main(string[] args)
        {
            var options = JitBenchHarnessOptions.Parse(args);

            SetupStatics(options);

            using (var h = new XunitPerformanceHarness(args))
            {
                ProcessStartInfo startInfo = options.UseExistingSetup ? UseExistingSetup() : CreateNewSetup();

                string scenarioName = "MusicStore";

                if (options.EnableTiering)
                {
                    startInfo.Environment.Add("COMPlus_EXPERIMENTAL_TieredCompilation", "1");
                    scenarioName += " Tiering";
                }

                if (options.Minopts)
                {
                    startInfo.Environment.Add("COMPlus_JITMinOpts", "1");
                    scenarioName += " Minopts";
                }

                if (options.DisableR2R)
                {
                    startInfo.Environment.Add("COMPlus_ReadyToRun", "0");
                    scenarioName += " NoR2R";
                }

                if (options.DisableNgen)
                {
                    startInfo.Environment.Add("COMPlus_ZapDisable", "1");
                    scenarioName += " NoNgen";
                }

                var scenarioConfiguration = CreateScenarioConfiguration();

                h.RunScenario(startInfo, () => { PrintHeader(scenarioName); }, PostIteration, PostProcessing, scenarioConfiguration);
            }
        }
Пример #7
0
        static void Main(string[] args)
        {
            var options = JitBenchHarnessOptions.Parse(args);

            SetupStatics(options);

            using (var h = new XunitPerformanceHarness(args))
            {
                ProcessStartInfo startInfo = options.UseExistingSetup ? UseExistingSetup() : CreateNewSetup();

                string scenarioName = "MusicStore";
                if (!startInfo.Environment.ContainsKey("DOTNET_MULTILEVEL_LOOKUP"))
                {
                    throw new InvalidOperationException("DOTNET_MULTILEVEL_LOOKUP was not defined.");
                }
                if (startInfo.Environment["DOTNET_MULTILEVEL_LOOKUP"] != "0")
                {
                    throw new InvalidOperationException("DOTNET_MULTILEVEL_LOOKUP was not set to 0.");
                }

                if (options.EnableTiering)
                {
                    startInfo.Environment.Add("COMPlus_EXPERIMENTAL_TieredCompilation", "1");
                    scenarioName += " Tiering";
                }

                if (options.Minopts)
                {
                    startInfo.Environment.Add("COMPlus_JITMinOpts", "1");
                    scenarioName += " Minopts";
                }

                if (options.DisableR2R)
                {
                    startInfo.Environment.Add("COMPlus_ReadyToRun", "0");
                    scenarioName += " NoR2R";
                }

                if (options.DisableNgen)
                {
                    startInfo.Environment.Add("COMPlus_ZapDisable", "1");
                    scenarioName += " NoNgen";
                }

                var program = new JitBenchHarness("JitBench");
                try
                {
                    var scenarioConfiguration = new ScenarioConfiguration(TimeSpan.FromMilliseconds(60000), startInfo)
                    {
                        Iterations            = (int)options.Iterations,
                        PreIterationDelegate  = program.PreIteration,
                        PostIterationDelegate = program.PostIteration,
                    };
                    var processesOfInterest = new string[] {
                        "dotnet.exe",
                    };
                    var modulesOfInterest = new string[] {
                        "Anonymously Hosted DynamicMethods Assembly",
                        "clrjit.dll",
                        "coreclr.dll",
                        "dotnet.exe",
                        "MusicStore.dll",
                        "ntoskrnl.exe",
                        "System.Private.CoreLib.dll",
                        "Unknown",
                    };

                    if (!File.Exists(startInfo.FileName))
                    {
                        throw new FileNotFoundException(startInfo.FileName);
                    }
                    if (!Directory.Exists(startInfo.WorkingDirectory))
                    {
                        throw new DirectoryNotFoundException(startInfo.WorkingDirectory);
                    }

                    h.RunScenario(scenarioConfiguration, teardownDelegate: () => {
                        return(program.PostRun("MusicStore", processesOfInterest, modulesOfInterest));
                    });
                }
                catch
                {
                    Console.WriteLine(program.StandardOutput);
                    Console.WriteLine(program.StandardError);
                    throw;
                }
            }
        }