Пример #1
0
        //[TestMethod]
        public void QueryLargeTest()
        {
            var context      = _dbContextProvider.Get <FakeEcDbContext>();
            var fakeUserRepo = new FakeUserRepository(_dbContextProvider);
            var sw           = new Stopwatch();

            sw.Start();
            var result = fakeUserRepo.Take(1000000);

            sw.Stop();
            context.Dispose();
            Trace.WriteLine("EF带跟踪 QueryLarge " + result.Count + ", 毫秒:" + sw.ElapsedMilliseconds);
        }
Пример #2
0
        public void BatchInsertTest()
        {
            var total        = 200;
            var context      = _dbContextProvider.Get <FakeEcDbContext>();
            var fakeUserRepo = new FakeUserRepository(_dbContextProvider);
            var sw           = new Stopwatch();

            sw.Start();

            var users = CreateOneUser(total);
            var time1 = sw.ElapsedMilliseconds;

            sw.Restart();
            fakeUserRepo.InsertRangeAsync(users).GetAwaiter();
            context.SaveChanges();
            sw.Stop();
            context.Dispose();

            Trace.WriteLine("Create FakeUser " + total + ", 毫秒:" + sw.ElapsedMilliseconds);
            Trace.WriteLine("Batch Insert " + total + ", 毫秒:" + sw.ElapsedMilliseconds);
        }