Skip to content

Commit 4b707a6

Browse files
derrickstoleegitster
authored andcommitted
p1500: add is-base performance tests
The previous two changes introduced a commit walking heuristic for finding the most likely base branch for a given source. This algorithm walks first-parent histories until reaching a collision. This walk _should_ be very fast. Exceptions include cases where a commit-graph file does not exist, leading to a full walk of all reachable commits to compute generation numbers, or a case where no collision in the first-parent history exists, leading to a walk of all first-parent history to the root commits. The p1500 test script guarantees a complete commit-graph file during its setup, so we will not test that scenario. Do create a new root commit in an effort to test the scenario of parallel first-parent histories. Even with the extra root commit, these tests take no longer than 0.02 seconds on my machine for the Git repository. However, the results are slightly more interesting in a copy of the Linux kernel repository: Test --------------------------------------------------------------- 1500.2: ahead-behind counts: git for-each-ref 0.12 1500.3: ahead-behind counts: git branch 0.12 1500.4: ahead-behind counts: git tag 0.12 1500.5: contains: git for-each-ref --merged 0.04 1500.6: contains: git branch --merged 0.04 1500.7: contains: git tag --merged 0.04 1500.8: is-base check: test-tool reach (refs) 0.03 1500.9: is-base check: test-tool reach (tags) 0.03 1500.10: is-base check: git for-each-ref 0.03 1500.11: is-base check: git for-each-ref (disjoint-base) 0.07 Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9c1732c commit 4b707a6

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

t/perf/p1500-graph-walks.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,21 @@ test_expect_success 'setup' '
2020
echo tag-$ref ||
2121
return 1
2222
done >tags &&
23+
24+
echo "A:HEAD" >test-tool-refs &&
25+
for line in $(cat refs)
26+
do
27+
echo "X:$line" >>test-tool-refs || return 1
28+
done &&
29+
echo "A:HEAD" >test-tool-tags &&
30+
for line in $(cat tags)
31+
do
32+
echo "X:$line" >>test-tool-tags || return 1
33+
done &&
34+
35+
commit=$(git commit-tree $(git rev-parse HEAD^{tree})) &&
36+
git update-ref refs/heads/disjoint-base $commit &&
37+
2338
git commit-graph write --reachable
2439
'
2540

@@ -47,4 +62,20 @@ test_perf 'contains: git tag --merged' '
4762
xargs git tag --merged=HEAD <tags
4863
'
4964

65+
test_perf 'is-base check: test-tool reach (refs)' '
66+
test-tool reach get_branch_base_for_tip <test-tool-refs
67+
'
68+
69+
test_perf 'is-base check: test-tool reach (tags)' '
70+
test-tool reach get_branch_base_for_tip <test-tool-tags
71+
'
72+
73+
test_perf 'is-base check: git for-each-ref' '
74+
git for-each-ref --format="%(is-base:HEAD)" --stdin <refs
75+
'
76+
77+
test_perf 'is-base check: git for-each-ref (disjoint-base)' '
78+
git for-each-ref --format="%(is-base:refs/heads/disjoint-base)" --stdin <refs
79+
'
80+
5081
test_done

0 commit comments

Comments
 (0)