bison-patches
[Top][All Lists]
Advanced

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

Bison torture test speedup: `assert (x);' -> `if (! (x)) abort ();'


From: Paul Eggert
Subject: Bison torture test speedup: `assert (x);' -> `if (! (x)) abort ();'
Date: Sat, 9 Nov 2002 23:08:16 -0800 (PST)

Bison's "make check" was taking too long for me, so I installed the
following patch to speed up the slowest test by a factor of 10.
"make check" still takes too long, but it's progress.

2002-11-09  Paul Eggert  <address@hidden>

        * tests/torture.at (AT_DATA_TRIANGULAR_GRAMMAR,
        AT_DATA_HORIZONTAL_GRAMMAR, AT_DATA_LOOKAHEADS_GRAMMAR,
        AT_DATA_STACK_TORTURE): Replace `assert (x);' with `if (! (x))
        abort ();'.  This reduces the runtime of the "Many lookaheads"
        test from 27.6 to 2.7 minutes on a 440 MHz Ultrasparc III running
        GCC 3.2.

--- torture.at.~1.20.~  2002-10-14 01:43:36.000000000 -0700
+++ torture.at  2002-11-09 22:33:52.726762000 -0800
@@ -51,7 +51,6 @@ print <<EOF;
 %{
 #include <stdio.h>
 #include <stdlib.h>
-#include <assert.h>
 
 #define YYERROR_VERBOSE 1
 #define YYDEBUG 1
@@ -76,8 +75,8 @@ for my $size (1 .. $max)
 print <<EOF;
 %%
 input:
-  exp        { assert (address@hidden|@1 == 0); \$\$ = address@hidden|@1; }
-| input exp  { assert (address@hidden|@2 == address@hidden|@1 + 1); \$\$ = 
address@hidden|@2; }
+  exp        { if (address@hidden|@1 != 0) abort (); \$\$ = address@hidden|@1; 
}
+| input exp  { if (address@hidden|@2 != address@hidden|@1 + 1) abort (); \$\$ 
= address@hidden|@2; }
 ;
 
 exp:
@@ -167,7 +166,6 @@ print <<EOF;
 %{
 #include <stdio.h>
 #include <stdlib.h>
-#include <assert.h>
 
 #define YYERROR_VERBOSE 1
 #define YYDEBUG 1
@@ -272,7 +270,6 @@ print <<EOF;
 %{
 #include <stdio.h>
 #include <stdlib.h>
-#include <assert.h>
 
 #define YYERROR_VERBOSE 1
 #define YYDEBUG 1
@@ -303,17 +300,17 @@ for my $count (1 .. $max)
 print <<EOF;
 %%
 input:
-  exp        { assert (address@hidden|@1 == 1); \$\$ = address@hidden|@1; }
-| input exp  { assert (address@hidden|@2 == address@hidden|@1 + 1); \$\$ = 
address@hidden|@2; }
+  exp        { if (address@hidden|@1 != 1) abort (); \$\$ = address@hidden|@1; 
}
+| input exp  { if (address@hidden|@2 != address@hidden|@1 + 1) abort (); \$\$ 
= address@hidden|@2; }
 ;
 
 exp:
-  n1 "1" { assert (address@hidden|@1 == 1); }
+  n1 "1" { if (address@hidden|@1 != 1) abort (); }
 EOF
 
 for my $count (2 .. $max)
   {
-    print "| n$count \"$count\" { assert (address@hidden|@1 == $count); }\n";
+    print "| n$count \"$count\" { if (address@hidden|@1 != $count) abort (); 
}\n";
   };
 print ";\n";
 
@@ -390,7 +387,6 @@ AT_DATA([input.y],
 [[%{
 #include <stdio.h>
 #include <stdlib.h>
-#include <assert.h>
 ]$1[
   static int yylex (void);
   static void yyerror (const char *msg);
@@ -423,7 +419,8 @@ yylex (void)
 int
 main (int argc, const char **argv)
 {
-  assert (argc == 2);
+  if (argc != 2)
+    abort ();
   yylval = atoi (argv[1]);
   yydebug = 1;
   return yyparse ();




reply via email to

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