honor request.ReponseSize for benchmark service

pull/5904/head
Jan Tattermusch 9 years ago
parent 3d6644aefd
commit c848502f55
  1. 9
      src/csharp/Grpc.IntegrationTesting/BenchmarkServiceImpl.cs
  2. 12
      src/csharp/Grpc.IntegrationTesting/ClientRunners.cs
  3. 6
      src/csharp/Grpc.IntegrationTesting/ServerRunners.cs

@ -46,16 +46,13 @@ namespace Grpc.Testing
/// </summary>
public class BenchmarkServiceImpl : BenchmarkService.IBenchmarkService
{
private readonly int responseSize;
public BenchmarkServiceImpl(int responseSize)
public BenchmarkServiceImpl()
{
this.responseSize = responseSize;
}
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);
}
@ -63,7 +60,7 @@ namespace Grpc.Testing
{
await requestStream.ForEachAsync(async request =>
{
var response = new SimpleResponse { Payload = CreateZerosPayload(responseSize) };
var response = new SimpleResponse { Payload = CreateZerosPayload(request.ResponseSize) };
await responseStream.WriteAsync(response);
});
}

@ -64,6 +64,8 @@ namespace Grpc.IntegrationTesting
string target = config.ServerTargets.Single();
GrpcPreconditions.CheckArgument(config.LoadParams.LoadCase == LoadParams.LoadOneofCase.ClosedLoop,
"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");
if (config.OutstandingRpcsPerChannel != 0)
@ -98,7 +100,7 @@ namespace Grpc.IntegrationTesting
{
case RpcType.UNARY:
return new SyncUnaryClientRunner(channel,
config.PayloadConfig.SimpleParams.ReqSize,
config.PayloadConfig.SimpleParams,
config.HistogramParams);
case RpcType.STREAMING:
@ -116,7 +118,7 @@ namespace Grpc.IntegrationTesting
const double SecondsToNanos = 1e9;
readonly Channel channel;
readonly int payloadSize;
readonly SimpleProtoParams payloadParams;
readonly Histogram histogram;
readonly BenchmarkService.IBenchmarkServiceClient client;
@ -124,10 +126,9 @@ namespace Grpc.IntegrationTesting
readonly CancellationTokenSource stoppedCts;
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.payloadSize = payloadSize;
this.histogram = new Histogram(histogramParams.Resolution, histogramParams.MaxPossible);
this.stoppedCts = new CancellationTokenSource();
@ -161,7 +162,8 @@ namespace Grpc.IntegrationTesting
{
var request = new SimpleRequest
{
Payload = CreateZerosPayload(payloadSize)
Payload = CreateZerosPayload(payloadParams.ReqSize),
ResponseSize = payloadParams.RespSize
};
var stopwatch = new Stopwatch();

@ -77,11 +77,11 @@ namespace Grpc.IntegrationTesting
Logger.Warning("ServerConfig.CoreList is not supported for C#. Ignoring the value");
}
// TODO: qps_driver needs to setup payload properly...
int responseSize = config.PayloadConfig != null ? config.PayloadConfig.SimpleParams.RespSize : 0;
GrpcPreconditions.CheckArgument(config.PayloadConfig == null,
"ServerConfig.PayloadConfig shouldn't be set for BenchmarkService based server.");
var server = new Server
{
Services = { BenchmarkService.BindService(new BenchmarkServiceImpl(responseSize)) },
Services = { BenchmarkService.BindService(new BenchmarkServiceImpl()) },
Ports = { new ServerPort("[::]", config.Port, credentials) }
};

Loading…
Cancel
Save