Re: [PATCH v4 10/16] Add n_d_add_message_with_indexopts (extension of n_d_add_message)
[notmuch-archives.git] / a0 / badb551dff3a701ef29e2462c833387bf5ef8c
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 B1EBF431FAF\r
6         for <notmuch@notmuchmail.org>; Wed, 21 Nov 2012 04:32:02 -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 zFeFnAThjxEZ for <notmuch@notmuchmail.org>;\r
16         Wed, 21 Nov 2012 04:32:00 -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 95DB5431FBC\r
21         for <notmuch@notmuchmail.org>; Wed, 21 Nov 2012 04:32:00 -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 1Tb9TC-0001w3-SB; Wed, 21 Nov 2012 08:31:59 -0400\r
28 Received: from bremner by zancas.localnet with local (Exim 4.80)\r
29         (envelope-from <bremner@tethera.net>)\r
30         id 1Tb9T7-0005Gf-Cy; Wed, 21 Nov 2012 08:31:53 -0400\r
31 From: david@tethera.net\r
32 To: notmuch@notmuchmail.org\r
33 Subject: [Patch v3 2/2] test: initial performance testing infrastructure\r
34 Date: Wed, 21 Nov 2012 08:31:40 -0400\r
35 Message-Id: <1353501100-20072-3-git-send-email-david@tethera.net>\r
36 X-Mailer: git-send-email 1.7.10.4\r
37 In-Reply-To: <1353501100-20072-1-git-send-email-david@tethera.net>\r
38 References: <1353501100-20072-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: Wed, 21 Nov 2012 12:32:03 -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                        |    1 +\r
65  performance-test/Makefile                          |    7 +++\r
66  performance-test/Makefile.local                    |   24 ++++++++\r
67  performance-test/README                            |   53 ++++++++++++++++\r
68  performance-test/basic                             |   15 +++++\r
69  performance-test/download/.gitignore               |    2 +\r
70  .../download/notmuch-email-corpus-0.2.tar.xz.asc   |    9 +++\r
71  performance-test/notmuch-perf-test                 |   25 ++++++++\r
72  performance-test/perf-test-lib.sh                  |   65 ++++++++++++++++++++\r
73  performance-test/version.sh                        |    3 +\r
74  11 files changed, 206 insertions(+), 1 deletion(-)\r
75  create mode 100644 performance-test/.gitignore\r
76  create mode 100644 performance-test/Makefile\r
77  create mode 100644 performance-test/Makefile.local\r
78  create mode 100644 performance-test/README\r
79  create mode 100755 performance-test/basic\r
80  create mode 100644 performance-test/download/.gitignore\r
81  create mode 100644 performance-test/download/notmuch-email-corpus-0.2.tar.xz.asc\r
82  create mode 100755 performance-test/notmuch-perf-test\r
83  create mode 100644 performance-test/perf-test-lib.sh\r
84  create mode 100644 performance-test/version.sh\r
85 \r
86 diff --git a/Makefile b/Makefile\r
87 index bb9c316..5decbea 100644\r
88 --- a/Makefile\r
89 +++ b/Makefile\r
90 @@ -3,7 +3,8 @@\r
91  all:\r
92  \r
93  # List all subdirectories here. Each contains its own Makefile.local\r
94 -subdirs = compat completion emacs lib man parse-time-string util test\r
95 +subdirs := compat completion emacs lib man parse-time-string\r
96 +subdirs := $(subdirs) performance-test util test\r
97  \r
98  # We make all targets depend on the Makefiles themselves.\r
99  global_deps = Makefile Makefile.config Makefile.local \\r
100 diff --git a/performance-test/.gitignore b/performance-test/.gitignore\r
101 new file mode 100644\r
102 index 0000000..53f2697\r
103 --- /dev/null\r
104 +++ b/performance-test/.gitignore\r
105 @@ -0,0 +1 @@\r
106 +tmp.*/\r
107 diff --git a/performance-test/Makefile b/performance-test/Makefile\r
108 new file mode 100644\r
109 index 0000000..de492a7\r
110 --- /dev/null\r
111 +++ b/performance-test/Makefile\r
112 @@ -0,0 +1,7 @@\r
113 +# See Makefile.local for the list of files to be compiled in this\r
114 +# directory.\r
115 +all:\r
116 +       $(MAKE) -C .. all\r
117 +\r
118 +.DEFAULT:\r
119 +       $(MAKE) -C .. $@\r
120 diff --git a/performance-test/Makefile.local b/performance-test/Makefile.local\r
121 new file mode 100644\r
122 index 0000000..ba505c4\r
123 --- /dev/null\r
124 +++ b/performance-test/Makefile.local\r
125 @@ -0,0 +1,24 @@\r
126 +# -*- makefile -*-\r
127 +\r
128 +dir := performance-test\r
129 +\r
130 +include $(dir)/version.sh\r
131 +\r
132 +TXZFILE := $(dir)/download/notmuch-email-corpus-$(PERFTEST_VERSION).tar.xz\r
133 +SIGFILE := $(TXZFILE).asc\r
134 +TEST_SCRIPT := $(dir)/notmuch-perf-test\r
135 +\r
136 +perf-test: setup-perf-test all\r
137 +       $(TEST_SCRIPT) $(OPTIONS)\r
138 +\r
139 +setup-perf-test: $(TXZFILE)\r
140 +       gpg --verify $(SIGFILE)\r
141 +\r
142 +$(TXZFILE):\r
143 +       @echo\r
144 +       @echo Please download ${TXZFILE}\r
145 +       @echo See http://notmuchmail.org/corpus for download locations\r
146 +       @echo\r
147 +       @false\r
148 +\r
149 +CLEAN := $(CLEAN) $(dir)/tmp.*\r
150 diff --git a/performance-test/README b/performance-test/README\r
151 new file mode 100644\r
152 index 0000000..6d3fbba\r
153 --- /dev/null\r
154 +++ b/performance-test/README\r
155 @@ -0,0 +1,53 @@\r
156 +Pre-requisites\r
157 +--------------\r
158 +\r
159 +In addition to having notmuch, you need:\r
160 +\r
161 +- gpg\r
162 +- gnu tar\r
163 +- gnu time\r
164 +- xz. Some speedup can be gotten by installing "pixz", but this is\r
165 +  probably only worthwhile if you are debugging the tests.\r
166 +\r
167 +Getting set up to run tests:\r
168 +----------------------------\r
169 +\r
170 +First, you need to get the corpus.\r
171 +\r
172 +It should work to run\r
173 +\r
174 +   % cd download\r
175 +   % wget http://notmuchmail.org/releases/notmuch-email-corpus-${V}.tar.gz\r
176 +\r
177 +Where $V is the current version.\r
178 +\r
179 +In case that fails or is too slow, check\r
180 +\r
181 +   http://notmuchmail.org/corpus\r
182 +\r
183 +for a list of mirrors.\r
184 +\r
185 +Running tests\r
186 +-------------\r
187 +\r
188 +The easiest way to run performance tests is to say "make perf-test", (or\r
189 +simply run the notmuch-perf-test script). Either command will run all\r
190 +available performance tests.\r
191 +\r
192 +Alternately, you can run a specific subset of tests by simply invoking\r
193 +one of the executable scripts in this directory, (such as ./basic).\r
194 +\r
195 +\r
196 +Writing tests\r
197 +-------------\r
198 +\r
199 +Have a look at "basic" for an example.\r
200 +\r
201 +add_email_corpus takes arguments "--small" and "--medium" for when you\r
202 +want smaller corpuses to check.\r
203 +\r
204 +time_done does the cleanup; comment it out or define "$debug" to leave\r
205 +the temporary files around.\r
206 +\r
207 +Currently there is no option processing (e.g. --debug) in the\r
208 +performance tests.\r
209 diff --git a/performance-test/basic b/performance-test/basic\r
210 new file mode 100755\r
211 index 0000000..9d015ee\r
212 --- /dev/null\r
213 +++ b/performance-test/basic\r
214 @@ -0,0 +1,15 @@\r
215 +#!/bin/bash\r
216 +\r
217 +. ./perf-test-lib.sh\r
218 +\r
219 +add_email_corpus\r
220 +\r
221 +print_header\r
222 +\r
223 +time_run 'initial notmuch new' 'notmuch new'\r
224 +time_run 'second notmuch new' 'notmuch new'\r
225 +time_run 'dump *' 'notmuch dump > tags.out'\r
226 +time_run 'restore *' 'notmuch restore < tags.out'\r
227 +time_run 'tag * +new_tag' "notmuch tag +new_tag '*'"\r
228 +\r
229 +time_done\r
230 diff --git a/performance-test/download/.gitignore b/performance-test/download/.gitignore\r
231 new file mode 100644\r
232 index 0000000..7b09234\r
233 --- /dev/null\r
234 +++ b/performance-test/download/.gitignore\r
235 @@ -0,0 +1,2 @@\r
236 +*.tar.gz\r
237 +*.tar.xz\r
238 diff --git a/performance-test/download/notmuch-email-corpus-0.2.tar.xz.asc b/performance-test/download/notmuch-email-corpus-0.2.tar.xz.asc\r
239 new file mode 100644\r
240 index 0000000..c8b4b3d\r
241 --- /dev/null\r
242 +++ b/performance-test/download/notmuch-email-corpus-0.2.tar.xz.asc\r
243 @@ -0,0 +1,9 @@\r
244 +-----BEGIN PGP SIGNATURE-----\r
245 +Version: GnuPG v1.4.12 (GNU/Linux)\r
246 +\r
247 +iJwEAAECAAYFAlCsvx0ACgkQTiiN/0Um85kZAwP9GgOQ22jK8mr5X4pT/mB8EjSH\r
248 +QbndlxxbRrP0ChTqjBQoD3IsTHjNL7W572BfXb/MNo94R/iIQ7yTHCDVNuwBhvKd\r
249 +7qgIuW2FUS1uTfJRP5KBNf8JPuin+6wqGe8/+y/iOs+XJSdiYg1ElS49Ntnpg0yl\r
250 +btImgEcxTxQ2qfzDS1g=\r
251 +=iuZR\r
252 +-----END PGP SIGNATURE-----\r
253 diff --git a/performance-test/notmuch-perf-test b/performance-test/notmuch-perf-test\r
254 new file mode 100755\r
255 index 0000000..1bea345\r
256 --- /dev/null\r
257 +++ b/performance-test/notmuch-perf-test\r
258 @@ -0,0 +1,25 @@\r
259 +#!/usr/bin/env bash\r
260 +\r
261 +# Run tests\r
262 +#\r
263 +# Copyright (c) 2005 Junio C Hamano\r
264 +#\r
265 +# Adapted from a Makefile to a shell script by Carl Worth (2010)\r
266 +\r
267 +if [ ${BASH_VERSINFO[0]} -lt 4 ]; then\r
268 +    echo "Error: The notmuch test suite requires a bash version >= 4.0"\r
269 +    echo "due to use of associative arrays within the test suite."\r
270 +    echo "Please try again with a newer bash (or help us fix the"\r
271 +    echo "test suite to be more portable). Thanks."\r
272 +    exit 1\r
273 +fi\r
274 +\r
275 +cd $(dirname "$0")\r
276 +\r
277 +TESTS="\r
278 +  basic\r
279 +"\r
280 +\r
281 +for test in $TESTS; do\r
282 +    ./$test "$@"\r
283 +done\r
284 diff --git a/performance-test/perf-test-lib.sh b/performance-test/perf-test-lib.sh\r
285 new file mode 100644\r
286 index 0000000..fae9161\r
287 --- /dev/null\r
288 +++ b/performance-test/perf-test-lib.sh\r
289 @@ -0,0 +1,65 @@\r
290 +. version.sh\r
291 +\r
292 +. ../test/test-lib-common.sh\r
293 +\r
294 +set -e\r
295 +\r
296 +if ! test -x ../notmuch\r
297 +then\r
298 +       echo >&2 'You do not seem to have built notmuch yet.'\r
299 +       exit 1\r
300 +fi\r
301 +\r
302 +add_email_corpus ()\r
303 +{\r
304 +    rm -rf ${MAIL_DIR}\r
305 +\r
306 +    arg=""\r
307 +    case "$1" in\r
308 +       --small)\r
309 +           arg="/enron/bailey-s"\r
310 +           ;;\r
311 +       --medium)\r
312 +           arg="/notmuch-archive"\r
313 +           ;;\r
314 +    esac\r
315 +\r
316 +    if command -v pixz > /dev/null; then\r
317 +       XZ=pixz\r
318 +    else\r
319 +       XZ=xz\r
320 +    fi\r
321 +\r
322 +    printf "Unpacking corpus\n"\r
323 +    tar --checkpoint=.5000 --extract --strip-components=1 \\r
324 +       --directory ${TMP_DIRECTORY} \\r
325 +       --use-compress-program ${XZ} \\r
326 +       --file ../download/notmuch-email-corpus-${PERFTEST_VERSION}.tar.xz \\r
327 +       notmuch-email-corpus/mail"$arg"\r
328 +\r
329 +    printf "\n"\r
330 +}\r
331 +\r
332 +print_header () {\r
333 +    printf "                      Wall(s)\tUsr(s)\tSys(s)\tRes(K)\tIn\tOut\n"\r
334 +}\r
335 +\r
336 +time_run () {\r
337 +    printf "%-22s" "$1"\r
338 +    if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi\r
339 +    if ! eval >&3 "/usr/bin/time -f '%e\t%U\t%S\t%M\t%I\t%O' $2" ; then\r
340 +       test_failure=$(($test_failure + 1))\r
341 +    fi\r
342 +}\r
343 +\r
344 +time_done () {\r
345 +    if [ "$test_failure" = "0" ]; then\r
346 +       rm -rf "$remove_tmp"\r
347 +       exit 0\r
348 +    else\r
349 +       exit 1\r
350 +    fi\r
351 +}\r
352 +\r
353 +cd -P "$test" || error "Cannot setup test environment"\r
354 +test_failure=0\r
355 diff --git a/performance-test/version.sh b/performance-test/version.sh\r
356 new file mode 100644\r
357 index 0000000..d9270b1\r
358 --- /dev/null\r
359 +++ b/performance-test/version.sh\r
360 @@ -0,0 +1,3 @@\r
361 +# this should be both a valid Makefile fragment and valid POSIX(ish) shell.\r
362 +\r
363 +PERFTEST_VERSION=0.2\r
364 -- \r
365 1.7.10.4\r
366 \r