mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-17 08:27:45 +03:00
bench: add structs benchmark
This commit is contained in:
parent
9a3b0e5f59
commit
b3b64d9cd9
22
bench/structs.carp
Normal file
22
bench/structs.carp
Normal file
@ -0,0 +1,22 @@
|
||||
(load "Bench.carp")
|
||||
(use Bench)
|
||||
|
||||
(deftype Point [x Int, y Int])
|
||||
|
||||
(def p (Point.init 0 0))
|
||||
|
||||
(defn creation [] (Point.init 0 0))
|
||||
(defn access [] (Point.x &p))
|
||||
(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 access)
|
||||
(IO.println "\nUpdate lens:")
|
||||
(bench update)
|
||||
(IO.println "\nSetter lens:")
|
||||
(bench set)))
|
Loading…
Reference in New Issue
Block a user