Esempio n. 1
0
        public static void Run()
        {
            Console.WriteLine("Loading from File Store...");
            var clients = new BiggyList <Client>(new JsonStore <Client>("clients"));

            clients.Clear();
            var sw = new Stopwatch();

            // Write a modest-sized batch to a file:
            int SMALL_BATCH_QTY = 1000;

            Console.WriteLine("Write {0} documents", SMALL_BATCH_QTY);
            var addRange = new List <Client>();

            for (int i = 0; i < SMALL_BATCH_QTY; i++)
            {
                addRange.Add(new Client()
                {
                    ClientId = i, LastName = string.Format("Atten {0}", i.ToString()), FirstName = "John", Email = "*****@*****.**"
                });
            }

            sw.Start();
            clients.Add(addRange);
            sw.Stop();
            Console.WriteLine("Just inserted {0} as documents in {1} ms", clients.Count(), sw.ElapsedMilliseconds);


            int LARGE_BATCH_QTY = 100000;

            Console.WriteLine("Write {0} documents", LARGE_BATCH_QTY);
            sw.Reset();
            clients.Clear();

            // Write a Bigger-sized batch to a file:

            // Reset the temp List;
            addRange = new List <Client>();
            for (int i = 0; i < LARGE_BATCH_QTY; i++)
            {
                addRange.Add(new Client()
                {
                    ClientId = i, LastName = string.Format("Atten {0}", i.ToString()), FirstName = "John", Email = "*****@*****.**"
                });
            }

            sw.Start();
            clients.Add(addRange);
            sw.Stop();
            Console.WriteLine("Just inserted {0} as documents in {1} ms", clients.Count(), sw.ElapsedMilliseconds);

            sw.Reset();
            sw.Start();
            Console.WriteLine("Querying Middle 400 Documents");
            var found = clients.Where(x => x.ClientId > 100 && x.ClientId < 500);

            sw.Stop();
            Console.WriteLine("Queried {0} documents in {1}ms", found.Count(), sw.ElapsedMilliseconds);
        }
Esempio n. 2
0
        public static void Run()
        {
            Console.WriteLine("Loading from File Store...");
            var monkies = new BiggyList <Monkey>();

            monkies.Clear();
            var sw = new Stopwatch();

            Console.WriteLine("Loading 10,000 documents");

            sw.Start();
            var addRange = new List <Monkey>();

            for (int i = 0; i < 10000; i++)
            {
                monkies.Add(new Monkey {
                    ID = i, Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back"
                });
            }
            sw.Stop();
            Console.WriteLine("Just inserted {0} as documents in {1} ms", monkies.Count(), sw.ElapsedMilliseconds);


            Console.WriteLine("Loading 100,000 documents");
            sw.Reset();
            monkies.Clear();
            sw.Start();
            for (int i = 0; i < 100000; i++)
            {
                monkies.Add(new Monkey {
                    ID = i, Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back"
                });
            }
            sw.Stop();
            Console.WriteLine("Just inserted {0} as documents in {1} ms", monkies.Count, sw.ElapsedMilliseconds);


            //use a DB that has an int PK
            sw.Reset();
            sw.Start();
            Console.WriteLine("Loading {0}...", monkies.Count);
            monkies.Reload();
            sw.Stop();
            Console.WriteLine("Loaded {0} documents from Postgres in {1}ms", monkies.Count, sw.ElapsedMilliseconds);

            sw.Reset();
            sw.Start();
            Console.WriteLine("Querying Middle 100 Documents");
            var found = monkies.Where(x => x.ID > 100 && x.ID < 500);

            sw.Stop();
            Console.WriteLine("Queried {0} documents in {1}ms", found.Count(), sw.ElapsedMilliseconds);
        }
Esempio n. 3
0
        public void Biggylist_Removes_All_Items_From_Json_Store()
        {
            var propertyList = new BiggyList <Property>(_propertyStore);
            int initialCount = propertyList.Count;

            var myBatch  = new List <Property>();
            int qtyToAdd = 10;

            for (int i = 0; i < qtyToAdd; i++)
            {
                myBatch.Add(new Property {
                    Id = i, Name = "Marvin Gardens " + i, Address = i + " Property Parkway, Portland, OR 97204"
                });
            }
            propertyList.Add(myBatch);

            // Re-load from back-end:
            propertyList = new BiggyList <Property>(_propertyStore);
            int qtyAdded = propertyList.Count;

            propertyList.Clear();

            // Delete:
            propertyList = new BiggyList <Property>(_propertyStore);
            int remaining = propertyList.Count;

            Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0);
        }
