Skip to content

Commit af38dee

Browse files
committed
Merge branch 'ab/perf-grep-threads' into maint
More perf tests for threaded grep * ab/perf-grep-threads: perf: amend the grep tests to test grep.threads
2 parents 8279ed0 + 7b31b55 commit af38dee

File tree

2 files changed

+86
-21
lines changed

2 files changed

+86
-21
lines changed

t/perf/p7820-grep-engines.sh

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,21 @@ e.g. GIT_PERF_7820_GREP_OPTS=' -i'. Some options to try:
1212
-vi
1313
-vw
1414
-viw
15+
16+
If GIT_PERF_GREP_THREADS is set to a list of threads (e.g. '1 4 8'
17+
etc.) we will test the patterns under those numbers of threads.
1518
"
1619

1720
. ./perf-lib.sh
1821

1922
test_perf_large_repo
2023
test_checkout_worktree
2124

25+
if test -n "$GIT_PERF_GREP_THREADS"
26+
then
27+
test_set_prereq PERF_GREP_ENGINES_THREADS
28+
fi
29+
2230
for pattern in \
2331
'how.to' \
2432
'^how to' \
@@ -39,18 +47,42 @@ do
3947
else
4048
prereq=""
4149
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+
if ! test_have_prereq PERF_GREP_ENGINES_THREADS
5051
then
51-
test_cmp out.basic out.perl
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
5262
fi
53-
'
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
5486
done
5587

5688
test_done

t/perf/p7821-grep-engines-fixed.sh

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,21 @@ Set GIT_PERF_7821_GREP_OPTS in the environment to pass options to
66
git-grep. Make sure to include a leading space,
77
e.g. GIT_PERF_7821_GREP_OPTS=' -w'. See p7820-grep-engines.sh for more
88
options to try.
9+
10+
If GIT_PERF_7821_THREADS is set to a list of threads (e.g. '1 4 8'
11+
etc.) we will test the patterns under those numbers of threads.
912
"
1013

1114
. ./perf-lib.sh
1215

1316
test_perf_large_repo
1417
test_checkout_worktree
1518

19+
if test -n "$GIT_PERF_GREP_THREADS"
20+
then
21+
test_set_prereq PERF_GREP_ENGINES_THREADS
22+
fi
23+
1624
for pattern in 'int' 'uncommon' 'æ'
1725
do
1826
for engine in fixed basic extended perl
@@ -23,19 +31,44 @@ do
2331
else
2432
prereq=""
2533
fi
26-
test_perf $prereq "$engine grep$GIT_PERF_7821_GREP_OPTS $pattern" "
27-
git -c grep.patternType=$engine grep$GIT_PERF_7821_GREP_OPTS $pattern >'out.$engine' || :
28-
"
29-
done
30-
31-
test_expect_success "assert that all engines found the same for$GIT_PERF_7821_GREP_OPTS $pattern" '
32-
test_cmp out.fixed out.basic &&
33-
test_cmp out.fixed out.extended &&
34-
if test_have_prereq PCRE
34+
if ! test_have_prereq PERF_GREP_ENGINES_THREADS
3535
then
36-
test_cmp out.fixed out.perl
36+
test_perf $prereq "$engine grep$GIT_PERF_7821_GREP_OPTS $pattern" "
37+
git -c grep.patternType=$engine grep$GIT_PERF_7821_GREP_OPTS $pattern >'out.$engine' || :
38+
"
39+
else
40+
for threads in $GIT_PERF_GREP_THREADS
41+
do
42+
test_perf PTHREADS,$prereq "$engine grep$GIT_PERF_7821_GREP_OPTS $pattern with $threads threads" "
43+
git -c grep.patternType=$engine -c grep.threads=$threads grep$GIT_PERF_7821_GREP_OPTS $pattern >'out.$engine.$threads' || :
44+
"
45+
done
3746
fi
38-
'
47+
done
48+
49+
if ! test_have_prereq PERF_GREP_ENGINES_THREADS
50+
then
51+
test_expect_success "assert that all engines found the same for$GIT_PERF_7821_GREP_OPTS $pattern" '
52+
test_cmp out.fixed out.basic &&
53+
test_cmp out.fixed out.extended &&
54+
if test_have_prereq PCRE
55+
then
56+
test_cmp out.fixed out.perl
57+
fi
58+
'
59+
else
60+
for threads in $GIT_PERF_GREP_THREADS
61+
do
62+
test_expect_success PTHREADS "assert that all engines found the same for$GIT_PERF_7821_GREP_OPTS $pattern under threading" "
63+
test_cmp out.fixed.$threads out.basic.$threads &&
64+
test_cmp out.fixed.$threads out.extended.$threads &&
65+
if test_have_prereq PCRE
66+
then
67+
test_cmp out.fixed.$threads out.perl.$threads
68+
fi
69+
"
70+
done
71+
fi
3972
done
4073

4174
test_done

0 commit comments

Comments
 (0)