1 . $(dirname "$0")/version.sh || exit 1
25 echo "error: unknown performance test option '$1'" >&2; exit 1 ;;
29 # Ensure NOTMUCH_SRCDIR and NOTMUCH_BUILDDIR are set.
30 . $(dirname "$0")/../test/export-dirs.sh || exit 1
32 . "$NOTMUCH_SRCDIR/test/test-lib-common.sh" || exit 1
36 # It appears that people try to run tests without building...
37 if [[ ! -x "$NOTMUCH_BUILDDIR/notmuch" ]]; then
38 echo >&2 'You do not seem to have built notmuch yet.'
42 DB_CACHE_DIR=${TEST_DIRECTORY}/notmuch.cache.$corpus_size
48 CORPUS_DIR=${TEST_DIRECTORY}/corpus
49 mkdir -p "${CORPUS_DIR}"
51 MAIL_CORPUS="${CORPUS_DIR}/mail.${corpus_size}"
52 TAG_CORPUS="${CORPUS_DIR}/tags"
54 if command -v pixz > /dev/null; then
60 if [ ! -d "${CORPUS_DIR}/manifest" ]; then
62 printf "Unpacking manifests\n"
63 tar --extract --use-compress-program ${XZ} --strip-components=1 \
64 --directory ${TEST_DIRECTORY}/corpus \
65 --wildcards --file ../download/notmuch-email-corpus-${PERFTEST_VERSION}.tar.xz \
66 'notmuch-email-corpus/manifest/*'
69 file_list=$(mktemp file_listXXXXXX)
70 declare -a extract_dirs
71 if [ ! -d "$TAG_CORPUS" ] ; then
72 extract_dirs=("${extract_dirs[@]}" notmuch-email-corpus/tags)
75 if [ ! -d "$MAIL_CORPUS" ] ; then
76 if [[ "$corpus_size" != "large" ]]; then
77 sed s,^,notmuch-email-corpus/, < \
78 ${TEST_DIRECTORY}/corpus/manifest/MANIFEST.${corpus_size} >> $file_list
80 extract_dirs=("${extract_dirs[@]}" notmuch-email-corpus/mail)
84 if [[ -s $file_list || -n "${extract_dirs[*]}" ]]; then
86 printf "Unpacking corpus\n"
87 tar --checkpoint=.5000 --extract --strip-components=1 \
88 --directory ${TEST_DIRECTORY}/corpus \
89 --use-compress-program ${XZ} \
90 --file ../download/notmuch-email-corpus-${PERFTEST_VERSION}.tar.xz \
91 --anchored --recursion \
92 --files-from $file_list "${extract_dirs[@]}"
96 if [[ ! -d ${MAIL_CORPUS} ]]; then
97 printf "creating link farm\n"
99 if [[ "$corpus_size" = large ]]; then
100 cp -rl ${TEST_DIRECTORY}/corpus/mail ${MAIL_CORPUS}
102 while read -r file; do
103 tdir=${MAIL_CORPUS}/$(dirname $file)
105 ln ${TEST_DIRECTORY}/corpus/$file $tdir
106 done <${TEST_DIRECTORY}/corpus/manifest/MANIFEST.${corpus_size}
113 cp -lr $TAG_CORPUS $TMP_DIRECTORY/corpus.tags
114 cp -lr $MAIL_CORPUS $MAIL_DIR
117 notmuch_new_with_cache ()
119 if [ -d $DB_CACHE_DIR ]; then
120 cp -r $DB_CACHE_DIR ${MAIL_DIR}/.notmuch
122 "$1" 'Initial notmuch new' "notmuch new"
133 notmuch_new_with_cache time_run
140 local timestamp=$(date +%Y%m%dT%H%M%S)
141 log_dir="${TEST_DIRECTORY}/log.$(basename $0)-$corpus_size-${timestamp}"
144 notmuch_new_with_cache memory_run
149 test_count=$(($test_count+1))
151 log_file=$log_dir/$test_count.log
152 talloc_log=$log_dir/$test_count.talloc
154 printf "[ %d ]\t%s\n" $test_count "$1"
156 NOTMUCH_TALLOC_REPORT="$talloc_log" eval "valgrind --leak-check=full --log-file='$log_file' $2"
158 awk '/LEAK SUMMARY/,/suppressed/ { sub(/^==[0-9]*==/," "); print }' "$log_file"
160 sed -n -e 's/.*[(]total *\([^)]*\)[)]/talloced at exit: \1/p' $talloc_log
171 if [ -d $MAIL_DIR/.notmuch ]; then
172 cp -r $MAIL_DIR/.notmuch $DB_CACHE_DIR
174 echo "Warning: No database found to cache"
185 printf "\t\t\tWall(s)\tUsr(s)\tSys(s)\tRes(K)\tIn/Out(512B)\n"
191 test_count=$(($test_count+1))
192 if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi
193 if ! eval >&3 "/usr/bin/time -f '%e\t%U\t%S\t%M\t%I/%O' $2" ; then
194 test_failure=$(($test_failure + 1))
202 if [ "$test_failure" = "0" ]; then
210 cd -P "$test" || error "Cannot set up test environment"
214 printf "\n%-55s [%s %s]\n" \
215 "$(basename "$0"): Testing ${test_description:-notmuch performance}" \
216 "${PERFTEST_VERSION}" "${corpus_size}"