Skip to content
Snippets Groups Projects
Commit c848502f authored by Jan Tattermusch's avatar Jan Tattermusch
Browse files

honor request.ReponseSize for benchmark service

parent 3d6644ae
No related branches found
No related tags found
No related merge requests found
...@@ -46,16 +46,13 @@ namespace Grpc.Testing ...@@ -46,16 +46,13 @@ namespace Grpc.Testing
/// </summary> /// </summary>
public class BenchmarkServiceImpl : BenchmarkService.IBenchmarkService public class BenchmarkServiceImpl : BenchmarkService.IBenchmarkService
{ {
private readonly int responseSize; public BenchmarkServiceImpl()
public BenchmarkServiceImpl(int responseSize)
{ {
this.responseSize = responseSize;
} }
public Task<SimpleResponse> UnaryCall(SimpleRequest request, ServerCallContext context) public Task<SimpleResponse> UnaryCall(SimpleRequest request, ServerCallContext context)
{ {
var response = new SimpleResponse { Payload = CreateZerosPayload(responseSize) }; var response = new SimpleResponse { Payload = CreateZerosPayload(request.ResponseSize) };
return Task.FromResult(response); return Task.FromResult(response);
} }
...@@ -63,7 +60,7 @@ namespace Grpc.Testing ...@@ -63,7 +60,7 @@ namespace Grpc.Testing
{ {
await requestStream.ForEachAsync(async request => await requestStream.ForEachAsync(async request =>
{ {
var response = new SimpleResponse { Payload = CreateZerosPayload(responseSize) }; var response = new SimpleResponse { Payload = CreateZerosPayload(request.ResponseSize) };
await responseStream.WriteAsync(response); await responseStream.WriteAsync(response);
}); });
} }
......
...@@ -64,6 +64,8 @@ namespace Grpc.IntegrationTesting ...@@ -64,6 +64,8 @@ namespace Grpc.IntegrationTesting
string target = config.ServerTargets.Single(); string target = config.ServerTargets.Single();
GrpcPreconditions.CheckArgument(config.LoadParams.LoadCase == LoadParams.LoadOneofCase.ClosedLoop, GrpcPreconditions.CheckArgument(config.LoadParams.LoadCase == LoadParams.LoadOneofCase.ClosedLoop,
"Only closed loop scenario supported for C#"); "Only closed loop scenario supported for C#");
GrpcPreconditions.CheckArgument(config.ClientType == ClientType.SYNC_CLIENT,
"Only sync client support for C#");
GrpcPreconditions.CheckArgument(config.ClientChannels == 1, "ClientConfig.ClientChannels needs to be 1"); GrpcPreconditions.CheckArgument(config.ClientChannels == 1, "ClientConfig.ClientChannels needs to be 1");
if (config.OutstandingRpcsPerChannel != 0) if (config.OutstandingRpcsPerChannel != 0)
...@@ -98,7 +100,7 @@ namespace Grpc.IntegrationTesting ...@@ -98,7 +100,7 @@ namespace Grpc.IntegrationTesting
{ {
case RpcType.UNARY: case RpcType.UNARY:
return new SyncUnaryClientRunner(channel, return new SyncUnaryClientRunner(channel,
config.PayloadConfig.SimpleParams.ReqSize, config.PayloadConfig.SimpleParams,
config.HistogramParams); config.HistogramParams);
case RpcType.STREAMING: case RpcType.STREAMING:
...@@ -116,7 +118,7 @@ namespace Grpc.IntegrationTesting ...@@ -116,7 +118,7 @@ namespace Grpc.IntegrationTesting
const double SecondsToNanos = 1e9; const double SecondsToNanos = 1e9;
readonly Channel channel; readonly Channel channel;
readonly int payloadSize; readonly SimpleProtoParams payloadParams;
readonly Histogram histogram; readonly Histogram histogram;
readonly BenchmarkService.IBenchmarkServiceClient client; readonly BenchmarkService.IBenchmarkServiceClient client;
...@@ -124,10 +126,9 @@ namespace Grpc.IntegrationTesting ...@@ -124,10 +126,9 @@ 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, HistogramParams histogramParams) public SyncUnaryClientRunner(Channel channel, SimpleProtoParams payloadParams, HistogramParams histogramParams)
{ {
this.channel = GrpcPreconditions.CheckNotNull(channel); this.channel = GrpcPreconditions.CheckNotNull(channel);
this.payloadSize = payloadSize;
this.histogram = new Histogram(histogramParams.Resolution, histogramParams.MaxPossible); this.histogram = new Histogram(histogramParams.Resolution, histogramParams.MaxPossible);
this.stoppedCts = new CancellationTokenSource(); this.stoppedCts = new CancellationTokenSource();
...@@ -161,7 +162,8 @@ namespace Grpc.IntegrationTesting ...@@ -161,7 +162,8 @@ namespace Grpc.IntegrationTesting
{ {
var request = new SimpleRequest var request = new SimpleRequest
{ {
Payload = CreateZerosPayload(payloadSize) Payload = CreateZerosPayload(payloadParams.ReqSize),
ResponseSize = payloadParams.RespSize
}; };
var stopwatch = new Stopwatch(); var stopwatch = new Stopwatch();
......
...@@ -77,11 +77,11 @@ namespace Grpc.IntegrationTesting ...@@ -77,11 +77,11 @@ namespace Grpc.IntegrationTesting
Logger.Warning("ServerConfig.CoreList is not supported for C#. Ignoring the value"); Logger.Warning("ServerConfig.CoreList is not supported for C#. Ignoring the value");
} }
// TODO: qps_driver needs to setup payload properly... GrpcPreconditions.CheckArgument(config.PayloadConfig == null,
int responseSize = config.PayloadConfig != null ? config.PayloadConfig.SimpleParams.RespSize : 0; "ServerConfig.PayloadConfig shouldn't be set for BenchmarkService based server.");
var server = new Server var server = new Server
{ {
Services = { BenchmarkService.BindService(new BenchmarkServiceImpl(responseSize)) }, Services = { BenchmarkService.BindService(new BenchmarkServiceImpl()) },
Ports = { new ServerPort("[::]", config.Port, credentials) } Ports = { new ServerPort("[::]", config.Port, credentials) }
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment