static void printBenchmarkResult(long durationNanos, long successes, long failures,
                                     OperationStats stats, OutputStream systemOut) throws IOException {
        try (JsonGenerator generator = factory.createGenerator(systemOut).useDefaultPrettyPrinter()) {
            generator.writeStartObject();

            writeFloatField(generator, "feeder.seconds", durationNanos * 1e-9, 3);
            generator.writeNumberField("feeder.ok.count", successes);
            writeFloatField(generator, "feeder.ok.rate", successes * 1e9 / Math.max(1, durationNanos), 3);
            generator.writeNumberField("feeder.error.count", failures);
            generator.writeNumberField("feeder.inflight.count", stats.inflight());

            generator.writeNumberField("http.request.count", stats.requests());
            generator.writeNumberField("http.request.bytes", stats.bytesSent());
            writeFloatField(generator, "http.request.MBps", stats.bytesSent() * 1e3 / durationNanos, 3);

            generator.writeNumberField("http.exception.count", stats.exceptions());

            generator.writeNumberField("http.response.count", stats.responses());
            generator.writeNumberField("http.response.bytes", stats.bytesReceived());
            writeFloatField(generator, "http.response.MBps", stats.bytesReceived() * 1e3 / durationNanos, 3);
            generator.writeNumberField("http.response.error.count", stats.responses() - stats.successes());
            writeFloatField(generator, "http.response.latency.millis.min", stats.minLatencyMillis(), 3);
            writeFloatField(generator, "http.response.latency.millis.avg", stats.averageLatencyMillis(), 3);
            writeFloatField(generator, "http.response.latency.millis.max", stats.maxLatencyMillis(), 3);

            // Hide new experimental output behind feature flag
            if (System.getenv("VESPA_EXTENDED_STATS") != null) {
                generator.writeObjectFieldStart("operation.latency");
                generator.writeNumberField("min", stats.operationMinLatencyMillis());
                generator.writeNumberField("avg", stats.operationAverageLatencyMillis());
                generator.writeNumberField("max", stats.operationMaxLatencyMillis());
                generator.writeEndObject();

                generator.writeObjectFieldStart("http.response");
                for (var e : stats.statsByCode().entrySet()) {
                    generator.writeObjectFieldStart(Integer.toString(e.getKey()));
                    generator.writeNumberField("count", e.getValue().count());
                    generator.writeObjectFieldStart("latency");
                    generator.writeNumberField("min", e.getValue().minLatencyMillis());
                    generator.writeNumberField("avg", e.getValue().averageLatencyMillis());
                    generator.writeNumberField("max", e.getValue().maxLatencyMillis());
                    generator.writeEndObject();
                    generator.writeEndObject();
                }
                generator.writeEndObject();
            } else {
                generator.writeObjectFieldStart("http.response.code.counts");
                for (Map.Entry<Integer, OperationStats.Response> entry : stats.statsByCode().entrySet())
                    generator.writeNumberField(Integer.toString(entry.getKey()), entry.getValue().count());
                generator.writeEndObject();
            }
            generator.writeEndObject();
        }
    }
Main method for CLI interface

@author bjorncs
vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliClient.java