Exemple #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);
        }
Exemple #2
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);
    }