Here impl2 may be favoured. By adding a call to sympy.core.cache.clear_cache in setup(self) they will be timed on equal footing (setup is called before each time_impl#()):
Clearing the cache before generating the exprs seems fair to me. This could all be a non issue and it might just make things more complicated. But if we want to compare two algorithms against each other, (cf. https://github.com/sympy/sympy_benchmarks/blob/master/benchmarks/logic.py#L26) this might make a difference so it could be worth looking into.
Should we make a habit of clearing the cache before each timing? Consider this:
Here impl2 may be favoured. By adding a call to
sympy.core.cache.clear_cache
insetup(self)
they will be timed on equal footing (setup is called before eachtime_impl#()
):Clearing the cache before generating the exprs seems fair to me. This could all be a non issue and it might just make things more complicated. But if we want to compare two algorithms against each other, (cf. https://github.com/sympy/sympy_benchmarks/blob/master/benchmarks/logic.py#L26) this might make a difference so it could be worth looking into.