1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-22 04:56:12 +03:00

termwiz: add bench for Cell creation/drop

This commit is contained in:
Wez Furlong 2022-04-30 13:01:55 -07:00
parent 3547efc567
commit bd79ee0bff
2 changed files with 27 additions and 0 deletions

View File

@ -85,3 +85,8 @@ rustdoc-args = ["--cfg", "feature=\"docs\""]
[[bench]]
name = "wcwidth"
harness = false
[[bench]]
name = "cell"
harness = false

22
termwiz/benches/cell.rs Normal file
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);