static int Main(string[] args) { var argsList = new List <string>(args); int? partitionCount; int? partitionIndex; List <string> exclusionFilterValue; // Parse and remove any additional parameters that we need that aren't part of BDN try { argsList = CommandLineOptions.ParseAndRemoveIntParameter(argsList, "--partition-count", out partitionCount); argsList = CommandLineOptions.ParseAndRemoveIntParameter(argsList, "--partition-index", out partitionIndex); argsList = CommandLineOptions.ParseAndRemoveStringsParameter(argsList, "--exclusion-filter", out exclusionFilterValue); CommandLineOptions.ValidatePartitionParameters(partitionCount, partitionIndex); } catch (ArgumentException e) { Console.WriteLine("ArgumentException: {0}", e.Message); return(1); } return(BenchmarkSwitcher .FromAssembly(typeof(Program).Assembly) .Run(argsList.ToArray(), RecommendedConfig.Create( artifactsPath: new DirectoryInfo(Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location), "BenchmarkDotNet.Artifacts")), mandatoryCategories: ImmutableHashSet.Create(Categories.Libraries, Categories.Runtime, Categories.ThirdParty), partitionCount: partitionCount, partitionIndex: partitionIndex, exclusionFilterValue: exclusionFilterValue)) .ToExitCode()); }
static int Main(string[] args) => BenchmarkSwitcher .FromAssembly(typeof(Program).Assembly) .Run(args, RecommendedConfig.Create( artifactsPath: new DirectoryInfo(Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location), "BenchmarkDotNet.Artifacts")), mandatoryCategories: ImmutableHashSet.Create(Categories.CoreFX, Categories.CoreCLR, Categories.ThirdParty))) .ToExitCode();
public void NoBenchmarksAreOmitted_RealData() { ILogger nullLogger = new NullLogger(); IConfig recommendedConfig = RecommendedConfig.Create( artifactsPath: new DirectoryInfo(Path.Combine(Path.GetDirectoryName(typeof(PartitionFilterTests).Assembly.Location), "BenchmarkDotNet.Artifacts")), mandatoryCategories: ImmutableHashSet.Create(Categories.Libraries, Categories.Runtime, Categories.ThirdParty)); (bool isSuccess, IConfig parsedConfig, var _) = ConfigParser.Parse(new string[] { "--filter", "*" }, nullLogger, recommendedConfig); Assert.True(isSuccess); Assembly microbenchmarksAssembly = typeof(Categories).Assembly; (bool allTypesValid, IReadOnlyList <Type> runnable) = Running.TypeFilter.GetTypesWithRunnableBenchmarks( Array.Empty <Type>(), new Assembly[1] { microbenchmarksAssembly }, nullLogger); Assert.True(allTypesValid); BenchmarkRunInfo[] allBenchmarks = GetAllBenchmarks(parsedConfig, runnable); Dictionary <string, int> idToPartitionIndex = new (); for (int i = 0; i < 10; i++) { Dictionary <string, int> hits = allBenchmarks .SelectMany(benchmark => benchmark.BenchmarksCases) .ToDictionary(benchmarkCase => GetId(benchmarkCase), _ => 0); for (int partitionIndex = 0; partitionIndex < PartitionCount; partitionIndex++) { PartitionFilter filter = new(PartitionCount, partitionIndex); foreach (BenchmarkCase benchmark in GetAllBenchmarks(parsedConfig, runnable).SelectMany(benchmark => benchmark.BenchmarksCases)) { if (filter.Predicate(benchmark)) { string id = GetId(benchmark); hits[id] += 1; if (idToPartitionIndex.ContainsKey(id)) { Assert.Equal(partitionIndex, idToPartitionIndex[id]); } else { idToPartitionIndex.Add(id, partitionIndex); } } } } Assert.All(hits.Values, hitCount => Assert.Equal(1, hitCount)); }
public static async Task <int> Main(string[] args) { await Setup(); return(BenchmarkSwitcher .FromAssembly(typeof(Program).Assembly) .Run(args, RecommendedConfig.Create( artifactsPath: new DirectoryInfo(Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location), "BenchmarkDotNet.Artifacts")), mandatoryCategories: ImmutableHashSet.Create("Roslyn"))) .ToExitCode()); }
static int Main(string[] args) { var argsList = new List <string>(args); int? partitionCount; int? partitionIndex; List <string> exclusionFilterValue; List <string> categoryExclusionFilterValue; Dictionary <string, string> parameterFilterValue; bool getDiffableDisasm; bool resumeRun; // Parse and remove any additional parameters that we need that aren't part of BDN try { argsList = CommandLineOptions.ParseAndRemoveIntParameter(argsList, "--partition-count", out partitionCount); argsList = CommandLineOptions.ParseAndRemoveIntParameter(argsList, "--partition-index", out partitionIndex); argsList = CommandLineOptions.ParseAndRemoveStringsParameter(argsList, "--exclusion-filter", out exclusionFilterValue); argsList = CommandLineOptions.ParseAndRemoveStringsParameter(argsList, "--category-exclusion-filter", out categoryExclusionFilterValue); argsList = CommandLineOptions.ParseAndRemovePairsParameter(argsList, "--parameter-filter", out parameterFilterValue); CommandLineOptions.ParseAndRemoveBooleanParameter(argsList, "--disasm-diff", out getDiffableDisasm); CommandLineOptions.ParseAndRemoveBooleanParameter(argsList, "--resume", out resumeRun); CommandLineOptions.ValidatePartitionParameters(partitionCount, partitionIndex); } catch (ArgumentException e) { Console.WriteLine("ArgumentException: {0}", e.Message); return(1); } return(BenchmarkSwitcher .FromAssembly(typeof(Program).Assembly) .Run(argsList.ToArray(), RecommendedConfig.Create( artifactsPath: new DirectoryInfo(Path.Combine(AppContext.BaseDirectory, "BenchmarkDotNet.Artifacts")), mandatoryCategories: ImmutableHashSet.Create(Categories.Libraries, Categories.Runtime, Categories.ThirdParty), partitionCount: partitionCount, partitionIndex: partitionIndex, exclusionFilterValue: exclusionFilterValue, categoryExclusionFilterValue: categoryExclusionFilterValue, parameterFilterValue: parameterFilterValue, getDiffableDisasm: getDiffableDisasm, resumeRun: resumeRun) .AddValidator(new NoWasmValidator(Categories.NoWASM))) .ToExitCode()); }
public static async Task Main() { var config = RecommendedConfig.Create( artifactsPath: new DirectoryInfo(Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location), "BenchmarkDotNet.Artifacts")), mandatoryCategories: ImmutableHashSet.Create <string>("Roslyn")); string cscSourceDownloadLink = "https://roslyninfra.blob.core.windows.net/perf-artifacts/CodeAnalysisRepro.zip"; string sourceDownloadDir = Path.Combine(AppContext.BaseDirectory, "roslynSource"); var sourceDir = Path.Combine(sourceDownloadDir, "CodeAnalysisRepro"); if (!Directory.Exists(sourceDir)) { await FileTasks.DownloadAndUnzip(cscSourceDownloadLink, sourceDownloadDir); } // Benchmark.NET creates a new process to run the benchmark, so the easiest way // to communicate information is pass by environment variable Environment.SetEnvironmentVariable(Helpers.TestProjectEnvVarName, sourceDir); _ = BenchmarkRunner.Run <StageBenchmarks>(config); }
static int Main(string[] args) { var argsList = new List <string>(args); int? partitionCount; int? partitionIndex; List <string> exclusionFilterValue; List <string> categoryExclusionFilterValue; bool getDiffableDisasm; bool interpTc; bool jitMinOpts; bool interpOnly; bool tier1Only; bool interpWithoutLoops; bool interpTcWithoutLoops; int? tcThreshold; // Parse and remove any additional parameters that we need that aren't part of BDN try { argsList = CommandLineOptions.ParseAndRemoveIntParameter(argsList, "--partition-count", out partitionCount); argsList = CommandLineOptions.ParseAndRemoveIntParameter(argsList, "--partition-index", out partitionIndex); argsList = CommandLineOptions.ParseAndRemoveStringsParameter(argsList, "--exclusion-filter", out exclusionFilterValue); argsList = CommandLineOptions.ParseAndRemoveStringsParameter(argsList, "--category-exclusion-filter", out categoryExclusionFilterValue); argsList = CommandLineOptions.ParseAndRemoveIntParameter(argsList, "--tc-threshold", out tcThreshold); CommandLineOptions.ParseAndRemoveBooleanParameter(argsList, "--disasm-diff", out getDiffableDisasm); CommandLineOptions.ParseAndRemoveBooleanParameter(argsList, "--interp-tc", out interpTc); CommandLineOptions.ParseAndRemoveBooleanParameter(argsList, "--jit-min-opts", out jitMinOpts); CommandLineOptions.ParseAndRemoveBooleanParameter(argsList, "--interp-only", out interpOnly); CommandLineOptions.ParseAndRemoveBooleanParameter(argsList, "--tier1-only", out tier1Only); CommandLineOptions.ParseAndRemoveBooleanParameter(argsList, "--interp-without-loops", out interpWithoutLoops); CommandLineOptions.ParseAndRemoveBooleanParameter(argsList, "--interp-tc-without-loops", out interpTcWithoutLoops); if (Convert.ToInt32(interpTc) + Convert.ToInt32(jitMinOpts) + Convert.ToInt32(interpOnly) + Convert.ToInt32(tier1Only) + Convert.ToInt32(interpWithoutLoops) + Convert.ToInt32(interpTcWithoutLoops) > 1) { throw new ArgumentException("Specify exactly one of --interp-tc, --jit-min-opts, --interp-only, --tier1-only, --interp-without-loops, and --interp-tc-without-loops."); } if (tcThreshold.HasValue && (jitMinOpts || interpOnly || tier1Only || interpWithoutLoops)) { throw new ArgumentException("--tc-threshold is only available for --interp-tc and for the default configuraiton."); } CommandLineOptions.ValidatePartitionParameters(partitionCount, partitionIndex); } catch (ArgumentException e) { Console.WriteLine("ArgumentException: {0}", e.Message); return(1); } return(BenchmarkSwitcher .FromAssembly(typeof(Program).Assembly) .Run(argsList.ToArray(), RecommendedConfig.Create( artifactsPath: new DirectoryInfo(Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location), "BenchmarkDotNet.Artifacts")), mandatoryCategories: ImmutableHashSet.Create(Categories.Libraries, Categories.Runtime, Categories.ThirdParty), partitionCount: partitionCount, partitionIndex: partitionIndex, exclusionFilterValue: exclusionFilterValue, categoryExclusionFilterValue: categoryExclusionFilterValue, getDiffableDisasm: getDiffableDisasm, interpTc: interpTc, jitMinOpts: jitMinOpts, interpOnly: interpOnly, tier1Only: tier1Only, interpWithoutLoops: interpWithoutLoops, interpTcWithoutLoops: interpTcWithoutLoops, tcThreshold: tcThreshold)) .ToExitCode()); }