termwiz: add bench for Cell creation/drop

This commit is contained in:
Wez Furlong committed 2022-07-22 19:23:53 -07:00
1 parent 3547efc567
commit bd79ee0bff
2 files changed
+27

No files matched your search

+5
View File
@@ -85,3 +85,8 @@ rustdoc-args = ["--cfg", "feature=\"docs\""]
[[bench]]
name = "wcwidth"
harness = false
[[bench]]
name = "cell"
harness = false
+22
View File
@@ -0,0 +1,22 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use termwiz::cell::{Cell, CellAttributes};
pub fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("Cell::blank", |b| b.iter(|| black_box(Cell::blank())));
c.bench_function("Cell::new", |b| {
b.iter(|| Cell::new(black_box('a'), CellAttributes::default()))
});
c.bench_function("Cell::new_grapheme", |b| {
b.iter(|| Cell::new_grapheme(black_box("a"), CellAttributes::default(), None))
});
c.bench_function("Cell::new_grapheme_with_width", |b| {
b.iter(|| Cell::new_grapheme_with_width(black_box("a"), 1, CellAttributes::default()))
});
c.bench_function("CellAttributes::blank", |b| {
b.iter(|| black_box(CellAttributes::blank()))
});
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);