/// <summary> /// Measures the performance of scheduled delete operation. /// </summary> /// <param name="ringMaster">RingMaster client</param> private void ScheduledDeletePerformanceTest(IRingMasterRequestHandler ringMaster) { var instrumentation = new DeletePerformanceInstrumentation(); var deletePerformanceTest = new DeletePerformance(instrumentation, this.MaxConcurrency, CancellationToken.None); Trace.TraceInformation($"Scheduled Delete performance test path={this.TestPath}"); var task = Task.Run(() => deletePerformanceTest.ScheduledDelete(ringMaster, this.TestPath)); var totalTime = Stopwatch.StartNew(); var timer = Stopwatch.StartNew(); while (!task.Wait(5000)) { timer.Stop(); Trace.TraceInformation($"Scheduled Delete ElapsedMilliseconds={totalTime.ElapsedMilliseconds}"); timer.Restart(); } }
/// <summary> /// Measures the performance of delete requests. /// </summary> /// <param name="ringMaster">RingMaster client</param> /// <returns>Task that tracks execution of this test</returns> private async Task DeletePerformanceTest(IRingMasterRequestHandler ringMaster) { var instrumentation = new DeletePerformanceInstrumentation(); var deletePerformanceTest = new DeletePerformance(instrumentation, this.MaxConcurrency, CancellationToken.None); Trace.TraceInformation($"Delete performance test path={this.TestPath}"); await deletePerformanceTest.LoadNodes(ringMaster, this.TestPath, this.MaxNodes, this.MaxGetChildrenEnumerationCount); var task = Task.Run(() => deletePerformanceTest.QueueDeletes(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($"Delete success={instrumentation.Success}, failure={instrumentation.Failure}, rate={rate}"); timer.Restart(); lastSuccessCount = instrumentation.Success; } }