public async void TestLargeNumberOfVersionsPerformance() { // Test the performance of writing and reading a single document with a large number of versions. // // CosmosDb emulator setup // - 2000 RU/s collection // - Rate limiting. // // Current performance // - 2nd write: 0.04 sec // - 1000th write: 0.04 sec // - Read: 0.04 sec // // The current implementation does not work when thrashed with lower RU/s due to the RU cost of // the read and write operations. There is a timeout waiting for retries. An improved // implementation should be considered to lower the cost of versioned read and write against // latest documents. E.g., a @latest flag would solve this issue. const int collectionRuLimit = 2000; const int numberOfVersions = 1000; var configManager = new ServiceDbConfigManager("TestService"); var dbAccess = await CreateDbAccess(configManager, collectionRuLimit); var dbAccessProvider = new TestDocumentDbAccessProvider(dbAccess); var store = new LargeDocumentStore(dbAccessProvider); var attachment = JsonConvert.DeserializeObject <LargeDocument>(File.ReadAllText("TestData/LargeDocument.json")); var document = new SmallDocumentWithLargeAttachment(); document.Id = Guid.NewGuid(); Stopwatch sw = new Stopwatch(); sw.Start(); for (var i = 0; i < numberOfVersions; i++) { sw.Restart(); await store.UpsertDocument(document, attachment); TestOutputHelper.WriteLine("Write={0}", sw.Elapsed); } var result = await store.GetSmallDocument(document.Id); TestOutputHelper.WriteLine("Read={0}", sw.Elapsed); Assert.NotNull(result); }
public async void TestLargeDocumentAsAttachmentWithMultipleVersionsPerformance() { // Test the performance of writing and reading a single document with multiple versions and attachment data. // // CosmosDb emulator setup // - 1000 RU/s collection. // - Rate limiting. // // Current performance // - Write: 1.9sec // - Read: 0.1sec const int numberOfVersions = 20; var configManager = new ServiceDbConfigManager("TestService"); var dbAccess = await CreateDbAccess(configManager); var dbAccessProvider = new TestDocumentDbAccessProvider(dbAccess); var store = new LargeDocumentStore(dbAccessProvider); var attachment = JsonConvert.DeserializeObject <LargeDocument>(File.ReadAllText("TestData/LargeDocument.json")); var document = new SmallDocumentWithLargeAttachment(); document.Id = Guid.NewGuid(); Stopwatch sw = new Stopwatch(); sw.Start(); // The same document is stored multiple times to simulate multiple versions. for (var i = 0; i < numberOfVersions; i++) { await store.UpsertDocument(document, attachment); } TestOutputHelper.WriteLine("Write={0}", sw.Elapsed); sw.Restart(); var result = await store.GetSmallDocumentAttachment(document.Id); TestOutputHelper.WriteLine("Read={0}", sw.Elapsed); Assert.NotNull(result); }
public async void TestSingleLargeDocumentPerformance() { // Test the performance of writing and reading a single large, complex document. // // CosmosDb emulator setup // - 1000 RU/s collection. // - Rate limiting. // // Current performance // - Write: 0.5sec // - Read: 0.9sec var configManager = new ServiceDbConfigManager("TestService"); var dbAccess = await CreateDbAccess(configManager); var dbAccessProvider = new TestDocumentDbAccessProvider(dbAccess); var store = new LargeDocumentStore(dbAccessProvider); var document = JsonConvert.DeserializeObject <LargeDocument>(File.ReadAllText("TestData/LargeDocument.json")); document.Id = Guid.NewGuid(); Stopwatch sw = new Stopwatch(); sw.Start(); await store.UpsertDocument(document); TestOutputHelper.WriteLine("Write={0}", sw.Elapsed); sw.Restart(); var result = await store.GetLargeDocument(document.Id); TestOutputHelper.WriteLine("Read={0}", sw.Elapsed); Assert.NotNull(result); }