Ejemplo n.º 1
0
        private DataSampling DeleteEntriesPerf(ReplicatedTable rtable, List <CustomerEntity> entries)
        {
            var stats = new DataSampling("[D]elete");

            foreach (var entry in entries)
            {
                TableOperation retrieveOperation = TableOperation.Retrieve <CustomerEntity>(entry.PartitionKey, entry.RowKey);
                TableResult    retrieveResult    = rtable.Execute(retrieveOperation);

                Assert.IsNotNull(retrieveResult, "retrieveResult = null");
                Assert.AreEqual((int)HttpStatusCode.OK, retrieveResult.HttpStatusCode, "retrieveResult.HttpStatusCode mismatch");
                Assert.IsNotNull((CustomerEntity)retrieveResult.Result, "Retrieve: customer = null");

                // Delete entity
                var customer = (CustomerEntity)retrieveResult.Result;
                Assert.IsTrue(customer._rtable_Version == 2, "entry was updated once, version should be 2");

                TableOperation deleteOperation = TableOperation.Delete(customer);

                TableResult deleteResult;
                var         watch = System.Diagnostics.Stopwatch.StartNew();
                {
                    deleteResult = rtable.Execute(deleteOperation);
                }
                watch.Stop();
                stats.AddPoint(watch.ElapsedMilliseconds);

                Assert.IsNotNull(deleteResult, "deleteResult = null");
                Assert.AreEqual((int)HttpStatusCode.NoContent, deleteResult.HttpStatusCode, "deleteResult.HttpStatusCode mismatch");
            }

            return(stats);
        }
Ejemplo n.º 2
0
        private DataSampling RetrieveEntriesPerf(ReplicatedTable rtable, List <CustomerEntity> entries)
        {
            var stats = new DataSampling("[R]etrieve");

            foreach (var entry in entries)
            {
                TableOperation retrieveOperation = TableOperation.Retrieve <CustomerEntity>(entry.PartitionKey, entry.RowKey);

                TableResult retrieveResult = null;
                var         watch          = System.Diagnostics.Stopwatch.StartNew();
                {
                    retrieveResult = rtable.Execute(retrieveOperation);
                }
                watch.Stop();
                stats.AddPoint(watch.ElapsedMilliseconds);

                Assert.IsNotNull(retrieveResult, "retrieveResult = null");
                Assert.AreEqual((int)HttpStatusCode.OK, retrieveResult.HttpStatusCode, "retrieveResult.HttpStatusCode mismatch");

                var customer = (CustomerEntity)retrieveResult.Result;
                Assert.IsNotNull(customer, "Retrieve: customer = null");

                Assert.IsTrue(customer._rtable_Version == 1, "new entry should have version 1");
            }

            return(stats);
        }
Ejemplo n.º 3
0
        private DataSampling UpdateEntriesPerf(ReplicatedTable rtable, List <CustomerEntity> entries)
        {
            var stats = new DataSampling("[U]pdate");

            foreach (var entry in entries)
            {
                TableOperation retrieveOperation = TableOperation.Retrieve <CustomerEntity>(entry.PartitionKey, entry.RowKey);
                TableResult    retrieveResult    = rtable.Execute(retrieveOperation);

                Assert.IsNotNull(retrieveResult, "retrieveResult = null");
                Assert.AreEqual((int)HttpStatusCode.OK, retrieveResult.HttpStatusCode, "retrieveResult.HttpStatusCode mismatch");
                Assert.IsNotNull((CustomerEntity)retrieveResult.Result, "Retrieve: customer = null");

                // Update entity
                var customer = (CustomerEntity)retrieveResult.Result;
                customer.Email = string.Format("{0}.{1}@email.com", entry.PartitionKey, entry.RowKey);

                TableOperation updateOperation = TableOperation.Replace(customer);

                TableResult updateResult;
                var         watch = System.Diagnostics.Stopwatch.StartNew();
                {
                    updateResult = rtable.Execute(updateOperation);
                }
                watch.Stop();
                stats.AddPoint(watch.ElapsedMilliseconds);

                Assert.IsNotNull(updateResult, "updateResult = null");
                Assert.AreEqual((int)HttpStatusCode.NoContent, updateResult.HttpStatusCode, "updateResult.HttpStatusCode mismatch");
            }

            return(stats);
        }
Ejemplo n.º 4
0
        private DataSampling CreateEntriesStats(ReplicatedTable rtable, List <CustomerEntity> entries)
        {
            var stats = new DataSampling("[C]reate");

            foreach (var entry in entries)
            {
                TableOperation insertOperation = TableOperation.Insert(entry);

                TableResult insertResult = null;
                var         watch        = System.Diagnostics.Stopwatch.StartNew();
                {
                    insertResult = rtable.Execute(insertOperation);
                }
                watch.Stop();
                stats.AddPoint(watch.ElapsedMilliseconds);

                Assert.IsNotNull(insertResult, "insertResult = null");
                Assert.AreEqual((int)HttpStatusCode.NoContent, insertResult.HttpStatusCode, "insertResult.HttpStatusCode mismatch");
            }

            return(stats);
        }