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 . "$NOTMUCH_SRCDIR/test/test-vars.sh" || exit 1
46 # Where to run the tests
47 TEST_DIRECTORY=$NOTMUCH_BUILDDIR/performance-test
49 . "$NOTMUCH_SRCDIR/test/test-lib-common.sh" || exit 1
53 # It appears that people try to run tests without building...
54 if [[ ! -x "$NOTMUCH_BUILDDIR/notmuch" ]]; then
55 echo >&2 'You do not seem to have built notmuch yet.'
59 DB_CACHE_DIR=${TEST_DIRECTORY}/notmuch.cache.$corpus_size
65 CORPUS_DIR=${TEST_DIRECTORY}/corpus
66 mkdir -p "${CORPUS_DIR}"
68 MAIL_CORPUS="${CORPUS_DIR}/mail.${corpus_size}"
69 TAG_CORPUS="${CORPUS_DIR}/tags"
71 if command -v pixz > /dev/null; then
77 if [ ! -d "${CORPUS_DIR}/manifest" ]; then
79 printf "Unpacking manifests\n"
80 tar --extract --use-compress-program ${XZ} --strip-components=1 \
81 --directory ${TEST_DIRECTORY}/corpus \
82 --wildcards --file ../download/notmuch-email-corpus-${PERFTEST_VERSION}.tar.xz \
83 'notmuch-email-corpus/manifest/*'
86 file_list=$(mktemp file_listXXXXXX)
87 declare -a extract_dirs
88 if [ ! -d "$TAG_CORPUS" ] ; then
89 extract_dirs=("${extract_dirs[@]}" notmuch-email-corpus/tags)
92 if [ ! -d "$MAIL_CORPUS" ] ; then
93 if [[ "$corpus_size" != "large" ]]; then
94 sed s,^,notmuch-email-corpus/, < \
95 ${TEST_DIRECTORY}/corpus/manifest/MANIFEST.${corpus_size} >> $file_list
97 extract_dirs=("${extract_dirs[@]}" notmuch-email-corpus/mail)
101 if [[ -s $file_list || -n "${extract_dirs[*]}" ]]; then
103 printf "Unpacking corpus\n"
104 tar --checkpoint=.5000 --extract --strip-components=1 \
105 --directory ${TEST_DIRECTORY}/corpus \
106 --use-compress-program ${XZ} \
107 --file ../download/notmuch-email-corpus-${PERFTEST_VERSION}.tar.xz \
108 --anchored --recursion \
109 --files-from $file_list "${extract_dirs[@]}"
113 if [[ ! -d ${MAIL_CORPUS} ]]; then
114 printf "creating link farm\n"
116 if [[ "$corpus_size" = large ]]; then
117 cp -rl ${TEST_DIRECTORY}/corpus/mail ${MAIL_CORPUS}
119 while read -r file; do
120 tdir=${MAIL_CORPUS}/$(dirname $file)
122 ln ${TEST_DIRECTORY}/corpus/$file $tdir
123 done <${TEST_DIRECTORY}/corpus/manifest/MANIFEST.${corpus_size}
130 cp -lr $TAG_CORPUS $TMP_DIRECTORY/corpus.tags
131 cp -lr $MAIL_CORPUS $MAIL_DIR
134 notmuch_new_with_cache ()
136 if [ -d $DB_CACHE_DIR ]; then
137 cp -r $DB_CACHE_DIR ${MAIL_DIR}/.notmuch
139 "$1" 'Initial notmuch new' "notmuch new"
145 local timestamp=$(date +%Y%m%dT%H%M%S)
146 log_dir=${TEST_DIRECTORY}/log.$(basename $0)-$corpus_size-${timestamp}
147 mkdir -p "${log_dir}"
154 if [[ "$use_perf" = 1 ]]; then
160 notmuch_new_with_cache time_run
169 notmuch_new_with_cache memory_run
174 test_count=$(($test_count+1))
176 log_file=$log_dir/$test_count.log
177 talloc_log=$log_dir/$test_count.talloc
179 printf "[ %d ]\t%s\n" $test_count "$1"
181 NOTMUCH_TALLOC_REPORT="$talloc_log" eval "valgrind --leak-check=full --log-file='$log_file' $2"
183 awk '/LEAK SUMMARY/,/suppressed/ { sub(/^==[0-9]*==/," "); print }' "$log_file"
185 sed -n -e 's/.*[(]total *\([^)]*\)[)]/talloced at exit: \1/p' $talloc_log
196 if [ -d $MAIL_DIR/.notmuch ]; then
197 cp -r $MAIL_DIR/.notmuch $DB_CACHE_DIR
199 echo "Warning: No database found to cache"
210 printf "\t\t\tWall(s)\tUsr(s)\tSys(s)\tRes(K)\tIn/Out(512B)\n"
213 print_emacs_header ()
215 printf "\t\t\tWall(s)\tGCs\tGC time(s)\n"
221 test_count=$(($test_count+1))
222 if test "$verbose" != "t"; then exec 4>test.output 3>&4; else exec 3>&1; fi
223 if [[ "$use_perf" = 1 ]]; then
224 command_str="perf record --call-graph=${perf_callgraph} -o ${log_dir}/${test_count}.perf $2"
226 command_str="/usr/bin/time -f '%e\t%U\t%S\t%M\t%I/%O' $2"
229 if ! eval >&3 "$command_str" ; then
230 test_failure=$(($test_failure + 1))
238 if [ "$test_failure" = "0" ]; then
246 cd -P "$test" || error "Cannot set up test environment"
250 printf "\n%-55s [%s %s]\n" \
251 "$(basename "$0"): Testing ${test_description:-notmuch performance}" \
252 "${PERFTEST_VERSION}" "${corpus_size}"