private async Task GetDataPerformanceTest(IRingMasterRequestHandler ringMaster, ConfigurationSection config, CancellationToken cancellationToken) { try { string testRootPath = config.GetStringValue("TestPath"); int maxConcurrentGetDataBatches = config.GetIntValue("MaxConcurrentBatches"); int batchLength = config.GetIntValue("BatchLength"); int maxNodes = config.GetIntValue("MaxNodesToLoad"); var instrumentation = new GetDataPerformanceInstrumentation(this.MetricsFactory); var getDataPerformanceTest = new GetDataPerformance(instrumentation, maxConcurrentGetDataBatches, cancellationToken); await getDataPerformanceTest.LoadNodes(ringMaster, testRootPath, maxNodes); ringMaster.Timeout = 100; ServingPlaneStressServiceEventSource.Log.GetDataPerformanceTestStarted(testRootPath, maxNodes, batchLength); await Task.Run(() => getDataPerformanceTest.QueueBatches(ringMaster, batchLength)); ServingPlaneStressServiceEventSource.Log.GetDataPerformanceTestCompleted(); } catch (Exception ex) { ServingPlaneStressServiceEventSource.Log.GetDataPerformanceTestFailed(ex.ToString()); } }
/// <summary> /// Measures the performance of GetData requests. /// </summary> /// <param name="ringMaster">RingMaster client</param> /// <param name="cancellation">The cancellation.</param> /// <returns> /// Task that tracks execution of this test /// </returns> private async Task GetDataPerformanceTest(IRingMasterRequestHandler ringMaster, CancellationTokenSource cancellation) { Trace.TraceInformation($"GetData performance test path={this.TestPath} batchLength={this.BatchLength}"); var cancellationToken = cancellation.Token; var instrumentation = new GetDataPerformanceInstrumentation(); var getDataPerformanceTest = new GetDataPerformance(instrumentation, this.MaxConcurrency, cancellationToken); await getDataPerformanceTest.LoadNodes(ringMaster, this.TestPath, this.MaxNodes, this.MaxGetChildrenEnumerationCount); var task = Task.Run(() => getDataPerformanceTest.QueueBatches(ringMaster, this.BatchLength)); long lastSuccessCount = 0; var timer = Stopwatch.StartNew(); while (!task.Wait(5000)) { timer.Stop(); long rate = (long)((instrumentation.Success - lastSuccessCount) * 1000) / timer.ElapsedMilliseconds; Trace.TraceInformation($"GetData success={instrumentation.Success} failure={instrumentation.Failure} rate={rate}"); timer.Restart(); lastSuccessCount = instrumentation.Success; } }