Create a gist now

Instantly share code, notes, and snippets.

namespace qualify keys of a map benchmark
Specter 1.0
Clojure 1.8.0
Mac OSX 10.11.6
Benchmark: namespace qualify keys of a small map (1000000 iterations)
Avg(ms) vs best Code
243.69 1.00 (setval [MAP-KEYS NAMESPACE] (str *ns*) data)
432.11 1.77 (reduce-kv (fn [m k v] (assoc m (keyword (str *ns*) (name k)) v)) {} data)
682.69 2.80 (into {} (map (fn [[k v]] [(keyword (str *ns*) (name k)) v])) data)
********************************
Benchmark: namespace qualify keys of a large map (1200 iterations)
Avg(ms) vs best Code
208.69 1.00 (setval [MAP-KEYS NAMESPACE] (str *ns*) data)
319.69 1.53 (reduce-kv (fn [m k v] (assoc m (keyword (str *ns*) (name k)) v)) {} data)
381.27 1.83 (into {} (map (fn [[k v]] [(keyword (str *ns*) (name k)) v])) data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment