Skip to content

Instantly share code, notes, and snippets.

@martinklepsch
Created August 20, 2017 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinklepsch/e6c04704c6f398cd48fa35676de84bd5 to your computer and use it in GitHub Desktop.
Save martinklepsch/e6c04704c6f398cd48fa35676de84bd5 to your computer and use it in GitHub Desktop.
Variation on Clojure's time macro but also printing the expression that is being timed
(defmacro timed [expr]
`(let [start# (. System (nanoTime))
ret# ~expr]
(prn (str ~(str expr) " elapsed time: " (/ (double (- (. System (nanoTime)) start#)) 1000000.0) " msecs"))
ret#))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment