Skip to content

Commit aa338d3

Browse files
peffgitster
authored andcommitted
p5550: factor out nonsense-pack creation
We have a function to create a bunch of irrelevant packs to measure the expense of reprepare_packed_git(). Let's make that available to other perf scripts. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fc849d8 commit aa338d3

File tree

2 files changed

+31
-23
lines changed

2 files changed

+31
-23
lines changed

t/perf/lib-pack.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Helpers for dealing with large numbers of packs.
2+
3+
# create $1 nonsense packs, each with a single blob
4+
create_packs () {
5+
perl -le '
6+
my ($n) = @ARGV;
7+
for (1..$n) {
8+
print "blob";
9+
print "data <<EOF";
10+
print "$_";
11+
print "EOF";
12+
}
13+
' "$@" |
14+
git fast-import &&
15+
16+
git cat-file --batch-all-objects --batch-check='%(objectname)' |
17+
while read sha1
18+
do
19+
echo $sha1 | git pack-objects .git/objects/pack/pack
20+
done
21+
}
22+
23+
# create a large number of packs, disabling any gc which might
24+
# cause us to repack them
25+
setup_many_packs () {
26+
git config gc.auto 0 &&
27+
git config gc.autopacklimit 0 &&
28+
create_packs 500
29+
}

t/perf/p5550-fetch-tags.sh

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ start to show a noticeable performance problem on my machine, but without
2020
taking too long to set up and run the tests.
2121
'
2222
. ./perf-lib.sh
23+
. "$TEST_DIRECTORY/perf/lib-pack.sh"
2324

2425
# make a long nonsense history on branch $1, consisting of $2 commits, each
2526
# with a unique file pointing to the blob at $2.
@@ -44,26 +45,6 @@ create_tags () {
4445
git update-ref --stdin
4546
}
4647

47-
# create $1 nonsense packs, each with a single blob
48-
create_packs () {
49-
perl -le '
50-
my ($n) = @ARGV;
51-
for (1..$n) {
52-
print "blob";
53-
print "data <<EOF";
54-
print "$_";
55-
print "EOF";
56-
}
57-
' "$@" |
58-
git fast-import &&
59-
60-
git cat-file --batch-all-objects --batch-check='%(objectname)' |
61-
while read sha1
62-
do
63-
echo $sha1 | git pack-objects .git/objects/pack/pack
64-
done
65-
}
66-
6748
test_expect_success 'create parent and child' '
6849
git init parent &&
6950
git -C parent commit --allow-empty -m base &&
@@ -84,9 +65,7 @@ test_expect_success 'populate parent tags' '
8465
test_expect_success 'create child packs' '
8566
(
8667
cd child &&
87-
git config gc.auto 0 &&
88-
git config gc.autopacklimit 0 &&
89-
create_packs 500
68+
setup_many_packs
9069
)
9170
'
9271

0 commit comments

Comments
 (0)