Last active
August 29, 2015 13:57
-
-
Save martintrojer/9372843 to your computer and use it in GitHub Desktop.
all vars
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
(defn- log-time [{:keys [ns name line]} f & args] | |
(let [start (System/nanoTime) | |
res (apply f args) | |
elapsed (quot (- (System/nanoTime) start) 1000)] | |
(log/debug (format "%s/%s:%s %dus" ns name line elapsed)) | |
res)) | |
(defn enable-timing [var] | |
(log/debug "enabling timings" var) | |
(add-hook var (partial log-time (meta var)))) | |
(defn enable-timing-on-blocking-functions [] | |
(->> (all-ns) | |
(mapcat ns-interns) | |
(map second) | |
(filter #(:blocking (meta %))) | |
(remove #(:robert.hooke/hook (meta (deref %)))) | |
(map enable-timing) | |
doall)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment