Skip to content

Prefix benchmark names with module path #16647

@BD103

Description

@BD103

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_intersect
  • entity_hash
  • easing_1000
  • param/combinator_system/8_piped_systems
  • concrete_list_clone_dynamic
  • ray_mesh_intersection/1000_vertices
  • despawn_world_recursive/100_entities
  • overhead_par_iter/threads_4
  • run_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::intersect
  • ecs::world::entity_hash
  • math::bezier::easing_1000
  • ecs::param::combinator_system::8_piped_systems
  • reflect::list::concrete_clone_dynamic
  • picking::ray_mesh_intersection/1000_vertices
  • ecs::world::despawn_recursive/100_entities
  • tasks::overhead_par_iter/threads_4
  • ecs::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:

  1. The name is far clearer on what is being tested.
  2. It's easy to locate the benchmark from the name alone.
    • With the name render::render_layers::intersect, you know the benchmark is within bevy_render/render_layers.rs.
  3. You can easily filter benchmarks to run by category.
    • For instance, you can run cargo bench -- ecs::world to run all World-related benchmarks.

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| {
      // ...
    });
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-Cross-CuttingImpacts the entire engineC-BenchmarksStress tests and benchmarks used to measure how fast things areC-Code-QualityA section of code that is hard to understand or changeD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions