示例#1
0
        static void Main(string[] args)
        {
#if DEBUG
            CustomConfig.BenchmarkType = BenchmarkType.Default;
            CustomConfig.ShowMemory    = false;
            var bench = new DictionaryInsertBenchmark
            {
                TotalCount = 100
            };
            bench.Setup();
            bench.InsertUuid();
#else
            var parser = new Parser(with =>
                                    with.HelpWriter = new HelpWriter());
            parser.ParseArguments <Options>(args)
            .WithParsed(o =>
            {
                CustomConfig.ShowMemory    = o.ShowMemory;
                CustomConfig.BenchmarkType = o.Type;

                if (o.BenchmarkName.EndsWith(".cs"))
                {
                    o.BenchmarkName = o.BenchmarkName.Substring(0, o.BenchmarkName.Length - ".cs".Length);
                }

                if (!BenchmarkDictionary.TryGetValue(o.BenchmarkName, out Type benchmark))
                {
                    Console.Error.WriteLine($"Not found benchmark '{o.BenchmarkName}'.");
                    HelpWriter.ShowAvailableBenchmarks();
                    return;
                }

                BenchmarkRunner.Run(benchmark);
            });
#endif
        }