use new proto option in C#

pull/4156/head
Jan Tattermusch 9 years ago
parent 4d7dbbfcbc
commit 18ce9d65ef
  1. 14
      src/csharp/Grpc.IntegrationTesting/ClientRunners.cs
  2. 8
      src/csharp/Grpc.IntegrationTesting/RunnerClientServerTest.cs
  3. 2
      src/csharp/Grpc.IntegrationTesting/ServerRunners.cs
  4. 1
      test/proto/benchmarks/stats.proto

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

@ -57,6 +57,7 @@ namespace Grpc.IntegrationTesting
var serverConfig = new ServerConfig
{
ServerType = ServerType.ASYNC_SERVER,
Host = Host,
PayloadConfig = new PayloadConfig
{
SimpleParams = new SimpleProtoParams
@ -90,6 +91,11 @@ namespace Grpc.IntegrationTesting
{
ReqSize = 100
}
},
HistogramParams = new HistogramParams
{
Resolution = 0.01,
MaxPossible = 60e9
}
};
@ -105,7 +111,7 @@ namespace Grpc.IntegrationTesting
await runner.StopAsync();
System.Console.WriteLine(stats);
System.Console.WriteLine("avg micros/call " + (long) ((stats.Latencies.Sum / stats.Latencies.Count) * 1000000));
System.Console.WriteLine("avg micros/call " + (long) (stats.Latencies.Sum / stats.Latencies.Count / 1000.0));
}
}
}

@ -65,7 +65,7 @@ namespace Grpc.IntegrationTesting
var server = new Server
{
Services = { BenchmarkService.BindService(new BenchmarkServiceImpl(responseSize)) },
Ports = { new ServerPort("0.0.0.0", config.Port, credentials) }
Ports = { new ServerPort(config.Host, config.Port, credentials) }
};
server.Start();

@ -60,6 +60,7 @@ message HistogramData {
}
message ClientStats {
// Latency histogram. Data points are in nanoseconds.
HistogramData latencies = 1;
// See ServerStats for details.

Loading…
Cancel
Save