public void benchmark()

in tchannel-benchmark/src/main/java/com/uber/tchannel/benchmarks/PingPongServerBenchmark.java [96:134]


    public void benchmark(final AdditionalCounters counters) throws Exception {
        JsonRequest<Ping> request = new JsonRequest.Builder<Ping>("ping-server", "ping")
            .setBody(new Ping("ping?"))
            .setTimeout(20000)
            .build();

        TFuture<JsonResponse<Pong>> future = this.subClient
            .send(
                request,
                this.host,
                this.port
            );
        future.addCallback(new TFutureCallback<JsonResponse<Pong>>() {
            @Override
            public void onResponse(JsonResponse<Pong> pongResponse) {
                if (!pongResponse.isError()) {
                    counters.actualQPS.incrementAndGet();
                    // uncomment the following code to enforce evaluation
                    // pongResponse.getBody(Pong.class);
                    // pongResponse.getHeaders();
                } else {
                    // System.out.println(pongResponse.getError().getMessage());
                    switch (pongResponse.getError().getErrorType()) {
                        case Busy:
                            counters.busyQPS.incrementAndGet();
                            break;
                        case Timeout:
                            counters.timeoutQPS.incrementAndGet();
                            break;
                        case NetworkError:
                            counters.networkQPS.incrementAndGet();
                            break;
                        default:
                            counters.errorQPS.incrementAndGet();
                    }
                }
            }
        });
    }