private void RunUnary(Channel channel, IInterarrivalTimer timer, BasicProfiler optionalProfiler) { if (optionalProfiler != null) { Profilers.SetForCurrentThread(optionalProfiler); } bool profilerReset = false; var client = new BenchmarkService.BenchmarkServiceClient(channel); var request = CreateSimpleRequest(); var stopwatch = new Stopwatch(); while (!stoppedCts.Token.IsCancellationRequested) { // after the first stats reset, also reset the profiler. if (optionalProfiler != null && !profilerReset && statsResetCount.Count > 0) { optionalProfiler.Reset(); profilerReset = true; } stopwatch.Restart(); client.UnaryCall(request); stopwatch.Stop(); // spec requires data point in nanoseconds. threadLocalHistogram.Value.AddObservation(stopwatch.Elapsed.TotalSeconds * SecondsToNanos); timer.WaitForNext(); } }
private void RunUnary(GrpcChannel channel, IInterarrivalTimer timer) { var client = new BenchmarkService.BenchmarkServiceClient(channel); var request = CreateSimpleRequest(); var stopwatch = new Stopwatch(); while (!_stoppedCts.Token.IsCancellationRequested) { stopwatch.Restart(); client.UnaryCall(request); stopwatch.Stop(); // spec requires data point in nanoseconds. _threadLocalHistogram.Value !.AddObservation(stopwatch.Elapsed.TotalSeconds * SecondsToNanos); timer.WaitForNext(); } }