Skip to content

Commit

Permalink
Add tool to combine sharded csv metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Quincunx271 committed Jul 17, 2021
1 parent fea4e58 commit 301922d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions util/misc/merge-csv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python3
import argparse
import csv
import sys


def main(infile, outfile):
metrics = {}
metric_names = []

for metric, total, bench in csv.reader(infile):
assert total == bench
if metric not in metrics:
metric_names.append(metric)

metrics.setdefault(metric, []).append(bench)

writer = csv.writer(outfile)
for metric in metric_names:
try:
writer.writerow([metric, sum(metrics[metric]), *metrics[metric]])
except TypeError:
writer.writerow([metric, 'Total', *metrics[metric]])


if __name__ == '__main__':
main(sys.stdin, sys.stdout)

0 comments on commit 301922d

Please sign in to comment.