Benchmark for swapping two elements in array.

This commit is contained in:
Erik Svedäng 2018-03-11 10:33:02 +01:00
parent bf8cc4de0c
commit 8da3aed90a

22
bench/array_swap.carp Normal file
View File

@ -0,0 +1,22 @@
(load "Bench.carp")
(use Bench)
(load "Debug.carp")
(Debug.sanitize-addresses)
(def a [0])
(defn some-swapping []
(let [b @&a]
(ignore (Array.swap &b 0 1))))
(defn perform-bench [n]
(do
(println* "\nSwap with array count " n)
(set! a (Array.replicate n &1))
(bench some-swapping)))
(defn main []
(do (perform-bench 1000)
(perform-bench 10000)
(perform-bench 100000)
(perform-bench 1000000)))