sympy / sympy_benchmarks

Some benchmarks of SymPy
13 stars 32 forks source link

Sympy caching #20

Closed bjodah closed 9 years ago

bjodah commented 9 years ago

Should we make a habit of clearing the cache before each timing? Consider this:

class TimeSomeAlgo:
    def setup(self):
        self.exprs, self.vars = _generate_exprs()

    def time_impl1(self):
        impl1(self.exprs, self.vars)

    def time_impl2(self):
        impl2(self.exprs, self.vars)

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#()):

...
    def setup(self):
        clear_cache()
        self.exprs, self.vars = _generate_exprs()
...

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.

pv commented 9 years ago

Note that each benchmark is run in a separate process, so time_impl1 and time_impl2 are isolated unless you save the cache on disk.

bjodah commented 9 years ago

Oh, I see. Thank you @pv for the info! I think this really is a non-issue then.