]> git.ipfire.org Git - thirdparty/git.git/blob - t/perf/p2000-sparse-operations.sh
Sync with 2.31.5
[thirdparty/git.git] / t / perf / p2000-sparse-operations.sh
1 #!/bin/sh
2
3 test_description="test performance of Git operations using the index"
4
5 . ./perf-lib.sh
6
7 test_perf_default_repo
8
9 SPARSE_CONE=f2/f4/f1
10
11 test_expect_success 'setup repo and indexes' '
12 git reset --hard HEAD &&
13
14 # Remove submodules from the example repo, because our
15 # duplication of the entire repo creates an unlikely data shape.
16 if git config --file .gitmodules --get-regexp "submodule.*.path" >modules
17 then
18 git rm $(awk "{print \$2}" modules) &&
19 git commit -m "remove submodules" || return 1
20 fi &&
21
22 echo bogus >a &&
23 cp a b &&
24 git add a b &&
25 git commit -m "level 0" &&
26 BLOB=$(git rev-parse HEAD:a) &&
27 OLD_COMMIT=$(git rev-parse HEAD) &&
28 OLD_TREE=$(git rev-parse HEAD^{tree}) &&
29
30 for i in $(test_seq 1 4)
31 do
32 cat >in <<-EOF &&
33 100755 blob $BLOB a
34 040000 tree $OLD_TREE f1
35 040000 tree $OLD_TREE f2
36 040000 tree $OLD_TREE f3
37 040000 tree $OLD_TREE f4
38 EOF
39 NEW_TREE=$(git mktree <in) &&
40 NEW_COMMIT=$(git commit-tree $NEW_TREE -p $OLD_COMMIT -m "level $i") &&
41 OLD_TREE=$NEW_TREE &&
42 OLD_COMMIT=$NEW_COMMIT || return 1
43 done &&
44
45 git sparse-checkout init --cone &&
46 git branch -f wide $OLD_COMMIT &&
47 git -c core.sparseCheckoutCone=true clone --branch=wide --sparse . full-index-v3 &&
48 (
49 cd full-index-v3 &&
50 git sparse-checkout init --cone &&
51 git sparse-checkout set $SPARSE_CONE &&
52 git config index.version 3 &&
53 git update-index --index-version=3
54 ) &&
55 git -c core.sparseCheckoutCone=true clone --branch=wide --sparse . full-index-v4 &&
56 (
57 cd full-index-v4 &&
58 git sparse-checkout init --cone &&
59 git sparse-checkout set $SPARSE_CONE &&
60 git config index.version 4 &&
61 git update-index --index-version=4
62 ) &&
63 git -c core.sparseCheckoutCone=true clone --branch=wide --sparse . sparse-index-v3 &&
64 (
65 cd sparse-index-v3 &&
66 git sparse-checkout init --cone --sparse-index &&
67 git sparse-checkout set $SPARSE_CONE &&
68 git config index.version 3 &&
69 git update-index --index-version=3
70 ) &&
71 git -c core.sparseCheckoutCone=true clone --branch=wide --sparse . sparse-index-v4 &&
72 (
73 cd sparse-index-v4 &&
74 git sparse-checkout init --cone --sparse-index &&
75 git sparse-checkout set $SPARSE_CONE &&
76 git config index.version 4 &&
77 git update-index --index-version=4
78 )
79 '
80
81 test_perf_on_all () {
82 command="$@"
83 for repo in full-index-v3 full-index-v4 \
84 sparse-index-v3 sparse-index-v4
85 do
86 test_perf "$command ($repo)" "
87 (
88 cd $repo &&
89 echo >>$SPARSE_CONE/a &&
90 $command
91 )
92 "
93 done
94 }
95
96 test_perf_on_all git status
97 test_perf_on_all git add -A
98 test_perf_on_all git add .
99 test_perf_on_all git commit -a -m A
100
101 test_done