Refresh CPAN.pm to 1.21
[p5sagit/p5-mst-13.2.git] / lib / Benchmark.pm
index 40481f9..c382fcb 100644 (file)
@@ -40,7 +40,7 @@ Returns the current time.   Example:
     # ... your code here ...
     $t1 = new Benchmark;
     $td = timediff($t1, $t0);
-    print "the code took:",timestr($dt),"\n";
+    print "the code took:",timestr($td),"\n";
 
 =item debug
 
@@ -146,14 +146,14 @@ than a short test; try:
 
 The system time of the null loop might be slightly
 more than the system time of the loop with the actual
-code and therefore the difference might end up being < 0.
+code and therefore the difference might end up being E<lt> 0.
 
 More documentation is needed :-( especially for styles and formats.
 
 =head1 AUTHORS
 
-Jarkko Hietaniemi <Jarkko.Hietaniemi@hut.fi>,
-Tim Bunce <Tim.Bunce@ig.co.uk>
+Jarkko Hietaniemi E<lt>F<Jarkko.Hietaniemi@hut.fi>E<gt>,
+Tim Bunce E<lt>F<Tim.Bunce@ig.co.uk>E<gt>
 
 =head1 MODIFICATION HISTORY
 
@@ -242,6 +242,7 @@ September 8th, 1994; by Tim Bunce.
 # Last updated:        Sept 8th 94 by Tim Bunce
 #
 
+use Carp;
 use Exporter;
 @ISA=(Exporter);
 @EXPORT=qw(timeit timethis timethese timediff timestr);
@@ -315,6 +316,10 @@ sub timedebug{
 
 sub runloop {
     my($n, $c) = @_;
+
+    $n+=0; # force numeric now, so garbage won't creep into the eval
+    croak "negativ loopcount $n" if $n<0;
+    confess "Usage: runloop(number, string)" unless defined $c;
     my($t0, $t1, $td); # before, after, difference
 
     # find package of caller so we can execute code there
@@ -326,7 +331,7 @@ sub runloop {
 
     my $subcode = "sub { package $pack; my(\$_i)=$n; while (\$_i--){$c;} }";
     my $subref  = eval $subcode;
-    die "runloop unable to compile '$c': $@\ncode: $subcode\n" if $@;
+    croak "runloop unable to compile '$c': $@\ncode: $subcode\n" if $@;
     print STDERR "runloop $n '$subcode'\n" if ($debug);
 
     $t0 = &new;