/// <summary> /// Measures the performance of create requests. /// </summary> /// <param name="ringMaster">RingMaster client</param> /// <param name="maxNodes">Number of nodes to create</param> private void CreatePerformanceTest(IRingMasterRequestHandler ringMaster, int maxNodes) { var instrumentation = new CreatePerformanceInstrumentation(); var createPerformanceTest = new CreatePerformance(instrumentation, this.MaxConcurrency, CancellationToken.None); createPerformanceTest.MinChildrenCountPerNode = this.MinChildrenPerNode; createPerformanceTest.MaxChildrenCountPerNode = this.MaxChildrenPerNode; createPerformanceTest.MaxDataSizePerNode = this.MaxDataSize; createPerformanceTest.MinDataSizePerNode = this.MinDataSize; createPerformanceTest.MaxAllowedCodePoint = this.MaxAllowedCodePoint; Trace.TraceInformation($"Create performance test path={this.TestPath}, maxNumberOfNodes={maxNodes}"); var task = Task.Run(() => createPerformanceTest.CreateHierarchy(ringMaster, this.TestPath, this.BatchLength, maxNodes)); long lastSuccessCount = 0; var timer = Stopwatch.StartNew(); while (!task.Wait(5000)) { timer.Stop(); long rate = (long)((instrumentation.Success - lastSuccessCount) * 1000) / timer.ElapsedMilliseconds; Trace.TraceInformation($"Create success={instrumentation.Success}, failure={instrumentation.Failure}, rate={rate}"); timer.Restart(); lastSuccessCount = instrumentation.Success; } }
private async Task CreateAndDeleteHierarchyTest(IRingMasterRequestHandler ringMaster, ConfigurationSection config, CancellationToken cancellationToken) { try { string testPath = config.GetStringValue("CreateAndDeleteHierarchy.TestPath"); int maxNodes = config.GetIntValue("CreateAndDeleteHierarchy.MaxNodes"); bool useScheduledDelete = config.GetBoolValue("CreateAndDeleteHierarchy.UseScheduledDelete"); await ringMaster.Create(testPath, null, null, CreateMode.PersistentAllowPathCreation, throwIfNodeExists : false); while (!cancellationToken.IsCancellationRequested) { var createInstrumentation = new CreatePerformanceInstrumentation(this.MetricsFactory); int maxConcurrentCreateBatches = config.GetIntValue("Create.MaxConcurrentBatches"); int createBatchLength = config.GetIntValue("Create.BatchLength"); var createPerformanceTest = new CreatePerformance(createInstrumentation, maxConcurrentCreateBatches, cancellationToken); createPerformanceTest.MinChildrenCountPerNode = config.GetIntValue("Create.MinChildrenCountPerNode"); createPerformanceTest.MaxChildrenCountPerNode = config.GetIntValue("Create.MaxChildrenCountPerNode"); createPerformanceTest.MinDataSizePerNode = config.GetIntValue("Create.MinDataSizePerNode"); createPerformanceTest.MaxDataSizePerNode = config.GetIntValue("Create.MaxDataSizePerNode"); createPerformanceTest.MaxNodeNameLength = config.GetIntValue("Create.MaxNodeNameLength"); PopulationStressServiceEventSource.Log.CreateAndDeleteHierarchyCreateStarted(testPath, maxNodes, createBatchLength); createPerformanceTest.CreateHierarchy(ringMaster, testPath, createBatchLength, maxNodes); int maxConcurrentDeleteBatches = config.GetIntValue("Delete.MaxConcurrentBatches"); int deleteBatchLength = config.GetIntValue("Delete.BatchLength"); var deleteInstrumentation = new DeletePerformanceInstrumentation(this.MetricsFactory); var deletePerformanceTest = new DeletePerformance(deleteInstrumentation, maxConcurrentDeleteBatches, cancellationToken); PopulationStressServiceEventSource.Log.CreateAndDeleteHierarchyDeleteStarted(testPath, maxNodes, deleteBatchLength, useScheduledDelete); if (useScheduledDelete) { deletePerformanceTest.ScheduledDelete(ringMaster, testPath); } else { await deletePerformanceTest.LoadNodes(ringMaster, testPath, maxNodes); deletePerformanceTest.QueueDeletes(ringMaster, deleteBatchLength); } } PopulationStressServiceEventSource.Log.CreateAndDeleteHierarchyTestCompleted(); } catch (Exception ex) { PopulationStressServiceEventSource.Log.CreateAndDeleteHierarchyTestFailed(ex.ToString()); } }