autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Autotest function usage


From: Ralf Wildenhues
Subject: Re: Autotest function usage
Date: Wed, 14 Nov 2007 22:42:27 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

* Paolo Bonzini wrote on Sun, Oct 21, 2007 at 05:49:35PM CEST:
>  > cat >"$at_test_source"-AT_ordinal <<_AT_T_EOF
>> ...
>> _AT_T_EOF
>>
>> and source the goo by the shell again.  I don't know of another portable
>> tool that can write to arbitrarily many files.
>
> Me neither.  Does not seem "too" disgusting.

Here we go.  Could somebody please time this on w32?  Thanks.

Timings on GNU/Linux:

Pre patch:
$ \time ./testsuite 1
1.10user 0.41system 0:01.53elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+93407minor)pagefaults 0swaps

$ \time ./testsuite -10
5.14user 2.30system 0:07.38elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+517926minor)pagefaults 0swaps

$ \time ./testsuite -100
66.59user 38.21system 1:45.91elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+9111780minor)pagefaults 0swaps


Post patch:
$ \time ./testsuite 1
1.22user 0.36system 0:01.63elapsed 97%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+94422minor)pagefaults 0swaps

$ \time ./testsuite -10
4.95user 2.12system 0:07.13elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+521334minor)pagefaults 0swaps

$ \time ./testsuite -100
63.14user 39.00system 1:43.64elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+9282312minor)pagefaults 0swaps

So we lose 7% on the single test, win 3.5% on 10 tests and 2% on 100
tests.  Of course Autoconf's tests are expensive.  (Yes, I did except
the new test that the patch added, from testing.)

With M4 master's testsuite, 5.5% are saved on the whole suite:

Pre patch:
12.46user 16.78system 0:28.54elapsed 102%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+3608715minor)pagefaults 0swaps

Post patch:
10.20user 17.48system 0:26.96elapsed 102%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+3636070minor)pagefaults 0swaps

Do you think this is worthwhile to apply?

FWIW, (the hack of) exiting the awk script prematurely shaves off
several seconds on Solaris 2.6, in case the highest test number
exercised is low.

Cheers,
Ralf

2007-11-14  Paolo Bonzini  <address@hidden>
        and Ralf Wildenhues  <address@hidden>

        * lib/autotest/general.m4 (at_func_test): Remove.
        (AT_INIT): Pre-extract test groups into separate files.
        (AT_CLEANUP): Source pre-extracted file instead of calling at_func_test.
        Remove at-test-source files together with the $at_group_dir.
        * tests/autotest.at (Long test source lines): New test.

diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index 4d92e6d..78c6d5f 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -185,6 +185,7 @@ m4_define([_AT_NORMALIZE_TEST_GROUP_NUMBER],
 # Begin test suite.
 m4_define([AT_INIT],
 [m4_pattern_forbid([^_?AT_])
+m4_pattern_allow([^_AT_T_EOF$])
 m4_define([AT_TESTSUITE_NAME],
          m4_defn([AT_PACKAGE_STRING])[ test suite]m4_ifval([$1], [: $1]))
 m4_define([AT_ordinal], 0)
@@ -310,15 +311,6 @@ at_func_diff_devnull ()
   $at_diff "$at_devnull" "$[1]"
 }
 
-# at_func_test NUMBER
-# -------------------
-# Parse out test NUMBER from the tail of this file.
-at_func_test ()
-{
-  sed -n 
'/address@hidden:@AT_START_'$[1]'$/,/address@hidden:@AT_STOP_'$[1]'$/p' 
"$at_myself" \
-       > "$at_test_source"
-}
-
 # at_func_create_debugging_script
 # -------------------------------
 # Create the debugging script $at_group_dir/run which will reproduce the
@@ -431,7 +423,7 @@ at_status_file=$at_suite_dir/at-status
 at_stdout=$at_suite_dir/at-stdout
 at_stder1=$at_suite_dir/at-stder1
 at_stderr=$at_suite_dir/at-stderr
-# The file containing the function to run a test group.
+# The stem for files containing a test group.
 at_test_source=$at_suite_dir/at-test-source
 # The file containing dates.
 at_times_file=$at_suite_dir/at-times
@@ -871,6 +863,36 @@ else
   at_diff=diff
 fi
 
+[{
+  echo 'BEGIN {'
+  for at_group in $at_groups; do
+    at_group_normalized=$at_group
+    ]_AT_NORMALIZE_TEST_GROUP_NUMBER(at_group_normalized)[
+    echo "  outfile[\"$at_group\"] = \"$at_test_source-$at_group_normalized\""
+  done
+  echo '}
+emit == 0 && /address@hidden:@AT_START_/ {
+  test = substr($ 0, 11);
+  if (outfile[test]) {
+    emit = 1
+    print "cat >\"" outfile[test] "\" <<'\''_AT_T_EOF'\''"
+  }
+}
+emit != 0 && /address@hidden:@AT_STOP_/ {
+  print "_AT_T_EOF"
+  emit = 0
+}
+emit != 0 { print }
+'
+}] > "$at_test_source.awk"
+
+# Extract test group that will be run from the tail of this file
+if awk -f "$at_test_source.awk" "$at_myself" >"$at_test_source.sh" \
+   && . "$at_test_source.sh" \
+   && rm -f "$at_test_source.awk" "$at_test_source.sh"; then :; else
+  AS_ECHO(["$as_me: unable to parse test groups"]) >&2
+  exit 1
+fi
 
 m4_text_box([Driver loop.])
 for at_group in $at_groups
@@ -906,10 +928,7 @@ do
     at_tee_pipe='cat >> "$at_group_log"'
   fi
 
-  if at_func_test $at_group && . "$at_test_source"; then :; else
-    AS_ECHO(["$as_me: unable to parse test group: $at_group"]) >&2
-    at_failed=:
-  fi
+  . "$at_test_source-$at_group_normalized"
 
   # Be sure to come back to the suite directory, in particular
   # since below we might `rm' the group directory we are in currently.
@@ -973,9 +992,12 @@ _ATEOF
       # Cleanup the group directory, unless the user wants the files.
       if $at_debug_p ; then
        at_func_create_debugging_script
-      elif test -d "$at_group_dir"; then
-       find "$at_group_dir" -type d ! -perm -700 -exec chmod u+rwx \{\} \;
-       rm -fr "$at_group_dir"
+      else
+       if test -d "$at_group_dir"; then
+         find "$at_group_dir" -type d ! -perm -700 -exec chmod u+rwx \{\} \;
+         rm -fr "$at_group_dir"
+        fi
+       rm -f "$at_test_source-$at_group_normalized"
       fi
       ;;
     *)
diff --git a/tests/autotest.at b/tests/autotest.at
index 54e7464..01e751b 100644
--- a/tests/autotest.at
+++ b/tests/autotest.at
@@ -335,6 +335,19 @@ AT_CHECK_AT_TITLE_CHAR([Longer test title],
                       [01234567890123456789012345678901234], [], [], [54])
 
 
+## ----------------------- ##
+## Long test source lines. ##
+## ----------------------- ##
+
+# Create a test file that has more than 99 words in a line, for Solaris awk.
+# While at that, try out the limit of 2000 bytes in a text file line.
+
+AT_CHECK_AT_TEST([Long test source lines],
+[m4_for([nnn], [1], [999], [], [: ])
+AT_CHECK([:])
+])
+
+
 ## ----------------- ##
 ## Debugging a test. ##
 ## ----------------- ##




reply via email to

[Prev in Thread] Current Thread [Next in Thread]