add walker vs. old clojure.walk version benchmark
This commit is contained in:
parent
edf9d8c544
commit
dbf3f60167
1 changed files with 15 additions and 4 deletions
|
|
@ -1,8 +1,8 @@
|
|||
(ns com.rpl.specter.benchmarks
|
||||
(:use [com.rpl.specter]
|
||||
[com.rpl.specter.transients]
|
||||
[com.rpl.specter.impl :only [benchmark]])
|
||||
(:require [clojure.walk :as walk]))
|
||||
[com.rpl.specter.transients])
|
||||
(:require [clojure.walk :as walk]
|
||||
[com.rpl.specter.impl :as i]))
|
||||
|
||||
|
||||
;; run via `lein repl` with `(load-file "scripts/benchmarks.clj")`
|
||||
|
|
@ -85,7 +85,6 @@
|
|||
(select-any [(keypath :a) (keypath :b) (keypath :c)] data)))
|
||||
|
||||
|
||||
|
||||
(let [data {:a {:b {:c 1}}}]
|
||||
(run-benchmark "set value in nested map" 2500000
|
||||
(assoc-in data [:a :b :c] 1)
|
||||
|
|
@ -360,3 +359,15 @@
|
|||
(reduce-kv (fn [m k v] (assoc m (keyword (str *ns*) (name k)) v)) {} data)
|
||||
(setval [MAP-KEYS NAMESPACE] (str *ns*) data)
|
||||
))
|
||||
|
||||
(defnav walker-old [afn]
|
||||
(select* [this structure next-fn]
|
||||
(i/walk-select afn next-fn structure))
|
||||
(transform* [this structure next-fn]
|
||||
(i/walk-until afn next-fn structure)))
|
||||
|
||||
(let [data {:a [1 2 {:c '(3 4) :d {:e [1 2 3] 7 8 9 10}}]}]
|
||||
(run-benchmark "walker vs. clojure.walk version" 150000
|
||||
(transform (walker number?) inc data)
|
||||
(transform (walker-old number?) inc data)
|
||||
))
|
||||
|
|
|
|||
Loading…
Reference in a new issue