Re: [PATCH v3] nmbug: Translate to Python
[notmuch-archives.git] / 18 / 9a860c02000efdc26fe7d925ca4f91ff012a25
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 B3421431FBD\r
6         for <notmuch@notmuchmail.org>; Mon, 24 Dec 2012 06:59:37 -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 zzTlHU3ij6Zw for <notmuch@notmuchmail.org>;\r
16         Mon, 24 Dec 2012 06:59:36 -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 A2D66431FAF\r
21         for <notmuch@notmuchmail.org>; Mon, 24 Dec 2012 06:59:36 -0800 (PST)\r
22 Received: from fctnnbsc30w-156034082078.dhcp-dynamic.fibreop.nb.bellaliant.net\r
23         ([156.34.82.78] 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>) id 1Tn9V9-0000TR-7K\r
27         for notmuch@notmuchmail.org; Mon, 24 Dec 2012 10:59:35 -0400\r
28 Received: from bremner by zancas.localnet with local (Exim 4.80)\r
29         (envelope-from <bremner@tethera.net>) id 1Tn9V3-0001kR-GO\r
30         for notmuch@notmuchmail.org; Mon, 24 Dec 2012 10:59:29 -0400\r
31 From: david@tethera.net\r
32 To: notmuch@notmuchmail.org\r
33 Subject: v2 of valgrind based memory tests\r
34 Date: Mon, 24 Dec 2012 10:59:16 -0400\r
35 Message-Id: <1356361160-6449-1-git-send-email-david@tethera.net>\r
36 X-Mailer: git-send-email 1.7.10.4\r
37 X-Spam_bar: -\r
38 X-BeenThere: notmuch@notmuchmail.org\r
39 X-Mailman-Version: 2.1.13\r
40 Precedence: list\r
41 List-Id: "Use and development of the notmuch mail system."\r
42         <notmuch.notmuchmail.org>\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
46 List-Post: <mailto:notmuch@notmuchmail.org>\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
50 X-List-Received-Date: Mon, 24 Dec 2012 14:59:38 -0000\r
51 \r
52 These obsolete\r
53       \r
54       id:1355196820-29734-1-git-send-email-david@tethera.net\r
55 \r
56 I tried to follow the suggestions of \r
57 \r
58   id:20121216191121.GH6187@mit.edu\r
59 \r
60 pretty closely.\r
61 \r
62 diff --git a/performance-test/M00-new b/performance-test/M00-new\r
63 index 733e9b0..99c3f52 100755\r
64 --- a/performance-test/M00-new\r
65 +++ b/performance-test/M00-new\r
66 @@ -9,6 +9,7 @@ uncache_database\r
67  \r
68  memory_start\r
69  \r
70 +# run 'notmuch new' a second time, to test different code paths\r
71  memory_run "notmuch new" "notmuch new"\r
72  \r
73  memory_done\r
74 diff --git a/performance-test/Makefile.local b/performance-test/Makefile.local\r
75 index 357d800..73aa963 100644\r
76 --- a/performance-test/Makefile.local\r
77 +++ b/performance-test/Makefile.local\r
78 @@ -4,7 +4,6 @@ dir := performance-test\r
79  \r
80  include $(dir)/version.sh\r
81  \r
82 -# these two are just make sure dir is expanded at the right time.\r
83  TIME_TEST_SCRIPT := ${dir}/notmuch-time-test\r
84  MEMORY_TEST_SCRIPT := ${dir}/notmuch-memory-test\r
85  \r
86 @@ -17,11 +16,11 @@ perf-test: time-test memory-test\r
87  \r
88  time-test: setup-perf-test all\r
89         @echo\r
90 -       $(TIME_TEST_SCRIPT) $(TEST_OPTIONS)\r
91 +       $(TIME_TEST_SCRIPT) $(OPTIONS)\r
92  \r
93  memory-test: setup-perf-test all\r
94         @echo\r
95 -       $(MEMORY_TEST_SCRIPT) $(TEST_OPTIONS)\r
96 +       $(MEMORY_TEST_SCRIPT) $(OPTIONS)\r
97  \r
98  \r
99  .PHONY: download-corpus setup-perf-test\r
100 diff --git a/performance-test/README b/performance-test/README\r
101 index 7eaf5f7..996724c 100644\r
102 --- a/performance-test/README\r
103 +++ b/performance-test/README\r
104 @@ -1,7 +1,7 @@\r
105  Performance Tests\r
106  -----------------\r
107  \r
108 -This directory contains two kinds of performance tests, time tests,\r
109 +This directory contains two kinds of performance tests: time tests,\r
110  and memory tests. The former use gnu time, and the latter use\r
111  valgrind.\r
112  \r
113 @@ -12,7 +12,7 @@ In addition to having notmuch, you need:\r
114  \r
115  - gpg\r
116  - gnu tar\r
117 -- gnu time (for the time tests).\r
118 +- gnu time (for the time tests)\r
119  - xz. Some speedup can be gotten by installing "pixz", but this is\r
120    probably only worthwhile if you are debugging the tests.\r
121  - valgrind (for the memory tests)\r
122 @@ -59,13 +59,13 @@ supports the following arguments\r
123                                 temporary directories.\r
124  \r
125  When using the make targets, you can pass arguments to all test\r
126 -scripts by defining the make variable TEST_OPTIONS.\r
127 +scripts by defining the make variable OPTIONS.\r
128  \r
129  Writing tests\r
130  -------------\r
131  \r
132 -Have a look at "T01-dump-restore" for an example time test and and\r
133 -"M00-new" for an example memory tests. In both cases sourcing\r
134 +Have a look at "T01-dump-restore" for an example time test and\r
135 +"M00-new" for an example memory test. In both cases sourcing\r
136  "perf-test-lib.sh" is mandatory.\r
137  \r
138  Basics:\r
139 diff --git a/performance-test/perf-test-lib.sh b/performance-test/perf-test-lib.sh\r
140 index 79eb2c5..10d05e0 100644\r
141 --- a/performance-test/perf-test-lib.sh\r
142 +++ b/performance-test/perf-test-lib.sh\r
143 @@ -89,11 +89,10 @@ add_email_corpus ()\r
144  \r
145      cp -lr $TAG_CORPUS $TMP_DIRECTORY/corpus.tags\r
146      cp -lr $MAIL_CORPUS $MAIL_DIR\r
147 -\r
148  }\r
149  \r
150 -notmuch_new_with_cache () {\r
151 -\r
152 +notmuch_new_with_cache ()\r
153 +{\r
154      if [ -d $DB_CACHE_DIR ]; then\r
155         cp -r $DB_CACHE_DIR ${MAIL_DIR}/.notmuch\r
156      else\r
157 @@ -102,8 +101,8 @@ notmuch_new_with_cache () {\r
158      fi\r
159  }\r
160  \r
161 -time_start () {\r
162 -\r
163 +time_start ()\r
164 +{\r
165      add_email_corpus\r
166  \r
167      print_header\r
168 @@ -111,17 +110,19 @@ time_start () {\r
169      notmuch_new_with_cache time_run\r
170  }\r
171  \r
172 -memory_start () {\r
173 -\r
174 +memory_start ()\r
175 +{\r
176      add_email_corpus\r
177  \r
178 -    _timestamp=$(printf "%x" $(date +"%s"))\r
179 -    log_dir=$(mktemp -d "${TEST_DIRECTORY}/log.$(basename $0)-$corpus_size-${_timestamp}-XXXXXX")\r
180 +    local timestamp=$(date +%Y%m%dT%H%M%S)\r
181 +    log_dir="${TEST_DIRECTORY}/log.$(basename $0)-$corpus_size-${timestamp}"\r
182 +    mkdir -p ${log_dir}\r
183  \r
184      notmuch_new_with_cache memory_run\r
185  }\r
186  \r
187 -memory_run () {\r
188 +memory_run ()\r
189 +{\r
190      test_count=$(($test_count+1))\r
191  \r
192      log_file=$log_dir/$test_count.log\r
193 @@ -134,11 +135,13 @@ memory_run () {\r
194      echo\r
195  }\r
196  \r
197 -memory_done () {\r
198 +memory_done ()\r
199 +{\r
200      time_done\r
201  }\r
202  \r
203 -cache_database () {\r
204 +cache_database ()\r
205 +{\r
206      if [ -d $MAIL_DIR/.notmuch ]; then\r
207         cp -r $MAIL_DIR/.notmuch $DB_CACHE_DIR\r
208      else\r
209 @@ -146,16 +149,18 @@ cache_database () {\r
210      fi\r
211  }\r
212  \r
213 -uncache_database () {\r
214 +uncache_database ()\r
215 +{\r
216      rm -rf $DB_CACHE_DIR\r
217  }\r
218  \r
219 -print_header () {\r
220 +print_header ()\r
221 +{\r
222      printf "\t\t\tWall(s)\tUsr(s)\tSys(s)\tRes(K)\tIn/Out(512B)\n"\r
223 -\r
224  }\r
225  \r
226 -time_run () {\r
227 +time_run ()\r
228 +{\r
229      printf "  %-22s" "$1"\r
230      test_count=$(($test_count+1))\r
231      if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi\r
232 @@ -166,7 +171,8 @@ time_run () {\r
233      return 0\r
234  }\r
235  \r
236 -time_done () {\r
237 +time_done ()\r
238 +{\r
239      if [ "$test_failure" = "0" ]; then\r
240         rm -rf "$remove_tmp"\r
241         exit 0\r