From 3b5d3e2b1a3e11a45c4f83b28d59c4eef300a60b Mon Sep 17 00:00:00 2001 From: whitequark Date: Wed, 29 Jul 2015 21:17:52 +0300 Subject: [PATCH] Add a performance measurement testbench. --- artiq/compiler/testbench/perf.py | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 artiq/compiler/testbench/perf.py diff --git a/artiq/compiler/testbench/perf.py b/artiq/compiler/testbench/perf.py new file mode 100644 index 000000000..036409b85 --- /dev/null +++ b/artiq/compiler/testbench/perf.py @@ -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()