t3302-notes-index-expensive: Speed up create_repo()
Creating repos with 10/100/1000/10000 commits and notes takes a lot of time. However, using git-fast-import to do the job is a lot more efficient than using plumbing commands to do the same. This patch decreases the overall run-time of this test on my machine from ~3 to ~1 minutes. Signed-off-by: Johan Herland <johan@herland.net> Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johan Herland committed
Oct 9, 2009 at 12:22 UTC
3ed24b6aaf35d6ca1eef2643cd0b9128eb152cda
1 file changed
+47
-27
t/t3302-notes-index-expensive.sh
+47
-27
@@ -16,30 +16,50 @@ test -z "$GIT_NOTES_TIMING_TESTS" && {
16
create_repo () {
17
number_of_commits=$1
18
nr=0
19
- parent=
19
test -d .git || {
20
git init &&
22
- tree=$(git write-tree) &&
23
- while [ $nr -lt $number_of_commits ]; do
24
- test_tick &&
25
- commit=$(echo $nr | git commit-tree $tree $parent) ||
26
- return
27
- parent="-p $commit"
28
- nr=$(($nr+1))
29
- done &&
30
- git update-ref refs/heads/master $commit &&
31
- {
32
- GIT_INDEX_FILE=.git/temp; export GIT_INDEX_FILE;
33
- git rev-list HEAD | cat -n | sed "s/^[ ][ ]*/ /g" |
34
- while read nr sha1; do
35
- blob=$(echo note $nr | git hash-object -w --stdin) &&
36
- echo $sha1 | sed "s/^/0644 $blob 0 /"
37
- done | git update-index --index-info &&
38
- tree=$(git write-tree) &&
21
+ (
22
+ while [ $nr -lt $number_of_commits ]; do
23
+ nr=$(($nr+1))
24
+ mark=$(($nr+$nr))
25
+ notemark=$(($mark+1))
26
+ test_tick &&
27
+ cat <<INPUT_END &&
28
+commit refs/heads/master
29
+mark :$mark
30
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
31
+data <<COMMIT
32
+commit #$nr
33
+COMMIT
34
+
35
+M 644 inline file
36
+data <<EOF
37
+file in commit #$nr
38
+EOF
39
+
40
+blob
41
+mark :$notemark
42
+data <<EOF
43
+note for commit #$nr
44
+EOF
45
+
46
+INPUT_END
47
+
48
+ echo "N :$notemark :$mark" >> note_commit
49
+ done &&
50
test_tick &&
40
- commit=$(echo notes | git commit-tree $tree) &&
41
- git update-ref refs/notes/commits $commit
42
- } &&
51
+ cat <<INPUT_END &&
52
+commit refs/notes/commits
53
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
54
+data <<COMMIT
55
+notes
56
+COMMIT
57
+
58
+INPUT_END
59
+
60
+ cat note_commit
61
+ ) |
62
+ git fast-import --quiet &&
63
git config core.notesRef refs/notes/commits
64
}
65
}
@@ -48,13 +68,13 @@ test_notes () {
68
count=$1 &&
69
git config core.notesRef refs/notes/commits &&
70
git log | grep "^ " > output &&
51
- i=1 &&
52
- while [ $i -le $count ]; do
53
- echo " $(($count-$i))" &&
54
- echo " note $i" &&
55
- i=$(($i+1));
71
+ i=$count &&
72
+ while [ $i -gt 0 ]; do
73
+ echo " commit #$i" &&
74
+ echo " note for commit #$i" &&
75
+ i=$(($i-1));
76
done > expect &&
57
- git diff expect output
77
+ test_cmp expect output
78
}
79
80
cat > time_notes << \EOF