public void Print(BenchmarkCaseGroup group, BenchmarkCaseGroupResult result)
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(group.Info);
            Console.ResetColor();
            Console.WriteLine();

            foreach (var cs in result.Cases)
            {
                Console.WriteLine("Items {0}", cs.Key);

                var table = new ConsoleTables.ConsoleTable(
                    "Logger",
                    "Total(ms)",
                    "Create(ms)",
                    "Write(ms)",
                    "Dispose(ms)"
                    );

                table.Options.EnableCount = false;

                foreach (var bc in cs.Value)
                {
                    table.AddRow(
                        $"{bc.LoggerInfo}",
                        $"{bc.BenchmarkResult.TotalTimeMs}",
                        $"{bc.BenchmarkResult.CreateTimeMs}",
                        $"{bc.BenchmarkResult.WriteTimeMs}",
                        $"{bc.BenchmarkResult.DisposeTimeMs}"
                        );
                }

                table.Write();
            }

            var resultTable = new ConsoleTables.ConsoleTable("Logger", "Rank");

            resultTable.Options.EnableCount = false;

            foreach (var place in result.Ranks)
            {
                resultTable.AddRow($"{place.Key}", $"{place.Value}");
            }

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Results:");
            Console.ResetColor();

            resultTable.Write(Format.Alternative);

            Console.WriteLine(new string('#', 50));
            Console.WriteLine();
        }
Esempio n. 2
0
        private static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            var items = new[] { 64000 };

            var benchmarks = new LoggerBenchmarkBase[]
            {
                new NWrathFileLoggerBenchmark(),
                new NWrathBackgroundFileLoggerBenchmark(),
                new SerilogFileLoggerBenchmark(),
                new NLogFileLoggerBenchmark(),

                //new SerilogSqlLoggerBenchmark(),
                //new NWrathDbLoggerBenchmark(),
                //new NWrathBackgroundDbLoggerBenchmark()

                new NWrathRollingFileLoggerBenchmark(),
                new NWrathBackgroundRollingFileLoggerBenchmark()
            };

            new BenchmarkCaseGroup
            {
                Info        = "run once for code precompile",
                ItemsCounts = new[] { 1 },
                Benchmarks  = benchmarks
            }.Start();

            var caseGroup = new BenchmarkCaseGroup
            {
                Info        = "File loggers benchmarks",
                ItemsCounts = items,
                Benchmarks  = benchmarks
            };

            var result = caseGroup.Start();

            new ConsoleBenchmarkPrint()
            .Print(caseGroup, result);

            Console.WriteLine();
            Console.WriteLine("Press any key...");
            Console.ReadKey();
        }