Liking cljdoc? Tell your friends :D

net.lewisship.bench

Useful wrappers around criterium.

Useful wrappers around criterium.
raw docstring

benchcljmacro

(bench & exprs)
(bench opts & exprs)

Benchmarks a sequence of expressions. Criterium is used to perform the benchmarking, then the results are reported in a tabular format, with the fastest and slowest expressions highlighted (marked in green and yellow, respectively).

The first argument may be a map of options, rather than an expression to benchmark.

Options: : :quick? If true (the default), used quick benchmarking options : :round-robin? If true (the default is false), uses round-robin testing of the expressions rather than running an independent benchmark for each expression. : report? If true (the default), print a report and return nil. Otherwise, returns a seq of benchmarking stats as returned by Criterium. : progress? If true (the default is false), enable Criterium progress reporting during benchmark collection. : sort? If true (the default is false), then when results are printed, they are sorted fastest to slowest (with no highlighting). : ratio? If true (the default), then in the report, the final column is a ratio of the row to the fastest row.

In addition, the options are passed to Criterium, allowing overrides of the options it uses when benchmarking, such as :samples, etc.

Benchmarks a sequence of expressions. Criterium is used to perform the benchmarking,
then the results are reported in a tabular format, with the fastest and slowest
expressions highlighted (marked in green and yellow, respectively).

The first argument may be a map of options, rather than an expression to benchmark.

Options:
: :quick?  If true (the default), used quick benchmarking options
: :round-robin? If true (the default is false), uses round-robin testing of the expressions rather
  than running an independent benchmark for each expression.
: report? If true (the default), print a report and return nil.  Otherwise,
  returns a seq of benchmarking stats as returned by Criterium.
: progress? If true (the default is false), enable Criterium progress reporting during benchmark
  collection.
: sort? If true (the default is false), then when results are printed, they are
  sorted fastest to slowest (with no highlighting).
: ratio? If true (the default), then in the report, the final column is a ratio of the row to the fastest row.

In addition, the options are passed to Criterium, allowing overrides of the options
it uses when benchmarking, such as :samples, etc.
sourceraw docstring

bench*clj

(bench* opts blocks)

The core of the bench macro; the expressions to bench are converted into blocks, each a map with keys :f (a no-args function) and :expr-str (the string representation of the form being benchmarked).

The core of the [[bench]] macro; the expressions to `bench` are converted into blocks, each a map
with keys :f (a no-args function) and :expr-str (the string representation of the form being
benchmarked).
sourceraw docstring

bench-forcljmacro

(bench-for bindings & exprs)
(bench-for opts bindings & exprs)

Often you will want to benchmark an expression (or set of expressions) while varying the exact values inside the expression; bench-for takes a vector of bindings, like clojure.core/for and builds a new list of expressions for each iteration of the for. The string version of the expression (used in the output report) will have the local symbols from the for replaced with the values for this iteration.

Example:

(let [coll (range 1000)]
  (bench-for [n [5 50 500 5000]]
    (reduce + (take n coll))))

Will be reported as four expressions:

(reduce + (take 5 coll))
(reduce + (take 50 coll))
(reduce + (take 500 coll))
(reduce + (take 5000 coll))

Note that the expression is only modified for the string representation used in the report; the actual expression is executed unchanged.

Often you will want to benchmark an expression (or set of expressions)
while varying the exact values inside the expression; `bench-for` takes
a vector of bindings, like `clojure.core/for` and builds a new list of
expressions for each iteration of the `for`.  The
string version of the expression (used in the output report)
will have the local symbols from the `for` replaced with the values for this iteration.

Example:

```
(let [coll (range 1000)]
  (bench-for [n [5 50 500 5000]]
    (reduce + (take n coll))))

```

Will be reported as four expressions:

```
(reduce + (take 5 coll))
(reduce + (take 50 coll))
(reduce + (take 500 coll))
(reduce + (take 5000 coll))
```

Note that the expression is only modified for the string representation
used in the report; the actual expression is executed unchanged.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close