mirror of
https://github.com/carp-lang/Carp.git
synced 2024-11-06 05:21:05 +03:00
7c1dd210d7
Issue #236
36 lines
809 B
Plaintext
36 lines
809 B
Plaintext
(load "Bench.carp")
|
|
(use Bench)
|
|
(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 length " n)
|
|
(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 length " 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-mutable-bench 1000)
|
|
(perform-mutable-bench 10000)
|
|
(perform-mutable-bench 100000)
|
|
(perform-mutable-bench 1000000)))
|