+notmuch_new_with_cache ()
+{
+ if [ -d $DB_CACHE_DIR ]; then
+ cp -r $DB_CACHE_DIR ${MAIL_DIR}/.notmuch
+ else
+ "$1" 'Initial notmuch new' "notmuch new"
+ cache_database
+ fi
+}
+
+make_log_dir () {
+ local timestamp=$(date +%Y%m%dT%H%M%S)
+ log_dir=${TEST_DIRECTORY}/log.$(basename $0)-$corpus_size-${timestamp}
+ mkdir -p "${log_dir}"
+}
+
+time_start ()
+{
+ add_email_corpus
+
+ if [[ "$use_perf" = 1 ]]; then
+ make_log_dir
+ fi
+
+ print_header
+
+ notmuch_new_with_cache time_run
+}
+
+memory_start ()
+{
+ add_email_corpus
+
+ make_log_dir
+
+ notmuch_new_with_cache memory_run
+}
+
+memory_run ()
+{
+ test_count=$(($test_count+1))
+
+ log_file=$log_dir/$test_count.log
+ talloc_log=$log_dir/$test_count.talloc
+
+ printf "[ %d ]\t%s\n" $test_count "$1"