1 #![feature(test)] 2 3 extern crate test; 4 5 use regex_syntax::Parser; 6 use test::Bencher; 7 8 #[bench] parse_simple1(b: &mut Bencher)9fn parse_simple1(b: &mut Bencher) { 10 b.iter(|| { 11 let re = r"^bc(d|e)*$"; 12 Parser::new().parse(re).unwrap() 13 }); 14 } 15 16 #[bench] parse_simple2(b: &mut Bencher)17fn parse_simple2(b: &mut Bencher) { 18 b.iter(|| { 19 let re = r"'[a-zA-Z_][a-zA-Z0-9_]*(')\b"; 20 Parser::new().parse(re).unwrap() 21 }); 22 } 23 24 #[bench] parse_small1(b: &mut Bencher)25fn parse_small1(b: &mut Bencher) { 26 b.iter(|| { 27 let re = r"\p{L}|\p{N}|\s|.|\d"; 28 Parser::new().parse(re).unwrap() 29 }); 30 } 31 32 #[bench] parse_medium1(b: &mut Bencher)33fn parse_medium1(b: &mut Bencher) { 34 b.iter(|| { 35 let re = r"\pL\p{Greek}\p{Hiragana}\p{Alphabetic}\p{Hebrew}\p{Arabic}"; 36 Parser::new().parse(re).unwrap() 37 }); 38 } 39 40 #[bench] parse_medium2(b: &mut Bencher)41fn parse_medium2(b: &mut Bencher) { 42 b.iter(|| { 43 let re = r"\s\S\w\W\d\D"; 44 Parser::new().parse(re).unwrap() 45 }); 46 } 47 48 #[bench] parse_medium3(b: &mut Bencher)49fn parse_medium3(b: &mut Bencher) { 50 b.iter(|| { 51 let re = 52 r"\p{age:3.2}\p{hira}\p{scx:hira}\p{alphabetic}\p{sc:Greek}\pL"; 53 Parser::new().parse(re).unwrap() 54 }); 55 } 56 57 #[bench] parse_huge(b: &mut Bencher)58fn parse_huge(b: &mut Bencher) { 59 b.iter(|| { 60 let re = r"\p{L}{100}"; 61 Parser::new().parse(re).unwrap() 62 }); 63 } 64