예제 #1
0
        public static void Main(string[] args)
        {
#if DEBUG
            WriteLineColor("Warning: DEBUG configuration; performance may be impacted!", ConsoleColor.Red);
            WriteLine();
#endif
            WriteLine("Welcome to Dapper's ORM performance benchmark suite, based on BenchmarkDotNet.");
            Write("  If you find a problem, please report it at: ");
            WriteLineColor("https://github.com/StackExchange/Dapper", ConsoleColor.Blue);
            WriteLine("  Or if you're up to it, please submit a pull request! We welcome new additions.");
            WriteLine();

            if (args.Length == 0)
            {
                WriteLine("Optional arguments:");
                WriteColor("  --all", ConsoleColor.Blue);
                WriteLine(": run all benchmarks");
                WriteColor("  --legacy", ConsoleColor.Blue);
                WriteLine(": run the legacy benchmark suite/format", ConsoleColor.Gray);
                WriteLine();
            }
            WriteLine("Using ConnectionString: " + BenchmarkBase.ConnectionString);
            EnsureDBSetup();
            WriteLine("Database setup complete.");

            if (args.Any(a => a == "--all"))
            {
                WriteLine("Iterations: " + BenchmarkBase.Iterations);
                var benchmarks = new List <Benchmark>();
                var benchTypes = Assembly.GetEntryAssembly().DefinedTypes.Where(t => t.IsSubclassOf(typeof(BenchmarkBase)));
                WriteLineColor("Running full benchmarks suite", ConsoleColor.Green);
                foreach (var b in benchTypes)
                {
                    benchmarks.AddRange(BenchmarkConverter.TypeToBenchmarks(b));
                }
                BenchmarkRunner.Run(benchmarks.ToArray(), null);
            }
            else if (args.Any(a => a == "--legacy"))
            {
                var       test       = new LegacyTests();
                const int iterations = 500;
                WriteLineColor($"Running legacy benchmarks: {iterations} iterations that load up a Post entity.", ConsoleColor.Green);
                test.RunAsync(iterations).GetAwaiter().GetResult();
                WriteLine();
                WriteLineColor("Run complete.", ConsoleColor.Green);
            }
            else
            {
                WriteLine("Iterations: " + BenchmarkBase.Iterations);
                BenchmarkSwitcher.FromAssembly(typeof(Program).GetTypeInfo().Assembly).Run(args);
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: Ahoo-Wang/Dapper
        public static void Main(string[] args)
        {
#if DEBUG
            WriteLineColor("Warning: DEBUG configuration; performance may be impacted!", ConsoleColor.Red);
            WriteLine();
#endif
            WriteLine("Welcome to Dapper's ORM performance benchmark suite, based on BenchmarkDotNet.");
            Write("  If you find a problem, please report it at: ");
            WriteLineColor("https://github.com/StackExchange/Dapper", ConsoleColor.Blue);
            WriteLine("  Or if you're up to it, please submit a pull request! We welcome new additions.");
            WriteLine();

            if (args.Length == 0)
            {
                WriteLine("Optional arguments:");
                WriteColor("  (no args)", ConsoleColor.Blue);
                WriteLine(": run all benchmarks");
                WriteColor("  --legacy", ConsoleColor.Blue);
                WriteLine(": run the legacy benchmark suite/format", ConsoleColor.Gray);
                WriteLine();
            }

            WriteLine("Using ConnectionString: " + BenchmarkBase.ConnectionString);
            EnsureDBSetup();
            WriteLine("Database setup complete.");
            if (args.Any(a => a == "--legacy"))
            {
                var       test       = new LegacyTests();
                const int iterations = 500;
                WriteLineColor($"Running legacy benchmarks: {iterations} iterations that load up a Post entity.",
                               ConsoleColor.Green);
                test.RunAsync(iterations).GetAwaiter().GetResult();
                WriteLine();
                WriteLineColor("Run complete.", ConsoleColor.Green);
            }
            else
            {
                WriteLine("Iterations: " + Config.Iterations);
                new BenchmarkSwitcher(typeof(BenchmarkBase).Assembly).Run(args, new Config());
            }
        }