@Override
    public void done(RouteMetricSet metrics) {
        try {
		    output.println("# Time used, num ok, num error, min latency, max latency, average latency");
            printMetrics(output, metrics);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
@Test
    void testSimple() {
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        ManualTimer timer = new ManualTimer();
        BenchmarkProgressPrinter printer = new BenchmarkProgressPrinter(timer, new PrintStream(output));
        RouteMetricSet metrics = new RouteMetricSet("foobar", timer, printer);

        {
            EmptyReply reply = new EmptyReply();
            reply.setMessage(PutDocumentMessage.createEmpty().setTimeReceived(-1));
            metrics.addReply(reply);
        }

        timer.set(1200);

        {
            EmptyReply reply = new EmptyReply();
            reply.setMessage(PutDocumentMessage.createEmpty().setTimeReceived(-1));
            metrics.addReply(reply);
        }

        {
            EmptyReply reply = new EmptyReply();
            reply.setMessage(UpdateDocumentMessage.createEmpty().setTimeReceived(-1));
            metrics.addReply(reply);
        }

        timer.set(2400);

        {
            EmptyReply reply = new EmptyReply();
            reply.setMessage(UpdateDocumentMessage.createEmpty().setTimeReceived(-1));
            reply.addError(new com.yahoo.messagebus.Error(32, "foo"));
            metrics.addReply(reply);
        }

        timer.set(62000);

        {
            EmptyReply reply = new EmptyReply();
            reply.setMessage(UpdateDocumentMessage.createEmpty().setTimeReceived(-1));
            reply.addError(new com.yahoo.messagebus.Error(64, "bar"));
            metrics.addReply(reply);
        }

        metrics.done();

        String val = output.toString().split("\n")[1];

        String correctPattern = "62000, \\d+, \\d+, \\d+, \\d+, \\d+$";
        assertTrue(val.matches(correctPattern), "Value '" + val + "' does not match pattern '" + correctPattern + "'");
    }