benchmarks.bench

bench

(bench f n)

bench receives a function f and an integer n. It runs f n times and reports the total elapsed time as well as the per-operation average time elapsed. It is intended to be called by a higher-level function that will pass in successively higher values of n until a time threshold is crossed.

benchmark

(benchmark f)

benchmark passes the provided function f to bench with successively higher n values until it has either: 1. exhausted a reasonable amount of time or 2. measured enough executions to have an accurate per-operation average. It returns the low-level results of the last call to bench.

format-duration

(format-duration ns)

format-duration turns nanosecond durations, such as those provided by bench and converts them to a microsecond, millisecond, or second value (ie. 32ns, 43.2µs, 54.7ms, 3.1s).

max-duration

max-ops

microsecond

millisecond

nanosecond

report

(report f)

Translates the result of benchmark into more human-readable values. Can be passed to println for a decent report.

second_

time-it

(time-it f n)