Closed wnats closed 1 year ago
This is cool. I like that we can guarantee that the timer is only started and ended once in succession.
One request: can we add a utility of some kind like this?
def {semipure} time(proc:{semipure}(), ?time:float) {
!start
!proc
!end(?time)
}
Thank you!
Added a library for benchmarking purposes, as requested by @pschachte.
This is similar to #304, but with @pschachte's suggestion to store the clock counter as a global variable in
cbits.c
.This library introduces two new
semipure
procedures,!benchmark.start
and!benchmark.end(?time:float)
, serving as a pair of probes to measure the CPU clock time elapsed between two points of a program. A utility procedure!benchmark.time_execution(proc:{semipure}(), ?time:float)
is also introduced which timesproc
. The library will throw an error if:!benchmark.start
is called twice without a!benchmark.end(?time:float)
in between!benchmark.end(?time:float)
is called when an un-ended!benchmark.start
has not been called!benchmark.time_execution(...)
is called when there is a preceding!benchmark.start
which has not been ended