Skip to content

Commit

Permalink
Add profiling to the performance testbench.
Browse files Browse the repository at this point in the history
whitequark committed Jul 29, 2015
1 parent d7f9af4 commit b0185f3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion artiq/compiler/testbench/perf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sys, os, time
import sys, os, time, cProfile as profile, pstats
from pythonparser import diagnostic
from .. import Module
from ..targets import OR1KTarget
@@ -21,6 +21,9 @@ def process_diagnostic(diag):
for filename in sys.argv[1:]]

def benchmark(f, name):
profiler = profile.Profile()
profiler.enable()

start = time.perf_counter()
end = 0
runs = 0
@@ -29,9 +32,14 @@ def benchmark(f, name):
runs += 1
end = time.perf_counter()

profiler.create_stats()

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

stats = pstats.Stats(profiler)
stats.strip_dirs().sort_stats('time').print_stats(10)

sources = []
for filename in sys.argv[1:]:
with open(filename) as f:

0 comments on commit b0185f3

Please sign in to comment.