-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Benchmarking Library #423
Conversation
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?
|
wybelibs/benchmark.wybe
Outdated
|
||
# Measure the running time of a semipure niladic procedure | ||
# Assumes any start() call has been ended | ||
pub def {semipure} time(proc:{semipure}(), ?time:float) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that I think about it, we probably want the call_source_location
from wherever we call time
. I think that means we have to manually call the foreign
procs in here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
wybelibs/benchmark.wybe
Outdated
} | ||
|
||
# End the benchmark clock, yielding the elapsed time in seconds | ||
# Can only be called after a start() has been called |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: can we remove the prepositions on start
and end
. start
doesn't use the preposition :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, didn't realise that, thank for pointing it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good except one request.
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