1#![feature(test)]
2
3extern crate test;
4
5use regex_syntax::Parser;
6use test::Bencher;
7
8#[bench]
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]
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]
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]
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]
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]
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]
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