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