Beispiel #1
0
        public void Run()
        {
            CreateTable();

            int iteration = 5;
            int count     = 1000;

            Dictionary <string, Dictionary <int, long> > insertTimings     = new Dictionary <string, Dictionary <int, long> >();
            Dictionary <string, Dictionary <int, long> > updateTimings     = new Dictionary <string, Dictionary <int, long> >();
            Dictionary <string, Dictionary <int, long> > selectTimings     = new Dictionary <string, Dictionary <int, long> >();
            Dictionary <string, Dictionary <int, long> > selectListTimings = new Dictionary <string, Dictionary <int, long> >();

            insertTimings.Add("ADO", new Dictionary <int, long>());
            insertTimings.Add("Vega", new Dictionary <int, long>());
            insertTimings.Add("Dapper", new Dictionary <int, long>());

            updateTimings.Add("ADO", new Dictionary <int, long>());
            updateTimings.Add("Vega", new Dictionary <int, long>());
            updateTimings.Add("Dapper", new Dictionary <int, long>());

            selectTimings.Add("ADO", new Dictionary <int, long>());
            selectTimings.Add("Vega", new Dictionary <int, long>());
            selectTimings.Add("Dapper", new Dictionary <int, long>());

            selectListTimings.Add("ADO", new Dictionary <int, long>());
            selectListTimings.Add("Vega", new Dictionary <int, long>());
            selectListTimings.Add("Dapper", new Dictionary <int, long>());

            for (int i = 1; i <= iteration; i++)
            {
                WriteLine("Iteration " + i, ConsoleColor.Yellow);

                ADOTest    adoTest    = new ADOTest();
                VegaTest   vegaTest   = new VegaTest();
                DapperTest dapperTest = new DapperTest();

                insertTimings["ADO"].Add(i, adoTest.InsertTest(count));
                insertTimings["Vega"].Add(i, vegaTest.InsertTest(count));
                insertTimings["Dapper"].Add(i, dapperTest.InsertTest(count));

                updateTimings["ADO"].Add(i, adoTest.UpdateTest(count));
                updateTimings["Vega"].Add(i, vegaTest.UpdateTest(count));
                updateTimings["Dapper"].Add(i, dapperTest.UpdateTest(count));

                selectTimings["ADO"].Add(i, adoTest.SelectTest(count));
                selectTimings["Vega"].Add(i, vegaTest.SelectTest(count));
                selectTimings["Dapper"].Add(i, dapperTest.SelectTest(count));

                selectListTimings["ADO"].Add(i, adoTest.SelectListTest(count));
                selectListTimings["Vega"].Add(i, vegaTest.SelectListTest(count));
                selectListTimings["Dapper"].Add(i, dapperTest.SelectListTest(count));
            }

            //show results
            Console.Clear();
            WriteLine($"Results for {count} records {iteration} iteration", ConsoleColor.Yellow);
            WriteLine("--------" + new string('-', 10 * iteration), ConsoleColor.Green);
            Write("Iteration\t", ConsoleColor.Green);
            for (int i = 1; i <= iteration; i++)
            {
                Write($"{i}\t", ConsoleColor.Green);
            }
            Write("Mean\t", ConsoleColor.Green);
            Write("stDEV\t", ConsoleColor.Green);
            WriteLine("");
            WriteLine("--------" + new string('-', 10 * iteration), ConsoleColor.Green);

            WriteStatus("Insert Tests", insertTimings);
            WriteStatus("Update Tests", updateTimings);
            WriteStatus("Select Tests", selectTimings);
            WriteStatus("Select List Tests", selectListTimings);

            Console.ReadLine();
        }
Beispiel #2
0
 public BenchmarkTest()
 {
     adoTest    = new ADOTest();
     vegaTest   = new VegaTest();
     dapperTest = new DapperTest();
 }