Esempio n. 4
0
        public void Initializes_Memory_Only_List_With_True_Argument()
        {
            _biggyMemoryList = new BiggyList <Widget>(inMemory: true);
            var BiggyJsonList = new BiggyList <Widget>();

            _biggyMemoryList.Clear();
            BiggyJsonList.Clear();

            var batch = new List <Widget>();

            for (int i = 0; i < INSERT_QTY; i++)
            {
                batch.Add(new Widget {
                    SKU = string.Format("00{0}", i), Name = string.Format("Test widget {0}", i), Price = i
                });
            }
            _biggyMemoryList.Add(batch);
            BiggyJsonList.Add(batch);

            int memoryCount = _biggyMemoryList.Count();

            _biggyMemoryList.Clear();

            BiggyJsonList = new BiggyList <Widget>();

            Assert.True(memoryCount == INSERT_QTY && _biggyMemoryList.Count() == 0 && BiggyJsonList.Count() == INSERT_QTY);
        }
        public void Biggylist_Removes_All_Items_From_Sqlite_Store()
        {
            var PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore);
            int initialCount         = PropertyDocumentList.Count;

            var myBatch  = new List <PropertyDocument>();
            int qtyToAdd = 10;

            for (int i = 0; i < qtyToAdd; i++)
            {
                myBatch.Add(new PropertyDocument {
                    Name = "Marvin Gardens " + i, Address = i + " PropertyDocument Parkway, Portland, OR 97204"
                });
            }
            PropertyDocumentList.Add(myBatch);

            // Re-load from back-end:
            PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore);
            int qtyAdded = PropertyDocumentList.Count;

            PropertyDocumentList.Clear();

            // Delete:
            PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore);
            int remaining = PropertyDocumentList.Count;

            Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0);
        }
Esempio n. 6
0
        public void Updates_Item_With_OVerride_From_List_And_Store()
        {
            // Just in case:
            var overriddenClients = new BiggyList <Client>(new SQLServerStore <Client>(_hostDb));

            overriddenClients.Clear();

            // Add a new record:
            var newClient = new Client()
            {
                LastName = "Atten", FirstName = "John", Email = "*****@*****.**"
            };

            overriddenClients.Add(newClient);
            int newId = newClient.ClientId;

            // Update the same record-by-id with a new instance. OverrideClient overrides Equals with the id:
            var updateMe = new Client()
            {
                ClientId = newId, LastName = "Appleseed", FirstName = "John", Email = "*****@*****.**"
            };

            overriddenClients.Update(updateMe);

            // Open a new instance, to see if the item was added to the backing store as well:
            var altClientList = new BiggyList <Client>(new SQLServerStore <Client>(_connectionStringName));
            var updated       = altClientList.FirstOrDefault(c => c.LastName == "Appleseed");

            Assert.True(updated != null && updated.LastName == "Appleseed");
        }
Esempio n. 7
0
        public static void Run()
        {
            Console.WriteLine("Loading from File Store...");
              var clients = new BiggyList<Client>(new JsonStore<Client>("clients"));
              clients.Clear();
              var sw = new Stopwatch();

              // Write a modest-sized batch to a file:
              int SMALL_BATCH_QTY = 1000;

              Console.WriteLine("Write {0} documents", SMALL_BATCH_QTY);
              var addRange = new List<Client>();
              for (int i = 0; i < SMALL_BATCH_QTY; i++) {
            addRange.Add(new Client() { ClientId = i, LastName = string.Format("Atten {0}", i.ToString()), FirstName = "John", Email = "*****@*****.**" });
              }

              sw.Start();
              clients.Add(addRange);
              sw.Stop();
              Console.WriteLine("Just inserted {0} as documents in {1} ms", clients.Count(), sw.ElapsedMilliseconds);

              int LARGE_BATCH_QTY = 100000;
              Console.WriteLine("Write {0} documents", LARGE_BATCH_QTY);
              sw.Reset();
              clients.Clear();

              // Write a Bigger-sized batch to a file:

              // Reset the temp List;
              addRange = new List<Client>();
              for (int i = 0; i < LARGE_BATCH_QTY; i++) {
            addRange.Add(new Client() { ClientId = i, LastName = string.Format("Atten {0}", i.ToString()), FirstName = "John", Email = "*****@*****.**" });
              }

              sw.Start();
              clients.Add(addRange);
              sw.Stop();
              Console.WriteLine("Just inserted {0} as documents in {1} ms", clients.Count(), sw.ElapsedMilliseconds);

              sw.Reset();
              sw.Start();
              Console.WriteLine("Querying Middle 400 Documents");
              var found = clients.Where(x => x.ClientId > 100 && x.ClientId < 500);
              sw.Stop();
              Console.WriteLine("Queried {0} documents in {1}ms", found.Count(), sw.ElapsedMilliseconds);
        }
