mirror of
https://github.com/carp-lang/Carp.git
synced 2024-11-04 01:25:04 +03:00
Added benchmark for mutating version of 'swap' ('swap!') for comparison.
This commit is contained in:
parent
ff6852d839
commit
c83f03d2bc
@ -15,8 +15,22 @@
|
||||
(set! a (Array.replicate n &1))
|
||||
(bench some-swapping)))
|
||||
|
||||
(defn some-mutable-swapping []
|
||||
(let [b @&a]
|
||||
(ignore (Array.swap! &b 0 1))))
|
||||
|
||||
(defn perform-mutable-bench [n]
|
||||
(do
|
||||
(println* "\nMutable swap with array count " n)
|
||||
(set! a (Array.replicate n &1))
|
||||
(bench some-mutable-swapping)))
|
||||
|
||||
(defn main []
|
||||
(do (perform-bench 1000)
|
||||
(perform-bench 10000)
|
||||
(perform-bench 100000)
|
||||
(perform-bench 1000000)))
|
||||
(perform-bench 1000000)
|
||||
(perform-mutable-bench 1000)
|
||||
(perform-mutable-bench 10000)
|
||||
(perform-mutable-bench 100000)
|
||||
(perform-mutable-bench 1000000)))
|
||||
|
Loading…
Reference in New Issue
Block a user