summaryrefslogtreecommitdiffstats
path: root/vendor/unicode-width/src/tests.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:11:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:12:43 +0000
commitcf94bdc0742c13e2a0cac864c478b8626b266e1b (patch)
tree044670aa50cc5e2b4229aa0b6b3df6676730c0a6 /vendor/unicode-width/src/tests.rs
parentAdding debian version 1.65.0+dfsg1-2. (diff)
downloadrustc-cf94bdc0742c13e2a0cac864c478b8626b266e1b.tar.xz
rustc-cf94bdc0742c13e2a0cac864c478b8626b266e1b.zip
Merging upstream version 1.66.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/unicode-width/src/tests.rs')
-rw-r--r--vendor/unicode-width/src/tests.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/vendor/unicode-width/src/tests.rs b/vendor/unicode-width/src/tests.rs
index 72808c64f..e49b1bfbe 100644
--- a/vendor/unicode-width/src/tests.rs
+++ b/vendor/unicode-width/src/tests.rs
@@ -13,7 +13,7 @@ use std::iter;
#[cfg(feature = "bench")]
use test::{self, Bencher};
#[cfg(feature = "bench")]
-use super::UnicodeWidthChar;
+use super::{UnicodeWidthChar, UnicodeWidthStr};
use std::prelude::v1::*;
@@ -93,7 +93,23 @@ fn simple_width_match(c: char) -> Option<usize> {
_ => UnicodeWidthChar::width(c)
}
}
-
+#[cfg(all(feature = "bench", not(feature = "no_std")))]
+#[bench]
+fn enwik8(b: &mut Bencher) {
+ // To benchmark, download & unzip `enwik8` from https://data.deepai.org/enwik8.zip
+ let data_path = "bench_data/enwik8";
+ let string = std::fs::read_to_string(data_path).unwrap_or_default();
+ b.iter(|| test::black_box(UnicodeWidthStr::width(string.as_str())));
+}
+#[cfg(all(feature = "bench", not(feature = "no_std")))]
+#[bench]
+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 data_path = "bench_data/jawiki-20220501-pages-articles-multistream-index.txt";
+ let string = std::fs::read_to_string(data_path).unwrap_or_default();
+ b.iter(|| test::black_box(UnicodeWidthStr::width(string.as_str())));
+}
#[test]
fn test_str() {
use super::UnicodeWidthStr;