--- layout: site.njk title: zul.benchmark.run ---
Simple benchmarking function.
allocator: std.mem.Allocator
Provided for any allocation the function must make. When used, the Result will contain the requested_bytes.
timer: *std.time.Timer
In some cases, the function under benchmark might require setup that should not count towards the execution time. Use timer.reset() to reset the execution time to 0.
In most cases, it is better to use runC and provide a context.
opts: zul.benchmark.Opts
Options that control how the benchmark is run. Must be comptime-known.
samples: u32 - The maximum number of samples to take for calculating metrics. Defaults to 10_000
runtime: usize - The time, in milliseconds, to run the benchmark for. Defaults ot 3000 (3 seconds).
A variant of run that passes arbitrary data to the benchmark function. For example, rather than relying on a global INPUT, our above example could leverage runC:
A zul.benchmark.Result(sample_size) is returned by the call to run or runC.
total: u64
Total time, in nanosecond, that the benchmark ran for. This can be greater than the sum of values in samples().
iterations: u64
Number of times the benchmarked function was called. This can be greater than samples().len.
requested_bytes: usize
Total number of bytes allocated by the allocator.
Outputs a summary to stderr (using std.debug.print)
Returns a sorted list of sample. The value is the time each sample took in nanoseconds.
Returns the worst (slowest) sample time.
Returns the mean of samples().
Returns the median of samples().
Returns the stdDev of samples().