Re: [PATCH 5/5] lib: Add "lastmod:" queries for filtering by last modification
[notmuch-archives.git] / 7e / e82aee20586547f9787b1b7cdc09c7d1d69c60
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 21329431FB6\r
6         for <notmuch@notmuchmail.org>; Sun, 25 Nov 2012 07:02:47 -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 zJXOu7xviP0c for <notmuch@notmuchmail.org>;\r
16         Sun, 25 Nov 2012 07:02:43 -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 06627431FC4\r
21         for <notmuch@notmuchmail.org>; Sun, 25 Nov 2012 07:02:41 -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 1TcdjD-0007HR-Du; Sun, 25 Nov 2012 11:02:40 -0400\r
28 Received: from bremner by zancas.localnet with local (Exim 4.80)\r
29         (envelope-from <bremner@tethera.net>)\r
30         id 1Tcdj7-00034t-UQ; Sun, 25 Nov 2012 11:02:33 -0400\r
31 From: david@tethera.net\r
32 To: notmuch@notmuchmail.org\r
33 Subject: [Patch v4 2/2] test: initial performance testing infrastructure\r
34 Date: Sun, 25 Nov 2012 11:02:24 -0400\r
35 Message-Id: <1353855745-11697-3-git-send-email-david@tethera.net>\r
36 X-Mailer: git-send-email 1.7.10.4\r
37 In-Reply-To: <1353855745-11697-1-git-send-email-david@tethera.net>\r
38 References: <1353855745-11697-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: Sun, 25 Nov 2012 15:02:47 -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                    |   32 ++++++++++\r
67  performance-test/README                            |   50 +++++++++++++++\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, 211 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..1114ec1\r
123 --- /dev/null\r
124 +++ b/performance-test/Makefile.local\r
125 @@ -0,0 +1,32 @@\r
126 +# -*- makefile -*-\r
127 +\r
128 +dir := performance-test\r
129 +\r
130 +include $(dir)/version.sh\r
131 +\r
132 +CORPUS_NAME := notmuch-email-corpus-$(PERFTEST_VERSION).tar.xz\r
133 +TXZFILE := ${dir}/download/${CORPUS_NAME}\r
134 +SIGFILE := ${TXZFILE}.asc\r
135 +TEST_SCRIPT := ${dir}/notmuch-perf-test\r
136 +DEFAULT_URL :=  http://notmuchmail.org/releases/${CORPUS_NAME}\r
137 +\r
138 +perf-test: setup-perf-test all\r
139 +       $(TEST_SCRIPT) $(OPTIONS)\r
140 +\r
141 +.PHONY: download-corpus setup-perf-test\r
142 +\r
143 +# Note that this intentionally does not depend on download-corpus.\r
144 +setup-perf-test: $(TXZFILE)\r
145 +       gpg --verify $(SIGFILE)\r
146 +\r
147 +$(TXZFILE):\r
148 +       @printf "\nPlease download ${TXZFILE}.\n\n"\r
149 +       @printf "\t%% make download-corpus\n\n"\r
150 +       @echo or see http://notmuchmail.org/corpus for download locations\r
151 +       @echo\r
152 +       @false\r
153 +\r
154 +download-corpus:\r
155 +       wget -O ${TXZFILE} ${DEFAULT_URL}\r
156 +\r
157 +CLEAN := $(CLEAN) $(dir)/tmp.*\r
158 diff --git a/performance-test/README b/performance-test/README\r
159 new file mode 100644\r
160 index 0000000..239d2fb\r
161 --- /dev/null\r
162 +++ b/performance-test/README\r
163 @@ -0,0 +1,50 @@\r
164 +Pre-requisites\r
165 +--------------\r
166 +\r
167 +In addition to having notmuch, you need:\r
168 +\r
169 +- gpg\r
170 +- gnu tar\r
171 +- gnu time\r
172 +- xz. Some speedup can be gotten by installing "pixz", but this is\r
173 +  probably only worthwhile if you are debugging the tests.\r
174 +\r
175 +Getting set up to run tests:\r
176 +----------------------------\r
177 +\r
178 +First, you need to get the corpus.\r
179 +\r
180 +It should work to run\r
181 +\r
182 +   % make download-corpus\r
183 +\r
184 +In case that fails or is too slow, check\r
185 +\r
186 +   http://notmuchmail.org/corpus\r
187 +\r
188 +for a list of mirrors.\r
189 +\r
190 +Running tests\r
191 +-------------\r
192 +\r
193 +The easiest way to run performance tests is to say "make perf-test", (or\r
194 +simply run the notmuch-perf-test script). Either command will run all\r
195 +available performance tests.\r
196 +\r
197 +Alternately, you can run a specific subset of tests by simply invoking\r
198 +one of the executable scripts in this directory, (such as ./basic).\r
199 +\r
200 +\r
201 +Writing tests\r
202 +-------------\r
203 +\r
204 +Have a look at "basic" for an example.\r
205 +\r
206 +add_email_corpus takes arguments "--small" and "--medium" for when you\r
207 +want smaller corpuses to check.\r
208 +\r
209 +time_done does the cleanup; comment it out or define "$debug" to leave\r
210 +the temporary files around.\r
211 +\r
212 +Currently there is no option processing (e.g. --debug) in the\r
213 +performance tests.\r
214 diff --git a/performance-test/basic b/performance-test/basic\r
215 new file mode 100755\r
216 index 0000000..9d015ee\r
217 --- /dev/null\r
218 +++ b/performance-test/basic\r
219 @@ -0,0 +1,15 @@\r
220 +#!/bin/bash\r
221 +\r
222 +. ./perf-test-lib.sh\r
223 +\r
224 +add_email_corpus\r
225 +\r
226 +print_header\r
227 +\r
228 +time_run 'initial notmuch new' 'notmuch new'\r
229 +time_run 'second notmuch new' 'notmuch new'\r
230 +time_run 'dump *' 'notmuch dump > tags.out'\r
231 +time_run 'restore *' 'notmuch restore < tags.out'\r
232 +time_run 'tag * +new_tag' "notmuch tag +new_tag '*'"\r
233 +\r
234 +time_done\r
235 diff --git a/performance-test/download/.gitignore b/performance-test/download/.gitignore\r
236 new file mode 100644\r
237 index 0000000..7b09234\r
238 --- /dev/null\r
239 +++ b/performance-test/download/.gitignore\r
240 @@ -0,0 +1,2 @@\r
241 +*.tar.gz\r
242 +*.tar.xz\r
243 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
244 new file mode 100644\r
245 index 0000000..c8b4b3d\r
246 --- /dev/null\r
247 +++ b/performance-test/download/notmuch-email-corpus-0.2.tar.xz.asc\r
248 @@ -0,0 +1,9 @@\r
249 +-----BEGIN PGP SIGNATURE-----\r
250 +Version: GnuPG v1.4.12 (GNU/Linux)\r
251 +\r
252 +iJwEAAECAAYFAlCsvx0ACgkQTiiN/0Um85kZAwP9GgOQ22jK8mr5X4pT/mB8EjSH\r
253 +QbndlxxbRrP0ChTqjBQoD3IsTHjNL7W572BfXb/MNo94R/iIQ7yTHCDVNuwBhvKd\r
254 +7qgIuW2FUS1uTfJRP5KBNf8JPuin+6wqGe8/+y/iOs+XJSdiYg1ElS49Ntnpg0yl\r
255 +btImgEcxTxQ2qfzDS1g=\r
256 +=iuZR\r
257 +-----END PGP SIGNATURE-----\r
258 diff --git a/performance-test/notmuch-perf-test b/performance-test/notmuch-perf-test\r
259 new file mode 100755\r
260 index 0000000..1bea345\r
261 --- /dev/null\r
262 +++ b/performance-test/notmuch-perf-test\r
263 @@ -0,0 +1,25 @@\r
264 +#!/usr/bin/env bash\r
265 +\r
266 +# Run tests\r
267 +#\r
268 +# Copyright (c) 2005 Junio C Hamano\r
269 +#\r
270 +# Adapted from a Makefile to a shell script by Carl Worth (2010)\r
271 +\r
272 +if [ ${BASH_VERSINFO[0]} -lt 4 ]; then\r
273 +    echo "Error: The notmuch test suite requires a bash version >= 4.0"\r
274 +    echo "due to use of associative arrays within the test suite."\r
275 +    echo "Please try again with a newer bash (or help us fix the"\r
276 +    echo "test suite to be more portable). Thanks."\r
277 +    exit 1\r
278 +fi\r
279 +\r
280 +cd $(dirname "$0")\r
281 +\r
282 +TESTS="\r
283 +  basic\r
284 +"\r
285 +\r
286 +for test in $TESTS; do\r
287 +    ./$test "$@"\r
288 +done\r
289 diff --git a/performance-test/perf-test-lib.sh b/performance-test/perf-test-lib.sh\r
290 new file mode 100644\r
291 index 0000000..11ccc77\r
292 --- /dev/null\r
293 +++ b/performance-test/perf-test-lib.sh\r
294 @@ -0,0 +1,65 @@\r
295 +. ./version.sh\r
296 +\r
297 +. ../test/test-lib-common.sh\r
298 +\r
299 +set -e\r
300 +\r
301 +if ! test -x ../notmuch\r
302 +then\r
303 +       echo >&2 'You do not seem to have built notmuch yet.'\r
304 +       exit 1\r
305 +fi\r
306 +\r
307 +add_email_corpus ()\r
308 +{\r
309 +    rm -rf ${MAIL_DIR}\r
310 +\r
311 +    arg=""\r
312 +    case "$1" in\r
313 +       --small)\r
314 +           arg="/enron/bailey-s"\r
315 +           ;;\r
316 +       --medium)\r
317 +           arg="/notmuch-archive"\r
318 +           ;;\r
319 +    esac\r
320 +\r
321 +    if command -v pixz > /dev/null; then\r
322 +       XZ=pixz\r
323 +    else\r
324 +       XZ=xz\r
325 +    fi\r
326 +\r
327 +    printf "Unpacking corpus\n"\r
328 +    tar --checkpoint=.5000 --extract --strip-components=1 \\r
329 +       --directory ${TMP_DIRECTORY} \\r
330 +       --use-compress-program ${XZ} \\r
331 +       --file ../download/notmuch-email-corpus-${PERFTEST_VERSION}.tar.xz \\r
332 +       notmuch-email-corpus/mail"$arg"\r
333 +\r
334 +    printf "\n"\r
335 +}\r
336 +\r
337 +print_header () {\r
338 +    printf "                      Wall(s)\tUsr(s)\tSys(s)\tRes(K)\tIn\tOut\n"\r
339 +}\r
340 +\r
341 +time_run () {\r
342 +    printf "%-22s" "$1"\r
343 +    if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi\r
344 +    if ! eval >&3 "/usr/bin/time -f '%e\t%U\t%S\t%M\t%I\t%O' $2" ; then\r
345 +       test_failure=$(($test_failure + 1))\r
346 +    fi\r
347 +}\r
348 +\r
349 +time_done () {\r
350 +    if [ "$test_failure" = "0" ]; then\r
351 +       rm -rf "$remove_tmp"\r
352 +       exit 0\r
353 +    else\r
354 +       exit 1\r
355 +    fi\r
356 +}\r
357 +\r
358 +cd -P "$test" || error "Cannot setup test environment"\r
359 +test_failure=0\r
360 diff --git a/performance-test/version.sh b/performance-test/version.sh\r
361 new file mode 100644\r
362 index 0000000..d9270b1\r
363 --- /dev/null\r
364 +++ b/performance-test/version.sh\r
365 @@ -0,0 +1,3 @@\r
366 +# this should be both a valid Makefile fragment and valid POSIX(ish) shell.\r
367 +\r
368 +PERFTEST_VERSION=0.2\r
369 -- \r
370 1.7.10.4\r
371 \r