Merge branch 'rs/find-pack-entry-bisection'
[git] / t / perf / p7820-grep-engines.sh
1 #!/bin/sh
2
3 test_description="Comparison of git-grep's regex engines
4
5 Set GIT_PERF_7820_GREP_OPTS in the environment to pass options to
6 git-grep. Make sure to include a leading space,
7 e.g. GIT_PERF_7820_GREP_OPTS=' -i'. Some options to try:
8
9         -i
10         -w
11         -v
12         -vi
13         -vw
14         -viw
15 "
16
17 . ./perf-lib.sh
18
19 test_perf_large_repo
20 test_checkout_worktree
21
22 for pattern in \
23         'how.to' \
24         '^how to' \
25         '[how] to' \
26         '\(e.t[^ ]*\|v.ry\) rare' \
27         'm\(ú\|u\)lt.b\(æ\|y\)te'
28 do
29         for engine in basic extended perl
30         do
31                 if test $engine != "basic"
32                 then
33                         # Poor man's basic -> extended converter.
34                         pattern=$(echo "$pattern" | sed 's/\\//g')
35                 fi
36                 if test $engine = "perl" && ! test_have_prereq PCRE
37                 then
38                         prereq="PCRE"
39                 else
40                         prereq=""
41                 fi
42                 test_perf $prereq "$engine grep$GIT_PERF_7820_GREP_OPTS '$pattern'" "
43                         git -c grep.patternType=$engine grep$GIT_PERF_7820_GREP_OPTS -- '$pattern' >'out.$engine' || :
44                 "
45         done
46
47         test_expect_success "assert that all engines found the same for$GIT_PERF_7820_GREP_OPTS '$pattern'" '
48                 test_cmp out.basic out.extended &&
49                 if test_have_prereq PCRE
50                 then
51                         test_cmp out.basic out.perl
52                 fi
53         '
54 done
55
56 test_done