• Stars
    star
    1,186
  • Rank 39,441 (Top 0.8 %)
  • Language
    Clojure
  • Created almost 15 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Benchmarking library for clojure

Criterium

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

Installation

Leiningen

Add the following to your :dependencies:

[criterium "0.4.6"]

Maven

<dependency>
  <groupId>criterium</groupId>
  <artifactId>criterium</artifactId>
  <version>0.4.6</version>
</dependency>

Usage

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.

Measurement Overhead Estimation

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.

References

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.

Todo

Serial correlation detection. Multimodal distribution detection. Use kernel density estimators?

Releasing

To release, run the release.sh script. This requires that you have git-flow enabled your git repository with git flow init, and that you have configured your credentials for clojars.

YourKit

YourKit is kindly supporting open source projects with its full-featured Java Profiler.

YourKit, LLC is the creator of innovative and intelligent tools for profiling Java and .NET applications. Take a look at YourKit's leading software products:

License

Licensed under EPL

More Repositories

1

muir

A Clojure AST transformation library
Clojure
39
star
2

swell

A CL style restart library for clojure
Clojure
30
star
3

atticus

Test helper functions, including an all clojure mocking facility
Clojure
24
star
4

lein-namespace-depends

A leiningen plugin to output a project's namespace use/require graph
Clojure
17
star
5

hornetq-clj

Trivial wrappers to hornet queue, server and client, with a lein plugin to start server
Clojure
16
star
6

makejack

A clojure CLI build tool, and build library.
Clojure
14
star
7

metamorphosis

Macro protocols for clojure
Clojure
11
star
8

ritz-conj

Talk on Ritz Debugger at conj 2012
JavaScript
9
star
9

papadom

HTML based page and event templates, using core.async
JavaScript
9
star
10

cl-blog-generator

A blog site generator in common lisp
Common Lisp
9
star
11

codox-md

Markdown output writer for codox
Clojure
7
star
12

pallet

Devops for the JVM
7
star
13

clasm

Bytecode assembler in Clojure
Clojure
6
star
14

clj-fluiddb

Client library for FluidDB written in Clojure
Clojure
6
star
15

oldmj

makejack, a clojure build tool invoker
Clojure
5
star
16

flycheck-cargo

Emacs Lisp
4
star
17

lein-remote-swank

This Leiningen plugin lets you launch a swank server on a remote machine via Leiningen
Clojure
3
star
18

clojure-mojo-example

Example of a maven mojo written in Clojure.
Clojure
2
star
19

signet

HTTP request map signing
Clojure
2
star
20

maven-plugin-tools-clojure

Descriptor extractor for Maven Mojo's written in Clojure.
Clojure
2
star
21

rust-systemd

A rust API for systemd DBus commands
Rust
2
star
22

edn-edit

Clojure
1
star
23

servlet-test

Clojure
1
star
24

pallet-minecraft

Clojure
1
star
25

orcloud-cookbooks

Chef cookbooks
Ruby
1
star
26

docblock

Documentation blocks for clojure
Clojure
1
star
27

maven-plugin-annotations-clojure

Annotations for maven mojo plugins
Java
1
star
28

swank-clj

Swank server for running clojure in SLIME
1
star
29

bridle

data
Clojure
1
star
30

has_bitfield

A rails gem for easy bitfield support
Ruby
1
star
31

plexus-clojure-factory

Plexus component factory for clojure components
Java
1
star
32

ritz-cw-2013

JavaScript
1
star
33

austenite

A library for building Iron handlers that implements HTTP header handling and content negotiation
Rust
1
star