Skip to content

Instantly share code, notes, and snippets.

@mfikes
Last active June 11, 2019 03:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfikes/2d6c5c805bb224fad59bbd5e7f00400f to your computer and use it in GitHub Desktop.
Save mfikes/2d6c5c805bb224fad59bbd5e7f00400f to your computer and use it in GitHub Desktop.
$ plk -Sdeps '{:deps {cljs-bean {:mvn/version "0.2.0"}}}'
ClojureScript 1.10.520
cljs.user=> (simple-benchmark [o #js {:a 1 :b 2 :c 3}]
#_=> (let [{:keys [a b c]} (js->clj o :keywordize-keys true)]
#_=> (+ a b c))
#_=> 1e6)
[o #object[cljs.tagged-literals.JSValue]], (let [{:keys [a b c]} (js->clj o :keywordize-keys true)] (+ a b c)), 1000000 runs, 3077 msecs
nil
cljs.user=> (require '[cljs-bean.core :refer [bean]])
nil
cljs.user=> (simple-benchmark [o #js {:a 1 :b 2 :c 3}]
#_=> (let [{:keys [a b c]} (bean o)]
#_=> (+ a b c))
#_=> 1e6)
[o #object[cljs.tagged-literals.JSValue]], (let [{:keys [a b c]} (bean o)] (+ a b c)), 1000000 runs, 156 msecs
nil
cljs.user=> (require '[goog.object :as gobj])
nil
cljs.user=> (simple-benchmark [o #js {:a 1 :b 2 :c 3}]
#_=> (let [a (gobj/get o "a")
#_=> b (gobj/get o "b")
#_=> c (gobj/get o "c")]
#_=> (+ a b c))
#_=> 1e6)
[o #object[cljs.tagged-literals.JSValue]], (let [a (gobj/get o "a") b (gobj/get o "b") c (gobj/get o "c")] (+ a b c)), 1000000 runs, 23 msecs
nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment