mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
Improve genericity of bench.pl.
* etc/bench.pl.in (&bench_grammar): Take the set of benches as argument. (&bench_push_parser): New. Call it.
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
2008-11-03 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
|
Improve genericity of bench.pl.
|
||||||
|
* etc/bench.pl.in (&bench_grammar): Take the set of benches as
|
||||||
|
argument.
|
||||||
|
(&bench_push_parser): New.
|
||||||
|
Call it.
|
||||||
|
|
||||||
2008-11-03 Akim Demaille <demaille@gostai.com>
|
2008-11-03 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
Add documentation to bench.pl.
|
Add documentation to bench.pl.
|
||||||
|
|||||||
@@ -398,28 +398,29 @@ sub compile ($)
|
|||||||
or die;
|
or die;
|
||||||
}
|
}
|
||||||
|
|
||||||
=item C<bench_grammar ($gram)>
|
=item C<bench_grammar ($gram, %bench)>
|
||||||
|
|
||||||
Generate benches for C<$gram>. C<$gram> should be C<calc> or
|
Generate benches for C<$gram>. C<$gram> should be C<calc> or
|
||||||
C<triangle>.
|
C<triangle>. C<%bench> is a hash of the form:
|
||||||
|
|
||||||
|
C<$name> => C<$directives>
|
||||||
|
|
||||||
|
where C<$name> is the name of the bench, and C<$directives> are the
|
||||||
|
Bison directive to use for this bench. All the benches are compared
|
||||||
|
against each other, repeated 50 times.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub bench_grammar ($)
|
sub bench_grammar ($%)
|
||||||
{
|
{
|
||||||
my ($gram) = @_;
|
my ($gram, %test) = @_;
|
||||||
my %test =
|
|
||||||
(
|
|
||||||
"pull-impure" => '',
|
|
||||||
"pull-pure" => '%define api.pure',
|
|
||||||
"push-impure" => '%define api.push_pull "both"',
|
|
||||||
"push-pure" => '%define api.push_pull "both" %define api.pure',
|
|
||||||
);
|
|
||||||
|
|
||||||
|
# Set up the benches as expected by timethese.
|
||||||
my %bench;
|
my %bench;
|
||||||
while (my ($name, $directives) = each %test)
|
while (my ($name, $directives) = each %test)
|
||||||
{
|
{
|
||||||
print STDERR "$name\n";
|
print STDERR "$name\n";
|
||||||
|
# Call the Bison input file generator.
|
||||||
my $generator = "$gram" . "_grammar";
|
my $generator = "$gram" . "_grammar";
|
||||||
&$generator ($name, 200, $directives);
|
&$generator ($name, 200, $directives);
|
||||||
compile ($name);
|
compile ($name);
|
||||||
@@ -427,13 +428,36 @@ sub bench_grammar ($)
|
|||||||
}
|
}
|
||||||
|
|
||||||
print "$gram:\n";
|
print "$gram:\n";
|
||||||
|
# Run the benches.
|
||||||
my $res = timethese (50, \%bench, 'nop');
|
my $res = timethese (50, \%bench, 'nop');
|
||||||
|
# Output the result.
|
||||||
cmpthese ($res, 'nop');
|
cmpthese ($res, 'nop');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
=item C<bench_push_parser ()>
|
||||||
|
|
||||||
|
Bench the C push parser against the pull parser, pure and impure
|
||||||
|
interfaces.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub bench_push_parser ()
|
||||||
|
{
|
||||||
print STDERR "Using $bison, $cc.\n";
|
print STDERR "Using $bison, $cc.\n";
|
||||||
calc_input ('calc', 200);
|
calc_input ('calc', 200);
|
||||||
bench_grammar ('calc');
|
bench_grammar
|
||||||
|
('calc',
|
||||||
|
(
|
||||||
|
"pull-impure" => '',
|
||||||
|
"pull-pure" => '%define api.pure',
|
||||||
|
"push-impure" => '%define api.push_pull "both"',
|
||||||
|
"push-pure" => '%define api.push_pull "both" %define api.pure',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
bench_push_parser();
|
||||||
|
|
||||||
### Setup "GNU" style for perl-mode and cperl-mode.
|
### Setup "GNU" style for perl-mode and cperl-mode.
|
||||||
## Local Variables:
|
## Local Variables:
|
||||||
|
|||||||
Reference in New Issue
Block a user