1 use regex_syntax::Expr; 2 use test::Bencher; 3 4 #[bench] parse_simple(b: &mut Bencher)5fn parse_simple(b: &mut Bencher) { 6 b.iter(|| { 7 let re = r"^bc(d|e)*$"; 8 Expr::parse(re).unwrap() 9 }); 10 } 11 12 #[bench] parse_simple2(b: &mut Bencher)13fn parse_simple2(b: &mut Bencher) { 14 b.iter(|| { 15 let re = r"'[a-zA-Z_][a-zA-Z0-9_]*(')\b"; 16 Expr::parse(re).unwrap() 17 }); 18 } 19 20 #[bench] parse_small(b: &mut Bencher)21fn parse_small(b: &mut Bencher) { 22 b.iter(|| { 23 let re = r"\p{L}|\p{N}|\s|.|\d"; 24 Expr::parse(re).unwrap() 25 }); 26 } 27 28 #[bench] parse_huge(b: &mut Bencher)29fn parse_huge(b: &mut Bencher) { 30 b.iter(|| { 31 let re = r"\p{L}{100}"; 32 Expr::parse(re).unwrap() 33 }); 34 } 35