示例#1
0
        // 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);
        }
示例#2
0
        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);
        }
示例#3
0
    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);
    }