Skip to content

Commit

Permalink
Add a performance measurement testbench.
Browse files Browse the repository at this point in the history
whitequark committed Jul 29, 2015
1 parent e8c1079 commit 3b5d3e2
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions artiq/compiler/testbench/perf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import sys, os, time
from pythonparser import diagnostic
from .. import Module
from ..targets import OR1KTarget

def main():
if not len(sys.argv) > 1:
print("Expected at least one module filename", file=sys.stderr)
exit(1)

def process_diagnostic(diag):
print("\n".join(diag.render()), file=sys.stderr)
if diag.level in ("fatal", "error"):
exit(1)

engine = diagnostic.Engine()
engine.process = process_diagnostic

modules = []
for filename in sys.argv[1:]:
modules.append(Module.from_filename(filename, engine=engine))

runs = 100
start = time.perf_counter()
for _ in range(runs):
llobj = OR1KTarget().compile_and_link(modules)
end = time.perf_counter()

print("{} compilation runs: {:.2f}s, {:.2f}ms/run".format(
runs, end - start, (end - start) / runs * 1000))

if __name__ == "__main__":
main()

0 comments on commit 3b5d3e2

Please sign in to comment.