|
|
@ -66,7 +66,9 @@ namespace Grpc.IntegrationTesting |
|
|
|
switch (config.RpcType) |
|
|
|
switch (config.RpcType) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case RpcType.UNARY: |
|
|
|
case RpcType.UNARY: |
|
|
|
return new SyncUnaryClientRunner(channel, config.PayloadConfig.SimpleParams.ReqSize); |
|
|
|
return new SyncUnaryClientRunner(channel, |
|
|
|
|
|
|
|
config.PayloadConfig.SimpleParams.ReqSize, |
|
|
|
|
|
|
|
config.HistogramParams); |
|
|
|
|
|
|
|
|
|
|
|
case RpcType.STREAMING: |
|
|
|
case RpcType.STREAMING: |
|
|
|
default: |
|
|
|
default: |
|
|
@ -80,6 +82,8 @@ namespace Grpc.IntegrationTesting |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
public class SyncUnaryClientRunner : IClientRunner |
|
|
|
public class SyncUnaryClientRunner : IClientRunner |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
const double SecondsToNanos = 1e9; |
|
|
|
|
|
|
|
|
|
|
|
readonly Channel channel; |
|
|
|
readonly Channel channel; |
|
|
|
readonly int payloadSize; |
|
|
|
readonly int payloadSize; |
|
|
|
readonly Histogram histogram; |
|
|
|
readonly Histogram histogram; |
|
|
@ -89,11 +93,11 @@ namespace Grpc.IntegrationTesting |
|
|
|
readonly CancellationTokenSource stoppedCts; |
|
|
|
readonly CancellationTokenSource stoppedCts; |
|
|
|
readonly WallClockStopwatch wallClockStopwatch = new WallClockStopwatch(); |
|
|
|
readonly WallClockStopwatch wallClockStopwatch = new WallClockStopwatch(); |
|
|
|
|
|
|
|
|
|
|
|
public SyncUnaryClientRunner(Channel channel, int payloadSize) |
|
|
|
public SyncUnaryClientRunner(Channel channel, int payloadSize, HistogramParams histogramParams) |
|
|
|
{ |
|
|
|
{ |
|
|
|
this.channel = Grpc.Core.Utils.Preconditions.CheckNotNull(channel); |
|
|
|
this.channel = Grpc.Core.Utils.Preconditions.CheckNotNull(channel); |
|
|
|
this.payloadSize = payloadSize; |
|
|
|
this.payloadSize = payloadSize; |
|
|
|
this.histogram = new Histogram(0.01, 60e9); // TODO: needs to be in sync with test/cpp/qps/histogram.h |
|
|
|
this.histogram = new Histogram(histogramParams.Resolution, histogramParams.MaxPossible); |
|
|
|
|
|
|
|
|
|
|
|
this.stoppedCts = new CancellationTokenSource(); |
|
|
|
this.stoppedCts = new CancellationTokenSource(); |
|
|
|
this.client = BenchmarkService.NewClient(channel); |
|
|
|
this.client = BenchmarkService.NewClient(channel); |
|
|
@ -136,8 +140,8 @@ namespace Grpc.IntegrationTesting |
|
|
|
client.UnaryCall(request); |
|
|
|
client.UnaryCall(request); |
|
|
|
stopwatch.Stop(); |
|
|
|
stopwatch.Stop(); |
|
|
|
|
|
|
|
|
|
|
|
// TODO: 1e9 needs to be in sync with C++ code |
|
|
|
// spec requires data point in nanoseconds. |
|
|
|
histogram.AddObservation(stopwatch.Elapsed.TotalSeconds * 1e9); |
|
|
|
histogram.AddObservation(stopwatch.Elapsed.TotalSeconds * SecondsToNanos); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|