1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 package org.apache.hc.core5.benchmark;
28
29 import java.io.PrintStream;
30 import java.text.NumberFormat;
31 import java.util.Locale;
32
33 public class ResultFormatter {
34
35 private ResultFormatter() {
36
37 }
38
39 static final NumberFormat nf2 = NumberFormat.getInstance(Locale.ROOT);
40 static final NumberFormat nf3 = NumberFormat.getInstance(Locale.ROOT);
41 static final NumberFormat nf6 = NumberFormat.getInstance(Locale.ROOT);
42
43 static {
44 nf2.setMaximumFractionDigits(2);
45 nf2.setMinimumFractionDigits(2);
46 nf3.setMaximumFractionDigits(3);
47 nf3.setMinimumFractionDigits(3);
48 nf6.setMaximumFractionDigits(6);
49 nf6.setMinimumFractionDigits(6);
50 }
51
52 public static void print(final PrintStream printStream, final Results results) {
53 printStream.println("Server Software:\t\t" + results.getServerName());
54 printStream.println("Protocol version:\t\t" + results.getProtocolVersion());
55 printStream.println("Server Hostname:\t\t" + results.getHostName());
56 printStream.println("Server Port:\t\t\t" + results.getHostPort());
57 printStream.println("Document Path:\t\t\t" + results.getDocumentPath());
58 printStream.println("Document Length:\t\t" + results.getContentLength() + " bytes\n");
59 printStream.println("Concurrency Level:\t\t" + results.getConcurrencyLevel());
60 printStream.println("Time taken for tests:\t" + nf6.format((double) results.getTotalTimeMillis() / 1000) + " seconds");
61 printStream.println("Complete requests:\t\t" + results.getSuccessCount());
62 printStream.println("Failed requests:\t\t" + results.getFailureCount());
63 printStream.println("Kept alive:\t\t\t\t" + results.getKeepAliveCount());
64 printStream.println("Total transferred:\t\t" + results.getTotalBytesRcvd() + " bytes");
65 printStream.println("Content transferred:\t" + results.getTotalContentBytesRecvd() + " bytes");
66 printStream.println("Requests per second:\t" + nf2.format(
67 results.getSuccessCount() / ((double) results.getTotalTimeMillis() / 1000)) + " [#/sec] (mean)");
68 printStream.println("Time per request:\t\t" + nf3.format(
69 (double) results.getTotalTimeMillis() * results.getConcurrencyLevel() / results.getSuccessCount()) + " [ms] (mean)");
70 printStream.println("Time per request:\t\t" + nf3.format(
71 (double) results.getTotalTimeMillis() / results.getSuccessCount()) + " [ms] (mean, across all concurrent requests)");
72 printStream.println("Transfer rate:\t\t\t" +
73 nf2.format((double) results.getTotalBytesRcvd() / 1024 / ((double) results.getTotalTimeMillis() / 1000)) + " [Kbytes/sec] received");
74 }
75
76 }