| 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 | git rev-list --first-parent --max-count=8192 HEAD >contains-commits && |
| 36 | test_file_not_empty contains-commits && |
| 37 | git update-ref refs/contains-perf-base "$(tail -n 1 contains-commits)" && |
| 38 | awk "{ |
| 39 | printf \"update refs/contains-perf/%04d %s\\n\", NR, \$1 |
| 40 | }" contains-commits | |
| 41 | git update-ref --stdin && |
| 42 | git pack-refs --include "refs/contains-perf/*" && |
| 43 | |
| 44 | commit=$(git commit-tree HEAD^{tree}) && |
| 45 | git update-ref refs/heads/disjoint-base $commit && |
| 46 | |
| 47 | git commit-graph write --reachable |
| 48 | ' |
| 49 | |
| 50 | test_perf 'ahead-behind counts: git for-each-ref' ' |
| 51 | git for-each-ref --format="%(ahead-behind:HEAD)" --stdin <refs |
| 52 | ' |
| 53 | |
| 54 | test_perf 'ahead-behind counts: git branch' ' |
| 55 | xargs git branch -l --format="%(ahead-behind:HEAD)" <branches |
| 56 | ' |
| 57 | |
| 58 | test_perf 'ahead-behind counts: git tag' ' |
| 59 | xargs git tag -l --format="%(ahead-behind:HEAD)" <tags |
| 60 | ' |
| 61 | |
| 62 | test_perf 'contains: git for-each-ref --merged' ' |
| 63 | git for-each-ref --merged=HEAD --stdin <refs |
| 64 | ' |
| 65 | |
| 66 | test_perf 'contains: git branch --merged' ' |
| 67 | xargs git branch --merged=HEAD <branches |
| 68 | ' |
| 69 | |
| 70 | test_perf 'contains: git tag --merged' ' |
| 71 | xargs git tag --merged=HEAD <tags |
| 72 | ' |
| 73 | |
| 74 | test_perf 'contains: git for-each-ref' ' |
| 75 | git for-each-ref --contains=refs/contains-perf-base --stdin <refs |
| 76 | ' |
| 77 | |
| 78 | test_perf 'contains: git branch' ' |
| 79 | xargs git branch --contains=refs/contains-perf-base <branches |
| 80 | ' |
| 81 | |
| 82 | test_perf 'contains: git tag' ' |
| 83 | xargs git tag --contains=refs/contains-perf-base <tags |
| 84 | ' |
| 85 | |
| 86 | test_perf 'contains: synthetic shared history' ' |
| 87 | git for-each-ref --contains=refs/contains-perf-base \ |
| 88 | refs/contains-perf/ >/dev/null |
| 89 | ' |
| 90 | |
| 91 | test_perf 'is-base check: test-tool reach (refs)' ' |
| 92 | test-tool reach get_branch_base_for_tip <test-tool-refs |
| 93 | ' |
| 94 | |
| 95 | test_perf 'is-base check: test-tool reach (tags)' ' |
| 96 | test-tool reach get_branch_base_for_tip <test-tool-tags |
| 97 | ' |
| 98 | |
| 99 | test_perf 'is-base check: git for-each-ref' ' |
| 100 | git for-each-ref --format="%(is-base:HEAD)" --stdin <refs |
| 101 | ' |
| 102 | |
| 103 | test_perf 'is-base check: git for-each-ref (disjoint-base)' ' |
| 104 | git for-each-ref --format="%(is-base:refs/heads/disjoint-base)" --stdin <refs |
| 105 | ' |
| 106 | |
| 107 | test_done |