Created
June 15, 2016 16:26
-
-
Save nathanmarz/bf571c9ed86bfad09816e17b9b6e59e3 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
Benchmark: transform values of a small map (1000000 iterations) | |
Avg(ms) vs best Code | |
141.61 1.00 (map-vals-map-iterable data inc) | |
146.86 1.04 (reduce-kv (fn [m k v] (assoc m k (inc v))) {} data) | |
156.66 1.11 (reduce-kv (fn [m k v] (assoc m k (inc v))) (empty data) data) | |
161.20 1.14 (transform MAP-VALS inc data) | |
211.53 1.49 (persistent! (reduce-kv (fn [m k v] (assoc! m k (inc v))) (transient {}) data)) | |
227.91 1.61 (map-vals-map-iterable-transient data inc) | |
332.09 2.35 (transform [ALL LAST] inc data) | |
953.39 6.73 (zipmap (keys data) (map inc (vals data))) | |
1018.7 7.19 (into {} (for [[k v] data] [k (inc v)])) | |
1053.5 7.44 (into {} (map (fn [e] [(key e) (inc (val e))]) data)) | |
Benchmark: transform values of large map (1000 iterations) | |
Avg(ms) vs best Code | |
140.87 1.00 (persistent! (reduce-kv (fn [m k v] (assoc! m k (inc v))) (transient clojure.lang.PersistentHashMap/EMPTY) data)) | |
141.39 1.00 (transform MAP-VALS inc data) | |
144.26 1.02 (persistent! (reduce-kv (fn [m k v] (assoc! m k (inc v))) (transient {}) data)) | |
177.62 1.26 (reduce-kv (fn [m k v] (assoc m k (inc v))) (empty data) data) | |
185.75 1.32 (reduce-kv (fn [m k v] (assoc m k (inc v))) {} data) | |
188.51 1.34 (transform [ALL LAST] inc data) | |
212.14 1.51 (map-vals-map-iterable-transient data inc) | |
254.10 1.80 (map-vals-map-iterable data inc) | |
321.05 2.28 (into {} (for [[k v] data] [k (inc v)])) | |
338.41 2.40 (into {} (map (fn [e] [(key e) (inc (val e))]) data)) | |
420.10 2.98 (zipmap (keys data) (map inc (vals data))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment