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 declare -a extract_dirs
67 if [ ! -d "$TAG_CORPUS" ] ; then
68 extract_dirs=("${extract_dirs[@]}" notmuch-email-corpus/tags)
71 if [ ! -d "$MAIL_CORPUS" ] ; then
72 if [[ "$corpus_size" != "large" ]]; then
73 sed s,^,notmuch-email-corpus/, < \
74 ${TEST_DIRECTORY}/corpus/manifest/MANIFEST.${corpus_size} >> $file_list
76 extract_dirs=("${extract_dirs[@]}" notmuch-email-corpus/mail)
80 if [[ -s $file_list || -n "${extract_dirs[*]}" ]]; then
82 printf "Unpacking corpus\n"
83 tar --checkpoint=.5000 --extract --strip-components=1 \
84 --directory ${TEST_DIRECTORY}/corpus \
85 --use-compress-program ${XZ} \
86 --file ../download/notmuch-email-corpus-${PERFTEST_VERSION}.tar.xz \
87 --anchored --recursion \
88 --files-from $file_list "${extract_dirs[@]}"
92 if [[ ! -d ${MAIL_CORPUS} ]]; then
93 printf "creating link farm\n"
95 if [[ "$corpus_size" = large ]]; then
96 cp -rl ${TEST_DIRECTORY}/corpus/mail ${MAIL_CORPUS}
98 while read -r file; do
99 tdir=${MAIL_CORPUS}/$(dirname $file)
101 ln ${TEST_DIRECTORY}/corpus/$file $tdir
102 done <${TEST_DIRECTORY}/corpus/manifest/MANIFEST.${corpus_size}
109 cp -lr $TAG_CORPUS $TMP_DIRECTORY/corpus.tags
110 cp -lr $MAIL_CORPUS $MAIL_DIR
113 notmuch_new_with_cache ()
115 if [ -d $DB_CACHE_DIR ]; then
116 cp -r $DB_CACHE_DIR ${MAIL_DIR}/.notmuch
118 "$1" 'Initial notmuch new' "notmuch new"
129 notmuch_new_with_cache time_run
136 local timestamp=$(date +%Y%m%dT%H%M%S)
137 log_dir="${TEST_DIRECTORY}/log.$(basename $0)-$corpus_size-${timestamp}"
140 notmuch_new_with_cache memory_run
145 test_count=$(($test_count+1))
147 log_file=$log_dir/$test_count.log
148 talloc_log=$log_dir/$test_count.talloc
150 printf "[ %d ]\t%s\n" $test_count "$1"
152 NOTMUCH_TALLOC_REPORT="$talloc_log" valgrind --leak-check=full --log-file="$log_file" $2
154 awk '/LEAK SUMMARY/,/suppressed/ { sub(/^==[0-9]*==/," "); print }' "$log_file"
156 sed -n -e 's/.*[(]total *\([^)]*\)[)]/talloced at exit: \1/p' $talloc_log
167 if [ -d $MAIL_DIR/.notmuch ]; then
168 cp -r $MAIL_DIR/.notmuch $DB_CACHE_DIR
170 echo "Warning: No database found to cache"
181 printf "\t\t\tWall(s)\tUsr(s)\tSys(s)\tRes(K)\tIn/Out(512B)\n"
187 test_count=$(($test_count+1))
188 if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi
189 if ! eval >&3 "/usr/bin/time -f '%e\t%U\t%S\t%M\t%I/%O' $2" ; then
190 test_failure=$(($test_failure + 1))
198 if [ "$test_failure" = "0" ]; then
206 cd -P "$test" || error "Cannot setup test environment"
210 printf "\n%-55s [%s %s]\n" \
211 "$(basename "$0"): Testing ${test_description:-notmuch performance}" \
212 "${PERFTEST_VERSION}" "${corpus_size}"