Merge branch 'jk/index-pack-threading-races'
[git/mjg.git] / t / t3302-notes-index-expensive.sh
blob8d44e04354f05856465904700ff0374dae74ba59
1 #!/bin/sh
3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description='Test commit notes index (expensive!)'
8 . ./test-lib.sh
10 test -n "$GIT_NOTES_TIMING_TESTS" && test_set_prereq EXPENSIVE
12 create_repo () {
13 number_of_commits=$1
14 nr=0
15 test -d .git || {
16 git init &&
18 while test $nr -lt $number_of_commits
20 nr=$(($nr+1))
21 mark=$(($nr+$nr))
22 notemark=$(($mark+1))
23 test_tick &&
24 cat <<-INPUT_END &&
25 commit refs/heads/master
26 mark :$mark
27 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
28 data <<COMMIT
29 commit #$nr
30 COMMIT
32 M 644 inline file
33 data <<EOF
34 file in commit #$nr
35 EOF
37 blob
38 mark :$notemark
39 data <<EOF
40 note for commit #$nr
41 EOF
43 INPUT_END
44 echo "N :$notemark :$mark" >>note_commit
45 done &&
46 test_tick &&
47 cat <<-INPUT_END &&
48 commit refs/notes/commits
49 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
50 data <<COMMIT
51 notes
52 COMMIT
54 INPUT_END
56 cat note_commit
57 ) |
58 git fast-import --quiet &&
59 git config core.notesRef refs/notes/commits
63 test_notes () {
64 count=$1 &&
65 git config core.notesRef refs/notes/commits &&
66 git log | grep "^ " >output &&
67 i=$count &&
68 while test $i -gt 0
70 echo " commit #$i" &&
71 echo " note for commit #$i" &&
72 i=$(($i-1))
73 done >expect &&
74 test_cmp expect output
77 write_script time_notes <<\EOF
78 mode=$1
79 i=1
80 while test $i -lt $2
82 case $1 in
83 no-notes)
84 GIT_NOTES_REF=non-existing
85 export GIT_NOTES_REF
87 notes)
88 unset GIT_NOTES_REF
90 esac
91 git log
92 i=$(($i+1))
93 done >/dev/null
94 EOF
96 time_notes () {
97 for mode in no-notes notes
99 echo $mode
100 /usr/bin/time ../time_notes $mode $1
101 done
104 do_tests () {
105 count=$1 pr=${2-}
107 test_expect_success $pr "setup $count" '
108 mkdir "$count" &&
110 cd "$count" &&
111 create_repo "$count"
115 test_expect_success $pr 'notes work' '
117 cd "$count" &&
118 test_notes "$count"
122 test_expect_success "USR_BIN_TIME${pr:+,$pr}" 'notes timing with /usr/bin/time' '
124 cd "$count" &&
125 time_notes 100
130 do_tests 10
131 for count in 100 1000 10000
133 do_tests "$count" EXPENSIVE
134 done
136 test_done