t / perf / p7820-grep-engines.shon commit Merge branch 'nd/diff-flush-before-warning' (17c8e0b)
   1#!/bin/sh
   2
   3test_description="Comparison of git-grep's regex engines
   4
   5Set GIT_PERF_7820_GREP_OPTS in the environment to pass options to
   6git-grep. Make sure to include a leading space,
   7e.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
  16If GIT_PERF_GREP_THREADS is set to a list of threads (e.g. '1 4 8'
  17etc.) we will test the patterns under those numbers of threads.
  18"
  19
  20. ./perf-lib.sh
  21
  22test_perf_large_repo
  23test_checkout_worktree
  24
  25if test -n "$GIT_PERF_GREP_THREADS"
  26then
  27        test_set_prereq PERF_GREP_ENGINES_THREADS
  28fi
  29
  30for pattern in \
  31        'how.to' \
  32        '^how to' \
  33        '[how] to' \
  34        '\(e.t[^ ]*\|v.ry\) rare' \
  35        'm\(ú\|u\)lt.b\(æ\|y\)te'
  36do
  37        for engine in basic extended perl
  38        do
  39                if test $engine != "basic"
  40                then
  41                        # Poor man's basic -> extended converter.
  42                        pattern=$(echo "$pattern" | sed 's/\\//g')
  43                fi
  44                if test $engine = "perl" && ! test_have_prereq PCRE
  45                then
  46                        prereq="PCRE"
  47                else
  48                        prereq=""
  49                fi
  50                if ! test_have_prereq PERF_GREP_ENGINES_THREADS
  51                then
  52                        test_perf $prereq "$engine grep$GIT_PERF_7820_GREP_OPTS '$pattern'" "
  53                                git -c grep.patternType=$engine grep$GIT_PERF_7820_GREP_OPTS -- '$pattern' >'out.$engine' || :
  54                        "
  55                else
  56                        for threads in $GIT_PERF_GREP_THREADS
  57                        do
  58                                test_perf PTHREADS,$prereq "$engine grep$GIT_PERF_7820_GREP_OPTS '$pattern' with $threads threads" "
  59                                        git -c grep.patternType=$engine -c grep.threads=$threads grep$GIT_PERF_7820_GREP_OPTS -- '$pattern' >'out.$engine.$threads' || :
  60                                "
  61                        done
  62                fi
  63        done
  64
  65        if ! test_have_prereq PERF_GREP_ENGINES_THREADS
  66        then
  67                test_expect_success "assert that all engines found the same for$GIT_PERF_7820_GREP_OPTS '$pattern'" '
  68                        test_cmp out.basic out.extended &&
  69                        if test_have_prereq PCRE
  70                        then
  71                                test_cmp out.basic out.perl
  72                        fi
  73                '
  74        else
  75                for threads in $GIT_PERF_GREP_THREADS
  76                do
  77                        test_expect_success PTHREADS "assert that all engines found the same for$GIT_PERF_7820_GREP_OPTS '$pattern' under threading" "
  78                                test_cmp out.basic.$threads out.extended.$threads &&
  79                                if test_have_prereq PCRE
  80                                then
  81                                        test_cmp out.basic.$threads out.perl.$threads
  82                                fi
  83                        "
  84                done
  85        fi
  86done
  87
  88test_done