micropython/tests/perf_bench/core_qstr.py
Damien George 75da124cf8 tests/perf_bench: Add perf tests for qstr interning and importing .mpy.
Signed-off-by: Damien George <damien@micropython.org>
2022-02-10 15:25:33 +11:00

22 lines
472 B
Python

# This tests qstr_find_strn() speed when the string being searched for is not found.
def test(r):
for _ in r:
str("a string that shouldn't be interned")
###########################################################################
# Benchmark interface
bm_params = {
(100, 10): (400,),
(1000, 10): (4000,),
(5000, 10): (40000,),
}
def bm_setup(params):
(nloop,) = params
return lambda: test(range(nloop)), lambda: (nloop // 100, None)