diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:32 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:32 +0000 |
commit | 4547b622d8d29df964fa2914213088b148c498fc (patch) | |
tree | 9fc6b25f3c3add6b745be9a2400a6e96140046e9 /vendor/tinystr/benches | |
parent | Releasing progress-linux version 1.66.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-4547b622d8d29df964fa2914213088b148c498fc.tar.xz rustc-4547b622d8d29df964fa2914213088b148c498fc.zip |
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | vendor/tinystr/benches/common/mod.rs | 79 | ||||
-rw-r--r-- | vendor/tinystr/benches/construct.rs | 181 | ||||
-rw-r--r-- | vendor/tinystr/benches/overview.rs | 165 | ||||
-rw-r--r-- | vendor/tinystr/benches/read.rs | 34 | ||||
-rw-r--r-- | vendor/tinystr/benches/serde.rs | 37 | ||||
-rw-r--r-- | vendor/tinystr/benches/tinystr.rs | 176 |
6 files changed, 373 insertions, 299 deletions
diff --git a/vendor/tinystr/benches/common/mod.rs b/vendor/tinystr/benches/common/mod.rs new file mode 100644 index 000000000..07654e1d9 --- /dev/null +++ b/vendor/tinystr/benches/common/mod.rs @@ -0,0 +1,79 @@ +// This file is part of ICU4X. For terms of use, please see the file +// called LICENSE at the top level of the ICU4X source tree +// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +// This file was adapted from parts of https://github.com/zbraniecki/tinystr + +pub static STRINGS_4: &[&str] = &[ + "US", "GB", "AR", "Hans", "CN", "AT", "PL", "FR", "AT", "Cyrl", "SR", "NO", "FR", "MK", "UK", +]; + +pub static STRINGS_8: &[&str] = &[ + "Latn", "windows", "AR", "Hans", "macos", "AT", "pl", "FR", "en", "Cyrl", "SR", "NO", "419", + "und", "UK", +]; + +pub static STRINGS_16: &[&str] = &[ + "Latn", + "windows", + "AR", + "Hans", + "macos", + "AT", + "infiniband", + "FR", + "en", + "Cyrl", + "FromIntegral", + "NO", + "419", + "MacintoshOSX2019", + "UK", +]; + +#[macro_export] +macro_rules! bench_block { + ($c:expr, $name:expr, $action:ident) => { + let mut group4 = $c.benchmark_group(&format!("{}/4", $name)); + group4.bench_function("String", $action!(String, STRINGS_4)); + group4.bench_function("TinyAsciiStr<4>", $action!(TinyAsciiStr<4>, STRINGS_4)); + group4.bench_function( + "tinystr_old::TinyStr4", + $action!(tinystr_old::TinyStr4, STRINGS_4), + ); + group4.bench_function("TinyAsciiStr<8>", $action!(TinyAsciiStr<8>, STRINGS_4)); + group4.bench_function( + "tinystr_old::TinyStr8", + $action!(tinystr_old::TinyStr8, STRINGS_4), + ); + group4.bench_function("TinyAsciiStr<16>", $action!(TinyAsciiStr<16>, STRINGS_4)); + group4.bench_function( + "tinystr_old::TinyStr16", + $action!(tinystr_old::TinyStr16, STRINGS_4), + ); + group4.finish(); + + let mut group8 = $c.benchmark_group(&format!("{}/8", $name)); + group8.bench_function("String", $action!(String, STRINGS_8)); + group8.bench_function("TinyAsciiStr<8>", $action!(TinyAsciiStr<8>, STRINGS_8)); + group8.bench_function("TinyAsciiStr<16>", $action!(TinyAsciiStr<16>, STRINGS_8)); + group8.bench_function( + "tinystr_old::TinyStr8", + $action!(tinystr_old::TinyStr8, STRINGS_8), + ); + group8.bench_function( + "tinystr_old::TinyStr16", + $action!(tinystr_old::TinyStr16, STRINGS_8), + ); + group8.finish(); + + let mut group16 = $c.benchmark_group(&format!("{}/16", $name)); + group16.bench_function("String", $action!(String, STRINGS_16)); + group16.bench_function("TinyAsciiStr<16>", $action!(TinyAsciiStr<16>, STRINGS_16)); + group16.bench_function( + "tinystr_old::TinyStr16", + $action!(tinystr_old::TinyStr16, STRINGS_16), + ); + group16.finish(); + }; +} diff --git a/vendor/tinystr/benches/construct.rs b/vendor/tinystr/benches/construct.rs index a93fce8f6..145e721e1 100644 --- a/vendor/tinystr/benches/construct.rs +++ b/vendor/tinystr/benches/construct.rs @@ -1,91 +1,41 @@ +// This file is part of ICU4X. For terms of use, please see the file +// called LICENSE at the top level of the ICU4X source tree +// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +// This file was adapted from https://github.com/zbraniecki/tinystr + +mod common; +use common::*; + use criterion::black_box; use criterion::criterion_group; use criterion::criterion_main; use criterion::Bencher; use criterion::Criterion; -use criterion::Fun; - -use tinystr::{TinyStr16, TinyStr4, TinyStr8, TinyStrAuto}; - -static STRINGS_4: &[&str] = &[ - "US", "GB", "AR", "Hans", "CN", "AT", "PL", "FR", "AT", "Cyrl", "SR", "NO", "FR", "MK", "UK", -]; - -static STRINGS_8: &[&str] = &[ - "Latn", "windows", "AR", "Hans", "macos", "AT", "pl", "FR", "en", "Cyrl", "SR", "NO", "419", - "und", "UK", -]; - -static STRINGS_16: &[&str] = &[ - "Latn", - "windows", - "AR", - "Hans", - "macos", - "AT", - "infiniband", - "FR", - "en", - "Cyrl", - "FromIntegral", - "NO", - "419", - "MacintoshOSX2019", - "UK", -]; - -macro_rules! bench_block { - ($c:expr, $name:expr, $action:ident) => { - let funcs = vec![ - Fun::new("String", $action!(String)), - Fun::new("TinyStr4", $action!(TinyStr4)), - Fun::new("TinyStr8", $action!(TinyStr8)), - Fun::new("TinyStr16", $action!(TinyStr16)), - Fun::new("TinyStrAuto", $action!(TinyStrAuto)), - ]; - $c.bench_functions(&format!("{}/4", $name), funcs, STRINGS_4); - - let funcs = vec![ - Fun::new("String", $action!(String)), - Fun::new("TinyStr8", $action!(TinyStr8)), - Fun::new("TinyStr16", $action!(TinyStr16)), - Fun::new("TinyStrAuto", $action!(TinyStrAuto)), - ]; - - $c.bench_functions(&format!("{}/8", $name), funcs, STRINGS_8); - - let funcs = vec![ - Fun::new("String", $action!(String)), - Fun::new("TinyStr16", $action!(TinyStr16)), - Fun::new("TinyStrAuto", $action!(TinyStrAuto)), - ]; - - $c.bench_functions(&format!("{}/16", $name), funcs, STRINGS_16); - }; -} +use tinystr::TinyAsciiStr; fn construct_from_str(c: &mut Criterion) { macro_rules! cfs { - ($r:ty) => { - |b: &mut Bencher, strings: &&[&str]| { + ($r:ty, $inputs:expr) => { + |b: &mut Bencher| { b.iter(|| { - for s in *strings { + for s in $inputs { let _: $r = black_box(s.parse().unwrap()); } }) } }; - }; + } bench_block!(c, "construct_from_str", cfs); } fn construct_from_bytes(c: &mut Criterion) { macro_rules! cfu { - ($r:ty) => { - |b, inputs: &&[&str]| { - let raw: Vec<&[u8]> = inputs.iter().map(|s| s.as_bytes()).collect(); + ($r:ty, $inputs:expr) => { + |b| { + let raw: Vec<&[u8]> = $inputs.iter().map(|s| s.as_bytes()).collect(); b.iter(move || { for u in &raw { let _ = black_box(<$r>::from_bytes(*u).unwrap()); @@ -93,62 +43,47 @@ fn construct_from_bytes(c: &mut Criterion) { }) } }; - }; - - let funcs = vec![ - Fun::new("TinyStr4", cfu!(TinyStr4)), - Fun::new("TinyStr8", cfu!(TinyStr8)), - Fun::new("TinyStr16", cfu!(TinyStr16)), - ]; - - c.bench_functions("construct_from_bytes/4", funcs, STRINGS_4); - - let funcs = vec![ - Fun::new("TinyStr8", cfu!(TinyStr8)), - Fun::new("TinyStr16", cfu!(TinyStr16)), - ]; - - c.bench_functions("construct_from_bytes/8", funcs, STRINGS_8); - - let funcs = vec![Fun::new("TinyStr16", cfu!(TinyStr16))]; - - c.bench_functions("construct_from_bytes/16", funcs, STRINGS_16); -} - -fn construct_unchecked(c: &mut Criterion) { - macro_rules! cu { - ($tty:ty, $rty:ty) => { - |b, inputs: &&[&str]| { - let raw: Vec<$rty> = inputs - .iter() - .map(|s| s.parse::<$tty>().unwrap().into()) - .collect(); - b.iter(move || { - for num in &raw { - let _ = unsafe { <$tty>::new_unchecked(black_box(*num)) }; - } - }) - } - }; - }; - - let funcs = vec![Fun::new("TinyStr4", cu!(TinyStr4, u32))]; - - c.bench_functions("construct_unchecked/4", funcs, STRINGS_4); - - let funcs = vec![Fun::new("TinyStr8", cu!(TinyStr8, u64))]; - - c.bench_functions("construct_unchecked/8", funcs, STRINGS_8); - - let funcs = vec![Fun::new("TinyStr16", cu!(TinyStr16, u128))]; - - c.bench_functions("construct_unchecked/16", funcs, STRINGS_16); + } + + let mut group4 = c.benchmark_group("construct_from_bytes/4"); + group4.bench_function("TinyAsciiStr<4>", cfu!(TinyAsciiStr<4>, STRINGS_4)); + group4.bench_function( + "tinystr_old::TinyStr4", + cfu!(tinystr_old::TinyStr4, STRINGS_4), + ); + group4.bench_function("TinyAsciiStr<8>", cfu!(TinyAsciiStr<8>, STRINGS_4)); + group4.bench_function( + "tinystr_old::TinyStr8", + cfu!(tinystr_old::TinyStr8, STRINGS_4), + ); + group4.bench_function("TinyAsciiStr<16>", cfu!(TinyAsciiStr<16>, STRINGS_4)); + group4.bench_function( + "tinystr_old::TinyStr16", + cfu!(tinystr_old::TinyStr16, STRINGS_4), + ); + group4.finish(); + + let mut group8 = c.benchmark_group("construct_from_bytes/8"); + group8.bench_function("TinyAsciiStr<8>", cfu!(TinyAsciiStr<8>, STRINGS_8)); + group8.bench_function( + "tinystr_old::TinyStr8", + cfu!(tinystr_old::TinyStr8, STRINGS_8), + ); + group8.bench_function("TinyAsciiStr<16>", cfu!(TinyAsciiStr<16>, STRINGS_8)); + group8.bench_function( + "tinystr_old::TinyStr16", + cfu!(tinystr_old::TinyStr16, STRINGS_8), + ); + group8.finish(); + + let mut group16 = c.benchmark_group("construct_from_bytes/16"); + group16.bench_function("TinyAsciiStr<16>", cfu!(TinyAsciiStr<16>, STRINGS_16)); + group16.bench_function( + "tinystr_old::TinyStr16", + cfu!(tinystr_old::TinyStr16, STRINGS_16), + ); + group16.finish(); } -criterion_group!( - benches, - construct_from_str, - construct_from_bytes, - construct_unchecked, -); +criterion_group!(benches, construct_from_str, construct_from_bytes,); criterion_main!(benches); diff --git a/vendor/tinystr/benches/overview.rs b/vendor/tinystr/benches/overview.rs new file mode 100644 index 000000000..4911832ec --- /dev/null +++ b/vendor/tinystr/benches/overview.rs @@ -0,0 +1,165 @@ +// This file is part of ICU4X. For terms of use, please see the file +// called LICENSE at the top level of the ICU4X source tree +// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +mod common; +use common::*; + +use criterion::black_box; +use criterion::criterion_group; +use criterion::criterion_main; +use criterion::Criterion; + +use tinystr::TinyAsciiStr; +use tinystr_old::TinyStr16; +use tinystr_old::TinyStr4; +use tinystr_old::TinyStr8; + +fn overview(c: &mut Criterion) { + let mut g = c.benchmark_group("overview"); + + g.bench_function("construct/TinyAsciiStr", |b| { + b.iter(|| { + for s in STRINGS_4 { + let _: TinyAsciiStr<4> = black_box(s).parse().unwrap(); + let _: TinyAsciiStr<8> = black_box(s).parse().unwrap(); + let _: TinyAsciiStr<16> = black_box(s).parse().unwrap(); + } + for s in STRINGS_8 { + let _: TinyAsciiStr<8> = black_box(s).parse().unwrap(); + let _: TinyAsciiStr<16> = black_box(s).parse().unwrap(); + } + for s in STRINGS_16 { + let _: TinyAsciiStr<16> = black_box(s).parse().unwrap(); + } + }); + }); + + g.bench_function("construct/TinyStr", |b| { + b.iter(|| { + for s in STRINGS_4 { + let _: TinyStr4 = black_box(s).parse().unwrap(); + let _: TinyStr8 = black_box(s).parse().unwrap(); + let _: TinyStr16 = black_box(s).parse().unwrap(); + } + for s in STRINGS_8 { + let _: TinyStr8 = black_box(s).parse().unwrap(); + let _: TinyStr16 = black_box(s).parse().unwrap(); + } + for s in STRINGS_16 { + let _: TinyStr16 = black_box(s).parse().unwrap(); + } + }); + }); + + let parsed_ascii_4: Vec<TinyAsciiStr<4>> = STRINGS_4 + .iter() + .map(|s| s.parse::<TinyAsciiStr<4>>().unwrap()) + .collect(); + let parsed_ascii_8: Vec<TinyAsciiStr<8>> = STRINGS_4 + .iter() + .chain(STRINGS_8) + .map(|s| s.parse::<TinyAsciiStr<8>>().unwrap()) + .collect(); + let parsed_ascii_16: Vec<TinyAsciiStr<16>> = STRINGS_4 + .iter() + .chain(STRINGS_8) + .chain(STRINGS_16) + .map(|s| s.parse::<TinyAsciiStr<16>>().unwrap()) + .collect(); + + let parsed_tiny_4: Vec<TinyStr4> = STRINGS_4 + .iter() + .map(|s| s.parse::<TinyStr4>().unwrap()) + .collect(); + let parsed_tiny_8: Vec<TinyStr8> = STRINGS_4 + .iter() + .chain(STRINGS_8) + .map(|s| s.parse::<TinyStr8>().unwrap()) + .collect(); + let parsed_tiny_16: Vec<TinyStr16> = STRINGS_4 + .iter() + .chain(STRINGS_8) + .chain(STRINGS_16) + .map(|s| s.parse::<TinyStr16>().unwrap()) + .collect(); + + g.bench_function("read/TinyAsciiStr", |b| { + b.iter(|| { + let mut collector: usize = 0; + for t in black_box(&parsed_ascii_4) { + let s: &str = t; + collector += s.bytes().map(usize::from).sum::<usize>(); + } + for t in black_box(&parsed_ascii_8) { + let s: &str = t; + collector += s.bytes().map(usize::from).sum::<usize>(); + } + for t in black_box(&parsed_ascii_16) { + let s: &str = t; + collector += s.bytes().map(usize::from).sum::<usize>(); + } + collector + }); + }); + + g.bench_function("read/TinyStr", |b| { + b.iter(|| { + let mut collector: usize = 0; + for t in black_box(&parsed_tiny_4) { + let s: &str = t; + collector += s.bytes().map(usize::from).sum::<usize>(); + } + for t in black_box(&parsed_tiny_8) { + let s: &str = t; + collector += s.bytes().map(usize::from).sum::<usize>(); + } + for t in black_box(&parsed_tiny_16) { + let s: &str = t; + collector += s.bytes().map(usize::from).sum::<usize>(); + } + collector + }); + }); + + g.bench_function("compare/TinyAsciiStr", |b| { + b.iter(|| { + let mut collector: usize = 0; + for ts in black_box(&parsed_ascii_4).windows(2) { + let o = ts[0].cmp(&ts[1]); + collector ^= o as usize; + } + for ts in black_box(&parsed_ascii_8).windows(2) { + let o = ts[0].cmp(&ts[1]); + collector ^= o as usize; + } + for ts in black_box(&parsed_ascii_16).windows(2) { + let o = ts[0].cmp(&ts[1]); + collector ^= o as usize; + } + collector + }); + }); + + g.bench_function("compare/TinyStr", |b| { + b.iter(|| { + let mut collector: usize = 0; + for ts in black_box(&parsed_tiny_4).windows(2) { + let o = ts[0].cmp(&ts[1]); + collector ^= o as usize; + } + for ts in black_box(&parsed_tiny_8).windows(2) { + let o = ts[0].cmp(&ts[1]); + collector ^= o as usize; + } + for ts in black_box(&parsed_tiny_16).windows(2) { + let o = ts[0].cmp(&ts[1]); + collector ^= o as usize; + } + collector + }); + }); +} + +criterion_group!(benches, overview,); +criterion_main!(benches); diff --git a/vendor/tinystr/benches/read.rs b/vendor/tinystr/benches/read.rs new file mode 100644 index 000000000..793bb14f8 --- /dev/null +++ b/vendor/tinystr/benches/read.rs @@ -0,0 +1,34 @@ +// This file is part of ICU4X. For terms of use, please see the file +// called LICENSE at the top level of the ICU4X source tree +// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +mod common; +use common::*; + +use criterion::black_box; +use criterion::criterion_group; +use criterion::criterion_main; +use criterion::Bencher; +use criterion::Criterion; + +use tinystr::TinyAsciiStr; + +fn read(c: &mut Criterion) { + macro_rules! cfs { + ($r:ty, $inputs:expr) => { + |b: &mut Bencher| { + let parsed: Vec<$r> = $inputs.iter().map(|s| s.parse().unwrap()).collect(); + b.iter(|| { + for s in &parsed { + let _: &str = black_box(&**s); + } + }) + } + }; + } + + bench_block!(c, "read", cfs); +} + +criterion_group!(benches, read,); +criterion_main!(benches); diff --git a/vendor/tinystr/benches/serde.rs b/vendor/tinystr/benches/serde.rs new file mode 100644 index 000000000..b0341221d --- /dev/null +++ b/vendor/tinystr/benches/serde.rs @@ -0,0 +1,37 @@ +// This file is part of ICU4X. For terms of use, please see the file +// called LICENSE at the top level of the ICU4X source tree +// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +mod common; +use common::*; + +use criterion::black_box; +use criterion::criterion_group; +use criterion::criterion_main; +use criterion::Bencher; +use criterion::Criterion; + +use tinystr::TinyAsciiStr; + +fn deserialize(c: &mut Criterion) { + macro_rules! cfs { + ($r:ty, $inputs:expr) => { + |b: &mut Bencher| { + let serialized: Vec<Vec<u8>> = $inputs + .iter() + .map(|s| postcard::to_stdvec(&s.parse::<$r>().unwrap()).unwrap()) + .collect(); + b.iter(|| { + for bytes in &serialized { + let _: Result<$r, _> = black_box(postcard::from_bytes(bytes)); + } + }) + } + }; + } + + bench_block!(c, "deserialize", cfs); +} + +criterion_group!(benches, deserialize,); +criterion_main!(benches); diff --git a/vendor/tinystr/benches/tinystr.rs b/vendor/tinystr/benches/tinystr.rs deleted file mode 100644 index 83b26a30a..000000000 --- a/vendor/tinystr/benches/tinystr.rs +++ /dev/null @@ -1,176 +0,0 @@ -use criterion::black_box; -use criterion::criterion_group; -use criterion::criterion_main; -use criterion::Bencher; -use criterion::Criterion; -use criterion::Fun; - -use tinystr::{TinyStr16, TinyStr4, TinyStr8}; - -static STRINGS_4: &[&str] = &[ - "US", "GB", "AR", "Hans", "CN", "AT", "PL", "FR", "AT", "Cyrl", "SR", "NO", "FR", "MK", "UK", -]; - -static STRINGS_8: &[&str] = &[ - "Latn", "windows", "AR", "Hans", "macos", "AT", "pl", "FR", "en", "Cyrl", "SR", "NO", "419", - "und", "UK", -]; - -static STRINGS_16: &[&str] = &[ - "Latn", - "windows", - "AR", - "Hans", - "macos", - "AT", - "infiniband", - "FR", - "en", - "Cyrl", - "FromIntegral", - "NO", - "419", - "MacintoshOSX2019", - "UK", -]; - -macro_rules! bench_block { - ($c:expr, $name:expr, $action:ident) => { - let funcs = vec![ - Fun::new("String", $action!(String)), - Fun::new("TinyStr4", $action!(TinyStr4)), - Fun::new("TinyStr8", $action!(TinyStr8)), - Fun::new("TinyStr16", $action!(TinyStr16)), - ]; - - $c.bench_functions(&format!("{}/4", $name), funcs, STRINGS_4); - - let funcs = vec![ - Fun::new("String", $action!(String)), - Fun::new("TinyStr8", $action!(TinyStr8)), - Fun::new("TinyStr16", $action!(TinyStr16)), - ]; - - $c.bench_functions(&format!("{}/8", $name), funcs, STRINGS_8); - - let funcs = vec![ - Fun::new("String", $action!(String)), - Fun::new("TinyStr16", $action!(TinyStr16)), - ]; - - $c.bench_functions(&format!("{}/16", $name), funcs, STRINGS_16); - }; -} - -macro_rules! convert_to_ascii { - ($ty:ty, $action:ident) => { - |b: &mut Bencher, inputs: &&[&str]| { - let raw: Vec<$ty> = inputs.iter().map(|s| s.parse::<$ty>().unwrap()).collect(); - b.iter(move || { - for s in &raw { - let _ = black_box(s.$action()); - } - }) - } - }; -} - -fn convert_to_ascii_lowercase(c: &mut Criterion) { - macro_rules! ctal { - ($ty:ty) => { - convert_to_ascii!($ty, to_ascii_lowercase) - }; - } - - bench_block!(c, "convert_to_ascii_lowercase", ctal); -} - -fn convert_to_ascii_uppercase(c: &mut Criterion) { - macro_rules! ctau { - ($ty:ty) => { - convert_to_ascii!($ty, to_ascii_uppercase) - }; - } - - bench_block!(c, "convert_to_ascii_uppercase", ctau); -} - -trait ExtToAsciiTitlecase { - #[inline(always)] - fn to_ascii_titlecase(&self) -> String; -} - -impl ExtToAsciiTitlecase for str { - fn to_ascii_titlecase(&self) -> String { - let mut result = self.to_ascii_lowercase(); - result[0..1].make_ascii_uppercase(); - result - } -} - -fn convert_to_ascii_titlecase(c: &mut Criterion) { - macro_rules! ctat { - ($ty:ty) => { - convert_to_ascii!($ty, to_ascii_titlecase) - }; - } - - bench_block!(c, "convert_to_ascii_titlecase", ctat); -} - -trait ExtIsAsciiAlphanumeric { - #[inline(always)] - fn is_ascii_alphanumeric(&self) -> bool; -} - -impl ExtIsAsciiAlphanumeric for str { - fn is_ascii_alphanumeric(&self) -> bool { - self.chars().all(|c| c.is_ascii_alphanumeric()) - } -} - -fn test_is_ascii_alphanumeric(c: &mut Criterion) { - macro_rules! tiaa { - ($ty:ty) => { - |b: &mut Bencher, inputs: &&[&str]| { - let raw: Vec<$ty> = inputs.iter().map(|s| s.parse::<$ty>().unwrap()).collect(); - b.iter(move || { - for s in &raw { - let _ = black_box(s.is_ascii_alphanumeric()); - } - }) - } - }; - } - - bench_block!(c, "test_is_ascii_alphanumeric", tiaa); -} - -fn test_eq(c: &mut Criterion) { - macro_rules! te { - ($ty:ty) => { - |b: &mut Bencher, inputs: &&[&str]| { - let raw: Vec<$ty> = inputs.iter().map(|s| s.parse::<$ty>().unwrap()).collect(); - b.iter(move || { - for s in &raw { - for l in &raw { - let _ = black_box(s == l); - } - } - }) - } - }; - } - - bench_block!(c, "test_eq", te); -} - -criterion_group!( - benches, - convert_to_ascii_lowercase, - convert_to_ascii_uppercase, - convert_to_ascii_titlecase, - test_is_ascii_alphanumeric, - test_eq, -); -criterion_main!(benches); |