The case
example in ClojureScript Case Constants is now an order of magnitude faster in ClojureScript master, due to a change by David Nolen to inline constants!
Old:
cljs.user=> (def ^:const n 3)
#'cljs.user/n
cljs.user=> (def ^:const m 4)
#'cljs.user/m
cljs.user=> (defn foo []
#_=> (let [x 4]
#_=> (case x
#_=> n 1
#_=> m 2
#_=> 7 3
#_=> "hi" 4
#_=> :no-match)))
#'cljs.user/foo
cljs.user=> (simple-benchmark [] (foo) 100000000)
[], (foo), 100000000 runs, 374 msecs
nil
cljs.user=> (simple-benchmark [] (foo) 100000000)
[], (foo), 100000000 runs, 375 msecs
nil
New:
cljs.user=> (def ^:const n 3)
#_=> (def ^:const m 4)
#'cljs.user/n
#'cljs.user/m
cljs.user=> (defn foo []
#_=> (let [x 4]
#_=> (case x
#_=> n 1
#_=> m 2
#_=> 7 3
#_=> "hi" 4
#_=> :no-match)))
#'cljs.user/foo
cljs.user=> (simple-benchmark [] (foo) 100000000)
[], (foo), 100000000 runs, 31 msecs
nil
cljs.user=> (simple-benchmark [] (foo) 100000000)
[], (foo), 100000000 runs, 30 msecs
nil
cljs.user=> (simple-benchmark [] (foo) 100000000)
[], (foo), 100000000 runs, 36 msecs
nil