Skip to content

Instantly share code, notes, and snippets.

@Hendekagon
Last active August 6, 2016 09:55
Show Gist options
  • Save Hendekagon/bcbdbd2edc841b4c326d7060683897ac to your computer and use it in GitHub Desktop.
Save Hendekagon/bcbdbd2edc841b4c326d7060683897ac to your computer and use it in GitHub Desktop.
Clojure arity vs map destructure cost
(require '[criterium.core :as crit])
=> nil
(defn Q ([x y z] [x y z]) ([{:keys [x y z]}] [x y z]))
=> #'repl/Q
(crit/quick-bench (Q 4 5 6))
Evaluation count : 43141050 in 6 samples of 7190175 calls.
Execution time mean : 12.030810 ns
Execution time std-deviation : 0.313706 ns
Execution time lower quantile : 11.631011 ns ( 2.5%)
Execution time upper quantile : 12.336856 ns (97.5%)
Overhead used : 2.469617 ns
=> nil
(crit/quick-bench (Q {:x 4 :y 5 :z 6}))
Evaluation count : 9313566 in 6 samples of 1552261 calls.
Execution time mean : 66.666807 ns
Execution time std-deviation : 1.789830 ns
Execution time lower quantile : 63.891117 ns ( 2.5%)
Execution time upper quantile : 68.513295 ns (97.5%)
Overhead used : 2.469617 ns
=> nil
(def m1 {:x 4 :y 5 :z 6})
=> #'repl/m1
(crit/quick-bench (Q m1))
Evaluation count : 6384156 in 6 samples of 1064026 calls.
Execution time mean : 92.957179 ns
Execution time std-deviation : 4.732466 ns
Execution time lower quantile : 86.714655 ns ( 2.5%)
Execution time upper quantile : 97.445779 ns (97.5%)
Overhead used : 2.469617 ns
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment