public static void Main(string[] args) { var types = typeof(Program) .Assembly .GetExportedTypes() .Where(r => r != typeof(Program) && r.IsPublic) .OrderBy(r => r.Name); var job = Job.Default; var config = new ManualConfig(); config.AddLogger(DefaultConfig.Instance.GetLoggers().ToArray()); config.AddExporter(DefaultConfig.Instance.GetExporters().ToArray()); config.AddColumnProvider(DefaultConfig.Instance.GetColumnProviders().ToArray()); config.AddValidator(JitOptimizationsValidator.DontFailOnError); //config.AddJob(job.WithRuntime(ClrRuntime.Net461)); //config.AddJob(job.WithRuntime(CoreRuntime.Core21)); //config.AddJob(job.WithRuntime(CoreRuntime.Core31)); config.AddJob(job.WithRuntime(CoreRuntime.Core50)); config.AddDiagnoser(MemoryDiagnoser.Default); config.AddColumn(StatisticColumn.OperationsPerSecond); config.AddColumn(RankColumn.Arabic); var switcher = new BenchmarkSwitcher(types.ToArray()); switcher.Run(args, config); }
// No exporter, less verbose logger. public static IConfig GetCustomConfig(string artifactsPath, bool shortRunJob) { var defaultConfig = DefaultConfig.Instance; var config = new ManualConfig(); config.AddAnalyser(defaultConfig.GetAnalysers().ToArray()); config.AddColumnProvider(defaultConfig.GetColumnProviders().ToArray()); config.AddDiagnoser(defaultConfig.GetDiagnosers().ToArray()); //config.AddExporter(defaultConfig.GetExporters().ToArray()); config.AddFilter(defaultConfig.GetFilters().ToArray()); config.AddHardwareCounters(defaultConfig.GetHardwareCounters().ToArray()); //config.AddJob(defaultConfig.GetJobs().ToArray()); config.AddLogicalGroupRules(defaultConfig.GetLogicalGroupRules().ToArray()); //config.AddLogger(defaultConfig.GetLoggers().ToArray()); config.AddValidator(defaultConfig.GetValidators().ToArray()); config.UnionRule = ConfigUnionRule.AlwaysUseGlobal; if (shortRunJob) { config.AddJob(Job.ShortRun); } config.ArtifactsPath = artifactsPath; config.AddLogger(new ConsoleLogger_()); return(config); }
public static ManualConfig GetManualConfigDefault() { ManualConfig config = ManualConfig.CreateEmpty(); //https://benchmarkdotnet.org/articles/configs/diagnosers.html config.AddDiagnoser(MemoryDiagnoser.Default); config.WithArtifactsPath(ArtifactsPath); config.AddExporter(DefaultExporters.Html); config.AddLogger(ConsoleLogger.Default); config.AddColumnProvider(DefaultColumnProviders.Instance); return(config); }
public NuGetConfigSourceAttribute(bool profileMemory = false) { // NOTE: The version of NuGet package referenced in this project should be <= // than every version in this array. const string BaselineVersion = "1.4.309"; string[] versions = { BaselineVersion, "1.5.314", }; Runtime[] runtimes = { ClrRuntime.Net472, CoreRuntime.Core31 }; ManualConfig config = ManualConfig.CreateEmpty(); foreach (Runtime runtime in runtimes) { foreach (string version in versions) { bool baseline = (version == BaselineVersion && runtime == ClrRuntime.Net472); config.AddJob(createJob("BitMiracle.LibJpeg.NET", version, runtime, baseline)); } } if (profileMemory) { config.AddDiagnoser(MemoryDiagnoser.Default); config.AddDiagnoser(new NativeMemoryProfiler()); } Config = config; }
static bool Run() { bool success = false; try { // NOTE: this is mostly working around bugs in BenchmarkDotNet configuration var logger = new Logger(); var baseConfig = new DebugInProcessConfig(); var config = new ManualConfig(); foreach (var e in baseConfig.GetExporters()) { config.AddExporter(e); } foreach (var d in baseConfig.GetDiagnosers()) { config.AddDiagnoser(d); } foreach (var a in baseConfig.GetAnalysers()) { config.AddAnalyser(a); } foreach (var v in baseConfig.GetValidators()) { config.AddValidator(v); } foreach (var p in baseConfig.GetColumnProviders()) { config.AddColumnProvider(p); } config.AddJob(JobMode <Job> .Default.WithToolchain(new InProcessEmitToolchain(TimeSpan.FromMinutes(10), logOutput: true))); config.UnionRule = ConfigUnionRule.AlwaysUseGlobal; // Overriding the default config.AddLogger(logger); // ImageBenchmark class is hardcoded here for now BenchmarkRunner.Run <ImageBenchmark>(config.WithOptions(ConfigOptions.DisableLogFile)); BenchmarkRunner.Run <ViewHandlerBenchmark>(config.WithOptions(ConfigOptions.DisableLogFile)); success = true; } catch (Exception ex) { Log.Error(Tag, $"Error: {ex}"); } return(success); }