mirror of
https://github.com/carp-lang/Carp.git
synced 2024-11-05 04:44:12 +03:00
23 lines
555 B
Plaintext
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)))
|