add benchmark for specialized select-any style composition
This commit is contained in:
parent
a06cb47bd8
commit
5162a23607
1 changed files with 13 additions and 0 deletions
|
|
@ -57,6 +57,17 @@
|
|||
(defn specter-dynamic-nested-get [data a b c]
|
||||
(select-any [(keypath a) (keypath b) (keypath c)] data))
|
||||
|
||||
|
||||
(defn get-k [k] (fn [m next] (next (get m k))))
|
||||
|
||||
(def get-a-b-c
|
||||
(reduce
|
||||
(fn [curr afn]
|
||||
(fn [structure]
|
||||
(afn structure curr)))
|
||||
[identity (get-k :c) (get-k :b) (get-k :a)]))
|
||||
|
||||
|
||||
(let [data {:a {:b {:c 1}}}
|
||||
p (comp-paths :a :b :c)]
|
||||
(run-benchmark "get value in nested map" 2500000
|
||||
|
|
@ -67,6 +78,8 @@
|
|||
(compiled-select-any p data)
|
||||
(specter-dynamic-nested-get data :a :b :c)
|
||||
(get-in data [:a :b :c])
|
||||
(get-a-b-c data)
|
||||
(-> data :a :b :c identity)
|
||||
(-> data (get :a) (get :b) (get :c))
|
||||
(-> data :a :b :c)
|
||||
(select-any [(keypath :a) (keypath :b) (keypath :c)] data)))
|
||||
|
|
|
|||
Loading…
Reference in a new issue