Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
By hugoduncanv0.5.0In 1 marketplace
Benchmarks Clojure expressions with statistics, handling JVM warm-up and GC noise to report mean times with confidence intervals. The underlying library's 0.5.x line is alpha with possible breaking changes; 0.4.6 is stable.
Trending plugins
7-day copy clicks
Claude loads one when your task matches it, or you run it by name.
1 marketplace, most starred first
clojure, benchmarking, jvm, microbenchmark, jit-warmup, statistics
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Master is now on 0.5.x, which should be considered ALPHA, subject to breaking changes on new features.
See ALPHA Readme
If you try it, please give feedback on any breaking changes with 0.4.6.
Criterium measures the computation time of an expression. It is designed to address some of the pitfalls of benchmarking, and benchmarking on the JVM in particular.
This includes:
This section describes current 0.5.x development behaviour, including the Unreleased array fix, not stable 0.4.6 guarantees.
The harness stops constant folding and dead-code elimination of the measured expression:
measured/expr expression is stored once, before
timing starts, in an atomic cell. The cell is published once to the
blackhole, so escape analysis can not prove that the cell is local to
the thread. The measured loop reads the cell
with an opaque read (getOpaque) on every iteration. The JIT can not
prove the input is stable, so it can not move the expression out of
the loop or fold a final field read (for example a record field) to
a constant.The opaque read has a small cost. For very cheap expressions the reported time includes about 0.07 ns per primitive argument and about 0.2-0.35 ns per reference argument (the value changes by about 25-30% between JVM runs). Criterium does not subtract this cost.
Every primitive argument (including boolean, byte, short and
char) reads through the opaque cell. Array arguments use
AtomicReference cells and opaque reads. Inferred array hints are exact
JVM-name strings, which preserve the component type and number of
dimensions. Transport preserves array identity and contents without array
copies or element boxing; it does not prevent mutations by the measured
expression. Separately, measured/callable arguments use plain bindings
without opaque reads.
Add the following to your :dependencies:
[criterium "0.4.6"]
<dependency>
<groupId>criterium</groupId>
<artifactId>criterium</artifactId>
<version>0.4.6</version>
</dependency>
The top level interface is in criterium.core.
(use 'criterium.core)
Use bench to run a benchmark in a simple manner.
(bench (Thread/sleep 1000))
=>
Execution time mean : 1.000803 sec
Execution time std-deviation : 328.501853 us
Execution time lower quantile : 1.000068 sec ( 2.5%)
Execution time upper quantile : 1.001186 sec (97.5%)
By default bench is quiet about its progress. Run with-progress-reporting to
get progress information on *out*.
(with-progress-reporting (bench (Thread/sleep 1000) :verbose))
(with-progress-reporting (quick-bench (Thread/sleep 1000) :verbose))
Lower level functions are available, that separate benchmark statistic generation and reporting.
(report-result (benchmark (Thread/sleep 1000) {:verbose true}))
(report-result (quick-benchmark (Thread/sleep 1000)))
Note that results are returned to the user to prevent JIT from recognising that the results are not used.
Criterium will automatically estimate a time for its measurement
overhead. The estimate is normally made once per session, and is
available in the criterium.core/estimated-overhead-cache var.
If the estimation is made while there is a lot of other processing
going on, then benchmarking quick functions may report small negative
times. You can force a recalculation of the overhead by calling
criterium.core/estimated-overhead!.
If you want consistency across JVM processes, it might be prudent to
explicitly set criterium.core/estimated-overhead! to a constant
value.
API Documentation Annotated Source
See Elliptic Group for a Java benchmarking library. The accompanying article describes many of the JVM benchmarking pitfalls.
See Criterion for a Haskell benchmarking library that applies many of the same statistical techniques.
Built from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
npx claudepluginhub hugoduncan/criterium --plugin criteriumPlugins from other owners that cover similar ground