25 echo "error: unknown performance test option '$1'" >&2; exit 1 ;;
28 . ../test/test-lib-common.sh
32 if ! test -x ../notmuch
34 echo >&2 'You do not seem to have built notmuch yet.'
38 DB_CACHE_DIR=${TEST_DIRECTORY}/notmuch.cache.$corpus_size
44 CORPUS_DIR=${TEST_DIRECTORY}/corpus
45 mkdir -p "${CORPUS_DIR}"
47 MAIL_CORPUS="${CORPUS_DIR}/mail.${corpus_size}"
48 TAG_CORPUS="${CORPUS_DIR}/tags"
50 if command -v pixz > /dev/null; then
56 if [ ! -d "${CORPUS_DIR}/manifest" ]; then
58 printf "Unpacking manifests\n"
59 tar --extract --use-compress-program ${XZ} --strip-components=1 \
60 --directory ${TEST_DIRECTORY}/corpus \
61 --wildcards --file ../download/notmuch-email-corpus-${PERFTEST_VERSION}.tar.xz \
62 'notmuch-email-corpus/manifest/*'
65 file_list=$(mktemp file_listXXXXXX)
66 if [ ! -d "$TAG_CORPUS" ] ; then
67 echo "notmuch-email-corpus/tags" >> $file_list
70 if [ ! -d "$MAIL_CORPUS" ] ; then
71 if [[ "$corpus_size" != "large" ]]; then
72 sed s,^,notmuch-email-corpus/, < \
73 ${TEST_DIRECTORY}/corpus/manifest/MANIFEST.${corpus_size} >> $file_list
75 echo "notmuch-email-corpus/mail" >> $file_list
79 if [[ -s $file_list ]]; then
81 printf "Unpacking corpus\n"
82 tar --checkpoint=.5000 --extract --strip-components=1 \
83 --directory ${TEST_DIRECTORY}/corpus \
84 --use-compress-program ${XZ} \
85 --file ../download/notmuch-email-corpus-${PERFTEST_VERSION}.tar.xz \
86 --anchored --recursion \
87 --files-from $file_list
91 if [[ ! -d ${MAIL_CORPUS} ]]; then
92 printf "creating link farm\n"
94 if [[ "$corpus_size" = large ]]; then
95 cp -rl ${TEST_DIRECTORY}/corpus/mail ${MAIL_CORPUS}
97 while read -r file; do
98 tdir=${MAIL_CORPUS}/$(dirname $file)
100 ln ${TEST_DIRECTORY}/corpus/$file $tdir
101 done <${TEST_DIRECTORY}/corpus/manifest/MANIFEST.${corpus_size}
108 cp -lr $TAG_CORPUS $TMP_DIRECTORY/corpus.tags
109 cp -lr $MAIL_CORPUS $MAIL_DIR
112 notmuch_new_with_cache ()
114 if [ -d $DB_CACHE_DIR ]; then
115 cp -r $DB_CACHE_DIR ${MAIL_DIR}/.notmuch
117 "$1" 'Initial notmuch new' "notmuch new"
128 notmuch_new_with_cache time_run
135 local timestamp=$(date +%Y%m%dT%H%M%S)
136 log_dir="${TEST_DIRECTORY}/log.$(basename $0)-$corpus_size-${timestamp}"
139 notmuch_new_with_cache memory_run
144 test_count=$(($test_count+1))
146 log_file=$log_dir/$test_count.log
147 talloc_log=$log_dir/$test_count.talloc
149 printf "[ %d ]\t%s\n" $test_count "$1"
151 NOTMUCH_TALLOC_REPORT="$talloc_log" valgrind --leak-check=full --log-file="$log_file" $2
153 awk '/LEAK SUMMARY/,/suppressed/ { sub(/^==[0-9]*==/," "); print }' "$log_file"
155 sed -n -e 's/.*[(]total *\([^)]*\)[)]/talloced at exit: \1/p' $talloc_log
166 if [ -d $MAIL_DIR/.notmuch ]; then
167 cp -r $MAIL_DIR/.notmuch $DB_CACHE_DIR
169 echo "Warning: No database found to cache"
180 printf "\t\t\tWall(s)\tUsr(s)\tSys(s)\tRes(K)\tIn/Out(512B)\n"
186 test_count=$(($test_count+1))
187 if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi
188 if ! eval >&3 "/usr/bin/time -f '%e\t%U\t%S\t%M\t%I/%O' $2" ; then
189 test_failure=$(($test_failure + 1))
197 if [ "$test_failure" = "0" ]; then
205 cd -P "$test" || error "Cannot setup test environment"
209 printf "\n%-55s [%s %s]\n" \
210 "$(basename "$0"): Testing ${test_description:-notmuch performance}" \
211 "${PERFTEST_VERSION}" "${corpus_size}"