5 public static void main(String
[] args
) throws Exception
{
6 BufferedReader br
= new BufferedReader(new FileReader(
9 SortedMap
<String
, String
> consensusParams
=
10 new TreeMap
<String
, String
>();
11 SortedSet
<String
> params
= new TreeSet
<String
>(Arrays
.asList((
12 "CircPriorityHalflifeMsec,CircuitPriorityHalflifeMsec,"
13 + "CircuitPriorityHalflife,bwconnburst,bwconnrate,"
14 + "circwindow,cbtquantile,refuseunknownexits,cbtnummodes").
16 while ((line
= br
.readLine()) != null) {
17 String date
= line
.substring(23, 33);
18 StringBuilder sb
= new StringBuilder();
19 for (String param
: params
) {
20 if (line
.contains(param
+ "=")) {
21 sb
.append("," + line
.substring(line
.indexOf(param
+ "=")).
22 split(" ")[0].split("=")[1]);
27 consensusParams
.put(date
, sb
.toString());
28 String
[] parts
= line
.split(" ");
29 for (int i
= 1; i
< parts
.length
; i
++) {
30 if (!params
.contains(parts
[i
].split("=")[0])) {
31 System
.out
.println("Unknown consensus param '"
32 + parts
[i
].split("=")[0] + "' in " + line
);
37 br
= new BufferedReader(new FileReader("votes-measured"));
38 SortedMap
<String
, String
> votesMeasured
=
39 new TreeMap
<String
, String
>();
40 long bwscannerStart
= 0L, bwscannerEnd
= 0L;
41 SimpleDateFormat dateFormat
= new SimpleDateFormat("yyyy-MM-dd");
42 dateFormat
.setTimeZone(TimeZone
.getTimeZone("UTC"));
43 SimpleDateFormat dateTimeFormat
= new SimpleDateFormat(
44 "yyyy-MM-dd HH:mm:ss");
45 dateTimeFormat
.setTimeZone(TimeZone
.getTimeZone("UTC"));
46 BufferedWriter bw
= new BufferedWriter(new FileWriter(
47 "bwscanner-failures.csv"));
48 bw
.write("start,end\n");
49 while ((line
= br
.readLine()) != null) {
50 String date
= line
.substring(5, 15);
51 String votes
= line
.substring(0, 5).trim();
52 votesMeasured
.put(date
, votes
);
53 String dateTime
= line
.substring(5, 15) + " "
54 + line
.substring(16, 18) + ":" + line
.substring(19, 21) + ":"
55 + line
.substring(22, 24);
56 long dateTimeSeconds
= dateTimeFormat
.parse(dateTime
).getTime();
57 if (Integer
.parseInt(votes
) >= 3) {
58 if (bwscannerStart
== 0L) {
59 bwscannerStart
= bwscannerEnd
= dateTimeSeconds
;
60 } else if (bwscannerEnd
+ 12L * 60L * 60L * 1000L >=
62 bwscannerEnd
= dateTimeSeconds
;
64 //bw.write(dateFormat.format(bwscannerStart) + ","
65 // + dateFormat.format(bwscannerEnd) + "\n");
66 bw
.write(dateFormat
.format(bwscannerEnd
) + ","
67 + dateFormat
.format(dateTimeSeconds
68 + 24L * 60L * 60L * 1000L) + "\n");
69 bwscannerStart
= bwscannerEnd
= dateTimeSeconds
;
73 /*if (bwscannerStart > 0L) {
74 bw.write(dateFormat.format(bwscannerStart) + ","
75 + dateFormat.format(bwscannerEnd) + "\n");
79 br
= new BufferedReader(new FileReader("torperf.csv"));
81 bw
= new BufferedWriter(new FileWriter("torperf-stats.csv"));
82 bw
.write("date,source,md");
83 for (String param
: params
) {
84 bw
.write("," + param
);
86 bw
.write(",votesMeasured\n");
87 long lastDateSeconds
= 0L;
88 String lastSource
= null;
89 while ((line
= br
.readLine()) != null) {
90 String
[] parts
= line
.split(",");
91 String date
= parts
[1];
92 long dateSeconds
= dateFormat
.parse(date
).getTime();
93 String source
= parts
[0];
94 while (source
.equals(lastSource
) &&
95 lastDateSeconds
+ 24L * 60L * 60L * 1000L < dateSeconds
) {
96 lastDateSeconds
+= 24L * 60L * 60L * 1000L;
97 bw
.write(dateFormat
.format(lastDateSeconds
) + "," + source
99 for (String param
: params
) {
104 lastDateSeconds
= dateSeconds
;
106 String md
= parts
[3];
107 bw
.write(date
+ "," + source
+ "," + md
);
108 if (consensusParams
.containsKey(date
)) {
109 bw
.write(consensusParams
.get(date
));
111 for (String param
: params
) {
115 if (votesMeasured
.containsKey(date
)) {
116 bw
.write("," + votesMeasured
.get(date
) + "\n");