]> git.cworth.org Git - notmuch/commitdiff
perf-test: allow running test_emacs from performance test suite.
authorDavid Bremner <david@tethera.net>
Sat, 12 Feb 2022 20:27:35 +0000 (16:27 -0400)
committerDavid Bremner <david@tethera.net>
Fri, 25 Feb 2022 12:38:03 +0000 (08:38 -0400)
test_require_external prereq has to move to test-lib-common.sh, and
the new shell functions print_emacs_header and time_emacs are provided.

The somewhat indirect way of printing the output is to avoid the extra
"" present on string values from emacsclient.

performance-test/perf-test-lib.sh
test/test-lib-common.sh
test/test-lib-emacs.sh
test/test-lib.el
test/test-lib.sh

index 0e4915e36b2ed7405be538f57d928d6d7628cee3..c34f8cd6ba975d4779c69313ab19b7af6697d616 100644 (file)
@@ -210,6 +210,11 @@ print_header ()
     printf "\t\t\tWall(s)\tUsr(s)\tSys(s)\tRes(K)\tIn/Out(512B)\n"
 }
 
+print_emacs_header ()
+{
+    printf "\t\t\tWall(s)\tGCs\tGC time(s)\n"
+}
+
 time_run ()
 {
     printf "  %-22s" "$1"
index ebbf4cdfa6fd2e727f78d651fdf31dcb8c3ead7d..18fa29c0dd86d3b7eb8ab5c3b69bd7f9a35cf89a 100644 (file)
@@ -29,6 +29,20 @@ if [[ -z "$NOTMUCH_SRCDIR" ]] || [[ -z "$NOTMUCH_BUILDDIR" ]]; then
        exit 1
 fi
 
+# Explicitly require external prerequisite.  Useful when binary is
+# called indirectly (e.g. from emacs).
+# Returns success if dependency is available, failure otherwise.
+test_require_external_prereq () {
+       local binary
+       binary="$1"
+       if [[ ${test_missing_external_prereq_["${binary}"]} == t ]]; then
+               # dependency is missing, call the replacement function to note it
+               eval "$binary"
+       else
+               true
+       fi
+}
+
 backup_database () {
     test_name=$(basename $0 .sh)
     rm -rf $TMP_DIRECTORY/notmuch-dir-backup."$test_name"
index a298526d5fedc7a310ffc98d44bf753ae649efa6..ad4c4aeb621afd02d5d3b4cf71b34cbe2f5b6d4e 100644 (file)
@@ -207,4 +207,12 @@ test_emacs () {
        ${TEST_EMACSCLIENT} --socket-name="$EMACS_SERVER" --eval "(notmuch-test-progn $*)"
 }
 
+time_emacs () {
+    rm -f MESSAGES
+    printf "%s" "$1"
+    shift
+    test_emacs "(test-time $*)" > emacs.out
+    tail -n 1 MESSAGES
+}
+
 emacs_generate_script
index 6831b46f668b771ed1234e7a3ed618a75adb8876..79a9d4d6fc5b574cbd21e6e9bd27039689a2d01a 100644 (file)
@@ -186,6 +186,11 @@ running, quit if it terminated."
        (t (message "%s" err)))
      (with-current-buffer "*Messages*" (test-output "MESSAGES"))))
 
+(defmacro test-time (&rest body)
+  `(let ((results (mapcar (lambda (x) (/ x 5.0)) (benchmark-run 5 ,@body))))
+     (message "\t\t%0.2f\t%0.2f\t%0.2f" (nth 0 results) (nth 1 results) (nth 2 results))
+     (with-current-buffer "*Messages*" (test-output "MESSAGES"))))
+
 ;; For historical reasons, we hide deleted tags by default in the test
 ;; suite
 (setq notmuch-tag-deleted-formats
index 89e5c6d8a70bf2402ffe0b875744fa81b40a2571..59b6079dd14acf6fedddc4dcd668fd147fdfb396 100644 (file)
@@ -603,20 +603,6 @@ $binary () {
        fi
 }
 
-# Explicitly require external prerequisite.  Useful when binary is
-# called indirectly (e.g. from emacs).
-# Returns success if dependency is available, failure otherwise.
-test_require_external_prereq () {
-       local binary
-       binary="$1"
-       if [[ ${test_missing_external_prereq_["${binary}"]} == t ]]; then
-               # dependency is missing, call the replacement function to note it
-               eval "$binary"
-       else
-               true
-       fi
-}
-
 # You are not expected to call test_ok_ and test_failure_ directly, use
 # the text_expect_* functions instead.