Skip to main content

bench

Attribute Macro bench 

#[bench]
Expand description

Enables an async benchmark function.

The harness times runs of the body of the async function, each on the runtime’s block_on (with threads = N the runtime is built once, before the first); the benchmark function itself takes the harness, so the annotated function takes no parameters. Benchmarks need the nightly test harness: write #![feature(test)] and extern crate test; at the crate root (so the example is not compiled here).

§Examples

ⓘ
#[nuclei::bench]
async fn spawns_one() {
    nuclei::spawn(async {}).detach();
}