From 6d8d0ff3f57cab688db1cbe7805cd86d747c89b3 Mon Sep 17 00:00:00 2001 From: whitequark Date: Wed, 29 Jul 2015 21:28:07 +0300 Subject: [PATCH] Update performance testbench to include time spent in ARTIQ. --- artiq/compiler/testbench/perf.py | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/artiq/compiler/testbench/perf.py b/artiq/compiler/testbench/perf.py index 036409b85..7b0b81487 100644 --- a/artiq/compiler/testbench/perf.py +++ b/artiq/compiler/testbench/perf.py @@ -16,18 +16,32 @@ def main(): engine = diagnostic.Engine() engine.process = process_diagnostic - modules = [] + # Make sure everything's valid + modules = [Module.from_filename(filename, engine=engine) + for filename in sys.argv[1:]] + + def benchmark(f, name): + start = time.perf_counter() + end = 0 + runs = 0 + while end - start < 5 or runs < 10: + f() + runs += 1 + end = time.perf_counter() + + print("{} {} runs: {:.2f}s, {:.2f}ms/run".format( + runs, name, end - start, (end - start) / runs * 1000)) + + sources = [] for filename in sys.argv[1:]: - modules.append(Module.from_filename(filename, engine=engine)) + with open(filename) as f: + sources.append(f.read()) - runs = 100 - start = time.perf_counter() - for _ in range(runs): - llobj = OR1KTarget().compile_and_link(modules) - end = time.perf_counter() + benchmark(lambda: [Module.from_string(src) for src in sources], + "ARTIQ typechecking and transforms") - print("{} compilation runs: {:.2f}s, {:.2f}ms/run".format( - runs, end - start, (end - start) / runs * 1000)) + benchmark(lambda: OR1KTarget().compile_and_link(modules), + "LLVM optimization and linking") if __name__ == "__main__": main()