public static Summary RunUrl(string url, IConfig config = null)
        {
#if CLASSIC
            return(BenchmarkRunnerCore.Run(BenchmarkConverter.UrlToBenchmarks(url, config), config, ToolchainExtensions.GetToolchain));
#else
            throw new NotSupportedException();
#endif
        }
예제 #2
0
        public static Summary RunSource(string source, IConfig config = null)
        {
#if CLASSIC
            return(BenchmarkRunnerCore.Run(BenchmarkConverter.SourceToBenchmarks(source, config), ToolchainExtensions.GetToolchain));
#else
            throw new NotSupportedException();
#endif
        }
예제 #3
0
        public static Summary Run(Benchmark[] benchmarks, IConfig config)
        {
            var targetType = benchmarks?.FirstOrDefault()?.Target.Type;

            return(BenchmarkRunnerCore.Run(
                       new BenchmarkRunInfo(benchmarks, targetType, BenchmarkConverter.GetFullConfig(targetType, config)),
                       ToolchainExtensions.GetToolchain));
        }
예제 #4
0
        private IEnumerable <Summary> RunBenchmarks(string[] args, IConfig config)
        {
            var globalChronometer = Chronometer.Start();
            var summaries         = new List <Summary>();

            if (ShouldDisplayOptions(args))
            {
                DisplayOptions();
                return(Enumerable.Empty <Summary>());
            }

            var  effectiveConfig = ManualConfig.Union(config ?? DefaultConfig.Instance, ManualConfig.Parse(args));
            bool join            = args.Any(arg => arg.EqualsWithIgnoreCase("--join"));

            if (join)
            {
                var typesWithMethods = typeParser.MatchingTypesWithMethods(args);
                var benchmarks       = typesWithMethods.SelectMany(typeWithMethods =>
                                                                   typeWithMethods.AllMethodsInType
                        ? BenchmarkConverter.TypeToBenchmarks(typeWithMethods.Type, effectiveConfig)
                        : BenchmarkConverter.MethodsToBenchmarks(typeWithMethods.Type, typeWithMethods.Methods, effectiveConfig)).ToArray();
                summaries.Add(BenchmarkRunner.Run(benchmarks, effectiveConfig));
            }
            else
            {
                foreach (var typeWithMethods in typeParser.MatchingTypesWithMethods(args))
                {
                    logger.WriteLineHeader("Target type: " + typeWithMethods.Type.Name);
                    if (typeWithMethods.AllMethodsInType)
                    {
                        summaries.Add(BenchmarkRunner.Run(typeWithMethods.Type, effectiveConfig));
                    }
                    else
                    {
                        summaries.Add(BenchmarkRunner.Run(typeWithMethods.Type, typeWithMethods.Methods, effectiveConfig));
                    }
                    logger.WriteLine();
                }
            }

            // TODO: move this logic to the RunUrl method
#if CLASSIC
            if (args.Length > 0 && (args[0].StartsWith("http://") || args[0].StartsWith("https://")))
            {
                var url  = args[0];
                Uri uri  = new Uri(url);
                var name = uri.IsFile ? Path.GetFileName(uri.LocalPath) : "URL";
                summaries.Add(BenchmarkRunner.RunUrl(url, effectiveConfig));
            }
#endif

            var clockSpan = globalChronometer.Stop();
            BenchmarkRunnerCore.LogTotalTime(logger, clockSpan.GetTimeSpan(), "Global total time");
            return(summaries);
        }
예제 #5
0
        private IEnumerable <Summary> RunBenchmarks(string[] args)
        {
            var globalChronometer = Chronometer.Start();
            var summaries         = new List <Summary>();

            if (ShouldDisplayOptions(args))
            {
                DisplayOptions();
                return(Enumerable.Empty <Summary>());
            }

            var config = ManualConfig.Union(DefaultConfig.Instance, ManualConfig.Parse(args));

            foreach (var typeWithMethods in typeParser.MatchingTypesWithMethods(args))
            {
                logger.WriteLineHeader("Target type: " + typeWithMethods.Type.Name);
                if (typeWithMethods.AllMethodsInType)
                {
                    summaries.Add(BenchmarkRunner.Run(typeWithMethods.Type, config));
                }
                else
                {
                    summaries.Add(BenchmarkRunner.Run(typeWithMethods.Type, typeWithMethods.Methods, config));
                }
                logger.WriteLine();
            }

            // TODO: move this logic to the RunUrl method
#if CLASSIC
            if (args.Length > 0 && (args[0].StartsWith("http://") || args[0].StartsWith("https://")))
            {
                var url  = args[0];
                Uri uri  = new Uri(url);
                var name = uri.IsFile ? Path.GetFileName(uri.LocalPath) : "URL";
                summaries.Add(BenchmarkRunner.RunUrl(url, config));
            }
#endif

            var clockSpan = globalChronometer.Stop();
            BenchmarkRunnerCore.LogTotalTime(logger, clockSpan.GetTimeSpan(), "Global total time");
            return(summaries);
        }
예제 #6
0
 public static Summary Run(BenchmarkRunInfo[] benchmarks) => BenchmarkRunnerCore.Run(benchmarks, ToolchainExtensions.GetToolchain);
예제 #7
0
 public static Summary Run(Type type, MethodInfo[] methods, IConfig config = null) =>
 BenchmarkRunnerCore.Run(BenchmarkConverter.MethodsToBenchmarks(type, methods, config), ToolchainExtensions.GetToolchain);
예제 #8
0
 public static Summary Run(Type type, IConfig config = null) =>
 BenchmarkRunnerCore.Run(BenchmarkConverter.TypeToBenchmarks(type, config), ToolchainExtensions.GetToolchain);
예제 #9
0
 public static Summary RunSource(string source, IConfig config = null) =>
 BenchmarkRunnerCore.Run(BenchmarkConverter.SourceToBenchmarks(source, config), config, ToolchainExtensions.GetToolchain);
예제 #10
0
 public static Summary RunUrl(string url, IConfig config = null) =>
 BenchmarkRunnerCore.Run(BenchmarkConverter.UrlToBenchmarks(url, config), config, ToolchainExtensions.GetToolchain);
예제 #11
0
 public static Summary Run(Benchmark[] benchmarks, IConfig config) =>
 BenchmarkRunnerCore.Run(benchmarks, config, ToolchainExtensions.GetToolchain);