]> git.notmuchmail.org Git - notmuch/blob - performance-test/perf-test-lib.sh
1399d0598060b82a3beb5be3679c4f4dba2ec1bf
[notmuch] / performance-test / perf-test-lib.sh
1 . ./version.sh
2
3 . ../test/test-lib-common.sh
4
5 set -e
6
7 if ! test -x ../notmuch
8 then
9         echo >&2 'You do not seem to have built notmuch yet.'
10         exit 1
11 fi
12
13 add_email_corpus ()
14 {
15     rm -rf ${MAIL_DIR}
16
17     case "$1" in
18         --small)
19             arg="mail/enron/bailey-s"
20             ;;
21         --medium)
22             arg="mail/notmuch-archive"
23             ;;
24         *)
25             arg=mail
26     esac
27
28     if command -v pixz > /dev/null; then
29         XZ=pixz
30     else
31         XZ=xz
32     fi
33
34     printf "Unpacking corpus\n"
35     tar --checkpoint=.5000 --extract --strip-components=1 \
36         --directory ${TMP_DIRECTORY} \
37         --use-compress-program ${XZ} \
38         --file ../download/notmuch-email-corpus-${PERFTEST_VERSION}.tar.xz \
39         notmuch-email-corpus/"$arg"
40
41     printf "\n"
42 }
43
44 print_header () {
45     printf "[v%4s]               Wall(s)\tUsr(s)\tSys(s)\tRes(K)\tIn(512B)\tOut(512B)\n" \
46            ${PERFTEST_VERSION}
47 }
48
49 time_run () {
50     printf "%-22s" "$1"
51     if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi
52     if ! eval >&3 "/usr/bin/time -f '%e\t%U\t%S\t%M\t%I\t%O' $2" ; then
53         test_failure=$(($test_failure + 1))
54     fi
55 }
56
57 time_done () {
58     if [ "$test_failure" = "0" ]; then
59         rm -rf "$remove_tmp"
60         exit 0
61     else
62         exit 1
63     fi
64 }
65
66 cd -P "$test" || error "Cannot setup test environment"
67 test_failure=0