forked from nitsanw/HdrLogProcessing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHdrToCsv.java
More file actions
68 lines (63 loc) · 2.15 KB
/
Copy pathHdrToCsv.java
File metadata and controls
68 lines (63 loc) · 2.15 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import org.HdrHistogram.Histogram;
import org.HdrHistogram.HistogramLogReader;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import java.io.File;
import java.io.FileNotFoundException;
import java.nio.file.Paths;
import java.util.Locale;
public class HdrToCsv
{
@Option(name = "--input-file",
aliases = "-i",
usage = "Relative or absolute path to the input file to read",
required = true)
public void setInputFile(String fileName)
{
File in = Paths.get(fileName).toFile();
if (!in.exists())
{
throw new IllegalArgumentException(
"Input file " + fileName + " does not exist");
}
inputFile = in;
}
private File inputFile;
public static void main(String[] args)
{
HdrToCsv app = new HdrToCsv();
CmdLineParser parser = new CmdLineParser(app);
try
{
parser.parseArgument(args);
app.execute();
}
catch (Exception e)
{
System.out.println(e.getMessage());
parser.printUsage(System.out);
}
}
private void execute() throws FileNotFoundException
{
HistogramLogReader reader = new HistogramLogReader(inputFile);
System.out.println(
"#Timestamp,Throughput,Min,Avg,p50,p90,p95,p99,p999,p9999,Max");
while (reader.hasNext())
{
Histogram interval = (Histogram) reader.nextIntervalHistogram();
System.out.printf(Locale.US,
"%.3f,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n",
interval.getStartTimeStamp() / 1000.0,
interval.getTotalCount(), interval.getMinValue(),
(long) interval.getMean(),
interval.getValueAtPercentile(50),
interval.getValueAtPercentile(90),
interval.getValueAtPercentile(95),
interval.getValueAtPercentile(99),
interval.getValueAtPercentile(99.9),
interval.getValueAtPercentile(99.99),
interval.getMaxValue());
}
}
}