brainevent.benchmark_function#
- brainevent.benchmark_function(fn, n_warmup, n_runs, n_batch_per_run=1, data=())[source]#
Benchmark a function and return timing statistics.
- Parameters:
fn (
Callable) – The callable to benchmark. It is invoked asfn(*data)and its result is used to seed the timing loop’s carry.n_warmup (
int) – Number of warmup runs (not timed).n_runs (
int) – Number of timed measurement intervals.n_batch_per_run (
int) – Number of back-to-backfn()calls issued within each timed interval before blocking. Default is1, which blocks after every call and measures per-call latency. Values greater than1amortise blocking overhead across multiple kernel launches, which is useful for measuring throughput on asynchronous GPU/TPU execution. The reported times are always per-call (i.e. the interval time divided by n_batch_per_run).data (
Tuple) – Positional arguments forwarded tofnon every call. Default is the empty tuple()(fnis called with no arguments).
- Returns:
(mean_time, std_time, min_time, max_time, output)where times are in seconds and represent per-call values.- Return type: