1 #![feature(test)]
2 
3 extern crate test;
4 extern crate utf8_ranges;
5 
6 use test::Bencher;
7 use utf8_ranges::Utf8Sequences;
8 
9 #[bench]
no_reuse(b: &mut Bencher)10 fn no_reuse(b: &mut Bencher) {
11     b.iter(|| {
12         let count = Utf8Sequences::new('\u{0}', '\u{10FFFF}').count();
13         assert_eq!(count, 9);
14     })
15 }
16 
17 #[bench]
reuse(b: &mut Bencher)18 fn reuse(b: &mut Bencher) {
19     let mut seqs = Utf8Sequences::new('\u{0}', '\u{10FFFF}');
20     b.iter(|| {
21         seqs.reset('\u{0}', '\u{10FFFF}');
22         let count = (&mut seqs).count();
23         assert_eq!(count, 9);
24     })
25 }
26