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:13:23 +0000
commit20431706a863f92cb37dc512fef6e48d192aaf2c (patch)
tree2867f13f5fd5437ba628c67d7f87309ccadcd286 /vendor/unicode-width/src/tests.rs
parentReleasing progress-linux version 1.65.0+dfsg1-2~progress7.99u1. (diff)
downloadrustc-20431706a863f92cb37dc512fef6e48d192aaf2c.tar.xz
rustc-20431706a863f92cb37dc512fef6e48d192aaf2c.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;