Expand description
yog bench — a mod’s benchmarks: benches/*.rs files whose
#[yog_api::bench] functions run under criterion.
ⓘ
// benches/casting.rs
use criterion::{Bencher, Criterion};
#[yog_api::bench]
fn parse(b: &mut Bencher) {
b.iter(|| hexcasting::math::HexPattern::from_angles("qaq", HexDir::East));
}
#[yog_api::bench]
fn vm(c: &mut Criterion) {
let mut group = c.benchmark_group("vm");
// ...
}No harness, no criterion_main!, no Cargo.toml: each file becomes a
[[bench]] target of the generated crate whose main
(.yog-build/generated/benches/<file>.rs) runs its functions in source
order. A function taking &mut Bencher is one benchmark named
<file>/<fn>; one taking &mut Criterion sets up its own (groups,
throughput, batched inputs). The mod is linked in as a library under
its crate name, and yog_api::core::NullServer stands in for a game.
Structs§
- Bench
File - One
benches/<name>.rsfile and its#[yog_api::bench]functions.
Enums§
- Takes
- What a benchmark function takes.
Constants§
- BENCH_
DIR - Where the mod’s benchmark files live, under the project root.
- GENERATED_
DIR - The generated
mains, under the project root.
Functions§
- cargo_
sections - The generated Cargo.toml’s
[dev-dependencies]and[[bench]]targets; empty without benchmarks. - discover
- The mod’s benchmark files, by name; none without a
benches/folder. - functions
- The
#[yog_api::bench]functions of a benchmark file, in source order. - main_
source - The generated
mainof one benchmark file. - write_
sources - Writes every benchmark file’s
main, dropping those of removed files.