mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 04:13:03 +00:00
Make benches in a sub dirs.
* etc/bench.pl.in ($dir): New. Use it. Check the use of constructors with an argument. (bench_variant_parser): Fix.
This commit is contained in:
101
etc/bench.pl.in
101
etc/bench.pl.in
@@ -598,12 +598,19 @@ $directives
|
||||
static yy::parser::token_type yylex(yy::parser::semantic_type* yylval);
|
||||
|
||||
#define STAGE_MAX ($max * 10) // max = $max
|
||||
|
||||
#define USE_VARIANTS $variant
|
||||
#if USE_VARIANTS
|
||||
# define IF_VARIANTS(True, False) True
|
||||
#else
|
||||
# define IF_VARIANTS(True, False) False
|
||||
#endif
|
||||
|
||||
#ifdef ONE_STAGE_BUILD
|
||||
# define IF_ONE_STAGE_BUILD(True, False) True
|
||||
#else
|
||||
# define IF_ONE_STAGE_BUILD(True, False) False
|
||||
#endif
|
||||
}
|
||||
EOF
|
||||
|
||||
@@ -675,12 +682,28 @@ yylex(yy::parser::semantic_type* yylval)
|
||||
return yy::parser::token::END_OF_FILE;
|
||||
else if (stage % 2)
|
||||
{
|
||||
IF_VARIANTS(yylval->build<int>(), yylval->ival) = stage;
|
||||
#if USE_VARIANTS
|
||||
# ifdef ONE_STAGE_BUILD
|
||||
yylval->build(stage);
|
||||
# else
|
||||
yylval->build<int>() = stage;
|
||||
# endif
|
||||
#else
|
||||
yylval->ival = stage;
|
||||
#endif
|
||||
return yy::parser::token::NUMBER;
|
||||
}
|
||||
else
|
||||
{
|
||||
IF_VARIANTS(yylval->build<std::string>() =, yylval->sval = new) std::string("A string.");
|
||||
#if USE_VARIANTS
|
||||
# ifdef ONE_STAGE_BUILD
|
||||
yylval->build(std::string("A string."));
|
||||
# else
|
||||
yylval->build<std::string>() = std::string("A string.");
|
||||
# endif
|
||||
#else
|
||||
yylval->sval = new std::string("A string.");
|
||||
#endif
|
||||
return yy::parser::token::TEXT;
|
||||
}
|
||||
abort();
|
||||
@@ -717,7 +740,7 @@ Generate F<$base.y> by calling C<&generate_grammar_$name>.
|
||||
sub generate_grammar ($$@)
|
||||
{
|
||||
my ($name, $base, @directive) = @_;
|
||||
verbose 2, "Generating $base.y\n";
|
||||
verbose 3, "Generating $base.y\n";
|
||||
my %generator =
|
||||
(
|
||||
"calc" => \&generate_grammar_calc,
|
||||
@@ -738,7 +761,7 @@ Run, possibly verbosely, the shell C<$command>.
|
||||
sub run ($)
|
||||
{
|
||||
my ($command) = @_;
|
||||
verbose 2, "$command\n";
|
||||
verbose 3, "$command\n";
|
||||
system ("$command") == 0
|
||||
or die "$command failed";
|
||||
}
|
||||
@@ -812,7 +835,7 @@ sub bench ($@)
|
||||
# shows only wallclock and the two children times. 'auto' (the
|
||||
# default) will act as 'all' unless the children times are both
|
||||
# zero, in which case it acts as 'noc'. 'none' prevents output.
|
||||
verbose 2, "Running the benches for $grammar\n";
|
||||
verbose 3, "Running the benches for $grammar\n";
|
||||
my $res = timethese ($iterations, \%bench, 'nop');
|
||||
|
||||
# Output the speed result.
|
||||
@@ -863,14 +886,17 @@ Bench the C++ lalr1.cc parser using Boost.Variants or %union.
|
||||
|
||||
sub bench_variant_parser ()
|
||||
{
|
||||
bench ('variant',
|
||||
bench ('list',
|
||||
('%skeleton "lalr1.cc"',
|
||||
'&',
|
||||
'[', '%debug', ']',
|
||||
'&',
|
||||
'[', '%define variant', ']',
|
||||
'&',
|
||||
'[', "%code {\n#define VARIANT_DESTROY\n}", ']'
|
||||
'[', '%define variant',
|
||||
'&',
|
||||
'[', "%code {\n#define VARIANT_DESTROY\n}", ']',
|
||||
'&',
|
||||
'[', "%code {\n#define ONE_STAGE_BUILD\n}", ']',
|
||||
']'
|
||||
));
|
||||
}
|
||||
|
||||
@@ -915,7 +941,7 @@ my @token;
|
||||
sub parse (@)
|
||||
{
|
||||
@token = @_;
|
||||
verbose 2, "Parsing: @token\n";
|
||||
verbose 3, "Parsing: @token\n";
|
||||
my @res = parse_expr ();
|
||||
die "expected end of directives, unexpected: @token"
|
||||
if defined $token[0];
|
||||
@@ -1002,36 +1028,49 @@ sub getopt ()
|
||||
Getopt::Long::Configure ("bundling", "pass_through");
|
||||
GetOptions (%option)
|
||||
or exit 1;
|
||||
|
||||
# Support -b: predefined benches.
|
||||
my %bench =
|
||||
(
|
||||
"fusion" => \&bench_fusion_parser,
|
||||
"push" => \&bench_push_parser,
|
||||
"variant" => \&bench_variant_parser,
|
||||
);
|
||||
|
||||
if (defined $bench)
|
||||
{
|
||||
die "invalid argument for --bench: $bench"
|
||||
unless defined $bench{$bench};
|
||||
&{$bench{$bench}}();
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
######################################################################
|
||||
|
||||
getopt;
|
||||
|
||||
# Create the directory we work in.
|
||||
my $count = 1;
|
||||
++$count
|
||||
while -d "bench-$count";
|
||||
my $dir = "bench-$count";
|
||||
mkdir $dir
|
||||
or die "cannot create $dir";
|
||||
chdir $dir
|
||||
or die "cannot chdir $dir";
|
||||
verbose 1, "Benching in $dir.\n";
|
||||
verbose 1, "Using bison=$bison.\n";
|
||||
verbose 1, "Using cc=$cc.\n";
|
||||
verbose 1, "Using cxx=$cxx.\n";
|
||||
verbose 1, "Using cflags=$cflags.\n";
|
||||
verbose 2, "Using cc=$cc.\n";
|
||||
verbose 2, "Using cxx=$cxx.\n";
|
||||
verbose 2, "Using cflags=$cflags.\n";
|
||||
verbose 2, "Grammar: $grammar\n";
|
||||
|
||||
# Launch the bench marking.
|
||||
bench ($grammar, @ARGV);
|
||||
|
||||
# Support -b: predefined benches.
|
||||
my %bench =
|
||||
(
|
||||
"fusion" => \&bench_fusion_parser,
|
||||
"push" => \&bench_push_parser,
|
||||
"variant" => \&bench_variant_parser,
|
||||
);
|
||||
|
||||
if (defined $bench)
|
||||
{
|
||||
die "invalid argument for --bench: $bench"
|
||||
unless defined $bench{$bench};
|
||||
&{$bench{$bench}}();
|
||||
exit 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
# Launch the bench marking.
|
||||
bench ($grammar, @ARGV);
|
||||
}
|
||||
|
||||
### Setup "GNU" style for perl-mode and cperl-mode.
|
||||
## Local Variables:
|
||||
|
||||
Reference in New Issue
Block a user