Created
August 20, 2017 13:14
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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