1 . $(dirname "$0")/version.sh || exit 1
37 echo "error: unknown performance test option '$1'" >&2; exit 1 ;;
41 # Ensure NOTMUCH_SRCDIR and NOTMUCH_BUILDDIR are set.
42 . $(dirname "$0")/../test/export-dirs.sh || exit 1
44 # Where to run the tests
45 TEST_DIRECTORY=$NOTMUCH_BUILDDIR/performance-test
47 . "$NOTMUCH_SRCDIR/test/test-lib-common.sh" || exit 1
51 # It appears that people try to run tests without building...
52 if [[ ! -x "$NOTMUCH_BUILDDIR/notmuch" ]]; then
53 echo >&2 'You do not seem to have built notmuch yet.'
57 DB_CACHE_DIR=${TEST_DIRECTORY}/notmuch.cache.$corpus_size
63 CORPUS_DIR=${TEST_DIRECTORY}/corpus
64 mkdir -p "${CORPUS_DIR}"
66 MAIL_CORPUS="${CORPUS_DIR}/mail.${corpus_size}"
67 TAG_CORPUS="${CORPUS_DIR}/tags"
69 if command -v pixz > /dev/null; then
75 if [ ! -d "${CORPUS_DIR}/manifest" ]; then
77 printf "Unpacking manifests\n"
78 tar --extract --use-compress-program ${XZ} --strip-components=1 \
79 --directory ${TEST_DIRECTORY}/corpus \
80 --wildcards --file ../download/notmuch-email-corpus-${PERFTEST_VERSION}.tar.xz \
81 'notmuch-email-corpus/manifest/*'
84 file_list=$(mktemp file_listXXXXXX)
85 declare -a extract_dirs
86 if [ ! -d "$TAG_CORPUS" ] ; then
87 extract_dirs=("${extract_dirs[@]}" notmuch-email-corpus/tags)
90 if [ ! -d "$MAIL_CORPUS" ] ; then
91 if [[ "$corpus_size" != "large" ]]; then
92 sed s,^,notmuch-email-corpus/, < \
93 ${TEST_DIRECTORY}/corpus/manifest/MANIFEST.${corpus_size} >> $file_list
95 extract_dirs=("${extract_dirs[@]}" notmuch-email-corpus/mail)
99 if [[ -s $file_list || -n "${extract_dirs[*]}" ]]; then
101 printf "Unpacking corpus\n"
102 tar --checkpoint=.5000 --extract --strip-components=1 \
103 --directory ${TEST_DIRECTORY}/corpus \
104 --use-compress-program ${XZ} \
105 --file ../download/notmuch-email-corpus-${PERFTEST_VERSION}.tar.xz \
106 --anchored --recursion \
107 --files-from $file_list "${extract_dirs[@]}"
111 if [[ ! -d ${MAIL_CORPUS} ]]; then
112 printf "creating link farm\n"
114 if [[ "$corpus_size" = large ]]; then
115 cp -rl ${TEST_DIRECTORY}/corpus/mail ${MAIL_CORPUS}
117 while read -r file; do
118 tdir=${MAIL_CORPUS}/$(dirname $file)
120 ln ${TEST_DIRECTORY}/corpus/$file $tdir
121 done <${TEST_DIRECTORY}/corpus/manifest/MANIFEST.${corpus_size}
128 cp -lr $TAG_CORPUS $TMP_DIRECTORY/corpus.tags
129 cp -lr $MAIL_CORPUS $MAIL_DIR
132 notmuch_new_with_cache ()
134 if [ -d $DB_CACHE_DIR ]; then
135 cp -r $DB_CACHE_DIR ${MAIL_DIR}/.notmuch
137 "$1" 'Initial notmuch new' "notmuch new"
143 local timestamp=$(date +%Y%m%dT%H%M%S)
144 log_dir=${TEST_DIRECTORY}/log.$(basename $0)-$corpus_size-${timestamp}
145 mkdir -p "${log_dir}"
152 if [[ "$use_perf" = 1 ]]; then
158 notmuch_new_with_cache time_run
167 notmuch_new_with_cache memory_run
172 test_count=$(($test_count+1))
174 log_file=$log_dir/$test_count.log
175 talloc_log=$log_dir/$test_count.talloc
177 printf "[ %d ]\t%s\n" $test_count "$1"
179 NOTMUCH_TALLOC_REPORT="$talloc_log" eval "valgrind --leak-check=full --log-file='$log_file' $2"
181 awk '/LEAK SUMMARY/,/suppressed/ { sub(/^==[0-9]*==/," "); print }' "$log_file"
183 sed -n -e 's/.*[(]total *\([^)]*\)[)]/talloced at exit: \1/p' $talloc_log
194 if [ -d $MAIL_DIR/.notmuch ]; then
195 cp -r $MAIL_DIR/.notmuch $DB_CACHE_DIR
197 echo "Warning: No database found to cache"
208 printf "\t\t\tWall(s)\tUsr(s)\tSys(s)\tRes(K)\tIn/Out(512B)\n"
214 test_count=$(($test_count+1))
215 if test "$verbose" != "t"; then exec 4>test.output 3>&4; else exec 3>&1; fi
216 if [[ "$use_perf" = 1 ]]; then
217 command_str="perf record --call-graph=${perf_callgraph} -o ${log_dir}/${test_count}.perf $2"
219 command_str="/usr/bin/time -f '%e\t%U\t%S\t%M\t%I/%O' $2"
222 if ! eval >&3 "$command_str" ; then
223 test_failure=$(($test_failure + 1))
231 if [ "$test_failure" = "0" ]; then
239 cd -P "$test" || error "Cannot set up test environment"
243 printf "\n%-55s [%s %s]\n" \
244 "$(basename "$0"): Testing ${test_description:-notmuch performance}" \
245 "${PERFTEST_VERSION}" "${corpus_size}"