Added benchmark for mutating version of 'swap' ('swap!') for comparison.

This commit is contained in:
Erik Svedäng 2018-03-11 10:44:02 +01:00
parent ff6852d839
commit c83f03d2bc

View File

@ -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)))