mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-17 08:27:45 +03:00
470f0f827d
* chore: Re-format Haskell code * fix: Unify aupdate and aupdate! with other update functions * fix: Re-add comment * fix: Also make StaticArray.aupdate! adhere to the normal update signature * fix: Failing test
30 lines
584 B
Plaintext
30 lines
584 B
Plaintext
(load "Bench.carp")
|
|
(use Bench)
|
|
(Debug.sanitize-addresses)
|
|
(use Array)
|
|
|
|
(def n 1000)
|
|
|
|
(defn inc-ref [ir]
|
|
(+ 1 @ir))
|
|
|
|
(defn some-updating []
|
|
(let-do [a (replicate n &12345)
|
|
b (aupdate a 0 &inc)]
|
|
(assert (= (unsafe-nth &b 0) &12346))
|
|
(assert (= (unsafe-nth &b 1) &12345))))
|
|
|
|
(defn perform-bench [new-n]
|
|
(do
|
|
(set! n new-n)
|
|
(println* "\nUpdating array with length " n)
|
|
(bench some-updating)))
|
|
|
|
(defn main []
|
|
(do
|
|
(perform-bench 1000)
|
|
(perform-bench 10000)
|
|
(perform-bench 100000)
|
|
(perform-bench 1000000)
|
|
(perform-bench 10000000)))
|