From 20431706a863f92cb37dc512fef6e48d192aaf2c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:11:38 +0200 Subject: Merging upstream version 1.66.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/unicode-width/src/tests.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'vendor/unicode-width/src/tests.rs') 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 { _ => 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; -- cgit v1.2.3