Debian Codegraph @

debian/missing-sources/utf-8/benches/from_utf8_lossy.rs

raw
1 #![feature(test)]
2
3 extern crate test;
4 extern crate utf8;
5
6 #[path = "../tests/shared/data.rs"]
7 mod data;
8
9 #[path = "../tests/shared/string_from_utf8_lossy.rs"]
10 mod string_from_utf8_lossy;
11
12 #[bench]
13 fn bench_our_string_from_utf8_lossy(bencher: &mut test::Bencher) {
14 bencher.bytes = data::DECODED_LOSSY.iter().map(|&(input, _expected)| input.len() as u64).sum();
15 bencher.iter(|| {
16 for &(input, _expected) in data::DECODED_LOSSY {
17 test::black_box(string_from_utf8_lossy::string_from_utf8_lossy(input));
18 }
19 })
20 }
21
22 #[bench]
23 fn bench_std_string_from_utf8_lossy(bencher: &mut test::Bencher) {
24 bencher.bytes = data::DECODED_LOSSY.iter().map(|&(input, _expected)| input.len() as u64).sum();
25 bencher.iter(|| {
26 for &(input, _expected) in data::DECODED_LOSSY {
27 test::black_box(String::from_utf8_lossy(input));
28 }
29 })
30 }