Skip to content

Instantly share code, notes, and snippets.

@jjttjj
Created June 26, 2018 22:57
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 jjttjj/686b3b84537e24a542e4ccfb53f8d73f to your computer and use it in GitHub Desktop.
Save jjttjj/686b3b84537e24a542e4ccfb53f8d73f to your computer and use it in GitHub Desktop.
(defn- child-vecV0
[this]
(let [x (.-childNodes this)
l (.-length x)]
(loop [i 0 ret (transient [])]
(or (and (= i l) (persistent! ret))
(recur (inc i) (conj! ret (.item x i)))))))
(defn- child-vecV1
[this]
(let [x (.-childNodes this)]
(persistent!
(areduce x i ret (transient []) (conj! ret (.item x i))))))
(defn- child-vecV2
[this]
(let [x (.-childNodes this)]
(areduce x i ret [] (conj ret (.item x i)))))
V1 transient areduce x 2,436,827 ops/sec ±6.05% (60 runs sampled)
V2 non-transient areduce x 7,240,502 ops/sec ±3.00% (58 runs sampled)
Fastest is  #js [V2 non-transient areduce]
======
Benchmark for [#<HoplonElement: DIV> #<HoplonElement: DIV>]
V0: hoplon v7.2 x 635,995 ops/sec ±8.26% (44 runs sampled)
V1 transient areduce x 2,021,949 ops/sec ±6.48% (57 runs sampled)
V2 non-transient areduce x 3,879,750 ops/sec ±4.69% (57 runs sampled)
Fastest is  #js [V2 non-transient areduce]
======
Benchmark for [#<HoplonElement: DIV> #<HoplonElement: DIV> #<HoplonElement: DIV> #<HoplonElement: DIV>]
V0: hoplon v7.2 x 370,422 ops/sec ±8.41% (42 runs sampled)
V1 transient areduce x 1,630,706 ops/sec ±4.70% (59 runs sampled)
V2 non-transient areduce x 2,121,646 ops/sec ±6.64% (56 runs sampled)
Fastest is  #js [V2 non-transient areduce]
======
Benchmark for [#<HoplonElement: DIV> #<HoplonElement: DIV> #<HoplonElement: DIV> #<HoplonElement: DIV> #<HoplonElement: DIV> #<HoplonElement: DIV> #<HoplonElement: DIV> #<HoplonElement: DIV> #<HoplonElement: DIV> #<HoplonElement: DIV>]
V0: hoplon v7.2 x 175,581 ops/sec ±5.34% (41 runs sampled)
V1 transient areduce x 1,013,786 ops/sec ±6.88% (60 runs sampled)
V2 non-transient areduce x 832,479 ops/sec ±13.32% (58 runs sampled)
Fastest is  #js [V1 transient areduce]
======
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment