termwiz: add bench for Cell creation/drop
This commit is contained in:
1 parent
3547efc567
commit
bd79ee0bff
2 files changed
+27
No files matched your search
@@ -85,3 +85,8 @@ rustdoc-args = ["--cfg", "feature=\"docs\""]
|
||||
[[bench]]
|
||||
name = "wcwidth"
|
||||
harness = false
|
||||
|
||||
[[bench]]
|
||||
name = "cell"
|
||||
harness = false
|
||||
|
||||
@@ -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);
|
||||
Reference in new issue
Block a user