mirror of https://github.com/m-labs/artiq.git
Add profiling to the performance testbench.
This commit is contained in:
parent
d7f9af4bb5
commit
b0185f3917
|
@ -1,4 +1,4 @@
|
||||||
import sys, os, time
|
import sys, os, time, cProfile as profile, pstats
|
||||||
from pythonparser import diagnostic
|
from pythonparser import diagnostic
|
||||||
from .. import Module
|
from .. import Module
|
||||||
from ..targets import OR1KTarget
|
from ..targets import OR1KTarget
|
||||||
|
@ -21,6 +21,9 @@ def main():
|
||||||
for filename in sys.argv[1:]]
|
for filename in sys.argv[1:]]
|
||||||
|
|
||||||
def benchmark(f, name):
|
def benchmark(f, name):
|
||||||
|
profiler = profile.Profile()
|
||||||
|
profiler.enable()
|
||||||
|
|
||||||
start = time.perf_counter()
|
start = time.perf_counter()
|
||||||
end = 0
|
end = 0
|
||||||
runs = 0
|
runs = 0
|
||||||
|
@ -29,9 +32,14 @@ def main():
|
||||||
runs += 1
|
runs += 1
|
||||||
end = time.perf_counter()
|
end = time.perf_counter()
|
||||||
|
|
||||||
|
profiler.create_stats()
|
||||||
|
|
||||||
print("{} {} runs: {:.2f}s, {:.2f}ms/run".format(
|
print("{} {} runs: {:.2f}s, {:.2f}ms/run".format(
|
||||||
runs, name, end - start, (end - start) / runs * 1000))
|
runs, name, end - start, (end - start) / runs * 1000))
|
||||||
|
|
||||||
|
stats = pstats.Stats(profiler)
|
||||||
|
stats.strip_dirs().sort_stats('time').print_stats(10)
|
||||||
|
|
||||||
sources = []
|
sources = []
|
||||||
for filename in sys.argv[1:]:
|
for filename in sys.argv[1:]:
|
||||||
with open(filename) as f:
|
with open(filename) as f:
|
||||||
|
|
Loading…
Reference in New Issue