Skip to main content

rl_lang/docs/entries/stdlib/debug/
bench.rs

1use crate::docs::entry::FnEntry;
2
3pub static BENCH: FnEntry = FnEntry {
4    signature: "bench(function, iterations)",
5    description: "calls a zero-argument function or lambda `iterations` times and returns the total elapsed time in milliseconds",
6    example: r#"
7get std::debug::bench
8get std::math::factorial
9get std::io::println
10
11dec float ms = bench(fn() { factorial(10) }, 1000)?
12println(ms)
13"#,
14    expected_output: None,
15    returns: "result[float]",
16    errors: Some(
17        "returns error when `function` is not callable, or `iterations` is not a positive int",
18    ),
19    see_also: &[],
20    since: Some("v0.1.5"),
21};