private void DisplayOptions()
        {
            logger.WriteLineHeader($"{BenchmarkDotNetInfo.FullTitle}");
            logger.WriteLine();
            logger.WriteLineHeader("Options:");

            var consoleWidth = 80;

            try
            {
                consoleWidth = Console.WindowWidth;
            }
            // IOException causes build error
            // The type 'IOException' exists in both
            //    'System.IO, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and
            //    'System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
            // TODO see if this error goes away after RC2, in the meantime just use "catch (Exception)"
            catch (Exception)
            {
                logger.WriteLine($"Unable to get the Console width, defaulting to {consoleWidth}");
            }

            ManualConfig.PrintOptions(logger, prefixWidth: 30, outputWidth: consoleWidth);
            logger.WriteLine();
            typeParser.PrintOptions(prefixWidth: 30, outputWidth: consoleWidth);
        }
Beispiel #2
0
        private void DisplayOptions()
        {
            logger.WriteLineHeader($"{BenchmarkDotNetInfo.FullTitle}");
            logger.WriteLine();
            logger.WriteLineHeader("Options:");

            ManualConfig.PrintOptions(logger, prefixWidth: 30, outputWidth: Console.WindowWidth);
            logger.WriteLine();
            typeParser.PrintOptions(logger, prefixWidth: 30, outputWidth: Console.WindowWidth);
        }
        private IEnumerable <Summary> RunBenchmarks(string[] args)
        {
            var globalChronometer = Chronometer.Start();
            var summaries         = new List <Summary>();

            if (ManualConfig.ShouldDisplayOptions(args))
            {
                ManualConfig.PrintOptions(logger);
                return(Enumerable.Empty <Summary>());
            }

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

            for (int i = 0; i < Types.Length; i++)
            {
                var type = Types[i];
                if (args.Any(arg => type.Name.ToLower().StartsWith(arg.ToLower())) || args.Contains("#" + i) || args.Contains("" + i) || args.Contains("*"))
                {
                    logger.WriteLineHeader("Target type: " + type.Name);
                    summaries.Add(BenchmarkRunner.Run(type, 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();
            BenchmarkRunner.LogTotalTime(logger, clockSpan.GetTimeSpan(), "Global total time");
            return(summaries);
        }