Skip to content

Commit 4aa6d7f

Browse files
committed
Add tool to combine sharded csv metrics
1 parent fea4e58 commit 4aa6d7f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

util/misc/merge-csv.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python3
2+
import argparse
3+
import csv
4+
import sys
5+
6+
7+
def main(infile, outfile):
8+
metrics = {}
9+
metric_names = []
10+
11+
for metric, total, bench in csv.reader(infile):
12+
assert total == bench or total == 'Total'
13+
if metric not in metrics:
14+
metric_names.append(metric)
15+
16+
metrics.setdefault(metric, []).append(bench)
17+
18+
writer = csv.writer(outfile)
19+
for metric in metric_names:
20+
try:
21+
writer.writerow([metric, sum(int(x) for x in metrics[metric]), *metrics[metric]])
22+
except ValueError:
23+
writer.writerow([metric, 'Total', *metrics[metric]])
24+
25+
26+
if __name__ == '__main__':
27+
main(sys.stdin, sys.stdout)

0 commit comments

Comments
 (0)