Source

cexp / cexp / bm_userestrict.py

Full commit
from cexputils import hashdict
from userestrict import UseRestrict

STORE_INSTANCE = {}


def setup_benchmark(num_s=100, num_n=100, x0=0, repeat=1,
                    method='with_const', **kwds):
    kwds.update(num_s=num_s, num_n=num_n)
    key = hashdict(**kwds)
    if not key in STORE_INSTANCE:
        STORE_INSTANCE[key] = UseRestrict(**kwds)


def run(num_s=100, num_n=100, x0=0, repeat=1, method='with_const', **kwds):
    kwds.update(num_s=num_s, num_n=num_n)
    key = hashdict(**kwds)
    inst = STORE_INSTANCE[key]
    inst.x0 = x0
    inst.run(repeat)