Skip to content

Instantly share code, notes, and snippets.

@nathanmarz
Last active March 1, 2017 12:57
Show Gist options
  • Save nathanmarz/8e1809bbd3a7632311c2b45ba02eb880 to your computer and use it in GitHub Desktop.
Save nathanmarz/8e1809bbd3a7632311c2b45ba02eb880 to your computer and use it in GitHub Desktop.
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