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
/// </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) }
};
......
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