public static int Main(String [] args) { bool doSetup = true; bool doBuild = true; string runId = ""; string runOne = null; bool benchmarkSpecified = false; for (int i = 0; i < args.Length; i++) { if (String.Compare(args[i], "--nosetup", true) == 0) { doSetup = false; } else if (String.Compare(args[i], "--nobuild", true) == 0) { doSetup = false; doBuild = false; } else if (String.Compare(args[i], "--perf:runid", true) == 0) { if (i + 1 < args.Length) { runId = args[++i] + "-"; } else { Console.WriteLine("Missing runID "); return(UsageError()); } } else if (args[i][0] == '-') { Console.WriteLine("Unknown Option {0}", args[i]); return(UsageError()); } else { foreach (Benchmark benchmark in Benchmarks) { if (String.Compare(args[i], benchmark.Name, true) == 0) { benchmark.SetToRun(); benchmarkSpecified = true; break; } } if (!benchmarkSpecified) { Console.WriteLine("Unknown Benchmark {0}", args[i]); } } } // If benchmarks are not explicitly specified, run all benchmarks if (!benchmarkSpecified) { foreach (Benchmark benchmark in Benchmarks) { if (String.Compare(benchmark.Name, "CoreFX", true) == 0) { // CoreFX is not enabled by default, because the lab cannot run it yet. // Jenkins runs on an older OS with path-length limit, which causes // CoreFX build to fail. continue; } benchmark.SetToRun(); } } // Workspace is the ROOT of the coreclr tree. // If CORECLR_REPO is not set, the script assumes that the location of sandbox // is <path>\coreclr\sandbox. LinkBenchRoot = Directory.GetCurrentDirectory(); Workspace = Environment.GetEnvironmentVariable("CORECLR_REPO"); if (Workspace == null) { Workspace = Directory.GetParent(LinkBenchRoot).FullName; } if (Workspace == null) { Console.WriteLine("CORECLR_REPO not found"); return(-1); } string linkBenchSrcDir = Workspace + "\\tests\\src\\performance\\linkbench\\"; ScriptDir = linkBenchSrcDir + "scripts\\"; AssetsDir = linkBenchSrcDir + "assets\\"; Environment.SetEnvironmentVariable("LinkBenchRoot", LinkBenchRoot); Environment.SetEnvironmentVariable("__dotnet1", LinkBenchRoot + "\\.Net1\\dotnet.exe"); Environment.SetEnvironmentVariable("__dotnet2", LinkBenchRoot + "\\.Net2\\dotnet.exe"); // Update the build files to facilitate the link step if (doSetup) { // Clone the benchmarks using (var setup = new Process()) { setup.StartInfo.FileName = ScriptDir + "clone.cmd"; setup.Start(); setup.WaitForExit(); if (setup.ExitCode != 0) { Console.WriteLine("Benchmark Setup failed"); return(-2); } } // Setup the benchmarks foreach (Benchmark benchmark in Benchmarks) { if (benchmark.ShouldRun && benchmark.Setup != null) { benchmark.Setup(); } } } if (doBuild) { // Run the setup Script, which clones, builds and links the benchmarks. using (var setup = new Process()) { setup.StartInfo.FileName = ScriptDir + "build.cmd"; setup.StartInfo.Arguments = AssetsDir; setup.Start(); setup.WaitForExit(); if (setup.ExitCode != 0) { Console.WriteLine("Benchmark build failed"); return(-3); } } } // Since this is a size measurement scenario, there are no iterations // to perform. So, create a process that does nothing, to satisfy XUnit. // All size measurements are performed PostRun() var emptyCmd = new ProcessStartInfo() { FileName = ScriptDir + "empty.cmd" }; for (int i = 0; i < Benchmarks.Length; i++) { CurrentBenchmark = Benchmarks[i]; if (!CurrentBenchmark.ShouldRun) { continue; } string[] scriptArgs = { "--perf:runid", runId + CurrentBenchmark.Name }; using (var h = new XunitPerformanceHarness(scriptArgs)) { h.RunScenario(emptyCmd, null, null, PostRun, scenarioConfiguration); } } return(0); }