Created
December 9, 2014 04:04
-
-
Save timsgardner/472148b929d4407f8aa2 to your computer and use it in GitHub Desktop.
time-it
This file contains hidden or 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
| (defn time-it | |
| "Signature slightly awkward to resemble that of time-it-mac" | |
| ([f] (time-it f 1)) | |
| ([n f] | |
| (. clojure.lang.RT (StartStopwatch)) | |
| (dotimes [_ n] (f)) | |
| (let [t (. clojure.lang.RT StopStopwatch)] | |
| (/ t n)))) | |
| (defmacro time-it-mac | |
| ([n & body] | |
| `(do | |
| (. clojure.lang.RT (StartStopwatch)) | |
| (dotimes [_# ~n] ~@body) | |
| (let [t# (. clojure.lang.RT StopStopwatch)] | |
| (/ t# ~n))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment