Commit 24f75e21f1e by Pierre Augier

Try to work on reproducibility

parent d1506e0a0b8
......@@ -34,6 +34,10 @@ Note: clang (or recent versions of GCC?) can give much better results than
gcc<=6.3.0. To compile Pythran files with clang: `CXX=clang++-6.0 CC=clang-6.0
python setup.py`.
Running `python3 -m pyperf system tune` before the benchmarks could also help
to get better stability.
## What we need now
Pieces of code to create realistic input parameters for all boosted functions
......
......@@ -19,7 +19,7 @@ import_from_skimage = {
}
def bench_one(name_module="cmorph", func=None):
def bench_one(name_module="cmorph", func=None, total_duration=2):
if func is not None:
raise NotImplementedError
......@@ -53,19 +53,19 @@ def bench_one(name_module="cmorph", func=None):
from transonic.util import timeit
setup = '''{setup}'''
stmt = '''{stmt}'''
print(timeit(stmt, setup, total_duration=2))
print(timeit(stmt, setup, total_duration={total_duration}))
"""
time_old = timeit(stmt, setup_pyx, total_duration=2)
time_old = timeit(stmt, setup_pyx, total_duration=total_duration)
print(f'cython pyx skimage {time_old:.2e} s (= norm)')
print(f"cython pyx skimage {time_old:.2e} s (= norm)")
with open("tmp.py", "w") as file:
file.write(code)
for backend in ("cython", "pythran", "numba"):
time = float(getoutput(f"TRANSONIC_BACKEND='{backend}' python tmp.py"))
print(f"{backend:18s} {time:.2e} s (= {time/time_old:.4f} * norm)")
print(f"{backend:18s} {time:.2e} s (= {time/time_old:.2f} * norm)")
# print(getoutput("TRANSONIC_NO_REPLACE=1 python tmp.py"))
......@@ -76,6 +76,6 @@ print(timeit(stmt, setup, total_duration=2))
f"from future.{name_module} import {name_function}",
import_from_skimage[(name_module, name_function)],
)
time = timeit(stmt, setup_from_skimage, total_duration=2)
time = timeit(stmt, setup_from_skimage, total_duration=total_duration)
print(f"{'from skimage':18s} {time:.2e} s (= {time/time_old:.4f} * norm)")
print(f"{'from skimage':18s} {time:.2e} s (= {time/time_old:.2f} * norm)")
......@@ -449,8 +449,14 @@ def timeit(stmt="pass", setup="pass", total_duration=2, globals=None):
duration1 = timer.timeit(10) / 10
number = max(1, int(round(total_duration / duration1)))
if number > 200:
repeat = int(round(number / 100))
number = int(round(number / repeat))
else:
repeat = 1
if number * duration1 > 2 * total_duration:
raise RuntimeError("number * duration1 > 2 * total_duration")
duration = timer.timeit(number)
duration = min(timer.repeat(repeat=repeat, number=number))
return duration / number
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment