add basic triangle_2d rendering criterion benchmark

just so i have it here for when i try to implement optimizations (again)
This commit is contained in:
Gered 2023-03-31 22:11:37 -04:00
parent 2b4c4d91dc
commit 4fcb6a9f0f
2 changed files with 28 additions and 0 deletions

View file

@ -38,3 +38,7 @@ harness = false
[[bench]]
name = "loading"
harness = false
[[bench]]
name = "triangles"
harness = false

24
ggdt/benches/triangles.rs Normal file
View file

@ -0,0 +1,24 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use ggdt::prelude::*;
pub fn criterion_benchmark(c: &mut Criterion) {
let width = 320;
let height = 240;
let mut dest = IndexedBitmap::new(width, height).unwrap();
c.bench_function("indexedbitmap_triangle_2d_solid_color", |b| {
b.iter(|| {
dest.triangle_2d_solid_color(
black_box(Vector2::new(47.0, 23.0)),
black_box(Vector2::new(60.0, 192.0)),
black_box(Vector2::new(280.0, 153.0)),
black_box(5),
);
})
});
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);