-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tool to combine sharded csv metrics
- Loading branch information
1 parent
fea4e58
commit 301922d
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |