[PATCH 2/2] test: initial performance testing infrastructure.
authordavid <david@tethera.net>
Sat, 17 Nov 2012 21:37:14 +0000 (17:37 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:50:39 +0000 (09:50 -0800)
5f/a29ee9652fd001ae6829a2a56351caf65fe386 [new file with mode: 0644]

diff --git a/5f/a29ee9652fd001ae6829a2a56351caf65fe386 b/5f/a29ee9652fd001ae6829a2a56351caf65fe386
new file mode 100644 (file)
index 0000000..f47e033
--- /dev/null
@@ -0,0 +1,293 @@
+Return-Path: <bremner@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id EBD9D431FBD\r
+       for <notmuch@notmuchmail.org>; Sat, 17 Nov 2012 13:41:55 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id MoMbm3FOsCfY for <notmuch@notmuchmail.org>;\r
+       Sat, 17 Nov 2012 13:41:53 -0800 (PST)\r
+Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238])\r
+       (using TLSv1 with cipher AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id AACE1431FBF\r
+       for <notmuch@notmuchmail.org>; Sat, 17 Nov 2012 13:41:47 -0800 (PST)\r
+Received: from fctnnbsc30w-156034089108.dhcp-dynamic.fibreop.nb.bellaliant.net\r
+       ([156.34.89.108] helo=zancas.localnet)\r
+       by tesseract.cs.unb.ca with esmtpsa\r
+       (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72)\r
+       (envelope-from <bremner@tethera.net>)\r
+       id 1TZq7u-0001Bh-LO; Sat, 17 Nov 2012 17:40:35 -0400\r
+Received: from bremner by zancas.localnet with local (Exim 4.80)\r
+       (envelope-from <bremner@tethera.net>)\r
+       id 1TZq4r-0007ks-1w; Sat, 17 Nov 2012 17:37:25 -0400\r
+From: david@tethera.net\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/2] test: initial performance testing infrastructure.\r
+Date: Sat, 17 Nov 2012 17:37:14 -0400\r
+Message-Id: <1353188234-29666-3-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1353188234-29666-1-git-send-email-david@tethera.net>\r
+References: <1353188234-29666-1-git-send-email-david@tethera.net>\r
+X-Spam_bar: -\r
+Cc: David Bremner <bremner@debian.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 17 Nov 2012 21:41:56 -0000\r
+\r
+From: David Bremner <bremner@debian.org>\r
+\r
+This is not near as fancy as as the unit tests, on the theory that\r
+the code should typically be crashing when performance tuning.\r
+Nonetheless, there is plenty of room for improvement.  Several more of\r
+the pieces of the test infrastructure (e.g. the option parsing) could\r
+be factored out into test/test-lib-common.sh\r
+---\r
+ Makefile                                           |    3 +-\r
+ performance-test/.gitignore                        |    2 ++\r
+ performance-test/Makefile                          |    7 ++++\r
+ performance-test/Makefile.local                    |   28 +++++++++++++++\r
+ performance-test/README                            |   26 ++++++++++++++\r
+ performance-test/basic                             |   12 +++++++\r
+ performance-test/download/.gitignore               |    2 ++\r
+ .../download/mail-corpus-0.1.mbox.sha256           |    1 +\r
+ performance-test/notmuch-perf-test                 |   25 ++++++++++++++\r
+ performance-test/perf-test-lib.sh                  |   36 ++++++++++++++++++++\r
+ 10 files changed, 141 insertions(+), 1 deletion(-)\r
+ create mode 100644 performance-test/.gitignore\r
+ create mode 100644 performance-test/Makefile\r
+ create mode 100644 performance-test/Makefile.local\r
+ create mode 100644 performance-test/README\r
+ create mode 100755 performance-test/basic\r
+ create mode 100644 performance-test/download/.gitignore\r
+ create mode 100644 performance-test/download/mail-corpus-0.1.mbox.sha256\r
+ create mode 100755 performance-test/notmuch-perf-test\r
+ create mode 100644 performance-test/perf-test-lib.sh\r
+\r
+diff --git a/Makefile b/Makefile\r
+index bb9c316..5decbea 100644\r
+--- a/Makefile\r
++++ b/Makefile\r
+@@ -3,7 +3,8 @@\r
+ all:\r
+ \r
+ # List all subdirectories here. Each contains its own Makefile.local\r
+-subdirs = compat completion emacs lib man parse-time-string util test\r
++subdirs := compat completion emacs lib man parse-time-string\r
++subdirs := $(subdirs) performance-test util test\r
+ \r
+ # We make all targets depend on the Makefiles themselves.\r
+ global_deps = Makefile Makefile.config Makefile.local \\r
+diff --git a/performance-test/.gitignore b/performance-test/.gitignore\r
+new file mode 100644\r
+index 0000000..e757e8d\r
+--- /dev/null\r
++++ b/performance-test/.gitignore\r
+@@ -0,0 +1,2 @@\r
++corpus/*\r
++tmp.*/\r
+diff --git a/performance-test/Makefile b/performance-test/Makefile\r
+new file mode 100644\r
+index 0000000..de492a7\r
+--- /dev/null\r
++++ b/performance-test/Makefile\r
+@@ -0,0 +1,7 @@\r
++# See Makefile.local for the list of files to be compiled in this\r
++# directory.\r
++all:\r
++      $(MAKE) -C .. all\r
++\r
++.DEFAULT:\r
++      $(MAKE) -C .. $@\r
+diff --git a/performance-test/Makefile.local b/performance-test/Makefile.local\r
+new file mode 100644\r
+index 0000000..b38bbbd\r
+--- /dev/null\r
++++ b/performance-test/Makefile.local\r
+@@ -0,0 +1,28 @@\r
++# -*- makefile -*-\r
++\r
++dir := performance-test\r
++\r
++PERFTEST_VERSION := 0.1\r
++\r
++MBNAME := mail-corpus-$(PERFTEST_VERSION).mbox\r
++GZFILE := $(CURDIR)/$(dir)/download/$(MBNAME).gz\r
++MBFILE := $(CURDIR)/$(dir)/download/$(MBNAME)\r
++MBDIR :=  $(CURDIR)/$(dir)/corpus\r
++SHA256FILE := $(dir)/download/mail-corpus-$(PERFTEST_VERSION).sha256\r
++TEST_SCRIPT := $(dir)/notmuch-perf-test\r
++\r
++perf-test: setup-perf-test all\r
++      $(TEST_SCRIPT) $(OPTIONS)\r
++\r
++setup-perf-test: $(MBFILE)\r
++      mb2md -s $(MBFILE) -d $(MBDIR)\r
++\r
++$(GZFILE):\r
++      wget -O $@ http://notmuchmail.org/releases/$(MBNAME).gz\r
++\r
++$(MBFILE): $(GZFILE)\r
++      gunzip -c $(GZFILE) > $(MBFILE)\r
++      sha256sum -c $(MBFILE).sha256\r
++\r
++CLEAN := $(CLEAN) $(dir)/tmp.*\r
++DISTCLEAN := $(DISTCLEAN) $(GZFILE) $(MBFILE) $(dir)/corpus\r
+diff --git a/performance-test/README b/performance-test/README\r
+new file mode 100644\r
+index 0000000..d22438a\r
+--- /dev/null\r
++++ b/performance-test/README\r
+@@ -0,0 +1,26 @@\r
++Pre-requisites\r
++--------------\r
++\r
++In addition to having notmuch, you need:\r
++\r
++- mb2md\r
++- gnu time\r
++- wget\r
++- sha256sum\r
++\r
++Getting set up to run tests:\r
++----------------------------\r
++\r
++% make setup-perf-test\r
++\r
++This requires a net connection to download the test corpus.\r
++\r
++Running tests\r
++-------------\r
++\r
++The easiest way to run performance tests is to say "make perf-test", (or\r
++simply run the notmuch-perf-test script). Either command will run all\r
++available performance tests.\r
++\r
++Alternately, you can run a specific subset of tests by simply invoking\r
++one of the executable scripts in this directory, (such as ./basic).\r
+diff --git a/performance-test/basic b/performance-test/basic\r
+new file mode 100755\r
+index 0000000..16b7d03\r
+--- /dev/null\r
++++ b/performance-test/basic\r
+@@ -0,0 +1,12 @@\r
++\r
++. ./perf-test-lib.sh\r
++\r
++add_email_corpus\r
++\r
++time_run 'initial notmuch new' 'notmuch new'\r
++time_run 'second notmuch new' 'notmuch new'\r
++time_run 'dump *' 'notmuch dump > tags.out'\r
++time_run 'restore *' 'notmuch restore < tags.out'\r
++time_run 'tag * +new_tag' "notmuch tag +new_tag '*'"\r
++\r
++time_done\r
+diff --git a/performance-test/download/.gitignore b/performance-test/download/.gitignore\r
+new file mode 100644\r
+index 0000000..b08aedd\r
+--- /dev/null\r
++++ b/performance-test/download/.gitignore\r
+@@ -0,0 +1,2 @@\r
++*.mbox.gz\r
++*.mbox\r
+diff --git a/performance-test/download/mail-corpus-0.1.mbox.sha256 b/performance-test/download/mail-corpus-0.1.mbox.sha256\r
+new file mode 100644\r
+index 0000000..85354c0\r
+--- /dev/null\r
++++ b/performance-test/download/mail-corpus-0.1.mbox.sha256\r
+@@ -0,0 +1 @@\r
++ed1163e6e331691d60af8f599866a5d16fa0bbc38793407227fd4b2381494b4b  performance-test/download/mail-corpus-0.1.mbox\r
+diff --git a/performance-test/notmuch-perf-test b/performance-test/notmuch-perf-test\r
+new file mode 100755\r
+index 0000000..1bea345\r
+--- /dev/null\r
++++ b/performance-test/notmuch-perf-test\r
+@@ -0,0 +1,25 @@\r
++#!/usr/bin/env bash\r
++\r
++# Run tests\r
++#\r
++# Copyright (c) 2005 Junio C Hamano\r
++#\r
++# Adapted from a Makefile to a shell script by Carl Worth (2010)\r
++\r
++if [ ${BASH_VERSINFO[0]} -lt 4 ]; then\r
++    echo "Error: The notmuch test suite requires a bash version >= 4.0"\r
++    echo "due to use of associative arrays within the test suite."\r
++    echo "Please try again with a newer bash (or help us fix the"\r
++    echo "test suite to be more portable). Thanks."\r
++    exit 1\r
++fi\r
++\r
++cd $(dirname "$0")\r
++\r
++TESTS="\r
++  basic\r
++"\r
++\r
++for test in $TESTS; do\r
++    ./$test "$@"\r
++done\r
+diff --git a/performance-test/perf-test-lib.sh b/performance-test/perf-test-lib.sh\r
+new file mode 100644\r
+index 0000000..0447852\r
+--- /dev/null\r
++++ b/performance-test/perf-test-lib.sh\r
+@@ -0,0 +1,36 @@\r
++\r
++. ../test/test-lib-common.sh\r
++\r
++set -e\r
++\r
++if ! test -x ../notmuch\r
++then\r
++      echo >&2 'You do not seem to have built notmuch yet.'\r
++      exit 1\r
++fi\r
++\r
++add_email_corpus ()\r
++{\r
++    rm -rf ${MAIL_DIR}\r
++    cp -a $TEST_DIRECTORY/corpus ${MAIL_DIR}\r
++}\r
++\r
++time_run () {\r
++    printf "%-25s" "$1"\r
++    if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi\r
++    if ! eval >&3 "/usr/bin/time -f '%e %U %S' $2" ; then\r
++      test_failure=$(($test_failure + 1))\r
++    fi\r
++}\r
++\r
++time_done () {\r
++    if [ "$test_failure" = "0" ]; then\r
++      rm -rf "$remove_tmp"\r
++      exit 0\r
++    else\r
++      exit 1\r
++    fi\r
++}\r
++\r
++cd -P "$test" || error "Cannot setup test environment"\r
++test_failure=0\r
+-- \r
+1.7.10.4\r
+\r