pocket_watch
Functions
pub fn callback(
label label: String,
with callback: fn(String, String) -> Nil,
time body: fn() -> a,
) -> a
Log time taken using a provided callback.
Examples:
let print_time = fn(label, elapsed) { io.println(label <> " took " <> elapsed) }
{
use <- pocket_watch.callback("test", print_time)
process.sleep(1000)
} // test took 1.0s
pub fn callback_us(
label label: String,
with callback: fn(String, Int) -> Nil,
time body: fn() -> a,
) -> a
Log time taken using a provided callback that takes Int
microseconds as argument.
Examples:
let print_time = fn(label, elapsed) {
io.println(label <> " took " <> int.to_string(elapsed / 1_000) <> "ms")
}
{
use <- pocket_watch.callback("test", print_time)
process.sleep(1000)
} // test took 1000ms