Skip to content

Commit 870c8e4

Browse files
committed
Add angle_weighted_normals benchmark
1 parent 3e1cbb5 commit 870c8e4

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

benches/benches/bevy_render/compute_normals.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn compute_normals(c: &mut Criterion) {
5454
});
5555
});
5656

57-
c.bench_function("face_weighted_normals", |b| {
57+
c.bench_function("angle_weighted_normals", |b| {
5858
b.iter_custom(|iters| {
5959
let mut total = Duration::default();
6060
for _ in 0..iters {
@@ -70,11 +70,23 @@ fn compute_normals(c: &mut Criterion) {
7070
});
7171
});
7272

73-
let new_mesh = || {
74-
new_mesh()
75-
.with_duplicated_vertices()
76-
.with_computed_flat_normals()
77-
};
73+
c.bench_function("face_weighted_normals", |b| {
74+
b.iter_custom(|iters| {
75+
let mut total = Duration::default();
76+
for _ in 0..iters {
77+
let mut mesh = new_mesh();
78+
black_box(mesh.attribute(Mesh::ATTRIBUTE_NORMAL));
79+
let start = Instant::now();
80+
mesh.compute_face_weighted_normals();
81+
let end = Instant::now();
82+
black_box(mesh.attribute(Mesh::ATTRIBUTE_NORMAL));
83+
total += end.duration_since(start);
84+
}
85+
total
86+
});
87+
});
88+
89+
let new_mesh = || new_mesh().with_duplicated_vertices();
7890

7991
c.bench_function("flat_normals", |b| {
8092
b.iter_custom(|iters| {

0 commit comments

Comments
 (0)