| 1 | #!/bin/sh |
| 2 | # |
| 3 | # This test measures the performance of various read-tree |
| 4 | # and checkout operations. It is primarily interested in |
| 5 | # the algorithmic costs of index operations and recursive |
| 6 | # tree traversal -- and NOT disk I/O on thousands of files. |
| 7 | |
| 8 | test_description="Tests performance of read-tree" |
| 9 | |
| 10 | . ./perf-lib.sh |
| 11 | |
| 12 | test_perf_default_repo |
| 13 | |
| 14 | # If the test repo was generated by ./repos/many-files.sh |
| 15 | # then we know something about the data shape and branches, |
| 16 | # so we can isolate testing to the ballast-related commits |
| 17 | # and setup sparse-checkout so we don't have to populate |
| 18 | # the ballast files and directories. |
| 19 | # |
| 20 | # Otherwise, we make some general assumptions about the |
| 21 | # repo and consider the entire history of the current |
| 22 | # branch to be the ballast. |
| 23 | |
| 24 | test_expect_success "setup repo" ' |
| 25 | if git rev-parse --verify refs/heads/p0006-ballast^{commit} |
| 26 | then |
| 27 | echo Assuming synthetic repo from many-files.sh && |
| 28 | git branch br_base master && |
| 29 | git branch br_ballast p0006-ballast^ && |
| 30 | git branch br_ballast_alias p0006-ballast^ && |
| 31 | git branch br_ballast_plus_1 p0006-ballast && |
| 32 | git config --local core.sparsecheckout 1 && |
| 33 | cat >.git/info/sparse-checkout <<-EOF |
| 34 | /* |
| 35 | !ballast/* |
| 36 | EOF |
| 37 | else |
| 38 | echo Assuming non-synthetic repo... && |
| 39 | git branch br_base $(git rev-list HEAD | tail -n 1) && |
| 40 | git branch br_ballast HEAD^ || error "no ancestor commit from current head" && |
| 41 | git branch br_ballast_alias HEAD^ && |
| 42 | git branch br_ballast_plus_1 HEAD |
| 43 | fi && |
| 44 | git checkout -q br_ballast && |
| 45 | nr_files=$(git ls-files | wc -l) |
| 46 | ' |
| 47 | |
| 48 | test_perf "read-tree br_base br_ballast ($nr_files)" ' |
| 49 | git read-tree -n -m br_base br_ballast |
| 50 | ' |
| 51 | |
| 52 | test_perf "read-tree br_ballast_plus_1 ($nr_files)" ' |
| 53 | # Run read-tree 100 times for clearer performance results & comparisons |
| 54 | for i in $(test_seq 100) |
| 55 | do |
| 56 | git read-tree -n -m br_ballast_plus_1 || return 1 |
| 57 | done |
| 58 | ' |
| 59 | |
| 60 | test_perf "switch between br_base br_ballast ($nr_files)" ' |
| 61 | git checkout -q br_base && |
| 62 | git checkout -q br_ballast |
| 63 | ' |
| 64 | |
| 65 | test_perf "switch between br_ballast br_ballast_plus_1 ($nr_files)" ' |
| 66 | git checkout -q br_ballast_plus_1 && |
| 67 | git checkout -q br_ballast |
| 68 | ' |
| 69 | |
| 70 | test_perf "switch between aliases ($nr_files)" ' |
| 71 | git checkout -q br_ballast_alias && |
| 72 | git checkout -q br_ballast |
| 73 | ' |
| 74 | |
| 75 | test_done |