chore: add rect::rows benchmark (#1301)

This commit is contained in:
Josh McKinney 2024-08-06 05:30:07 -07:00 committed by GitHub
parent 1b9bdd425c
commit 45fcab7497
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 0 deletions

View file

@ -196,6 +196,10 @@ harness = false
name = "list"
harness = false
[[bench]]
name = "rect"
harness = false
[lib]
bench = false

25
benches/rect.rs Normal file
View file

@ -0,0 +1,25 @@
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
use ratatui::layout::Rect;
fn rect_rows_benchmark(c: &mut Criterion) {
let rect_sizes = vec![
Rect::new(0, 0, 1, 16),
Rect::new(0, 0, 1, 1024),
Rect::new(0, 0, 1, 65535),
];
let mut group = c.benchmark_group("rect_rows");
for rect in rect_sizes {
group.bench_with_input(BenchmarkId::new("rows", rect.height), &rect, |b, rect| {
b.iter(|| {
for row in rect.rows() {
// Perform any necessary operations on each row
black_box(row);
}
});
});
}
group.finish();
}
criterion_group!(benches, rect_rows_benchmark);
criterion_main!(benches);