medusa.benchmark
#
Module Contents#
- class medusa.benchmark.FancyTimer[source]#
Fancy timer to time Python functions.
- static iter(params, pbar=True)[source]#
Iterates over a dictionary of parameters.
- Parameters:
params (dict) – Dictionary of parameters to iterate over
pbar (bool) – Whether to show a progress bar
- Yields:
Dictionary of flattened parameters (from all possible combinations)
- time(f, args, n_warmup=2, repeats=10, params=None)[source]#
Time a function for a number of repetitions.
- Parameters:
f (func) – Function to time
args (iterable) – Arguments to pass to
f
n_warmup (int) – Number of warmup calls to
f
repeats (int) – Number of times the function
f
is calledparams (dict) – Extra parameters to add to output dictionary
Examples
>>> timer = FancyTimer() >>> timer.time(lambda x: x ** 2, [5]) >>> timer