| 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='Commit walk performance tests' |
| 4 | . ./perf-lib.sh |
| 5 | |
| 6 | test_perf_large_repo |
| 7 | |
| 8 | test_expect_success 'setup' ' |
| 9 | git for-each-ref --format="%(refname)" "refs/heads/*" "refs/tags/*" >allrefs && |
| 10 | sort -r allrefs | head -n 50 >refs && |
| 11 | for ref in $(cat refs) |
| 12 | do |
| 13 | git branch -f ref-$ref $ref && |
| 14 | echo ref-$ref || |
| 15 | return 1 |
| 16 | done >branches && |
| 17 | for ref in $(cat refs) |
| 18 | do |
| 19 | git tag -f tag-$ref $ref && |
| 20 | echo tag-$ref || |
| 21 | return 1 |
| 22 | 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 | |
| 38 | git commit-graph write --reachable |
| 39 | ' |
| 40 | |
| 41 | test_perf 'ahead-behind counts: git for-each-ref' ' |
| 42 | git for-each-ref --format="%(ahead-behind:HEAD)" --stdin <refs |
| 43 | ' |
| 44 | |
| 45 | test_perf 'ahead-behind counts: git branch' ' |
| 46 | xargs git branch -l --format="%(ahead-behind:HEAD)" <branches |
| 47 | ' |
| 48 | |
| 49 | test_perf 'ahead-behind counts: git tag' ' |
| 50 | xargs git tag -l --format="%(ahead-behind:HEAD)" <tags |
| 51 | ' |
| 52 | |
| 53 | test_perf 'contains: git for-each-ref --merged' ' |
| 54 | git for-each-ref --merged=HEAD --stdin <refs |
| 55 | ' |
| 56 | |
| 57 | test_perf 'contains: git branch --merged' ' |
| 58 | xargs git branch --merged=HEAD <branches |
| 59 | ' |
| 60 | |
| 61 | test_perf 'contains: git tag --merged' ' |
| 62 | xargs git tag --merged=HEAD <tags |
| 63 | ' |
| 64 | |
| 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 | |
| 81 | test_done |