From 622f9a35b6918662ae1febd0ed49c52282260e1e Mon Sep 17 00:00:00 2001 From: "W. Black" Date: Fri, 29 Mar 2024 13:30:26 -0700 Subject: [PATCH] Torus benchmark (#12781) # Objective - Primitive meshing is suboptimal - Improve primitive meshing ## Solution - Add primitive meshing benchmark - Allows measuring future improvements --- First of a few PRs to refactor and improve primitive meshing. --- benches/Cargo.toml | 6 ++++++ benches/benches/bevy_render/torus.rs | 15 +++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 benches/benches/bevy_render/torus.rs diff --git a/benches/Cargo.toml b/benches/Cargo.toml index e64a79d2b3..ee9d45953a 100644 --- a/benches/Cargo.toml +++ b/benches/Cargo.toml @@ -17,6 +17,7 @@ bevy_reflect = { path = "../crates/bevy_reflect" } bevy_tasks = { path = "../crates/bevy_tasks" } bevy_utils = { path = "../crates/bevy_utils" } bevy_math = { path = "../crates/bevy_math" } +bevy_render = { path = "../crates/bevy_render" } [profile.release] opt-level = 3 @@ -62,6 +63,11 @@ name = "bezier" path = "benches/bevy_math/bezier.rs" harness = false +[[bench]] +name = "torus" +path = "benches/bevy_render/torus.rs" +harness = false + [[bench]] name = "entity_hash" path = "benches/bevy_ecs/world/entity_hash.rs" diff --git a/benches/benches/bevy_render/torus.rs b/benches/benches/bevy_render/torus.rs new file mode 100644 index 0000000000..8ec81c8040 --- /dev/null +++ b/benches/benches/bevy_render/torus.rs @@ -0,0 +1,15 @@ +use criterion::{black_box, criterion_group, criterion_main, Criterion}; + +use bevy_render::mesh::TorusMeshBuilder; + +fn torus(c: &mut Criterion) { + c.bench_function("build_torus", |b| { + b.iter(|| black_box(TorusMeshBuilder::new(black_box(0.5),black_box(1.0)))); + }); +} + +criterion_group!( + benches, + torus, +); +criterion_main!(benches);