Liking cljdoc? Tell your friends :D

criterium.core

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:

  • statistical processing of multiple evaluations
  • inclusion of a warm-up period, designed to allow the JIT compiler to optimise its code
  • purging of gc before testing, to isolate timings from GC state prior to testing
  • a final forced GC after testing to estimate impact of cleanup on the timing results

Usage: (use 'criterium.core) (bench (Thread/sleep 1000) :verbose) (with-progress-reporting (bench (Thread/sleep 1000) :verbose)) (report-result (benchmark (Thread/sleep 1000)) :verbose) (report-result (quick-bench (Thread/sleep 1000)))

References: See http://www.ellipticgroup.com/html/benchmarkingArticle.html for a Java benchmarking library. The accompanying article describes many of the JVM benchmarking pitfalls.

See http://hackage.haskell.org/package/criterion for a Haskell benchmarking library that applies many of the same statistical techniques.

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:
- statistical processing of multiple evaluations
- inclusion of a warm-up period, designed to allow the JIT compiler to
  optimise its code
- purging of gc before testing, to isolate timings from GC state prior
  to testing
- a final forced GC after testing to estimate impact of cleanup on the
  timing results

Usage:
(use 'criterium.core)
(bench (Thread/sleep 1000) :verbose)
(with-progress-reporting (bench (Thread/sleep 1000) :verbose))
(report-result (benchmark (Thread/sleep 1000)) :verbose)
(report-result (quick-bench (Thread/sleep 1000)))

References:
See http://www.ellipticgroup.com/html/benchmarkingArticle.html for a Java
benchmarking library.  The accompanying article describes many of the JVM
benchmarking pitfalls.

See http://hackage.haskell.org/package/criterion for a Haskell benchmarking
library that applies many of the same statistical techniques.
raw docstring

*default-benchmark-opts*clj

source

*default-quick-bench-opts*clj

source

*final-gc-problem-threshold*clj

Fraction of excution time allowed for final cleanup before a warning is issued.

Fraction of excution time allowed for final cleanup before a
warning is issued.
sourceraw docstring

*max-gc-attempts*clj

Maximum number of attempts to run finalisers and gc.

Maximum number of attempts to run finalisers and gc.
sourceraw docstring

*report-debug*clj

Flag to control output of debug messages

Flag to control output of debug messages
sourceraw docstring

*report-progress*clj

Flag to control output of progress messages

Flag to control output of progress messages
sourceraw docstring

*report-warn*clj

Flag to control output of warning messages

Flag to control output of warning messages
sourceraw docstring

*sample-count*clj

Number of executions required

Number of executions required
sourceraw docstring

*target-execution-time*clj

Target elapsed time for execution for a single measurement.

Target elapsed time for execution for a single measurement.
sourceraw docstring

*warmup-jit-period*clj

Time period used to let the code run so that jit compiler can do its work.

Time period used to let the code run so that jit compiler can do
its work.
sourceraw docstring

benchcljmacro

(bench expr & opts)

Convenience macro for benchmarking an expression, expr. Results are reported to out in human readable format. Options for report format are: :os, :runtime, and :verbose.

Convenience macro for benchmarking an expression, expr.  Results are reported
to *out* in human readable format. Options for report format are: :os,
:runtime, and :verbose.
sourceraw docstring

benchmarkcljmacrodeprecated

(benchmark expr options)

Benchmark an expression. This tries its best to eliminate sources of error. This also means that it runs for a while. It will typically take 70s for a fast test expression (less than 1s run time) or 10s plus 60 run times for longer running expressions.

Benchmark an expression. This tries its best to eliminate sources of error.
This also means that it runs for a while.  It will typically take 70s for a
fast test expression (less than 1s run time) or 10s plus 60 run times for
longer running expressions.
sourceraw docstring

benchmark*clj

(benchmark* measured {:keys [supress-jvm-option-warnings] :as options})

Benchmark a function. This tries its best to eliminate sources of error. This also means that it runs for a while. It will typically take 70s for a fast test expression (less than 1s run time) or 10s plus 60 run times for longer running expressions.

Benchmark a function. This tries its best to eliminate sources of error.
This also means that it runs for a while.  It will typically take 70s for a
fast test expression (less than 1s run time) or 10s plus 60 run times for
longer running expressions.
sourceraw docstring

extract-report-optionsclj

(extract-report-options opts)

Extract reporting options from the given options vector. Returns a two element vector containing the reporting options followed by the non-reporting options

Extract reporting options from the given options vector.  Returns a two
element vector containing the reporting options followed by the non-reporting
options
sourceraw docstring

options->time-configclj

(options->time-config {:keys [max-gc-attempts warmup-jit-period] :as options})
source

quick-benchcljmacro

(quick-bench expr & opts)

Convenience macro for benchmarking an expression, expr. Results are reported to out in human readable format. Options for report format are: :os, :runtime, and :verbose.

Convenience macro for benchmarking an expression, expr.  Results are reported
to *out* in human readable format. Options for report format are: :os,
:runtime, and :verbose.
sourceraw docstring

quick-benchmarkcljmacrodeprecated

(quick-benchmark expr options)

Benchmark an expression. Less rigorous benchmark (higher uncertainty).

Benchmark an expression. Less rigorous benchmark (higher uncertainty).
sourceraw docstring

quick-benchmark*clj

(quick-benchmark* f {:as options})

Benchmark an expression. Less rigorous benchmark (higher uncertainty).

Benchmark an expression. Less rigorous benchmark (higher uncertainty).
sourceraw docstring

s-to-nsclj

source

warn-on-suspicious-jvm-optionsclj

(warn-on-suspicious-jvm-options)

Warn if the JIT options are suspicious looking.

Warn if the JIT options are suspicious looking.
sourceraw docstring

with-progress-reportingcljmacro

(with-progress-reporting expr)

Macro to enable progress reporting during the benchmark.

Macro to enable progress reporting during the benchmark.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close