(assert-bench-opts stats opts)(defbench bench-name & args)Defines a benchmark test using criterium/quick-benchmark.
Requires criterium/criterium on the classpath of the calling project. It is not a dependency of telsos-lib itself.
Usage: (defbench my-bench-name {:max-mean-ns 5000} ; optional assertion map (my-fn arg1 arg2)) ; expression to benchmark
The assertion map is optional. Without it, the benchmark only reports.
Supported assertion keys (all optional):
:max-mean-ns Upper bound on mean execution time (nanoseconds). The most common budget assertion.
:min-mean-ns Lower bound on mean execution time (nanoseconds). Guards against JIT elision: if the JVM optimises the benchmarked expression away entirely, the measured mean drops to near zero and this assertion fails.
:max-upper-q-ns Upper bound on the 97.5th-percentile execution time (nanoseconds). More sensitive to outliers than :max-mean-ns; use this for latency-critical paths where tail behaviour matters.
:max-std-dev-ns Upper bound on absolute standard deviation (nanoseconds). Catches high jitter in functions that should execute in consistent time.
:max-variance-ratio Upper bound on the coefficient of variation, i.e. std-dev / mean (dimensionless, 0.0–1.0). More portable across machines than :max-std-dev-ns because it is relative to the mean.
:max-outlier-ratio Upper bound on the fraction of severe outliers (low-severe + high-severe) over total samples (0.0–1.0). Note: severe outliers are often environmental (GC pauses, OS scheduler) rather than code regressions, so this assertion can be flaky in shared or noisy environments.
Defines a benchmark test using criterium/quick-benchmark.
Requires criterium/criterium on the classpath of the calling project.
It is not a dependency of telsos-lib itself.
Usage:
(defbench my-bench-name
{:max-mean-ns 5000} ; optional assertion map
(my-fn arg1 arg2)) ; expression to benchmark
The assertion map is optional. Without it, the benchmark only reports.
Supported assertion keys (all optional):
:max-mean-ns Upper bound on mean execution time (nanoseconds).
The most common budget assertion.
:min-mean-ns Lower bound on mean execution time (nanoseconds).
Guards against JIT elision: if the JVM optimises the
benchmarked expression away entirely, the measured mean
drops to near zero and this assertion fails.
:max-upper-q-ns Upper bound on the 97.5th-percentile execution time
(nanoseconds). More sensitive to outliers than
:max-mean-ns; use this for latency-critical paths where
tail behaviour matters.
:max-std-dev-ns Upper bound on absolute standard deviation (nanoseconds).
Catches high jitter in functions that should execute in
consistent time.
:max-variance-ratio Upper bound on the coefficient of variation,
i.e. std-dev / mean (dimensionless, 0.0–1.0).
More portable across machines than :max-std-dev-ns
because it is relative to the mean.
:max-outlier-ratio Upper bound on the fraction of severe outliers
(low-severe + high-severe) over total samples (0.0–1.0).
Note: severe outliers are often environmental (GC pauses,
OS scheduler) rather than code regressions, so this
assertion can be flaky in shared or noisy environments.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |