use of io.grpc.benchmarks.proto.Messages.SimpleRequest in project grpc-java by grpc.
the class AsyncClient method doStreamingCalls.
private static Future<Histogram> doStreamingCalls(Channel channel, final SimpleRequest request, final long endTime) {
final BenchmarkServiceStub stub = BenchmarkServiceGrpc.newStub(channel);
final Histogram histogram = new Histogram(HISTOGRAM_MAX_VALUE, HISTOGRAM_PRECISION);
final HistogramFuture future = new HistogramFuture(histogram);
ThisIsAHackStreamObserver responseObserver = new ThisIsAHackStreamObserver(request, histogram, future, endTime);
StreamObserver<SimpleRequest> requestObserver = stub.streamingCall(responseObserver);
responseObserver.requestObserver = requestObserver;
requestObserver.onNext(request);
return future;
}
use of io.grpc.benchmarks.proto.Messages.SimpleRequest in project grpc-java by grpc.
the class AsyncClient method run.
/**
* Start the QPS Client.
*/
public void run() throws Exception {
if (config == null) {
return;
}
SimpleRequest req = newRequest();
List<ManagedChannel> channels = new ArrayList<ManagedChannel>(config.channels);
for (int i = 0; i < config.channels; i++) {
channels.add(config.newChannel());
}
// Do a warmup first. It's the same as the actual benchmark, except that
// we ignore the statistics.
warmup(req, channels);
long startTime = System.nanoTime();
long endTime = startTime + TimeUnit.SECONDS.toNanos(config.duration);
List<Histogram> histograms = doBenchmark(req, channels, endTime);
long elapsedTime = System.nanoTime() - startTime;
Histogram merged = merge(histograms);
printStats(merged, elapsedTime);
if (config.histogramFile != null) {
saveHistogram(merged, config.histogramFile);
}
shutdown(channels);
}
use of io.grpc.benchmarks.proto.Messages.SimpleRequest in project grpc-java by grpc.
the class OpenLoopClient method run.
/**
* Start the open loop client.
*/
public void run() throws Exception {
if (config == null) {
return;
}
config.channels = 1;
config.directExecutor = true;
ManagedChannel ch = config.newChannel();
SimpleRequest req = config.newRequest();
LoadGenerationWorker worker = new LoadGenerationWorker(ch, req, config.targetQps, config.duration);
final long start = System.nanoTime();
Histogram histogram = worker.call();
final long end = System.nanoTime();
printStats(histogram, end - start);
if (config.histogramFile != null) {
saveHistogram(histogram, config.histogramFile);
}
ch.shutdown();
}
Aggregations