v2 of valgrind based memory tests
authordavid <david@tethera.net>
Mon, 24 Dec 2012 14:59:16 +0000 (10:59 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:52:41 +0000 (09:52 -0800)
18/9a860c02000efdc26fe7d925ca4f91ff012a25 [new file with mode: 0644]

diff --git a/18/9a860c02000efdc26fe7d925ca4f91ff012a25 b/18/9a860c02000efdc26fe7d925ca4f91ff012a25
new file mode 100644 (file)
index 0000000..060f3d7
--- /dev/null
@@ -0,0 +1,241 @@
+Return-Path: <bremner@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id B3421431FBD\r
+       for <notmuch@notmuchmail.org>; Mon, 24 Dec 2012 06:59:37 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id zzTlHU3ij6Zw for <notmuch@notmuchmail.org>;\r
+       Mon, 24 Dec 2012 06:59:36 -0800 (PST)\r
+Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238])\r
+       (using TLSv1 with cipher AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id A2D66431FAF\r
+       for <notmuch@notmuchmail.org>; Mon, 24 Dec 2012 06:59:36 -0800 (PST)\r
+Received: from fctnnbsc30w-156034082078.dhcp-dynamic.fibreop.nb.bellaliant.net\r
+       ([156.34.82.78] helo=zancas.localnet)\r
+       by tesseract.cs.unb.ca with esmtpsa\r
+       (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72)\r
+       (envelope-from <bremner@tethera.net>) id 1Tn9V9-0000TR-7K\r
+       for notmuch@notmuchmail.org; Mon, 24 Dec 2012 10:59:35 -0400\r
+Received: from bremner by zancas.localnet with local (Exim 4.80)\r
+       (envelope-from <bremner@tethera.net>) id 1Tn9V3-0001kR-GO\r
+       for notmuch@notmuchmail.org; Mon, 24 Dec 2012 10:59:29 -0400\r
+From: david@tethera.net\r
+To: notmuch@notmuchmail.org\r
+Subject: v2 of valgrind based memory tests\r
+Date: Mon, 24 Dec 2012 10:59:16 -0400\r
+Message-Id: <1356361160-6449-1-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 1.7.10.4\r
+X-Spam_bar: -\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 24 Dec 2012 14:59:38 -0000\r
+\r
+These obsolete\r
+      \r
+      id:1355196820-29734-1-git-send-email-david@tethera.net\r
+\r
+I tried to follow the suggestions of \r
+\r
+  id:20121216191121.GH6187@mit.edu\r
+\r
+pretty closely.\r
+\r
+diff --git a/performance-test/M00-new b/performance-test/M00-new\r
+index 733e9b0..99c3f52 100755\r
+--- a/performance-test/M00-new\r
++++ b/performance-test/M00-new\r
+@@ -9,6 +9,7 @@ uncache_database\r
\r
+ memory_start\r
\r
++# run 'notmuch new' a second time, to test different code paths\r
+ memory_run "notmuch new" "notmuch new"\r
\r
+ memory_done\r
+diff --git a/performance-test/Makefile.local b/performance-test/Makefile.local\r
+index 357d800..73aa963 100644\r
+--- a/performance-test/Makefile.local\r
++++ b/performance-test/Makefile.local\r
+@@ -4,7 +4,6 @@ dir := performance-test\r
\r
+ include $(dir)/version.sh\r
\r
+-# these two are just make sure dir is expanded at the right time.\r
+ TIME_TEST_SCRIPT := ${dir}/notmuch-time-test\r
+ MEMORY_TEST_SCRIPT := ${dir}/notmuch-memory-test\r
\r
+@@ -17,11 +16,11 @@ perf-test: time-test memory-test\r
\r
+ time-test: setup-perf-test all\r
+       @echo\r
+-      $(TIME_TEST_SCRIPT) $(TEST_OPTIONS)\r
++      $(TIME_TEST_SCRIPT) $(OPTIONS)\r
\r
+ memory-test: setup-perf-test all\r
+       @echo\r
+-      $(MEMORY_TEST_SCRIPT) $(TEST_OPTIONS)\r
++      $(MEMORY_TEST_SCRIPT) $(OPTIONS)\r
\r
\r
+ .PHONY: download-corpus setup-perf-test\r
+diff --git a/performance-test/README b/performance-test/README\r
+index 7eaf5f7..996724c 100644\r
+--- a/performance-test/README\r
++++ b/performance-test/README\r
+@@ -1,7 +1,7 @@\r
+ Performance Tests\r
+ -----------------\r
\r
+-This directory contains two kinds of performance tests, time tests,\r
++This directory contains two kinds of performance tests: time tests,\r
+ and memory tests. The former use gnu time, and the latter use\r
+ valgrind.\r
\r
+@@ -12,7 +12,7 @@ In addition to having notmuch, you need:\r
\r
+ - gpg\r
+ - gnu tar\r
+-- gnu time (for the time tests).\r
++- gnu time (for the time tests)\r
+ - xz. Some speedup can be gotten by installing "pixz", but this is\r
+   probably only worthwhile if you are debugging the tests.\r
+ - valgrind (for the memory tests)\r
+@@ -59,13 +59,13 @@ supports the following arguments\r
+                               temporary directories.\r
\r
+ When using the make targets, you can pass arguments to all test\r
+-scripts by defining the make variable TEST_OPTIONS.\r
++scripts by defining the make variable OPTIONS.\r
\r
+ Writing tests\r
+ -------------\r
\r
+-Have a look at "T01-dump-restore" for an example time test and and\r
+-"M00-new" for an example memory tests. In both cases sourcing\r
++Have a look at "T01-dump-restore" for an example time test and\r
++"M00-new" for an example memory test. In both cases sourcing\r
+ "perf-test-lib.sh" is mandatory.\r
\r
+ Basics:\r
+diff --git a/performance-test/perf-test-lib.sh b/performance-test/perf-test-lib.sh\r
+index 79eb2c5..10d05e0 100644\r
+--- a/performance-test/perf-test-lib.sh\r
++++ b/performance-test/perf-test-lib.sh\r
+@@ -89,11 +89,10 @@ add_email_corpus ()\r
\r
+     cp -lr $TAG_CORPUS $TMP_DIRECTORY/corpus.tags\r
+     cp -lr $MAIL_CORPUS $MAIL_DIR\r
+-\r
+ }\r
\r
+-notmuch_new_with_cache () {\r
+-\r
++notmuch_new_with_cache ()\r
++{\r
+     if [ -d $DB_CACHE_DIR ]; then\r
+       cp -r $DB_CACHE_DIR ${MAIL_DIR}/.notmuch\r
+     else\r
+@@ -102,8 +101,8 @@ notmuch_new_with_cache () {\r
+     fi\r
+ }\r
\r
+-time_start () {\r
+-\r
++time_start ()\r
++{\r
+     add_email_corpus\r
\r
+     print_header\r
+@@ -111,17 +110,19 @@ time_start () {\r
+     notmuch_new_with_cache time_run\r
+ }\r
\r
+-memory_start () {\r
+-\r
++memory_start ()\r
++{\r
+     add_email_corpus\r
\r
+-    _timestamp=$(printf "%x" $(date +"%s"))\r
+-    log_dir=$(mktemp -d "${TEST_DIRECTORY}/log.$(basename $0)-$corpus_size-${_timestamp}-XXXXXX")\r
++    local timestamp=$(date +%Y%m%dT%H%M%S)\r
++    log_dir="${TEST_DIRECTORY}/log.$(basename $0)-$corpus_size-${timestamp}"\r
++    mkdir -p ${log_dir}\r
\r
+     notmuch_new_with_cache memory_run\r
+ }\r
\r
+-memory_run () {\r
++memory_run ()\r
++{\r
+     test_count=$(($test_count+1))\r
\r
+     log_file=$log_dir/$test_count.log\r
+@@ -134,11 +135,13 @@ memory_run () {\r
+     echo\r
+ }\r
\r
+-memory_done () {\r
++memory_done ()\r
++{\r
+     time_done\r
+ }\r
\r
+-cache_database () {\r
++cache_database ()\r
++{\r
+     if [ -d $MAIL_DIR/.notmuch ]; then\r
+       cp -r $MAIL_DIR/.notmuch $DB_CACHE_DIR\r
+     else\r
+@@ -146,16 +149,18 @@ cache_database () {\r
+     fi\r
+ }\r
\r
+-uncache_database () {\r
++uncache_database ()\r
++{\r
+     rm -rf $DB_CACHE_DIR\r
+ }\r
\r
+-print_header () {\r
++print_header ()\r
++{\r
+     printf "\t\t\tWall(s)\tUsr(s)\tSys(s)\tRes(K)\tIn/Out(512B)\n"\r
+-\r
+ }\r
\r
+-time_run () {\r
++time_run ()\r
++{\r
+     printf "  %-22s" "$1"\r
+     test_count=$(($test_count+1))\r
+     if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi\r
+@@ -166,7 +171,8 @@ time_run () {\r
+     return 0\r
+ }\r
\r
+-time_done () {\r
++time_done ()\r
++{\r
+     if [ "$test_failure" = "0" ]; then\r
+       rm -rf "$remove_tmp"\r
+       exit 0\r