summaryrefslogtreecommitdiffstats
path: root/vendor/unicode-segmentation/benches/word_bounds.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/unicode-segmentation/benches/word_bounds.rs
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/unicode-segmentation/benches/word_bounds.rs')
-rw-r--r--vendor/unicode-segmentation/benches/word_bounds.rs55
1 files changed, 26 insertions, 29 deletions
diff --git a/vendor/unicode-segmentation/benches/word_bounds.rs b/vendor/unicode-segmentation/benches/word_bounds.rs
index 6b01ddb10..cae7a8819 100644
--- a/vendor/unicode-segmentation/benches/word_bounds.rs
+++ b/vendor/unicode-segmentation/benches/word_bounds.rs
@@ -1,55 +1,52 @@
-#[macro_use]
-extern crate bencher;
-extern crate unicode_segmentation;
+use criterion::{black_box, criterion_group, criterion_main, Criterion};
-use bencher::Bencher;
use std::fs;
use unicode_segmentation::UnicodeSegmentation;
-fn word_bounds(bench: &mut Bencher, path: &str) {
+fn word_bounds(c: &mut Criterion, lang: &str, path: &str) {
let text = fs::read_to_string(path).unwrap();
- bench.iter(|| {
- for w in text.split_word_bounds() {
- bencher::black_box(w);
- }
+ c.bench_function(&format!("word_bounds_{}", lang), |bench| {
+ bench.iter(|| {
+ for w in text.split_word_bounds() {
+ black_box(w);
+ }
+ });
});
-
- bench.bytes = text.len() as u64;
}
-fn word_bounds_arabic(bench: &mut Bencher) {
- word_bounds(bench, "benches/texts/arabic.txt");
+fn word_bounds_arabic(c: &mut Criterion) {
+ word_bounds(c, "arabic", "benches/texts/arabic.txt");
}
-fn word_bounds_english(bench: &mut Bencher) {
- word_bounds(bench, "benches/texts/english.txt");
+fn word_bounds_english(c: &mut Criterion) {
+ word_bounds(c, "english", "benches/texts/english.txt");
}
-fn word_bounds_hindi(bench: &mut Bencher) {
- word_bounds(bench, "benches/texts/hindi.txt");
+fn word_bounds_hindi(c: &mut Criterion) {
+ word_bounds(c, "hindi", "benches/texts/hindi.txt");
}
-fn word_bounds_japanese(bench: &mut Bencher) {
- word_bounds(bench, "benches/texts/japanese.txt");
+fn word_bounds_japanese(c: &mut Criterion) {
+ word_bounds(c, "japanese", "benches/texts/japanese.txt");
}
-fn word_bounds_korean(bench: &mut Bencher) {
- word_bounds(bench, "benches/texts/korean.txt");
+fn word_bounds_korean(c: &mut Criterion) {
+ word_bounds(c, "korean", "benches/texts/korean.txt");
}
-fn word_bounds_mandarin(bench: &mut Bencher) {
- word_bounds(bench, "benches/texts/mandarin.txt");
+fn word_bounds_mandarin(c: &mut Criterion) {
+ word_bounds(c, "mandarin", "benches/texts/mandarin.txt");
}
-fn word_bounds_russian(bench: &mut Bencher) {
- word_bounds(bench, "benches/texts/russian.txt");
+fn word_bounds_russian(c: &mut Criterion) {
+ word_bounds(c, "russian", "benches/texts/russian.txt");
}
-fn word_bounds_source_code(bench: &mut Bencher) {
- word_bounds(bench, "benches/texts/source_code.txt");
+fn word_bounds_source_code(c: &mut Criterion) {
+ word_bounds(c, "source_code", "benches/texts/source_code.txt");
}
-benchmark_group!(
+criterion_group!(
benches,
word_bounds_arabic,
word_bounds_english,
@@ -61,4 +58,4 @@ benchmark_group!(
word_bounds_source_code,
);
-benchmark_main!(benches);
+criterion_main!(benches);