Esempio n. 8
0
        public static void Run()
        {
            Console.WriteLine("Loading from File Store...");
              var monkies = new BiggyList<Monkey>();
              monkies.Clear();
              var sw = new Stopwatch();

              Console.WriteLine("Loading 10,000 documents");

              sw.Start();
              var addRange = new List<Monkey>();
              for (int i = 0; i < 10000; i++) {
            monkies.Add(new Monkey {ID = i, Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" });
              }
              sw.Stop();
              Console.WriteLine("Just inserted {0} as documents in {1} ms", monkies.Count(), sw.ElapsedMilliseconds);

              Console.WriteLine("Loading 100,000 documents");
              sw.Reset();
              monkies.Clear();
              sw.Start();
              for (int i = 0; i < 100000; i++) {
            monkies.Add(new Monkey { ID = i, Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" });
              }
              sw.Stop();
              Console.WriteLine("Just inserted {0} as documents in {1} ms", monkies.Count, sw.ElapsedMilliseconds);

              //use a DB that has an int PK
              sw.Reset();
              sw.Start();
              Console.WriteLine("Loading {0}...", monkies.Count);
              monkies.Reload();
              sw.Stop();
              Console.WriteLine("Loaded {0} documents from Postgres in {1}ms", monkies.Count, sw.ElapsedMilliseconds);

              sw.Reset();
              sw.Start();
              Console.WriteLine("Querying Middle 100 Documents");
              var found = monkies.Where(x => x.ID > 100 && x.ID < 500);
              sw.Stop();
              Console.WriteLine("Queried {0} documents in {1}ms", found.Count(), sw.ElapsedMilliseconds);
        }
        public IHttpActionResult ArchiveLogs([FromUri] string password)
        {
            if (password != "ArchiveLogs") //just to make
            {
                return(Unauthorized());
            }

            foreach (var item in Log)
            {
                ArchiveLogList.Add(item);
            }
            foreach (var item in BlogLogs)
            {
                ArchiveLogList.Add(item);
            }

            Log.Clear();
            BlogLogs.Clear();

            return(Ok());
        }
Esempio n. 10
0
        //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 products = new BiggyList <Product>();

            products.Clear();
            //File.Delete(products.DbPath);
            //products.Reload();
            //1000 writes?
            var sw = new Stopwatch();

            sw.Start();

            for (int i = 0; i < 1000; i++)
            {
                var p = new Product {
                    Sku = "SKU" + i, Name = "Steve", Price = 12.00M
                };
                products.Add(p);
            }
            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();
        }
Esempio n. 11
0
        public void Updates_Item_In_List_And_Store_With_Equals_Override()
        {
            var overrideWidgetList = new BiggyList <OverrideWidget>(new JsonStore <OverrideWidget>());

            overrideWidgetList.Clear();
            overrideWidgetList.Add(new OverrideWidget {
                SKU = "001", Name = "Test widget 1", Price = 2.00M
            });

            var updatedItem = new OverrideWidget {
                SKU = "001", Name = "UPDATED", Price = 2.00M
            };

            overrideWidgetList.Update(updatedItem);

            // Reload the list:
            overrideWidgetList = new BiggyList <OverrideWidget>(new JsonStore <OverrideWidget>());

            // Grab from the list:
            var updatedInList = overrideWidgetList.FirstOrDefault(w => w.Name == "UPDATED");

            // Make sure updated in both:
            Assert.True(updatedInList.Name == "UPDATED");
        }
Esempio n. 12
0
        public void Updates_Item_With_OVerride_From_List_And_Store()
        {
            // Just in case:
              var overriddenClients = new BiggyList<Client>(new SQLServerStore<Client>(_hostDb));
              overriddenClients.Clear();

              // Add a new record:
              var newClient = new Client() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" };
              overriddenClients.Add(newClient);
              int newId = newClient.ClientId;

              // Update the same record-by-id with a new instance. OverrideClient overrides Equals with the id:
              var updateMe = new Client() { ClientId = newId, LastName = "Appleseed", FirstName = "John", Email = "*****@*****.**" };

              overriddenClients.Update(updateMe);

              // Open a new instance, to see if the item was added to the backing store as well:
              var altClientList = new BiggyList<Client>(new SQLServerStore<Client>(_connectionStringName));
              var updated = altClientList.FirstOrDefault(c => c.LastName == "Appleseed");
              Assert.True(updated != null && updated.LastName == "Appleseed");
        }
Esempio n. 13
0
    public void Biggylist_Removes_All_Items_From_Json_Store() {
      var propertyList = new BiggyList<Property>(_propertyStore);
      int initialCount = propertyList.Count;

      var myBatch = new List<Property>();
      int qtyToAdd = 10;
      for (int i = 0; i < qtyToAdd; i++) {
        myBatch.Add(new Property { Id = i, Name = "Marvin Gardens " + i, Address = i + " Property Parkway, Portland, OR 97204" });
      }
      propertyList.Add(myBatch);

      // Re-load from back-end:
      propertyList = new BiggyList<Property>(_propertyStore);
      int qtyAdded = propertyList.Count;

      propertyList.Clear();

      // Delete:
      propertyList = new BiggyList<Property>(_propertyStore);
      int remaining = propertyList.Count;
      Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0);
    }
        public void Initializes_Memory_Only_List_With_True_Argument()
        {
            _biggyMemoryList = new BiggyList<Widget>(inMemory: true);
              var BiggyJsonList = new BiggyList<Widget>();
              _biggyMemoryList.Clear();
              BiggyJsonList.Clear();

              var batch = new List<Widget>();
              for (int i = 0; i < INSERT_QTY; i++) {
            batch.Add(new Widget { SKU = string.Format("00{0}", i), Name = string.Format("Test widget {0}", i), Price = i });
              }
              _biggyMemoryList.Add(batch);
              BiggyJsonList.Add(batch);

              int memoryCount = _biggyMemoryList.Count();
              _biggyMemoryList.Clear();

              BiggyJsonList = new BiggyList<Widget>();

              Assert.True(memoryCount == INSERT_QTY && _biggyMemoryList.Count() == 0 && BiggyJsonList.Count() == INSERT_QTY);
        }
    public void Biggylist_Removes_All_Items_From_Sqlite_Store() {
      var PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore);
      int initialCount = PropertyDocumentList.Count;

      var myBatch = new List<PropertyDocument>();
      int qtyToAdd = 10;
      for (int i = 0; i < qtyToAdd; i++) {
        myBatch.Add(new PropertyDocument { Name = "Marvin Gardens " + i, Address = i + " PropertyDocument Parkway, Portland, OR 97204" });
      }
      PropertyDocumentList.Add(myBatch);

      // Re-load from back-end:
      PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore);
      int qtyAdded = PropertyDocumentList.Count;

      PropertyDocumentList.Clear();

      // Delete:
      PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore);
      int remaining = PropertyDocumentList.Count;
      Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0);
    }
Esempio n. 16
0
        public void Updates_Item_In_List_And_Store_With_Equals_Override()
        {
            var overrideWidgetList = new BiggyList<OverrideWidget>(new JsonStore<OverrideWidget>());
              overrideWidgetList.Clear();
              overrideWidgetList.Add(new OverrideWidget { SKU = "001", Name = "Test widget 1", Price = 2.00M });

              var updatedItem = new OverrideWidget { SKU = "001", Name = "UPDATED", Price = 2.00M };
              overrideWidgetList.Update(updatedItem);

              // Reload the list:
              overrideWidgetList = new BiggyList<OverrideWidget>(new JsonStore<OverrideWidget>());

              // Grab from the list:
              var updatedInList = overrideWidgetList.FirstOrDefault(w => w.Name == "UPDATED");

              // Make sure updated in both:
              Assert.True(updatedInList.Name == "UPDATED");
        }