O'Reilly logo

Clojure Programming Cookbook by Nicolas Modrzyk, Makoto Hashimoto

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Benchmarking with Criterium, performance tips, and other tools

In this recipe, we will learn how to test, measure, and improve the performance of your application. We will show you a Clojure-based benchmark tool.

Getting ready

To use Criterium, we need to add the criterium library in your project.clj as follows:

(defproject performance-example "0.1.0-SNAPSHOT" 
  :description "FIXME: write description" 
  :url "http://example.com/FIXME" 
  :license {:name "Eclipse Public License" 
            :url "http://www.eclipse.org/legal/epl-v10.html"} 
  :dependencies [[org.clojure/clojure "1.8.0"] 
                 [criterium "0.4.4"]]) 

Then, restart your REPL.

How to do it...

Here, we will show you how to test the performance of your code using Criterium.

Using Criterium

Criterium is a micro benchmark ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required