In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/52b4b0e0361aa3b508faa5976f08af4626cd49ae?hp=2042c7f7297a837020c16f688bf5ba7c4d904b32>
- Log ----------------------------------------------------------------- commit 52b4b0e0361aa3b508faa5976f08af4626cd49ae Author: Jarkko Hietaniemi <[email protected]> Date: Mon Feb 20 09:17:14 2017 -0500 Implement --help|--usage. M Porting/harness-timer-report.pl commit 690264d73b9b545133a402f9723e3853bc096e9d Author: Jarkko Hietaniemi <[email protected]> Date: Mon Feb 20 09:10:16 2017 -0500 Also understand the output of "make test_harness". M Porting/harness-timer-report.pl commit a0d88a8fc36c52529e3ae2c0ec66bc64cace0e16 Author: Jarkko Hietaniemi <[email protected]> Date: Mon Feb 20 08:48:54 2017 -0500 Be more verbose about what failed and from which input. M Porting/harness-timer-report.pl ----------------------------------------------------------------------- Summary of changes: Porting/harness-timer-report.pl | 72 ++++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 22 deletions(-) diff --git a/Porting/harness-timer-report.pl b/Porting/harness-timer-report.pl index 899af862c1..0fe2fe7e31 100755 --- a/Porting/harness-timer-report.pl +++ b/Porting/harness-timer-report.pl @@ -43,9 +43,11 @@ $ME [--scale=[sum|max]] [--min=[[cpu|wall|ratio|self|kids]=value,...]] [--max=[[cpu|wall|ratio|self|kids]=value,...]] [--order] - logfile + [--help|--usage] + [logfile] The --order includes the original test order as the last column. +The logfile default is STDIN. __EOF__ } @@ -59,7 +61,9 @@ usage() 'min=s' => \$Opt{min}, 'max=s' => \$Opt{max}, 'order' => \$Opt{order}, + 'help|usage' => \$Opt{help}, ); +usage() if $Opt{help}; my %SHOW; if (defined $Opt{show}) { @@ -97,33 +101,57 @@ use List::Util qw[max]; my ($sa, $sb, $sc, $sd, $se); my ($ma, $mb, $mc, $md, $me); +my $logfn; +my $logfh; +if (@ARGV == 1) { + $logfn = $ARGV[0]; + open($logfh, "<", $logfn) or die "$ME: Failed to open logfn: $logfn\n"; +} elsif (@ARGV == 0) { + $logfn = "-"; + $logfh = *STDIN; +} else { + die "$ME: Unexpected logfile arguments: @ARGV\n"; +} + my $order = 0; my @t; -while (<>) { + +while (<$logfh>) { + my ($test, $wall, $self, $kids); + # Output of "env HARNESS_TIMER=1 make test": # t/re/pat ....................................................... ok 2876 ms 2660 ms 210 ms - if (m{(.+)\s+\.+\s+ok\s+(\d+)\s+ms\s+(\d+)\s+ms\s+(\d+)\s+ms$}) { - my ($test, $wall, $self, $kids) = ($1, $2, $3, $4); - next unless $wall > 0; - # Milliseconds to seconds. - $wall /= 1000; - $self /= 1000; - $kids /= 1000; - my $cpu = $self + $kids; - my $ratio = $cpu / $wall; - push @t, [ $test, $wall, $self, $kids, $cpu, $ratio, $order++ ]; - $sa += $wall; - $sb += $self; - $sc += $kids; - $sd += $cpu; - $ma = max($wall, $ma // $wall); - $mb = max($self, $mb // $self); - $mc = max($kids, $mc // $kids); - $md = max($cpu, $md // $cpu); - $me = max($ratio, $md // $ratio); + if (m{^#\s+(\S+)\s+\.+\s+ok\s+(\d+)\s+ms\s+(\d+)\s+ms\s+(\d+)\s+ms$}) { + ($test, $wall, $self, $kids) = ($1, $2, $3, $4); + } + # Output of "env HARNESS_TIMER=1 make test_harness": + # [08:26:11] base/cond.t ........................................................ ok 2 ms ( 0.00 usr 0.00 sys + 0.00 cusr 0.00 csys = 0.00 CPU) + if (m{^\[.+?\]+\s+(\S+)\s+\.+\s+ok\s+(\d+)\s+ms\s+\(\s*(\d+\.\d+)\s+usr\s+\s+(\d+\.\d+)\s+sys\s+\+\s+(\d+\.\d+)\s+cusr\s+(\d+\.\d+)\s+csys\s+=\s+(\d+\.\d+)\s+CPU\)}) { + $test = $1; + $wall = $2; + $self = $3 + $4; + $kids = $5 + $6; + $test =~ s{^\.\./}{}; # "../lib/foo" -> "../lib/foo" } + next unless defined $test && defined $wall && $wall > 0; + # Milliseconds to seconds. + $wall /= 1000; + $self /= 1000; + $kids /= 1000; + my $cpu = $self + $kids; + my $ratio = $cpu / $wall; + push @t, [ $test, $wall, $self, $kids, $cpu, $ratio, $order++ ]; + $sa += $wall; + $sb += $self; + $sc += $kids; + $sd += $cpu; + $ma = max($wall, $ma // $wall); + $mb = max($self, $mb // $self); + $mc = max($kids, $mc // $kids); + $md = max($cpu, $md // $cpu); + $me = max($ratio, $md // $ratio); } -die "$ME: No input found\n" unless @t; +die "$ME: No input detected in '$logfn'\n" unless @t; # Compute the sum for the ratio only after the loop. $se = $sd / $sa; -- Perl5 Master Repository
