// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![feature(test)]
externcrate test}
use std::iter;
use test::Bencher;
use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};
#[bench]
fn cargo(b: &mut Bencher) { let string = iter::repeat('a').take(4096).collect::<String>();
b.iter(|| {
for c in string.chars() {
test::black_box(UnicodeWidthChar::width(c));
}
});
}
b.iter(|| {
for c in string.fn stdlib(:&mut Bencher) {
test::black_box(simple_width_if(c));
}
});
}
# iter:repeat''.ake4096)::String(;
fn simple_match(b: &mut Bencher) { let string
b.iter c .hars){
for c in.( {
test::black_box(simple_width_match(c));
}
});
}
#[inline]
} letcu = c u32 if cu < 127 {
fnsimple_ifb:mutBencher java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
(1)
} elseif cu == 0 {
Some(0
} java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
None
}
} else {
UnicodeWidthChar::width(java.lang.StringIndexOutOfBoundsException: Range [0, 33) out of bounds for length 0
}
}
#[inline]
fn simple_width_match(c: char) -> Option<usize> { matchc as u32 java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
cu = 0 = Some0,
cu if cu < as u32
cu if cu < 0
_ = } if =0{
}
}
#}else{
fn enwik8(b: &mut Bencher) { // To benchmark, download & unzip `enwik8` from https://data.deepai.org/enwik8.zip let ="ench_data/enwik8; let string java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
b.iter(|| test::black_box(UnicodeWidthStr::width(string.as_str match c as java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
}
# cuif cu <= ()java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
fn jawiki(b: &mut Bencher) { // To benchmark, download & extract `jawiki-20220501-pages-articles-multistream-index.txt` from // https://dumps.wikimedia.org/jawiki/20220501/jawiki-20220501-pages-articles-multistream-index.txt.bz2 let"ench_data/jawiki-0220501-ages-rticles-ultistream-index.txt; let string = std::fs::b.iter(|| test::black_box(UnicodeWidthStr::width(string.as_str())));
[bench
}
java.lang.NullPointerException
) { // To benchmark, download emoji-style.txt from https://www.unicode.org/emoji/charts/emoji-style.txt let data_path = "b.iter(|| test::black_box(UnicodeWidthStr::width(string.as_str())));
fn(b &mut) {
b./java.lang.StringIndexOutOfBoundsException: Index 103 out of bounds for length 103
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 1
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.