benchmark_func(run_func[, warmup, number, ...])

Benchmark given function.

hidet.testing.benchmark_func(run_func, warmup=1, number=5, repeat=5, median=True)[source]

Benchmark given function.

The given function run_func will be executed \(warmup + repeat * number\) times. Each \(number\) times of execution will be grouped and conducted together.

  • run_func (Callable[[], Any]) – Any callable function to be benchmarked.

  • warmup (int) – The number of warm-up executions.

  • number (int) – The number of executions to be grouped for measurement.

  • repeat (int) – The number of repeat times of the group measurement.

  • median (bool) – Whether the median latency is returned, instead of the latency.



  • When median == True, a single latency number is returned.

  • When median == False, the latency of each repeat is returned, as a list of floats.

Return type

Union[float, List[float]]