Database Reference
In-Depth Information
For this recipe, we'll take the functions that we created to do the Monte Carlo pi estimates
in the Using type hints recipe, and compare the timings we get with the time macro against
those we get from Criterium.
Getting ready
To use Criterium, we just need to add it to the list of dependencies in our project.clj ile:
(defproject parallel-data ""0.1.0""
:dependencies [[org.clojure/clojure ""1.6.0""]
[criterium ""0.4.3""]])
We need to use it in our script or REPL:
(use 'criterium.core)
We'll also need the code the benchmark, which means the mc-pi and mc-pi-hint functions
from the Using type hints recipe along with their dependencies.
How to do it…
First, let's look at the results of running the time macro several times on each function.
Here's how we do it once:
user=> (time (mc-pi 1000000))
""Elapsed time: 1304.007 msecs""
3.14148
The following chart shows the results of all ive calls on each:
 
Search WWH ::




Custom Search