include #iters in benchmark output
This commit is contained in:
parent
85b91d19c4
commit
db08499eaf
1 changed files with 11 additions and 11 deletions
|
|
@ -47,21 +47,11 @@
|
|||
(defmacro run-benchmark [name amt-per-iter & exprs]
|
||||
(let [afn-map (->> exprs shuffle (map (fn [e] [`(quote ~e) `(fn [] ~e)])) (into {}))]
|
||||
`(do
|
||||
(println "Benchmark:" ~name)
|
||||
(println "Benchmark:" ~name (str "(" ~amt-per-iter " iterations)"))
|
||||
(compare-benchmark ~amt-per-iter ~afn-map)
|
||||
(println "\n********************************\n")
|
||||
)))
|
||||
|
||||
(let [data (range 1000)]
|
||||
(run-benchmark "Traverse into a set" 5000
|
||||
(set data)
|
||||
(set (select ALL data))
|
||||
(into #{} (traverse ALL data))
|
||||
(persistent!
|
||||
(reduce conj! (transient #{}) (traverse ALL data)))
|
||||
(reduce conj #{} (traverse ALL data))
|
||||
))
|
||||
|
||||
(let [data {:a {:b {:c 1}}}
|
||||
p (comp-paths :a :b :c)]
|
||||
(run-benchmark "get value in nested map" 5000000
|
||||
|
|
@ -254,3 +244,13 @@
|
|||
(vary-meta data assoc :y 2)
|
||||
(setval [META :y] 2 data)))
|
||||
|
||||
(let [data (range 1000)]
|
||||
(run-benchmark "Traverse into a set" 5000
|
||||
(set data)
|
||||
(set (select ALL data))
|
||||
(into #{} (traverse ALL data))
|
||||
(persistent!
|
||||
(reduce conj! (transient #{}) (traverse ALL data)))
|
||||
(reduce conj #{} (traverse ALL data))
|
||||
))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue