-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract_benchmark_analyzer.py
executable file
·52 lines (48 loc) · 1.67 KB
/
extract_benchmark_analyzer.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
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
# Author: Sawood Alam <[email protected]>
#
# This scripts analyzes benchmarks and creates summary files to generate plots.
import os
import sys
import json
from collections import OrderedDict
def process_benchmarks(benchmarks):
"""Accepts a list of JSON benchmark file names/paths and creates CSV summary from them."""
print("Benchmarking started...")
for bm in benchmarks:
print("Benchmarking: " + bm)
f = open(bm, "r")
data = json.load(f)
f.close()
bms = OrderedDict(sorted(data["bms"].items()))
flds = ["profile_id",
"suburi_keys",
"mediatype_keys",
"time_keys",
"language_keys",
"profile_size",
"profile_size_compressed",
"cdx_processing_time",
"stats_calculation_time",
"profiling_time",
"collection",
"cdx_size",
"extract_size",
"urim_count",
"urir_count"]
opstr = ", ".join(flds)
for k, v in bms.iteritems():
v["profile_id"] = k
opstr += "\n" + ", ".join([str(v[i]) for i in flds])
print(opstr)
bmdir = os.path.dirname(os.path.abspath(bm))
summary = os.path.join(bmdir, "summary-{0}.csv".format(data["about"]["id"]))
f = open(summary, "w")
f.write(opstr)
f.close()
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Please provide path to benchmark JSON file(s) as command line argument.")
sys.exit(0)
print("Analyzing benchmarks...")
process_benchmarks(sys.argv[1:])