Carp/bench/array_subarray.carp

26 lines
462 B
Plaintext
Raw Normal View History

(load "Bench.carp")
(use Bench)
(Debug.sanitize-addresses)
(use Array)
(def n 1000)
(defn some-subarray []
(let-do [a (replicate n &1)
2020-02-11 11:09:30 +03:00
b (slice &a 0 (/ n 2))]
(assert (= (/ n 2) (length &b)))))
(defn perform-bench [new-n]
(do
(set! n new-n)
(println* "\nTaking sub-array of array with length " n)
(bench some-subarray)))
(defn main []
(do
(perform-bench 1000)
(perform-bench 10000)
(perform-bench 100000)
))