mirror of
https://github.com/git/git
synced 2024-11-05 01:58:18 +00:00
4b707a6e99
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 <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
81 lines
1.9 KiB
Bash
Executable file
81 lines
1.9 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='Commit walk performance tests'
|
|
. ./perf-lib.sh
|
|
|
|
test_perf_large_repo
|
|
|
|
test_expect_success 'setup' '
|
|
git for-each-ref --format="%(refname)" "refs/heads/*" "refs/tags/*" >allrefs &&
|
|
sort -r allrefs | head -n 50 >refs &&
|
|
for ref in $(cat refs)
|
|
do
|
|
git branch -f ref-$ref $ref &&
|
|
echo ref-$ref ||
|
|
return 1
|
|
done >branches &&
|
|
for ref in $(cat refs)
|
|
do
|
|
git tag -f tag-$ref $ref &&
|
|
echo tag-$ref ||
|
|
return 1
|
|
done >tags &&
|
|
|
|
echo "A:HEAD" >test-tool-refs &&
|
|
for line in $(cat refs)
|
|
do
|
|
echo "X:$line" >>test-tool-refs || return 1
|
|
done &&
|
|
echo "A:HEAD" >test-tool-tags &&
|
|
for line in $(cat tags)
|
|
do
|
|
echo "X:$line" >>test-tool-tags || return 1
|
|
done &&
|
|
|
|
commit=$(git commit-tree $(git rev-parse HEAD^{tree})) &&
|
|
git update-ref refs/heads/disjoint-base $commit &&
|
|
|
|
git commit-graph write --reachable
|
|
'
|
|
|
|
test_perf 'ahead-behind counts: git for-each-ref' '
|
|
git for-each-ref --format="%(ahead-behind:HEAD)" --stdin <refs
|
|
'
|
|
|
|
test_perf 'ahead-behind counts: git branch' '
|
|
xargs git branch -l --format="%(ahead-behind:HEAD)" <branches
|
|
'
|
|
|
|
test_perf 'ahead-behind counts: git tag' '
|
|
xargs git tag -l --format="%(ahead-behind:HEAD)" <tags
|
|
'
|
|
|
|
test_perf 'contains: git for-each-ref --merged' '
|
|
git for-each-ref --merged=HEAD --stdin <refs
|
|
'
|
|
|
|
test_perf 'contains: git branch --merged' '
|
|
xargs git branch --merged=HEAD <branches
|
|
'
|
|
|
|
test_perf 'contains: git tag --merged' '
|
|
xargs git tag --merged=HEAD <tags
|
|
'
|
|
|
|
test_perf 'is-base check: test-tool reach (refs)' '
|
|
test-tool reach get_branch_base_for_tip <test-tool-refs
|
|
'
|
|
|
|
test_perf 'is-base check: test-tool reach (tags)' '
|
|
test-tool reach get_branch_base_for_tip <test-tool-tags
|
|
'
|
|
|
|
test_perf 'is-base check: git for-each-ref' '
|
|
git for-each-ref --format="%(is-base:HEAD)" --stdin <refs
|
|
'
|
|
|
|
test_perf 'is-base check: git for-each-ref (disjoint-base)' '
|
|
git for-each-ref --format="%(is-base:refs/heads/disjoint-base)" --stdin <refs
|
|
'
|
|
|
|
test_done
|