summaryrefslogtreecommitdiff
path: root/lib/Benchmark.pm
diff options
context:
space:
mode:
authorChip Salzenberg <chip@atlantic.net>1997-04-01 12:01:35 +1200
committerChip Salzenberg <chip@atlantic.net>1997-04-01 12:01:35 +1200
commit80eab818475f84cd8786effbe5e0c40e35810af9 (patch)
treeb86df734ab40baaefbe287ada748d792a0f0bb93 /lib/Benchmark.pm
parent7e5dee47ee5bc43e90e14d8c27c33a42dd0a26ae (diff)
downloadperl-80eab818475f84cd8786effbe5e0c40e35810af9.tar.gz
Document eval vs. sub in Benchmark
(this is the same change as commit 446534a1e286d6fde0fd79424865d3cf1291546b, but as applied)
Diffstat (limited to 'lib/Benchmark.pm')
-rw-r--r--lib/Benchmark.pm6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Benchmark.pm b/lib/Benchmark.pm
index a3c8544002..fa5c9e81d4 100644
--- a/lib/Benchmark.pm
+++ b/lib/Benchmark.pm
@@ -176,6 +176,10 @@ for Exporter.
=head1 CAVEATS
+Comparing eval'd strings with code references will give you
+inaccurate results: a code reference will show a slower
+execution time than the equivalent eval'd string.
+
The real time timing is done using time(2) and
the granularity is therefore only one second.
@@ -258,7 +262,7 @@ sub timestr {
my($pt, $ct, $t) = ($tr->cpu_p, $tr->cpu_c, $tr->cpu_a);
$f = $defaultfmt unless defined $f;
# format a time in the required style, other formats may be added here
- $style = $defaultstyle unless defined $style;
+ $style ||= $defaultstyle;
$style = ($ct>0) ? 'all' : 'noc' if $style eq 'auto';
my $s = "@t $style"; # default for unknown style
$s=sprintf("%2d secs (%$f usr %$f sys + %$f cusr %$f csys = %$f cpu)",