-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a performance measurement testbench.
whitequark
committed
Jul 29, 2015
1 parent
e8c1079
commit 3b5d3e2
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |