Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinsert_data.py
More file actions
Latest commit
70 lines (57 loc) · 1.95 KB
/
Copy pathinsert_data.py
File metadata and controls
70 lines (57 loc) · 1.95 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python3
importos
importsys
importjson
importhashlib
fromdatetimeimportdatetime
benchmarks_dir=sys.argv[1]
json_file=sys.argv[2]
test_name=sys.argv[3]
arkscript_commit_id=sys.argv[4] or""
now=datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
defsha256sum(filename):
withopen(filename, 'rb', buffering=0) asf:
returnhashlib.file_digest(f, 'sha256').hexdigest()
defread_data(path):
ifos.path.exists(path):
withopen(path) asf:
returnjson.load(f)
else:
return {}
defcompute(path, run):
data=read_data(path)
file_hash=sha256sum(run["command"].split(" ")[-1])
test_key=f"{test_name}-{file_hash}"
ifdata.get(test_key) isNone:
data[test_key] = []
data[test_key].append({
"date": now,
"mean": run["mean"],
"median": run["median"],
"min": run["min"],
"max": run["max"]
})
if"arkscript"inrun["command"]:
data[test_key][-1]["commit"] =arkscript_commit_id
ifnotos.path.exists(os.path.dirname(path)):
os.mkdir(os.path.dirname(path))
withopen(path, "w") asf:
json.dump(data, f)
results=read_data(json_file)
forruninresults["results"]:
command=run["command"]
ifcommand.startswith("build/arkscript "):
compute(f"{benchmarks_dir}/data/arkscript.json", run)
elifcommand.startswith("lua "):
compute(f"{benchmarks_dir}/data/lua.json", run)
elifcommand.startswith("node "):
compute(f"{benchmarks_dir}/data/node.json", run)
elifcommand.startswith("python "):
compute(f"{benchmarks_dir}/data/python.json", run)
elifcommand.startswith("ruby "):
compute(f"{benchmarks_dir}/data/ruby.json", run)
elifcommand.startswith("./wren_cli "):
compute(f"{benchmarks_dir}/data/wren.json", run)
else:
print(f"Unrecognized command: {command} -- It seems this script needs to be updated!")
sys.exit(1)