2018-01-25 19:37:30 +03:00
|
|
|
(load "Bench.carp")
|
|
|
|
(use Bench)
|
|
|
|
|
|
|
|
(deftype Point [x Int, y Int])
|
|
|
|
|
|
|
|
(def p (Point.init 0 0))
|
|
|
|
|
|
|
|
(defn creation [] (Point.init 0 0))
|
2018-02-06 11:02:46 +03:00
|
|
|
(defn bench-access [] (ignore (Point.x &p))) ;; The name 'access' collides with an existing C-function.
|
2018-01-25 19:37:30 +03:00
|
|
|
(defn set [] (Point.set-x @&p 5))
|
2019-09-21 00:40:05 +03:00
|
|
|
(defn update [] (Point.update-x @&p &Int.inc))
|
2018-01-25 19:37:30 +03:00
|
|
|
|
|
|
|
(defn main []
|
|
|
|
(do
|
|
|
|
(IO.println "Struct creation:")
|
|
|
|
(bench creation)
|
|
|
|
(IO.println "\nStruct access:")
|
2018-02-06 11:02:46 +03:00
|
|
|
(bench bench-access)
|
2018-01-25 19:37:30 +03:00
|
|
|
(IO.println "\nUpdate lens:")
|
|
|
|
(bench update)
|
|
|
|
(IO.println "\nSetter lens:")
|
|
|
|
(bench set)))
|