unicode-display-width 0.3.0

Unicode 15.1.0 compliant utility for determining the number of columns required to display an arbitrary string
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use criterion::{criterion_group, criterion_main, Criterion};
use unicode_display_width::width;

fn bench(bencher: &mut Criterion) {
    let random_unicode = "|asdf j;agj;asdlkj as;ldgj a≈߃/woietl;,mxc,mjio;øˆ∆˙©†ƒ©¬˙∆≥ngar;lj092389034t[ergopgsfdmăܦؤـ|";

    bencher.bench_function("line with random Unicode", |b| {
        b.iter(|| width(random_unicode))
    });
}

criterion_group!(benches, bench);
criterion_main!(benches);