brainevent.benchmark_function

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) – A callable that takes no arguments and returns the result.

  • 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-back fn() calls issued within each timed interval before blocking. Default is 1, which blocks after every call and measures per-call latency. Values greater than 1 amortise 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).

Returns:

(mean_time, std_time, min_time, max_time, output) where times are in seconds and represent per-call values.

Return type:

Tuple[float, float, float, float, Any]