mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-26 14:43:24 +00:00
std::str: Bench test for char iterators
This commit is contained in:
parent
680eb71564
commit
548bdbaa29
@ -3267,6 +3267,62 @@ mod tests {
|
||||
mod bench {
|
||||
use extra::test::BenchHarness;
|
||||
use super::*;
|
||||
use prelude::*;
|
||||
|
||||
#[bench]
|
||||
fn char_iterator(bh: &mut BenchHarness) {
|
||||
let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
|
||||
let len = s.char_len();
|
||||
|
||||
do bh.iter {
|
||||
assert_eq!(s.iter().len(), len);
|
||||
}
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn char_iterator_ascii(bh: &mut BenchHarness) {
|
||||
let s = "Mary had a little lamb, Little lamb
|
||||
Mary had a little lamb, Little lamb
|
||||
Mary had a little lamb, Little lamb
|
||||
Mary had a little lamb, Little lamb
|
||||
Mary had a little lamb, Little lamb
|
||||
Mary had a little lamb, Little lamb";
|
||||
let len = s.char_len();
|
||||
|
||||
do bh.iter {
|
||||
assert_eq!(s.iter().len(), len);
|
||||
}
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn char_iterator_rev(bh: &mut BenchHarness) {
|
||||
let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
|
||||
let len = s.char_len();
|
||||
|
||||
do bh.iter {
|
||||
assert_eq!(s.rev_iter().len(), len);
|
||||
}
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn char_offset_iterator(bh: &mut BenchHarness) {
|
||||
let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
|
||||
let len = s.char_len();
|
||||
|
||||
do bh.iter {
|
||||
assert_eq!(s.char_offset_iter().len(), len);
|
||||
}
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn char_offset_iterator_rev(bh: &mut BenchHarness) {
|
||||
let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
|
||||
let len = s.char_len();
|
||||
|
||||
do bh.iter {
|
||||
assert_eq!(s.char_offset_rev_iter().len(), len);
|
||||
}
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn is_utf8_100_ascii(bh: &mut BenchHarness) {
|
||||
|
Loading…
Reference in New Issue
Block a user