+2008-11-03 Akim Demaille <demaille@gostai.com>
+
+ bench: report the size too.
+ * etc/bench.pl.in ($iterations): Defaults to -3.
+ (&bench_grammar): Require hireswallclock.
+ Compute and display the size of the result.
+ More comments.
+
2008-11-03 Akim Demaille <demaille@gostai.com>
bench: More use of the verbosity level.
=item B<-i>, B<--iterations>=I<integer>
-Say how many times a single test of the bench must be run.
+Say how many times a single test of the bench must be run. If
+negative, specify the minimum number of CPU seconds to run. Defaults
+to -3.
=item B<-v>, B<--verbose>
=cut
use IO::File;
-use Benchmark qw (:all);
##################################################################
my $cc = $ENV{'CC'} || 'gcc';
my $cxx = $ENV{'CXX'} || 'g++';
my $cflags = '';
-my $iterations = 50;
+my $iterations = -3;
my $verbose = 0;
=head1 FUNCTIONS
{
my ($gram, %test) = @_;
+ use Benchmark qw (:all :hireswallclock);
+
# Set up the benches as expected by timethese.
my %bench;
+ # For each bench, capture the size.
+ my %size;
while (my ($name, $directives) = each %test)
{
verbose 1, "Generating $name\n";
&$generator ($name, 200, @$directives);
compile ($name);
$bench{$name} = "system ('./$name');";
+ chop($size{$name} = `wc -c <$name`);
}
- verbose 1, "Running the benches for $gram\n";
# Run the benches.
+ #
+ # STYLE can be any of 'all', 'none', 'noc', 'nop' or 'auto'. 'all'
+ # shows each of the 5 times available ('wallclock' time, user time,
+ # system time, user time of children, and system time of
+ # children). 'noc' shows all except the two children times. 'nop'
+ # 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 1, "Running the benches for $gram\n";
my $res = timethese ($iterations, \%bench, 'nop');
- # Output the result.
+
+ # Output the speed result.
cmpthese ($res, 'nop');
+
+ # Display the sizes.
+ print "Sizes:\n";
+ for my $bench (keys %size)
+ {
+ printf "%10s: %10dkB\n", $bench, int ($size{$bench} / 1024);
+ }
}