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