public void InsertNotInTransactionSpeed() { using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;")) { var sum = new Stopwatch(); sum.Start(); var sw = new Stopwatch(); sw.Start(); for (var i = 0; i < 100; i++) { var guid = Guid.NewGuid(); var newEntity = new ClassD { EntityId = guid, Name = "Lorem ipsum", NumberOfSomething = 5 }; context.TestTable.Add(newEntity); Console.WriteLine("Add " + sw.Elapsed); sw.Restart(); context.SaveChanges(); Console.WriteLine("Persist " + sw.Elapsed); sw.Restart(); } Console.WriteLine("-----"); Console.WriteLine(sum.Elapsed); } }
public void WriteAndReadBack() { var sw = new Stopwatch(); sw.Start(); using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;")) { Console.WriteLine("Init " + sw.Elapsed); sw.Restart(); var guid = Guid.NewGuid(); var newEntity = new ClassD { EntityId = guid, Name = "Lorem ipsum", NumberOfSomething = 5 }; context.TestTable.Add(newEntity); Console.WriteLine("Add " + sw.Elapsed); sw.Restart(); context.SaveChanges(); Console.WriteLine("Persist " + sw.Elapsed); sw.Restart(); var storedEntity = context.TestTable.SingleOrDefault(e => e.EntityId == guid); Console.WriteLine("Select " + sw.Elapsed); Assert.IsInstanceOfType(storedEntity, typeof(ClassD)); var classD = (ClassD)storedEntity; Assert.AreEqual(classD.Name, newEntity.Name); Assert.AreEqual(classD.NumberOfSomething, newEntity.NumberOfSomething); Assert.AreNotEqual(classD.Id, 0); } }
public void ReadAll() { using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;")) { var sw = new Stopwatch(); sw.Start(); var entities = context.TestTable.ToList(); Console.WriteLine("{0} Select {1}", entities.Count, sw.Elapsed); } }
public void Count() { using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;")) { var sw = new Stopwatch(); sw.Start(); var c = context.TestTable.Count(); Console.WriteLine("Count {0}: {1}", c, sw.Elapsed); } }
private void X(int x) { using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;")) { var sw = new Stopwatch(); sw.Start(); var c = context.TestTable.Where(e => e.Id > x).ToList(); Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed); } }
public void SelectAndOr() { using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;")) { var sw = new Stopwatch(); sw.Start(); var c = context.TestTable.Where(e => e.Name == "Lorem ipsum" && (e.Id == 100 || e.Id == 200 || e.Id == 300)).ToList(); Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed); } }
public void SelectStringContains() { using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;")) { var sw = new Stopwatch(); sw.Start(); var c = context.TestTable.Where(e => e.Name.Contains("ipsum")).ToList(); Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed); } }
public void SelectOrderBy() { using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;")) { var sw = new Stopwatch(); sw.Start(); var c = context.TestTable.OrderByDescending(e => e.Id).ThenBy(e => e.Name).ToList(); Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed); } }
public void Update() { using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;")) { var sw = new Stopwatch(); sw.Start(); //context.TestTable.Where(e => e.Id == 1).Update(); //Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed); } }
public void GetTimePart() { using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;")) { var sw = new Stopwatch(); sw.Start(); var ts = new TimeSpan(10, 0, 0); var c = context.TestTable.Count(e => e.Date.TimeOfDay > ts); Console.WriteLine("Count {0}: {1}", c, sw.Elapsed); } }
public void SelectContains() { using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;")) { var sw = new Stopwatch(); sw.Start(); var ids = new[] { 100, 200, 300, 400, 500 }; var c = context.TestTable.Where(e => ids.Contains(e.Id)).ToList(); Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed); } }
public void Count() { using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;")) { var sw = new Stopwatch(); sw.Start(); var c = context.TestTable.Count(); Console.WriteLine("Count {0}: {1}", c, sw.Elapsed); } }
public void InsertNotInTransactionSpeed() { using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;")) { var sum = new Stopwatch(); sum.Start(); var sw = new Stopwatch(); sw.Start(); for (var i = 0; i < 100; i++) { var guid = Guid.NewGuid(); var newEntity = new ClassD { EntityId = guid, Name = "Lorem ipsum", NumberOfSomething = 5 }; context.TestTable.Add(newEntity); Console.WriteLine("Add " + sw.Elapsed); sw.Restart(); context.SaveChanges(); Console.WriteLine("Persist " + sw.Elapsed); sw.Restart(); } Console.WriteLine("-----"); Console.WriteLine(sum.Elapsed); } }
public void ReadAll() { using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;")) { var sw = new Stopwatch(); sw.Start(); var entities = context.TestTable.ToList(); Console.WriteLine("{0} Select {1}", entities.Count, sw.Elapsed); } }
public void SelectAndOr() { using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;")) { var sw = new Stopwatch(); sw.Start(); var c = context.TestTable.Where(e => e.Name == "Lorem ipsum" && (e.Id == 100 || e.Id == 200 || e.Id == 300)).ToList(); Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed); } }
public void SelectContains() { using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;")) { var sw = new Stopwatch(); sw.Start(); var ids = new[] {100, 200, 300, 400, 500}; var c = context.TestTable.Where(e => ids.Contains(e.Id)).ToList(); Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed); } }
public void SelectOrderBy() { using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;")) { var sw = new Stopwatch(); sw.Start(); var c = context.TestTable.OrderByDescending(e => e.Id).ThenBy(e => e.Name).ToList(); Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed); } }
public void SelectStringContains() { using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;")) { var sw = new Stopwatch(); sw.Start(); var c = context.TestTable.Where(e => e.Name.Contains("ipsum")).ToList(); Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed); } }
public void Update() { using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;")) { var sw = new Stopwatch(); sw.Start(); //context.TestTable.Where(e => e.Id == 1).Update(); //Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed); } }
public void WriteAndReadBack() { var sw = new Stopwatch(); sw.Start(); using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;")) { Console.WriteLine("Init " + sw.Elapsed); sw.Restart(); var guid = Guid.NewGuid(); var newEntity = new ClassD { EntityId = guid, Name = "Lorem ipsum", NumberOfSomething = 5 }; context.TestTable.Add(newEntity); Console.WriteLine("Add " + sw.Elapsed); sw.Restart(); context.SaveChanges(); Console.WriteLine("Persist " + sw.Elapsed); sw.Restart(); var storedEntity = context.TestTable.SingleOrDefault(e => e.EntityId == guid); Console.WriteLine("Select " + sw.Elapsed); Assert.IsInstanceOfType(storedEntity, typeof(ClassD)); var classD = (ClassD) storedEntity; Assert.AreEqual(classD.Name, newEntity.Name); Assert.AreEqual(classD.NumberOfSomething, newEntity.NumberOfSomething); Assert.AreNotEqual(classD.Id, 0); } }
public void GetTimePart() { using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;")) { var sw = new Stopwatch(); sw.Start(); var ts = new TimeSpan(10, 0, 0); var c = context.TestTable.Count(e => e.Date.TimeOfDay > ts); Console.WriteLine("Count {0}: {1}", c, sw.Elapsed); } }
private void X(int x) { using (var context = new TestContext("Server=.;Initial Catalog=TestDb;Integrated security=True;")) { var sw = new Stopwatch(); sw.Start(); var c = context.TestTable.Where(e => e.Id > x).ToList(); Console.WriteLine("Count {0}: {1}", c.Count, sw.Elapsed); } }