From: Akim Demaille Date: Thu, 17 Jul 2008 13:23:46 +0000 (+0200) Subject: bench: report the size too. X-Git-Tag: v2.7.90~1175 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/d11ee647c32a0216902e8b4da5d9501c0fbc6d11 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. --- diff --git a/ChangeLog b/ChangeLog index beb19714..1dbff82f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-11-03 Akim Demaille + + 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 bench: More use of the verbosity level. diff --git a/etc/bench.pl.in b/etc/bench.pl.in index a783d434..1d6d90c8 100755 --- a/etc/bench.pl.in +++ b/etc/bench.pl.in @@ -35,7 +35,9 @@ Flags to pass to the C or C++ compiler. =item B<-i>, B<--iterations>=I -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> @@ -46,7 +48,6 @@ Raise the verbosity level. Currently only affects B<--help>. =cut use IO::File; -use Benchmark qw (:all); ################################################################## @@ -86,7 +87,7 @@ my $bison = $ENV{'BISON'} || '@abs_top_builddir@/tests/bison'; my $cc = $ENV{'CC'} || 'gcc'; my $cxx = $ENV{'CXX'} || 'g++'; my $cflags = ''; -my $iterations = 50; +my $iterations = -3; my $verbose = 0; =head1 FUNCTIONS @@ -658,8 +659,12 @@ sub bench_grammar ($%) { 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"; @@ -668,13 +673,30 @@ sub bench_grammar ($%) &$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); + } }