Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A small clojure benchmarking helper
branch: master
Failed to load latest commit information.
src clean up and add more comments in the file
cbench.jar update README and add the jar for people who don't want to mess with …


cbench is a small helper library for doing benchmarking.

Here's some sample output:

cbench=> (cbench-pp 50 #(Thread/sleep 15))
| avg    | 15.22 ms
| min    | 15.0 ms
| max    | 19.0 ms
| stddev | 0.614119729717384 ms
| total  | 784 ms

cbench provides 2 function, cbench and cbench-pp.

First, you'll need to be leinigen - ,
when leinigen is installed, use "lein jar" to build the cbench jar.

Place the cbench.jar file somewhere in your java classpath. From the Clojure
REPL you should be able to access the cbench and cbench-pp functions:

user=> (use 'cbench)
user=> (cbench 50 #(Thread/sleep 10))
[10.06 11.0 10.0 0.3392674720850722 509]
user=> (cbench-pp 50 #(Thread/sleep 10))
| avg    | 10.1 ms
| min    | 10.0 ms
| max    | 11.0 ms
| stddev | 0.4285717918757761 ms
| total  | 509 ms

As you can see, cbench-pp is just pretty formatting for cbench.

cbench and cbench-pp both take a number of iterations (50 in the example)
and a no-argument function, which is benchmarked the number of times given.

Use it to test how much reflection helps, or whether there's a lot of
variance between your function call times.
Something went wrong with that request. Please try again.