Created
April 6, 2012 16:08
-
-
Save trptcolin/2321036 to your computer and use it in GitHub Desktop.
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
user=> (time (dotimes [i 10000000] (reduce (fn [acc [k v]] (conj acc k)) [] {:a 1 :b 2 :c 3}))) | |
"Elapsed time: 2782.152 msecs" | |
nil | |
user=> (time (dotimes [i 10000000] (reduce-kv (fn [acc k v] (conj acc k)) [] {:a 1 :b 2 :c 3}))) | |
"Elapsed time: 1300.516 msecs" | |
nil | |
user=> (def size 10000) | |
#'user/size | |
user=> (def h (into {} (map vector (range size) (range size)))) | |
#'user/h | |
user=> (time (dotimes [i 1000] (reduce (fn [acc [k v]] (conj acc k)) [] h))) | |
"Elapsed time: 1901.776 msecs" | |
nil | |
user=> (time (dotimes [i 1000] (reduce-kv (fn [acc k v] (conj acc k)) [] h))) | |
"Elapsed time: 747.798 msecs" | |
nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment