• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // This file is part of ICU4X. For terms of use, please see the file
2 // called LICENSE at the top level of the ICU4X source tree
3 // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4 
5 mod common;
6 use common::*;
7 
8 use criterion::black_box;
9 use criterion::criterion_group;
10 use criterion::criterion_main;
11 use criterion::Bencher;
12 use criterion::Criterion;
13 
14 use tinystr::TinyAsciiStr;
15 
read(c: &mut Criterion)16 fn read(c: &mut Criterion) {
17     macro_rules! cfs {
18         ($r:ty, $inputs:expr) => {
19             |b: &mut Bencher| {
20                 let parsed: Vec<$r> = $inputs.iter().map(|s| s.parse().unwrap()).collect();
21                 b.iter(|| {
22                     for s in &parsed {
23                         let _: &str = black_box(&**s);
24                     }
25                 })
26             }
27         };
28     }
29 
30     bench_block!(c, "read", cfs);
31 }
32 
33 criterion_group!(benches, read,);
34 criterion_main!(benches);
35