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 # Where to run the tests
33 TEST_DIRECTORY=$NOTMUCH_BUILDDIR/performance-test
35 . "$NOTMUCH_SRCDIR/test/test-lib-common.sh" || exit 1
39 # It appears that people try to run tests without building...
40 if [[ ! -x "$NOTMUCH_BUILDDIR/notmuch" ]]; then
41 echo >&2 'You do not seem to have built notmuch yet.'
45 DB_CACHE_DIR=${TEST_DIRECTORY}/notmuch.cache.$corpus_size
51 CORPUS_DIR=${TEST_DIRECTORY}/corpus
52 mkdir -p "${CORPUS_DIR}"
54 MAIL_CORPUS="${CORPUS_DIR}/mail.${corpus_size}"
55 TAG_CORPUS="${CORPUS_DIR}/tags"
57 if command -v pixz > /dev/null; then
63 if [ ! -d "${CORPUS_DIR}/manifest" ]; then
65 printf "Unpacking manifests\n"
66 tar --extract --use-compress-program ${XZ} --strip-components=1 \
67 --directory ${TEST_DIRECTORY}/corpus \
68 --wildcards --file ../download/notmuch-email-corpus-${PERFTEST_VERSION}.tar.xz \
69 'notmuch-email-corpus/manifest/*'
72 file_list=$(mktemp file_listXXXXXX)
73 declare -a extract_dirs
74 if [ ! -d "$TAG_CORPUS" ] ; then
75 extract_dirs=("${extract_dirs[@]}" notmuch-email-corpus/tags)
78 if [ ! -d "$MAIL_CORPUS" ] ; then
79 if [[ "$corpus_size" != "large" ]]; then
80 sed s,^,notmuch-email-corpus/, < \
81 ${TEST_DIRECTORY}/corpus/manifest/MANIFEST.${corpus_size} >> $file_list
83 extract_dirs=("${extract_dirs[@]}" notmuch-email-corpus/mail)
87 if [[ -s $file_list || -n "${extract_dirs[*]}" ]]; then
89 printf "Unpacking corpus\n"
90 tar --checkpoint=.5000 --extract --strip-components=1 \
91 --directory ${TEST_DIRECTORY}/corpus \
92 --use-compress-program ${XZ} \
93 --file ../download/notmuch-email-corpus-${PERFTEST_VERSION}.tar.xz \
94 --anchored --recursion \
95 --files-from $file_list "${extract_dirs[@]}"
99 if [[ ! -d ${MAIL_CORPUS} ]]; then
100 printf "creating link farm\n"
102 if [[ "$corpus_size" = large ]]; then
103 cp -rl ${TEST_DIRECTORY}/corpus/mail ${MAIL_CORPUS}
105 while read -r file; do
106 tdir=${MAIL_CORPUS}/$(dirname $file)
108 ln ${TEST_DIRECTORY}/corpus/$file $tdir
109 done <${TEST_DIRECTORY}/corpus/manifest/MANIFEST.${corpus_size}
116 cp -lr $TAG_CORPUS $TMP_DIRECTORY/corpus.tags
117 cp -lr $MAIL_CORPUS $MAIL_DIR
120 notmuch_new_with_cache ()
122 if [ -d $DB_CACHE_DIR ]; then
123 cp -r $DB_CACHE_DIR ${MAIL_DIR}/.notmuch
125 "$1" 'Initial notmuch new' "notmuch new"
136 notmuch_new_with_cache time_run
143 local timestamp=$(date +%Y%m%dT%H%M%S)
144 log_dir="${TEST_DIRECTORY}/log.$(basename $0)-$corpus_size-${timestamp}"
147 notmuch_new_with_cache memory_run
152 test_count=$(($test_count+1))
154 log_file=$log_dir/$test_count.log
155 talloc_log=$log_dir/$test_count.talloc
157 printf "[ %d ]\t%s\n" $test_count "$1"
159 NOTMUCH_TALLOC_REPORT="$talloc_log" eval "valgrind --leak-check=full --log-file='$log_file' $2"
161 awk '/LEAK SUMMARY/,/suppressed/ { sub(/^==[0-9]*==/," "); print }' "$log_file"
163 sed -n -e 's/.*[(]total *\([^)]*\)[)]/talloced at exit: \1/p' $talloc_log
174 if [ -d $MAIL_DIR/.notmuch ]; then
175 cp -r $MAIL_DIR/.notmuch $DB_CACHE_DIR
177 echo "Warning: No database found to cache"
188 printf "\t\t\tWall(s)\tUsr(s)\tSys(s)\tRes(K)\tIn/Out(512B)\n"
194 test_count=$(($test_count+1))
195 if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi
196 if ! eval >&3 "/usr/bin/time -f '%e\t%U\t%S\t%M\t%I/%O' $2" ; then
197 test_failure=$(($test_failure + 1))
205 if [ "$test_failure" = "0" ]; then
213 cd -P "$test" || error "Cannot set up test environment"
217 printf "\n%-55s [%s %s]\n" \
218 "$(basename "$0"): Testing ${test_description:-notmuch performance}" \
219 "${PERFTEST_VERSION}" "${corpus_size}"