Skip to content

Instantly share code, notes, and snippets.

@fsodomka
fsodomka / timings.clj
Last active December 19, 2015 03:29
Helper functions for timing expressions and examples of use.
;; Copyright (c) Frantisek Sodomka
;; Distributed under the Eclipse Public License, the same as Clojure.
(defmacro timings [n & exprs]
`(if (= ~@exprs)
~(vec (for [expr exprs]
`(let [start# (System/nanoTime)
ret# (dotimes [~'_ ~n] ~expr)
end# (System/nanoTime)]
{:expr '~expr