in benchmark-java/src/main/java/org/apache/pekko/grpc/benchmarks/qps/AsyncClient.java [71:107]
public void run() throws Exception {
if (config == null) {
return;
}
SimpleRequest req = newRequest();
InetSocketAddress socketAddress = (InetSocketAddress) config.address;
if (!config.tls)
system.log().info("Using plaintext gRPC HTTP/2 connections");
GrpcClientSettings settings = Utils.createGrpcClientSettings(socketAddress, config.tls, system);
List<BenchmarkServiceClient> clients = new ArrayList<BenchmarkServiceClient>(config.channels);
for (int i = 0; i < config.channels; i++) {
BenchmarkServiceClient client = BenchmarkServiceClient.create(settings, system);
clients.add(client);
}
// Do a warmup first. It's the same as the actual benchmark, except that
// we ignore the statistics.
warmup(req, clients);
long startTime = System.nanoTime();
long endTime = startTime + TimeUnit.SECONDS.toNanos(config.duration);
List<Histogram> histograms = doBenchmark(req, clients, endTime);
long elapsedTime = System.nanoTime() - startTime;
Histogram merged = merge(histograms);
printStats(merged, elapsedTime);
if (config.histogramFile != null) {
saveHistogram(merged, config.histogramFile);
}
shutdown(clients);
}