Closed p5pRT closed 18 years ago
Whenever I use Benchmark with the ":hireswallclock" option\, I get:
Subroutine Benchmark::mytime redefined at /usr/lib/perl5/5.8.8/Benchmark.pm line 459.
This happens as subroutine "mytime" is first defined as:
sub mytime () { time }
Then in line 459\, it is redefined as an alias of "\&Time::HiRes::time".
The easiest fix is to disable warnings just before the 2nd assignment using "local $^W=0;". Then the assignment happens with no warning\, and the value of $^w immediately goes out of scope as an internal "if" block is exited.
The following is a patch to run in the same directory as Benchmark.pm. It also bumps the version number from .07 to .08
-------file Benchmark07_to_08.patch-----------------
I'm surprised this has gone this long without being changed -- maybe people don't run with warnings (-w) enabled when benchmarking?
Thanks\, Linda Walsh
[perl-diddler@tlinx.org - Mon Apr 10 18:53:45 2006]:
This is a bug report for perl from perl-diddler@tlinx.org\, generated with the help of perlbug 1.35 running under perl v5.8.8.
----------------------------------------------------------------- [Please enter your report here]
Whenever I use Benchmark with the ":hireswallclock" option\, I get:
Subroutine Benchmark::mytime redefined at /usr/lib/perl5/5.8.8/Benchmark.pm line 459.
This happens as subroutine "mytime" is first defined as:
sub mytime \(\) \{ time \}
Then in line 459\, it is redefined as an alias of "\&Time::HiRes::time".
The easiest fix is to disable warnings just before the 2nd
assignment using "local $^W=0;". Then the assignment happens with no warning\, and the value of $^w immediately goes out of scope as an internal "if" block is exited.
The following is a patch to run in the same directory as Benchmark.pm. It also bumps the version number from .07 to .08
-------file Benchmark07_to_08.patch----------------- --- Benchmark.pm.orig 2006-03-06 21:13:56.000000000 -0800 +++ Benchmark.pm 2006-04-10 12:24:07.803036405 -0700 @@ -435\,7 +435\,7 @@ clearcache clearallcache disablecache enablecache); %EXPORT_TAGS=( all => [ @EXPORT\, @EXPORT_OK ] ) ;
-$VERSION = 1.07; +$VERSION = 1.08;
# --- ':hireswallclock' special handling
@@ -456\,6 +456\,7 @@ my $class = shift; if (grep { $_ eq ":hireswallclock" } @_) { @_ = grep { $_ ne ":hireswallclock" } @_; + local $^W=0; *mytime = $hirestime if defined $hirestime; } Benchmark->export_to_level(1\, $class\, @_); -------end of patch file----------------------------
I'm surprised this has gone this long without being changed -- maybe people don't run with warnings (-w) enabled when benchmarking?
Thanks\, Linda Walsh
This patch was applied as change #27906.
The RT System itself - Status changed from 'new' to 'open'
@smpeters - Status changed from 'open' to 'resolved'
Migrated from rt.perl.org#38892 (status was 'resolved')
Searchable as RT38892$