Date: | Sat, 5 Jul 2003 18:12:28 -0500 |
From: | Andy Lester <andy [...] petdance.com> |
To: | bug-test-harness [...] rt.cpan.org |
Subject: | Patch for only-print-once-per-second |
----- Forwarded message from Michael G Schwern <schwern@pobox.com> -----
Date: Sat, 5 Jul 2003 13:34:37 -0700
From: Michael G Schwern <schwern@pobox.com>
To: Abigail <abigail@abigail.nl>
Cc: Jarkko Hietaniemi <jhi@iki.fi>, perl5-porters@perl.org, petdance@cpan.org
Subject: Re: maint @ 19975 [PATCH lib/Test/Harness.pm]
On Fri, Jul 04, 2003 at 05:06:29PM +0200, Abigail wrote:
Show quoted text
> The simple patch below speeds up testing dramatically in certain
> conditions. It eliminates the printing of NNN/NNNN after each
> test, saving about 35 bytes of output per test. When testing
> a package like Regexp::Common, this saves about 5 Mb of output.
> If you are doing a test when logged in remotely, this saves
> a lot. I just ran a test, which took 25 minutes without the
> patch. With the patch, 'make test' only took 65 seconds.
>
> Jarkko, is it too late to put this in 5.8.1?
This certainly cannot be put in, crudely striking out a longstanding
feature at the last minute.
But the problem remains. Even on a local connection, testing Regexp::Common
takes a long time due to the printing. Nick's idea of only printing every
second is a good one. Printing every N is less good because you can't tell
if a test has hung or its just N-1 taking a long time.
So here's a patch to make Test::Harness only print the 'ok' output every
second, taking care to always print the first 'ok' and always print every
'NOK'. Printing once a second feels a bit too slow, but I'm loathe to
get into attempting half-seconds.
While I'm at it, it seems a fix for "local $Test::Harness::verbose" didn't
get in. See
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2003-02/msg01230.html
for the bug.
--- lib/Test/Harness.pm 13 Dec 2002 22:11:51 -0000 1.41
+++ lib/Test/Harness.pm 5 Jul 2003 20:13:49 -0000
@@ -13,12 +13,12 @@
use vars qw($VERSION $Verbose $Switches $Have_Devel_Corestack $Curtest
$Columns $verbose $switches $ML $Strap
- @ISA @EXPORT @EXPORT_OK
+ @ISA @EXPORT @EXPORT_OK $Last_ML_Print
);
# Backwards compatibility for exportable variable names.
-*verbose = \$Verbose;
-*switches = \$Switches;
+*verbose = *Verbose;
+*switches = *Switches;
$Have_Devel_Corestack = 0;
@@ -448,7 +448,7 @@
my $width = _leader_width(@tests);
foreach my $tfile (@tests) {
-
+ $Last_ML_Print = 0; # so each test prints at least once
my($leader, $ml) = _mk_leader($tfile, $width);
local $ML = $ml;
print $leader;
@@ -705,7 +705,7 @@
my $detail = $totals->{details}[-1];
if( $detail->{ok} ) {
- _print_ml("ok $curr/$max");
+ _print_ml_less("ok $curr/$max");
if( $detail->{type} eq 'skip' ) {
$totals->{skip_reason} = $detail->{reason}
@@ -740,6 +740,15 @@
print join '', $ML, @_ if $ML;
}
+
+# For slow connections, we save lots of bandwidth by printing only once
+# per second.
+sub _print_ml_less {
+ if( $Last_ML_Print != time ) {
+ _print_ml(@_);
+ $Last_ML_Print = time;
+ }
+}
sub _bonusmsg {
my($tot) = @_;
--
I sit on the floor and pick my nose
and think of dirty things
Of deviant dwarfs who suck their toes
and elves who drub their dings.
-- Frito Bugger, "Bored Of The Rings"
Show quoted text----- End forwarded message -----
--
Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance