Carp/bench/structs.carp
2018-02-06 09:02:46 +01:00

23 lines
555 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)))