File tree Expand file tree Collapse file tree 2 files changed +46
-1
lines changed
branches/snap-stage3/src/libstd Expand file tree Collapse file tree 2 files changed +46
-1
lines changed Original file line number Diff line number Diff line change 1
1
---
2
2
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
- refs/heads/snap-stage3: 786318f61b3d41238937d194970d2aaac34886cd
4
+ refs/heads/snap-stage3: e5cbede103fca018089b113ec35f0cf863df7106
5
5
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
Original file line number Diff line number Diff line change @@ -3532,3 +3532,48 @@ mod tests {
3532
3532
assert_eq!(5, sum_len([s.as_slice()]));
3533
3533
}
3534
3534
}
3535
+
3536
+ #[cfg(test)]
3537
+ mod bench {
3538
+ use extra::test::BenchHarness;
3539
+ use str;
3540
+
3541
+ #[bench]
3542
+ fn is_utf8_100_ascii(bh: &mut BenchHarness) {
3543
+
3544
+ let s = bytes!(" Hello there, the quick brown fox jumped over the lazy dog! \
3545
+ Lorem ipsum dolor sit amet, consectetur. ");
3546
+
3547
+ assert_eq!(100, s.len());
3548
+ do bh.iter {
3549
+ str::is_utf8(s);
3550
+ }
3551
+ }
3552
+
3553
+ #[bench]
3554
+ fn is_utf8_100_multibyte(bh: &mut BenchHarness) {
3555
+ let s = bytes!(" 𐌀𐌖𐌋𐌄𐌑𐌉ปรدولة الكويتทศไทย中华𐍅𐌿𐌻𐍆𐌹𐌻𐌰");
3556
+ assert_eq!(100, s.len());
3557
+ do bh.iter {
3558
+ str::is_utf8(s);
3559
+ }
3560
+ }
3561
+
3562
+ #[bench]
3563
+ fn map_chars_100_ascii(bh: &mut BenchHarness) {
3564
+ let s = " HelloHelloHelloHelloHelloHelloHelloHelloHelloHello \
3565
+ HelloHelloHelloHelloHelloHelloHelloHelloHelloHello ";
3566
+ do bh.iter {
3567
+ s.map_chars(|c| ((c as uint) + 1) as char);
3568
+ }
3569
+ }
3570
+
3571
+ #[bench]
3572
+ fn map_chars_100_multibytes(bh: &mut BenchHarness) {
3573
+ let s = " 𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑\
3574
+ 𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑𐌀𐌖𐌋𐌄𐌑" ;
3575
+ do bh. iter {
3576
+ s. map_chars( |c| ( ( c as uint) + 1 ) as char ) ;
3577
+ }
3578
+ }
3579
+ }
You can’t perform that action at this time.
0 commit comments