mirror of
https://github.com/carp-lang/Carp.git
synced 2024-11-05 04:44:12 +03:00
9848e8fb34
- don’t do function copying in benchmarking - fix the array_update benchmark - add Filepath.file-from-path - add tests for the `Filepath` module - reformat a lot of documentation
30 lines
571 B
Plaintext
30 lines
571 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-ref)]
|
|
(assert (= (nth &b 0) &12346))
|
|
(assert (= (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)))
|