private static void printResults(int numMessages, double totalTime, long[] latencies) {
        System.out.printf("Avg latency: %.4f ms%n", totalTime / numMessages / 1000.0 / 1000.0);
        Arrays.sort(latencies);
        int p50 = (int) latencies[(int) (latencies.length * 0.5)];
        int p99 = (int) latencies[(int) (latencies.length * 0.99)];
        int p999 = (int) latencies[(int) (latencies.length * 0.999)];
        System.out.printf("Percentiles: 50th = %d, 99th = %d, 99.9th = %d%n", p50, p99, p999);
    }
This class records the average end to end latency for a single message to travel through Kafka.
Following are the required arguments
<p> broker_list = location of the bootstrap broker for both the producer and the consumer </p>
<p> topic = topic name used by both the producer and the consumer to send/receive messages </p>
<p> num_messages = # messages to send </p>
<p> producer_acks = See ProducerConfig.ACKS_DOC </p>
<p> message_size_bytes = size of each message in bytes </p>

<p> e.g. [localhost:9092 test 10000 1 20] </p>
tools/src/main/java/org/apache/kafka/tools/EndToEndLatency.java