Skip to content
A small clojure benchmarking helper
Clojure
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
src
README
cbench.jar
project.clj

README

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
-----------------------------------
nil

cbench provides 2 function, cbench and cbench-pp.

First, you'll need to be leinigen - http://github.com/technomancy/leiningen ,
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)
nil
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
-----------------------------------
nil

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.