public static IEnumerable <BenchmarkResult> Start() { var databaseName = "Test"; Console.WriteLine($"--- Benchmark Start ---"); var stopWatch = new Stopwatch(); // STEP 1: DELETE DB var database = new Database(databaseName); database.Delete(); database.Close(); var deleteDBResult = new BenchmarkResult("Delete DB", stopWatch.Elapsed); Log(deleteDBResult); stopWatch.Restart(); // STEP 2: NEW DB stopWatch.Start(); database = new Database(databaseName); var newDBResult = new BenchmarkResult("Create New DB", stopWatch.Elapsed); Log(newDBResult); stopWatch.Restart(); // STEP 3: ENSURE INDEXES var indexes = new HashSet <string> { ICouchbaseDocumentExtensions.JsonProperties.CouchbaseId, ICouchbaseDocumentExtensions.JsonProperties.CouchbaseType, IPerishableDataExtensions.JsonProperties.LastUpdated, IPerishableDataExtensions.JsonProperties.ExpirationDate, nameof(PersonObfuscated.EntryGuid), nameof(PersonObfuscated.FirstName), nameof(PersonObfuscated.LastName), nameof(PersonObfuscated.DisplayName), nameof(PersonObfuscated.SiteName), nameof(PersonObfuscated.DepartmentName), nameof(PersonObfuscated.TeamName), }; foreach (var index in indexes) { var indexName = $"ValueIndex_{index}"; database.CreateIndex(indexName, IndexBuilder.ValueIndex(ValueIndexItem.Expression(Expression.Property(indexName)))); } var createIndexes = new BenchmarkResult($"Create {indexes.Count} Indexes", stopWatch.Elapsed); Log(createIndexes); stopWatch.Restart(); // STEP 4: CREATE MODELS var numberOfDocuments = 11000; var entryType = "entryType"; var firstName = "John"; var lastName = "Smith"; var maidenName = "maidenName"; var displayName = "John Smith"; var organizationName = "John Smith"; var locationGuid = Guid.NewGuid(); var siteGuid = Guid.NewGuid(); var siteName = "Main Site"; var userStatus = "Regular User"; var departmentName = "Information Technology > Apps"; var residenceArea = "Anytown - PA (USA)"; var workAreaName = "Office 1"; var teamName = "Blue Team"; var contacts = new List <Contact> { new Contact(ContactType.Work, ContactMethod.Phone, "12345"), new Contact(ContactType.Work, ContactMethod.Fax, "12345"), new Contact(ContactType.Personal, ContactMethod.Mobile, "+1 8885551212"), new Contact(ContactType.Personal, ContactMethod.Email, "*****@*****.**"), new Contact(ContactType.Work, ContactMethod.Email, "*****@*****.**") }; var spouseEntryGuid = Guid.NewGuid(); var personPrimaryPhotoGuid = Guid.NewGuid(); string primaryPhotoUrl = "https://myphotoserver.blob.core.windows.net/primaryphotos/8891be56-47c6-4546-8954-9116743f2efc?sv=2018-03-28&sr=b&sig=vJTpHXMYefdVrehAo%2FJiDHNnq60rMlwk3d4QHZQSRmk%3D&se=2019-11-15T23%3A00%3A48Z&sp=r"; var emergencyContactGuids = new List <Guid> { }; var lastUpdated = DateTimeOffset.Now; var expirationDate = DateTimeOffset.Now; var models = new PersonObfuscated[numberOfDocuments]; for (int i = 0; i < numberOfDocuments; i++) { var entryGuid = Guid.NewGuid(); var person = new PersonObfuscated( entryGuid, entryType, firstName, lastName, maidenName, displayName, organizationName, locationGuid, siteGuid, siteName, userStatus, departmentName, residenceArea, workAreaName, teamName, contacts, spouseEntryGuid, personPrimaryPhotoGuid, primaryPhotoUrl, emergencyContactGuids, lastUpdated, expirationDate); models[i] = person; } var createModels = new BenchmarkResult($"Create {models.Length} Models", stopWatch.Elapsed); Log(createModels); stopWatch.Restart(); // STEP 5: CREATE MUTABLE DOCUMENTS var documents = models.AsParallel().Select(model => model.ToMutableDocument()).ToArray(); var createDocuments = new BenchmarkResult($"Create {documents.Length} Documents", stopWatch.Elapsed); Log(createDocuments); stopWatch.Restart(); // STEP 6: INSERT INTO COUCHBASE database.InBatch(() => { foreach (var doc in documents) { database.Save(doc); } }); var batchSaveDocuments = new BenchmarkResult($"Batch Save {documents.Length} Documents", stopWatch.Elapsed); Log(batchSaveDocuments); stopWatch.Restart(); database.Close(); Console.WriteLine($"--- Benchmark End ---"); return(new BenchmarkResult[] { deleteDBResult, newDBResult, createIndexes, createModels, createDocuments, batchSaveDocuments }); }