-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Problem
I've slowly been returning to bevy-bencher, and am trying to migrate it to use Bevy's in-tree benchmarks instead of custom ones. One of the original issues I had with this approach is that it's difficult to see what a benchmark is testing from its name alone. For example:
layers_intersectentity_hasheasing_1000param/combinator_system/8_piped_systemsconcrete_list_clone_dynamicray_mesh_intersection/1000_verticesdespawn_world_recursive/100_entitiesoverhead_par_iter/threads_4run_condition/yes_using_resource
All of these names were pulled from our current benchmarks, and are the names that would be displayed in Bencher's UI. Can you guess what each benchmark tracks specifically? Probably not, unless you're deeply familiar with that specific subsystem.
Solution
Now look at the same list again, but with a few changes:
render::render_layers::intersectecs::world::entity_hashmath::bezier::easing_1000ecs::param::combinator_system::8_piped_systemsreflect::list::concrete_clone_dynamicpicking::ray_mesh_intersection/1000_verticesecs::world::despawn_recursive/100_entitiestasks::overhead_par_iter/threads_4ecs::scheduling::run_condition/yes_using_resource
This naming scheme includes the module path in the benchmark name, and removes any redundant words from the benchmark name. There are a few benefits to this approach:
- The name is far clearer on what is being tested.
- It's easy to locate the benchmark from the name alone.
- With the name
render::render_layers::intersect, you know the benchmark is withinbevy_render/render_layers.rs.
- With the name
- You can easily filter benchmarks to run by category.
- For instance, you can run
cargo bench -- ecs::worldto run allWorld-related benchmarks.
- For instance, you can run
Automation
We can automate this naming a little bit using macros, specifically with module_path!(). For a quick sketch, you may be able to do this:
// I may have messed up this syntax, but you get the idea :)
macro_rules! bench {
($name:lit) => {
concat!(module_path!(), $name)
}
}
// Crate: `bevy_math`
mod bezier {
fn easing(c: &mut Criterion) {
// Name is `bevy_math::bezier::easing`.
c.bench_function(bench!("easing"), |b| {
// ...
});
}
}