circuitpython/tests/perf_bench/benchrun.py
Scott Shawcroft 5bb8a7a7c6
Improve iMX RT performance
* Enable dcache for OCRAM where the VM heap lives.
* Add CIRCUITPY_SWO_TRACE for pushing program counters out over the
  SWO pin via the ITM module in the CPU. Exempt some functions from
  instrumentation to reduce traffic and allow inlining.
* Place more functions in ITCM to handle errors using code in RAM-only
  and speed up CP.
* Use SET and CLEAR registers for digitalio. The SDK does read, mask
  and write.
* Switch to 2MiB reserved for CircuitPython code. Up from 1MiB.
* Run USB interrupts during flash erase and write.
* Allow storage writes from CP if the USB drive is disabled.
* Get perf bench tests running on CircuitPython and increase timeouts
  so it works when instrumentation is active.
2023-03-14 12:30:58 -07:00

28 lines
705 B
Python

def bm_run(N, M):
try:
from utime import ticks_us, ticks_diff
except ImportError:
import time
ticks_us = lambda: int(time.monotonic_ns() / 1000)
ticks_diff = lambda a, b: a - b
# Pick sensible parameters given N, M
cur_nm = (0, 0)
param = None
for nm, p in bm_params.items():
if 10 * nm[0] <= 12 * N and nm[1] <= M and nm > cur_nm:
cur_nm = nm
param = p
if param is None:
print(-1, -1, "no matching params")
return
# Run and time benchmark
run, result = bm_setup(param)
t0 = ticks_us()
run()
t1 = ticks_us()
norm, out = result()
print(ticks_diff(t1, t0), norm, out)