Created
October 1, 2012 02:53
-
-
Save w01fe/3809219 to your computer and use it in GitHub Desktop.
Monitoring a Graph
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 observe-graph [g record-node-time!] | |
(into {} | |
(for [[k f] g] | |
[k | |
(with-meta | |
(fn [m] | |
(let [t0 (System/nanoTime) | |
v (f m) | |
t1 (System/nanoTime)] | |
(record-node-time! k (- t1 t0)) | |
v)) | |
(meta f))]))) | |
(def observed-stats | |
(graph/eager-compile | |
(observe-graph stats-graph record-to-dashboard!))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment