//static void WhatWhat() { // var sw = new Stopwatch(); // sw.Start(); // var products = new MassiveList<NWProduct>(connectionStringName: "northwind", tableName: "products", primaryKeyName: "productid"); // sw.Stop(); // Console.WriteLine("Read " + products.Count + " into memory in " + sw.ElapsedMilliseconds + "ms"); // foreach (var p in products) { // Console.WriteLine(p.Sku); // } // sw.Reset(); // sw.Start(); // var readOne = products.FirstOrDefault(x => x.ProductName == "Product24"); // Console.WriteLine(readOne.ProductName); // sw.Stop(); // Console.WriteLine("Read single in " + sw.ElapsedMilliseconds + "ms"); // sw.Reset(); // sw.Start(); // var details = new MassiveList<OrderDetail>(connectionStringName: "northwind", tableName: "orderdetails", primaryKeyName: "orderdetailid"); // sw.Stop(); // Console.WriteLine("Read " + details.Count + " into memory in " + sw.ElapsedMilliseconds + "ms"); // Console.Read(); //} static void RunBenchmarks() { Console.WriteLine("Writing 1000 records sync"); var sw = new Stopwatch(); var products = new BiggyList<Product>(); //1000 writes? for (int i = 0; i < 1000; i++) { var p = new Product { Sku = "SKU" + i, Name = "Steve", Price = 12.00M }; products.Add(p); } sw.Start(); products.Save(); sw.Stop(); Console.WriteLine("{0}ms", sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("Resetting..."); products.Purge(); Console.WriteLine("Writing 1000 records async"); //1000 writes? for (int i = 0; i < 1000; i++) { var p = new Product { Sku = "SKUDDY" + i, Name = "Steve", Price = 12.00M }; products.Add(p); } sw.Start(); products.SaveAsync(); sw.Stop(); Console.WriteLine("{0}ms", sw.ElapsedMilliseconds); sw.Reset(); //1000 writes? Console.WriteLine("Writing 1000 records with write happening in a loop"); sw.Start(); for (int i = 0; i < 1000; i++) { var p = new Product { Sku = "SKU" + i, Name = "Steve", Price = 12.00M }; products.Add(p); //bad idea... run it and see why products.Save(); } sw.Stop(); Console.WriteLine("{0}ms", sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("Reading from records"); sw.Start(); var p2 = products.Where(x => x.Sku == "SKU22").FirstOrDefault(); Console.WriteLine(p2.Sku); sw.Stop(); Console.WriteLine("{0}ms", sw.ElapsedMilliseconds); Console.Read(); }
static void Main(string[] args) { Console.WriteLine("Writing 1000 records sync"); var sw = new Stopwatch(); var products = new BiggyList <Product>(); //1000 writes? for (int i = 0; i < 1000; i++) { var p = new Product { Sku = "SKU" + i, Name = "Steve", Price = 12.00M }; products.Add(p); } sw.Start(); products.Save(); sw.Stop(); Console.WriteLine("{0}ms", sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("Resetting..."); products.ClearAndSave(); Console.WriteLine("Writing 1000 records async"); //1000 writes? for (int i = 0; i < 1000; i++) { var p = new Product { Sku = "SKUDDY" + i, Name = "Steve", Price = 12.00M }; products.Add(p); } sw.Start(); products.SaveAsync(); sw.Stop(); Console.WriteLine("{0}ms", sw.ElapsedMilliseconds); sw.Reset(); //1000 writes? Console.WriteLine("Writing 1000 records with write happening in a loop"); sw.Start(); for (int i = 0; i < 1000; i++) { var p = new Product { Sku = "SKU" + i, Name = "Steve", Price = 12.00M }; products.Add(p); //bad idea... run it and see why products.Save(); } sw.Stop(); Console.WriteLine("{0}ms", sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("Reading from records"); sw.Start(); var p2 = products.Where(x => x.Sku == "SKU22").FirstOrDefault(); Console.WriteLine(p2.Sku); sw.Stop(); Console.WriteLine("{0}ms", sw.ElapsedMilliseconds); Console.Read(); }