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 tool for measuring the computation time of Clojure expressions.
It performs given expressions multiple times and reports statistical information including means and std-deviations of execution time. Criterium...
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime