Re: [PATCH v3] nmbug: Translate to Python
[notmuch-archives.git] / 5f / a29ee9652fd001ae6829a2a56351caf65fe386
1 Return-Path: <bremner@tethera.net>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id EBD9D431FBD\r
6         for <notmuch@notmuchmail.org>; Sat, 17 Nov 2012 13:41:55 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id MoMbm3FOsCfY for <notmuch@notmuchmail.org>;\r
16         Sat, 17 Nov 2012 13:41:53 -0800 (PST)\r
17 Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238])\r
18         (using TLSv1 with cipher AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id AACE1431FBF\r
21         for <notmuch@notmuchmail.org>; Sat, 17 Nov 2012 13:41:47 -0800 (PST)\r
22 Received: from fctnnbsc30w-156034089108.dhcp-dynamic.fibreop.nb.bellaliant.net\r
23         ([156.34.89.108] helo=zancas.localnet)\r
24         by tesseract.cs.unb.ca with esmtpsa\r
25         (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72)\r
26         (envelope-from <bremner@tethera.net>)\r
27         id 1TZq7u-0001Bh-LO; Sat, 17 Nov 2012 17:40:35 -0400\r
28 Received: from bremner by zancas.localnet with local (Exim 4.80)\r
29         (envelope-from <bremner@tethera.net>)\r
30         id 1TZq4r-0007ks-1w; Sat, 17 Nov 2012 17:37:25 -0400\r
31 From: david@tethera.net\r
32 To: notmuch@notmuchmail.org\r
33 Subject: [PATCH 2/2] test: initial performance testing infrastructure.\r
34 Date: Sat, 17 Nov 2012 17:37:14 -0400\r
35 Message-Id: <1353188234-29666-3-git-send-email-david@tethera.net>\r
36 X-Mailer: git-send-email 1.7.10.4\r
37 In-Reply-To: <1353188234-29666-1-git-send-email-david@tethera.net>\r
38 References: <1353188234-29666-1-git-send-email-david@tethera.net>\r
39 X-Spam_bar: -\r
40 Cc: David Bremner <bremner@debian.org>\r
41 X-BeenThere: notmuch@notmuchmail.org\r
42 X-Mailman-Version: 2.1.13\r
43 Precedence: list\r
44 List-Id: "Use and development of the notmuch mail system."\r
45         <notmuch.notmuchmail.org>\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
49 List-Post: <mailto:notmuch@notmuchmail.org>\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
53 X-List-Received-Date: Sat, 17 Nov 2012 21:41:56 -0000\r
54 \r
55 From: David Bremner <bremner@debian.org>\r
56 \r
57 This is not near as fancy as as the unit tests, on the theory that\r
58 the code should typically be crashing when performance tuning.\r
59 Nonetheless, there is plenty of room for improvement.  Several more of\r
60 the pieces of the test infrastructure (e.g. the option parsing) could\r
61 be factored out into test/test-lib-common.sh\r
62 ---\r
63  Makefile                                           |    3 +-\r
64  performance-test/.gitignore                        |    2 ++\r
65  performance-test/Makefile                          |    7 ++++\r
66  performance-test/Makefile.local                    |   28 +++++++++++++++\r
67  performance-test/README                            |   26 ++++++++++++++\r
68  performance-test/basic                             |   12 +++++++\r
69  performance-test/download/.gitignore               |    2 ++\r
70  .../download/mail-corpus-0.1.mbox.sha256           |    1 +\r
71  performance-test/notmuch-perf-test                 |   25 ++++++++++++++\r
72  performance-test/perf-test-lib.sh                  |   36 ++++++++++++++++++++\r
73  10 files changed, 141 insertions(+), 1 deletion(-)\r
74  create mode 100644 performance-test/.gitignore\r
75  create mode 100644 performance-test/Makefile\r
76  create mode 100644 performance-test/Makefile.local\r
77  create mode 100644 performance-test/README\r
78  create mode 100755 performance-test/basic\r
79  create mode 100644 performance-test/download/.gitignore\r
80  create mode 100644 performance-test/download/mail-corpus-0.1.mbox.sha256\r
81  create mode 100755 performance-test/notmuch-perf-test\r
82  create mode 100644 performance-test/perf-test-lib.sh\r
83 \r
84 diff --git a/Makefile b/Makefile\r
85 index bb9c316..5decbea 100644\r
86 --- a/Makefile\r
87 +++ b/Makefile\r
88 @@ -3,7 +3,8 @@\r
89  all:\r
90  \r
91  # List all subdirectories here. Each contains its own Makefile.local\r
92 -subdirs = compat completion emacs lib man parse-time-string util test\r
93 +subdirs := compat completion emacs lib man parse-time-string\r
94 +subdirs := $(subdirs) performance-test util test\r
95  \r
96  # We make all targets depend on the Makefiles themselves.\r
97  global_deps = Makefile Makefile.config Makefile.local \\r
98 diff --git a/performance-test/.gitignore b/performance-test/.gitignore\r
99 new file mode 100644\r
100 index 0000000..e757e8d\r
101 --- /dev/null\r
102 +++ b/performance-test/.gitignore\r
103 @@ -0,0 +1,2 @@\r
104 +corpus/*\r
105 +tmp.*/\r
106 diff --git a/performance-test/Makefile b/performance-test/Makefile\r
107 new file mode 100644\r
108 index 0000000..de492a7\r
109 --- /dev/null\r
110 +++ b/performance-test/Makefile\r
111 @@ -0,0 +1,7 @@\r
112 +# See Makefile.local for the list of files to be compiled in this\r
113 +# directory.\r
114 +all:\r
115 +       $(MAKE) -C .. all\r
116 +\r
117 +.DEFAULT:\r
118 +       $(MAKE) -C .. $@\r
119 diff --git a/performance-test/Makefile.local b/performance-test/Makefile.local\r
120 new file mode 100644\r
121 index 0000000..b38bbbd\r
122 --- /dev/null\r
123 +++ b/performance-test/Makefile.local\r
124 @@ -0,0 +1,28 @@\r
125 +# -*- makefile -*-\r
126 +\r
127 +dir := performance-test\r
128 +\r
129 +PERFTEST_VERSION := 0.1\r
130 +\r
131 +MBNAME := mail-corpus-$(PERFTEST_VERSION).mbox\r
132 +GZFILE := $(CURDIR)/$(dir)/download/$(MBNAME).gz\r
133 +MBFILE := $(CURDIR)/$(dir)/download/$(MBNAME)\r
134 +MBDIR :=  $(CURDIR)/$(dir)/corpus\r
135 +SHA256FILE := $(dir)/download/mail-corpus-$(PERFTEST_VERSION).sha256\r
136 +TEST_SCRIPT := $(dir)/notmuch-perf-test\r
137 +\r
138 +perf-test: setup-perf-test all\r
139 +       $(TEST_SCRIPT) $(OPTIONS)\r
140 +\r
141 +setup-perf-test: $(MBFILE)\r
142 +       mb2md -s $(MBFILE) -d $(MBDIR)\r
143 +\r
144 +$(GZFILE):\r
145 +       wget -O $@ http://notmuchmail.org/releases/$(MBNAME).gz\r
146 +\r
147 +$(MBFILE): $(GZFILE)\r
148 +       gunzip -c $(GZFILE) > $(MBFILE)\r
149 +       sha256sum -c $(MBFILE).sha256\r
150 +\r
151 +CLEAN := $(CLEAN) $(dir)/tmp.*\r
152 +DISTCLEAN := $(DISTCLEAN) $(GZFILE) $(MBFILE) $(dir)/corpus\r
153 diff --git a/performance-test/README b/performance-test/README\r
154 new file mode 100644\r
155 index 0000000..d22438a\r
156 --- /dev/null\r
157 +++ b/performance-test/README\r
158 @@ -0,0 +1,26 @@\r
159 +Pre-requisites\r
160 +--------------\r
161 +\r
162 +In addition to having notmuch, you need:\r
163 +\r
164 +- mb2md\r
165 +- gnu time\r
166 +- wget\r
167 +- sha256sum\r
168 +\r
169 +Getting set up to run tests:\r
170 +----------------------------\r
171 +\r
172 +% make setup-perf-test\r
173 +\r
174 +This requires a net connection to download the test corpus.\r
175 +\r
176 +Running tests\r
177 +-------------\r
178 +\r
179 +The easiest way to run performance tests is to say "make perf-test", (or\r
180 +simply run the notmuch-perf-test script). Either command will run all\r
181 +available performance tests.\r
182 +\r
183 +Alternately, you can run a specific subset of tests by simply invoking\r
184 +one of the executable scripts in this directory, (such as ./basic).\r
185 diff --git a/performance-test/basic b/performance-test/basic\r
186 new file mode 100755\r
187 index 0000000..16b7d03\r
188 --- /dev/null\r
189 +++ b/performance-test/basic\r
190 @@ -0,0 +1,12 @@\r
191 +\r
192 +. ./perf-test-lib.sh\r
193 +\r
194 +add_email_corpus\r
195 +\r
196 +time_run 'initial notmuch new' 'notmuch new'\r
197 +time_run 'second notmuch new' 'notmuch new'\r
198 +time_run 'dump *' 'notmuch dump > tags.out'\r
199 +time_run 'restore *' 'notmuch restore < tags.out'\r
200 +time_run 'tag * +new_tag' "notmuch tag +new_tag '*'"\r
201 +\r
202 +time_done\r
203 diff --git a/performance-test/download/.gitignore b/performance-test/download/.gitignore\r
204 new file mode 100644\r
205 index 0000000..b08aedd\r
206 --- /dev/null\r
207 +++ b/performance-test/download/.gitignore\r
208 @@ -0,0 +1,2 @@\r
209 +*.mbox.gz\r
210 +*.mbox\r
211 diff --git a/performance-test/download/mail-corpus-0.1.mbox.sha256 b/performance-test/download/mail-corpus-0.1.mbox.sha256\r
212 new file mode 100644\r
213 index 0000000..85354c0\r
214 --- /dev/null\r
215 +++ b/performance-test/download/mail-corpus-0.1.mbox.sha256\r
216 @@ -0,0 +1 @@\r
217 +ed1163e6e331691d60af8f599866a5d16fa0bbc38793407227fd4b2381494b4b  performance-test/download/mail-corpus-0.1.mbox\r
218 diff --git a/performance-test/notmuch-perf-test b/performance-test/notmuch-perf-test\r
219 new file mode 100755\r
220 index 0000000..1bea345\r
221 --- /dev/null\r
222 +++ b/performance-test/notmuch-perf-test\r
223 @@ -0,0 +1,25 @@\r
224 +#!/usr/bin/env bash\r
225 +\r
226 +# Run tests\r
227 +#\r
228 +# Copyright (c) 2005 Junio C Hamano\r
229 +#\r
230 +# Adapted from a Makefile to a shell script by Carl Worth (2010)\r
231 +\r
232 +if [ ${BASH_VERSINFO[0]} -lt 4 ]; then\r
233 +    echo "Error: The notmuch test suite requires a bash version >= 4.0"\r
234 +    echo "due to use of associative arrays within the test suite."\r
235 +    echo "Please try again with a newer bash (or help us fix the"\r
236 +    echo "test suite to be more portable). Thanks."\r
237 +    exit 1\r
238 +fi\r
239 +\r
240 +cd $(dirname "$0")\r
241 +\r
242 +TESTS="\r
243 +  basic\r
244 +"\r
245 +\r
246 +for test in $TESTS; do\r
247 +    ./$test "$@"\r
248 +done\r
249 diff --git a/performance-test/perf-test-lib.sh b/performance-test/perf-test-lib.sh\r
250 new file mode 100644\r
251 index 0000000..0447852\r
252 --- /dev/null\r
253 +++ b/performance-test/perf-test-lib.sh\r
254 @@ -0,0 +1,36 @@\r
255 +\r
256 +. ../test/test-lib-common.sh\r
257 +\r
258 +set -e\r
259 +\r
260 +if ! test -x ../notmuch\r
261 +then\r
262 +       echo >&2 'You do not seem to have built notmuch yet.'\r
263 +       exit 1\r
264 +fi\r
265 +\r
266 +add_email_corpus ()\r
267 +{\r
268 +    rm -rf ${MAIL_DIR}\r
269 +    cp -a $TEST_DIRECTORY/corpus ${MAIL_DIR}\r
270 +}\r
271 +\r
272 +time_run () {\r
273 +    printf "%-25s" "$1"\r
274 +    if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi\r
275 +    if ! eval >&3 "/usr/bin/time -f '%e %U %S' $2" ; then\r
276 +       test_failure=$(($test_failure + 1))\r
277 +    fi\r
278 +}\r
279 +\r
280 +time_done () {\r
281 +    if [ "$test_failure" = "0" ]; then\r
282 +       rm -rf "$remove_tmp"\r
283 +       exit 0\r
284 +    else\r
285 +       exit 1\r
286 +    fi\r
287 +}\r
288 +\r
289 +cd -P "$test" || error "Cannot setup test environment"\r
290 +test_failure=0\r
291 -- \r
292 1.7.10.4\r
293 \r