Search in sources :

Example 1 with SimpleRequest

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;
}
Also used : Utils.saveHistogram(io.grpc.benchmarks.Utils.saveHistogram) Histogram(org.HdrHistogram.Histogram) SimpleRequest(io.grpc.benchmarks.proto.Messages.SimpleRequest) BenchmarkServiceStub(io.grpc.benchmarks.proto.BenchmarkServiceGrpc.BenchmarkServiceStub)

Example 2 with SimpleRequest

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);
}
Also used : Utils.saveHistogram(io.grpc.benchmarks.Utils.saveHistogram) Histogram(org.HdrHistogram.Histogram) ArrayList(java.util.ArrayList) ManagedChannel(io.grpc.ManagedChannel) SimpleRequest(io.grpc.benchmarks.proto.Messages.SimpleRequest)

Example 3 with SimpleRequest

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();
}
Also used : Utils.saveHistogram(io.grpc.benchmarks.Utils.saveHistogram) AtomicHistogram(org.HdrHistogram.AtomicHistogram) Histogram(org.HdrHistogram.Histogram) ManagedChannel(io.grpc.ManagedChannel) SimpleRequest(io.grpc.benchmarks.proto.Messages.SimpleRequest)

Aggregations

Utils.saveHistogram (io.grpc.benchmarks.Utils.saveHistogram)3 SimpleRequest (io.grpc.benchmarks.proto.Messages.SimpleRequest)3 Histogram (org.HdrHistogram.Histogram)3 ManagedChannel (io.grpc.ManagedChannel)2 BenchmarkServiceStub (io.grpc.benchmarks.proto.BenchmarkServiceGrpc.BenchmarkServiceStub)1 ArrayList (java.util.ArrayList)1 AtomicHistogram (org.HdrHistogram.AtomicHistogram)1