Carp/bench/structs.carp
2019-09-20 23:40:05 +02:00

23 lines
556 B
Plaintext

(load "Bench.carp")
(use Bench)
(deftype Point [x Int, y Int])
(def p (Point.init 0 0))
(defn creation [] (Point.init 0 0))
(defn bench-access [] (ignore (Point.x &p))) ;; The name 'access' collides with an existing C-function.
(defn set [] (Point.set-x @&p 5))
(defn update [] (Point.update-x @&p &Int.inc))
(defn main []
(do
(IO.println "Struct creation:")
(bench creation)
(IO.println "\nStruct access:")
(bench bench-access)
(IO.println "\nUpdate lens:")
(bench update)
(IO.println "\nSetter lens:")
(bench set)))