The sixth batch
[git/gitster.git] / t / perf / p5551-fetch-rescan.sh
blobb99dc23e328d1d5d41552295cc4f8450c2e63b79
1 #!/bin/sh
3 test_description='fetch performance with many packs
5 It is common for fetch to consider objects that we might not have, and it is an
6 easy mistake for the code to use a function like `parse_object` that might
7 give the correct _answer_ on such an object, but do so slowly (due to
8 re-scanning the pack directory for lookup failures).
10 The resulting performance drop can be hard to notice in a real repository, but
11 becomes quite large in a repository with a large number of packs. So this
12 test creates a more pathological case, since any mistakes would produce a more
13 noticeable slowdown.
15 . ./perf-lib.sh
16 . "$TEST_DIRECTORY"/perf/lib-pack.sh
18 test_expect_success 'create parent and child' '
19 git init parent &&
20 git clone parent child
24 test_expect_success 'create refs in the parent' '
26 cd parent &&
27 git commit --allow-empty -m foo &&
28 head=$(git rev-parse HEAD) &&
29 test_seq 1000 |
30 sed "s,.*,update refs/heads/& $head," |
31 $MODERN_GIT update-ref --stdin
35 test_expect_success 'create many packs in the child' '
37 cd child &&
38 setup_many_packs
42 test_perf 'fetch' '
43 # start at the same state for each iteration
44 obj=$($MODERN_GIT -C parent rev-parse HEAD) &&
46 cd child &&
47 $MODERN_GIT for-each-ref --format="delete %(refname)" refs/remotes |
48 $MODERN_GIT update-ref --stdin &&
49 rm -vf .git/objects/$(echo $obj | sed "s|^..|&/|") &&
51 git fetch
55 test_done