diff --color-moved: add perf tests

Add some tests so we can monitor changes to the performance of the move detection code. The tests record the performance --color-moved and --color-moved-ws=allow-indentation-change for a large diff and a sequence of smaller diffs. The range of commits used for the large diff can be customized by exporting TEST_REV_A and TEST_REV_B when running the test. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Phillip Wood committed Dec 9, 2021 at 10:29 UTC f73613ac33aad6f08aa1bc07e596202f19e760d1
1 file changed +57
t/perf/p4002-diff-color-moved.sh new
+57
@@ -0,0 +1,57 @@
1 +#!/bin/sh
2 +
3 +test_description='Tests diff --color-moved performance'
4 +. ./perf-lib.sh
5 +
6 +test_perf_default_repo
7 +
8 +# The endpoints of the diff can be customized by setting TEST_REV_A
9 +# and TEST_REV_B in the environment when running this test.
10 +
11 +rev="${TEST_REV_A:-v2.28.0}"
12 +if ! rev_a="$(git rev-parse --quiet --verify "$rev")"
13 +then
14 + skip_all="skipping because '$rev' was not found. \
15 + Use TEST_REV_A and TEST_REV_B to set the revs to use"
16 + test_done
17 +fi
18 +rev="${TEST_REV_B:-v2.29.0}"
19 +if ! rev_b="$(git rev-parse --quiet --verify "$rev")"
20 +then
21 + skip_all="skipping because '$rev' was not found. \
22 + Use TEST_REV_A and TEST_REV_B to set the revs to use"
23 + test_done
24 +fi
25 +
26 +GIT_PAGER_IN_USE=1
27 +test_export GIT_PAGER_IN_USE rev_a rev_b
28 +
29 +test_perf 'diff --no-color-moved --no-color-moved-ws large change' '
30 + git diff --no-color-moved --no-color-moved-ws $rev_a $rev_b
31 +'
32 +
33 +test_perf 'diff --color-moved --no-color-moved-ws large change' '
34 + git diff --color-moved=zebra --no-color-moved-ws $rev_a $rev_b
35 +'
36 +
37 +test_perf 'diff --color-moved-ws=allow-indentation-change large change' '
38 + git diff --color-moved=zebra --color-moved-ws=allow-indentation-change \
39 + $rev_a $rev_b
40 +'
41 +
42 +test_perf 'log --no-color-moved --no-color-moved-ws' '
43 + git log --no-color-moved --no-color-moved-ws --no-merges --patch \
44 + -n1000 $rev_b
45 +'
46 +
47 +test_perf 'log --color-moved --no-color-moved-ws' '
48 + git log --color-moved=zebra --no-color-moved-ws --no-merges --patch \
49 + -n1000 $rev_b
50 +'
51 +
52 +test_perf 'log --color-moved-ws=allow-indentation-change' '
53 + git log --color-moved=zebra --color-moved-ws=allow-indentation-change \
54 + --no-merges --patch -n1000 $rev_b
55 +'
56 +
57 +test_done