Example #1
0
        public void InsertRecords(int amount)
        {
            var entities = new List <BenchmarkEntity>();

            for (var i = 0; i < amount; i++)
            {
                bool?nullableBool = null;

                if (i % 5 == 0)
                {
                    nullableBool = false;
                }
                else if (i % 6 == 0)
                {
                    nullableBool = true;
                }

                entities.Add(new BenchmarkEntity
                {
                    DecimalValue    = i,
                    TextValue       = i.ToString(),
                    IntegerValue    = i,
                    NullableBoolean = nullableBool
                });
            }

            var dbContext = new SqlRepoBenchmarkDbContext();

            dbContext.AddRange(entities);
            dbContext.SaveChanges();

            Console.WriteLine($"Completed inserting {amount} records");
        }
Example #2
0
        static void Main(string[] args)
        {
            var services = new ServiceCollection()
                           .AddSqlRepo();

            SqlRepoBenchmarkDbContext dbContext = new SqlRepoBenchmarkDbContext();

            dbContext.Database.Migrate();

            services.AddSingleton <ISqlLogger, NoOpSqlLogger>();
            services.AddSingleton <IBenchmarkHelpers, BenchmarkHelpers>();

            services.AddSingleton <IBenchmarkOperation, SelectUpdateDeleteBenchmarkOperationDapper>();
            services.AddSingleton <IBenchmarkOperation, SelectUpdateDeleteBenchmarkOperationSqlRepo>();

            services.AddSingleton <IBenchmarkOperation, SelectByDecimalValueBenchmarkOperationDapper>();
            services.AddSingleton <IBenchmarkOperation, SelectAllBenchmarkOperationDapper>();
            services.AddSingleton <IBenchmarkOperation, SelectTop5000BenchmarkOperationDapper>();
            services.AddSingleton <IBenchmarkOperation, SelectTop1BenchmarkOperationDapper>();
            services.AddSingleton <IBenchmarkOperation, SelectWhereBetweenBenchmarkOperationDapper>();
            services.AddSingleton <IBenchmarkOperation, SelectSingleColumnBenchmarkDapper>();
            services.AddSingleton <IBenchmarkOperation, SelectByDecimalValueBenchmarkOperationSqlRepo>();
            services.AddSingleton <IBenchmarkOperation, SelectAllBenchmarkOperationSqlRepo>();
            services.AddSingleton <IBenchmarkOperation, SelectWhereBetweenBenchmarkOperationSqlRepo>();
            services.AddSingleton <IBenchmarkOperation, SelectTop5000BenchmarkOperationSqlRepo>();
            services.AddSingleton <IBenchmarkOperation, SelectTop1BenchmarkOperationSqlRepo>();
            services.AddSingleton <IBenchmarkOperation, SelectSingleColumnBenchmarkSqlRepo>();

            services.AddSingleton <IBenchmarkOperation, SelectAllBenchmarkOperationEfCore>();
            services.AddSingleton <IBenchmarkOperation, SelectTop5000BenchmarkOperationEfCore>();
            services.AddSingleton <IBenchmarkOperation, SelectWhereBetweenBenchmarkOperationEfCore>();
            services.AddSingleton <IBenchmarkOperation, SelectTop1BenchmarkOperationEfCore>();
            services.AddSingleton <IBenchmarkOperation, SelectSingleColumnBenchmarkEfCore>();

            services.AddSingleton <IBenchmarkRunner, BenchmarkRunner>();

            services.AddSingleton <IConnectionProvider>(new ConnectionStringConnectionProvider(ConnectionString.Value));

            var serviceCollection = services.BuildServiceProvider();

            serviceCollection.GetService <IBenchmarkRunner>().Run();

            Console.WriteLine("Completed All Benchmarks");

            Console.ReadLine();
            Console.ReadLine();
            Console.ReadLine();
        }
Example #3
0
        public void ClearBufferPool()
        {
            var dbContext = new SqlRepoBenchmarkDbContext();

            dbContext.Database.ExecuteSqlCommand("DBCC DROPCLEANBUFFERS");
        }