コード例 #1
0
        public DapperBenchmarkResult RunBenchmark(int numberOfEntriesToInsertPerRun, int numberOfRuns)
        {
            var result = new DapperBenchmarkResult(numberOfEntriesToInsertPerRun, numberOfRuns);

            WriteLine(
                $"Starging a dapper Benchmark run with {numberOfEntriesToInsertPerRun} per run, repeated {numberOfRuns} times");

            GenerateProducts(numberOfEntriesToInsertPerRun);

            for (int i = 0; i < numberOfRuns; i++)
            {
                WriteLine(@"Cleaning Database!");
                productWriter.CleanProducts();

                WriteLine(@"====================================================");
                WriteLine($"Starting run number {i + 1}");
                WriteLine(@"====================================================");

                WriteLine(@"Running inserts with separate Dapper Execute Calls");
                WriteLine(@"Running connection.Execute(Commands.WriteOne, product);");
                var insertUsingForLoopTime = InsertUsingForLoop();

                WriteLine(@"Cleaning Database!");
                productWriter.CleanProducts();

                WriteLine(@"===============================================");
                WriteLine(@"Running inserts with Single Dapper Execute Call and Passing a Collection!");
                WriteLine(@"Running connection.Execute(Commands.WriteOne, products);");
                var insertUsingDapperCollectionTime = InsertUsingDapperCollectionInsert();

                WriteLine(@"Cleaning Database!");
                productWriter.CleanProducts();

                WriteLine(@"===============================================");
                WriteLine(@"Running inserts with Data Table, table value parameter!");
                WriteLine(@"connection.Execute(Commands.BatchInsert, new { @data = dataTable.AsTableValuedParameter(""dbo.ProductType"") });");
                var insertUsingBatcAndTableValueParamTime = InsertUsingDataTable();
                
                WriteLine(@"Cleaning Database!");
                productWriter.CleanProducts();

                result.Add(insertUsingForLoopTime, insertUsingDapperCollectionTime, insertUsingBatcAndTableValueParamTime);
            }

            return result;
        }
コード例 #2
0
        public DapperBenchmarkResult RunBenchmark(int numberOfEntriesToInsertPerRun, int numberOfRuns)
        {
            var result = new DapperBenchmarkResult(numberOfEntriesToInsertPerRun, numberOfRuns);

            WriteLine(
                $"Starging a dapper Benchmark run with {numberOfEntriesToInsertPerRun} per run, repeated {numberOfRuns} times");

            GenerateProducts(numberOfEntriesToInsertPerRun);

            for (int i = 0; i < numberOfRuns; i++)
            {
                WriteLine(@"Cleaning Database!");
                productWriter.CleanProducts();

                WriteLine(@"====================================================");
                WriteLine($"Starting run number {i + 1}");
                WriteLine(@"====================================================");

                WriteLine(@"Running inserts with separate Dapper Execute Calls");
                WriteLine(@"Running connection.Execute(Commands.WriteOne, product);");
                var insertUsingForLoopTime = InsertUsingForLoop();

                WriteLine(@"Cleaning Database!");
                productWriter.CleanProducts();

                WriteLine(@"===============================================");
                WriteLine(@"Running inserts with Single Dapper Execute Call and Passing a Collection!");
                WriteLine(@"Running connection.Execute(Commands.WriteOne, products);");
                var insertUsingDapperCollectionTime = InsertUsingDapperCollectionInsert();

                WriteLine(@"Cleaning Database!");
                productWriter.CleanProducts();

                WriteLine(@"===============================================");
                WriteLine(@"Running inserts with Data Table, table value parameter!");
                WriteLine(@"connection.Execute(Commands.BatchInsert, new { @data = dataTable.AsTableValuedParameter(""dbo.ProductType"") });");
                var insertUsingBatcAndTableValueParamTime = InsertUsingDataTable();

                WriteLine(@"Cleaning Database!");
                productWriter.CleanProducts();

                result.Add(insertUsingForLoopTime, insertUsingDapperCollectionTime, insertUsingBatcAndTableValueParamTime);
            }

            return(result);
        }