private async Task SetDataPerformanceTest(IRingMasterRequestHandler ringMasterClient, ConfigurationSection config, CancellationToken cancellationToken) { try { string testRootPath = config.GetStringValue("TestPath"); int maxConcurrentSetDataBatches = config.GetIntValue("MaxConcurrentBatches"); int maxNodes = config.GetIntValue("MaxNodesToLoad"); int batchLength = config.GetIntValue("BatchLength"); ControlPlaneStressServiceEventSource.Log.SetDataPerformanceTestStarted(testRootPath, maxNodes, batchLength); var instrumentation = new SetDataPerformanceInstrumentation(this.MetricsFactory); var setDataPerformanceTest = new SetDataPerformance(instrumentation, maxConcurrentSetDataBatches, cancellationToken); setDataPerformanceTest.MinDataSizePerNode = config.GetIntValue("MinDataSizePerNode"); setDataPerformanceTest.MaxDataSizePerNode = config.GetIntValue("MaxDataSizePerNode"); await setDataPerformanceTest.LoadNodes(ringMasterClient, testRootPath, maxNodes); await Task.Run(() => setDataPerformanceTest.QueueRequests(ringMasterClient, batchLength)); ControlPlaneStressServiceEventSource.Log.SetDataPerformanceTestCompleted(); } catch (Exception ex) { ControlPlaneStressServiceEventSource.Log.SetDataPerformanceTestFailed(ex.ToString()); } }
/// <summary> /// Measures the performance of SetData requests. /// </summary> /// <param name="ringMaster">RingMaster client</param> /// <returns>Task that tracks execution of this test</returns> private async Task SetDataPerformanceTest(IRingMasterRequestHandler ringMaster) { Trace.TraceInformation($"SetData performance test path={this.TestPath}"); var cancellationToken = CancellationToken.None; var instrumentation = new SetDataPerformanceInstrumentation(); var setDataPerformanceTest = new SetDataPerformance(instrumentation, this.MaxConcurrency, CancellationToken.None); await setDataPerformanceTest.LoadNodes(ringMaster, this.TestPath, this.MaxNodes, this.MaxGetChildrenEnumerationCount); var task = Task.Run(() => setDataPerformanceTest.QueueRequests(ringMaster, this.BatchLength, this.MaxSetOperations)); long lastSuccessCount = 0; var timer = Stopwatch.StartNew(); while (!task.Wait(5000)) { timer.Stop(); long rate = (long)((instrumentation.Success - lastSuccessCount) * 1000) / timer.ElapsedMilliseconds; Trace.TraceInformation($"SetData success={instrumentation.Success}, failure={instrumentation.Failure}, rate={rate}"); timer.Restart(); lastSuccessCount = instrumentation.Success; } }