Skip to content

Commit 6d8d0ff

Browse files
author
whitequark
committedJul 29, 2015
Update performance testbench to include time spent in ARTIQ.
1 parent 3b5d3e2 commit 6d8d0ff

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed
 

Diff for: ‎artiq/compiler/testbench/perf.py

+23-9
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,32 @@ def process_diagnostic(diag):
1616
engine = diagnostic.Engine()
1717
engine.process = process_diagnostic
1818

19-
modules = []
19+
# Make sure everything's valid
20+
modules = [Module.from_filename(filename, engine=engine)
21+
for filename in sys.argv[1:]]
22+
23+
def benchmark(f, name):
24+
start = time.perf_counter()
25+
end = 0
26+
runs = 0
27+
while end - start < 5 or runs < 10:
28+
f()
29+
runs += 1
30+
end = time.perf_counter()
31+
32+
print("{} {} runs: {:.2f}s, {:.2f}ms/run".format(
33+
runs, name, end - start, (end - start) / runs * 1000))
34+
35+
sources = []
2036
for filename in sys.argv[1:]:
21-
modules.append(Module.from_filename(filename, engine=engine))
37+
with open(filename) as f:
38+
sources.append(f.read())
2239

23-
runs = 100
24-
start = time.perf_counter()
25-
for _ in range(runs):
26-
llobj = OR1KTarget().compile_and_link(modules)
27-
end = time.perf_counter()
40+
benchmark(lambda: [Module.from_string(src) for src in sources],
41+
"ARTIQ typechecking and transforms")
2842

29-
print("{} compilation runs: {:.2f}s, {:.2f}ms/run".format(
30-
runs, end - start, (end - start) / runs * 1000))
43+
benchmark(lambda: OR1KTarget().compile_and_link(modules),
44+
"LLVM optimization and linking")
3145

3246
if __name__ == "__main__":
3347
main()

0 commit comments

Comments
 (0)
Please sign in to comment.