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 avg [xs] (/ (apply + xs) (count xs))) | |
(defn timed | |
"Returns a function returning a two element vector with the execution time of f | |
as the first element and the original result as the second" | |
[f] | |
(fn [& args] | |
(let [start (. System (nanoTime)) | |
res (apply f args)] | |
> [(/ (double (- (. System (nanoTime)) start)) 1000000.0) res]))) | |
(defn timed-sink |