-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathassemble_bench.py
44 lines (33 loc) · 1.13 KB
/
assemble_bench.py
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
import json
import os
import sys
from glob import glob
import argparse
def name_to_entry(f):
return {
'file_name': f,
'file_type': f.split('.')[-1],
'nbor_cap_type': 'int32',
'term_cap_type': 'int32'
}
def is_benchfile(f):
return f.endswith('.bq') or f.endswith('.bbk')
def main(argv):
parser = argparse.ArgumentParser(
description="Build 'data_sets' entry for benchmark file"
)
parser.add_argument('file_glob', default='*', nargs='?',
help='pattern forwarded to glob (default: %(default)s)')
parser.add_argument('--base_file', help='file with JSON data to insert into')
args = parser.parse_args(argv)
files = sorted(glob(args.file_glob))
entries = [name_to_entry(os.path.abspath(f)) for f in files if is_benchfile(f)]
if args.base_file is not None:
with open(args.base_file) as in_file:
bench_data = json.load(in_file)
bench_data['data_sets'] = entries
print(json.dumps(bench_data, indent=2))
else:
print(json.dumps(entries, indent=2))
if __name__ == '__main__':
main(sys.argv[1:])