pschachte / wybe

A programming language supporting most of both declarative and imperative programming
MIT License
47 stars 6 forks source link

Added Benchmarking Library #423

Closed wnats closed 1 year ago

wnats commented 1 year ago

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 times proc. The library will throw an error if:

jimbxb commented 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)
}
pschachte commented 1 year ago

Thank you!