benchmark

In-Language Micro-Benchmarking

Functions

FunctionDescription
bench_now_nsGet current timestamp in nanoseconds.
bench_startStart a benchmark timer.
bench_stopStop timer, return elapsed nanoseconds.
bench_msStop timer, return elapsed milliseconds.
bench_usStop timer, return elapsed microseconds.
bench_print_intInternal: print integer.
bench_reportPrint benchmark result: “name: 12345ns (12.345ms)”
bench_iterRun fn_ptr() n times. Returns total nanoseconds.
bench_iter_reportRun fn_ptr() n times and print results.

Details

bench_now_ns

fn bench_now_ns() -> i64

Get current timestamp in nanoseconds.

bench_start

fn bench_start() -> i64

Start a benchmark timer.

bench_stop

fn bench_stop(start: i64) -> i64

Stop timer, return elapsed nanoseconds.

bench_ms

fn bench_ms(start: i64) -> i64

Stop timer, return elapsed milliseconds.

bench_us

fn bench_us(start: i64) -> i64

Stop timer, return elapsed microseconds.

bench_print_int

fn bench_print_int(val: i64)

Internal: print integer.

bench_report

fn bench_report(name: &i8, nlen: i64, start: i64)

Print benchmark result: “name: 12345ns (12.345ms)”

bench_iter

fn bench_iter(fn_ptr: i64, n: i64) -> i64

Run fn_ptr() n times. Returns total nanoseconds.

bench_iter_report

fn bench_iter_report(name: &i8, nlen: i64, fn_ptr: i64, n: i64)

Run fn_ptr() n times and print results.