From 359218de2862c98ccfadd5880b5a17387de633db Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Thu, 7 Aug 2003 14:43:57 +0000 Subject: [PATCH] [PATCH 5.8.1] Benchmark problem From: Radu Greab Date: Thu, 07 Aug 2003 16:18:25 +0300 (EEST) Message-Id: <20030807.161825.106541372.radu@yx.primIT.ro> Subject: Re: [PATCH 5.8.1] Benchmark problem From: Rafael Garcia-Suarez Date: Thu, 7 Aug 2003 15:48:38 +0200 Message-Id: <20030807154838.5d240dbb.rgarciasuarez@free.fr> p4raw-id: //depot/perl@20546 --- lib/Benchmark.pm | 37 ++++++++----------------------------- lib/Benchmark.t | 2 +- 2 files changed, 9 insertions(+), 30 deletions(-) diff --git a/lib/Benchmark.pm b/lib/Benchmark.pm index 3d154bc..0ca7c59 100644 --- a/lib/Benchmark.pm +++ b/lib/Benchmark.pm @@ -440,7 +440,7 @@ my $hirestime; sub mytime () { time } -&init; +init(); sub BEGIN { if (eval 'require Time::HiRes') { @@ -470,8 +470,8 @@ sub init { # The cache can cause a slight loss of sys time accuracy. If a # user does many tests (>10) with *very* large counts (>10000) # or works on a very slow machine the cache may be useful. - &disablecache; - &clearallcache; + disablecache(); + clearallcache(); } sub debug { $Debug = ($_[1] != 0); } @@ -482,43 +482,22 @@ sub usage { return $_Usage{$calling_sub} || ''; } - # The cache needs two branches: 's' for strings and 'c' for code. The -# emtpy loop is different in these two cases. +# empty loop is different in these two cases. -$_Usage{clearcache} = <<'USAGE'; -usage: clearcache($count); -USAGE - -sub clearcache { - die usage unless @_ == 1; +sub clearcache ($) { delete $Cache{"$_[0]c"}; delete $Cache{"$_[0]s"}; } -$_Usage{clearallcache} = <<'USAGE'; -usage: clearallcache(); -USAGE - -sub clearallcache { - die usage if @_; +sub clearallcache () { %Cache = (); } -$_Usage{enablecache} = <<'USAGE'; -usage: enablecache(); -USAGE - -sub enablecache { - die usage if @_; +sub enablecache () { $Do_Cache = 1; } -$_Usage{disablecache} = <<'USAGE'; -usage: disablecache(); -USAGE - -sub disablecache { - die usage if @_; +sub disablecache () { $Do_Cache = 0; } diff --git a/lib/Benchmark.t b/lib/Benchmark.t index 8081476..b4d7149 100644 --- a/lib/Benchmark.t +++ b/lib/Benchmark.t @@ -583,7 +583,7 @@ is_deeply ([keys %Benchmark::Cache], \@before_keys, foreach my $func (@takes_no_args) { eval "$func(42)"; - is( $@, $usage{$func}, "$func usage: with args" ); + like( $@, qr/Too many arguments for Benchmark::$func/, "$func usage: with args" ); } } -- 2.7.4