Skip to content

Commit 3b5d3e2

Browse files
author
whitequark
committedJul 29, 2015
Add a performance measurement testbench.
1 parent e8c1079 commit 3b5d3e2

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
 

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

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import sys, os, time
2+
from pythonparser import diagnostic
3+
from .. import Module
4+
from ..targets import OR1KTarget
5+
6+
def main():
7+
if not len(sys.argv) > 1:
8+
print("Expected at least one module filename", file=sys.stderr)
9+
exit(1)
10+
11+
def process_diagnostic(diag):
12+
print("\n".join(diag.render()), file=sys.stderr)
13+
if diag.level in ("fatal", "error"):
14+
exit(1)
15+
16+
engine = diagnostic.Engine()
17+
engine.process = process_diagnostic
18+
19+
modules = []
20+
for filename in sys.argv[1:]:
21+
modules.append(Module.from_filename(filename, engine=engine))
22+
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()
28+
29+
print("{} compilation runs: {:.2f}s, {:.2f}ms/run".format(
30+
runs, end - start, (end - start) / runs * 1000))
31+
32+
if __name__ == "__main__":
33+
main()

0 commit comments

Comments
 (0)
Please sign in to comment.