diff options
author | Abigail <abigail@abigail.be> | 2002-08-21 21:10:39 -0700 |
---|---|---|
committer | hv <hv@crypt.org> | 2002-08-25 15:29:42 +0000 |
commit | 8962dfd6c069786370901f53b09ae56ec61390dd (patch) | |
tree | c86dfafe3480f20600f63f0e44ef31bf23e04d95 /lib/Benchmark.t | |
parent | 69e2f04480336aed2ad842f2b92ce366bcd2e9e1 (diff) | |
download | perl-8962dfd6c069786370901f53b09ae56ec61390dd.tar.gz |
Make cmpthese work as documented.
Message-ID: <20020822041039.A2089@ucan.foad.org>
p4raw-id: //depot/perl@17774
Diffstat (limited to 'lib/Benchmark.t')
-rw-r--r-- | lib/Benchmark.t | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/Benchmark.t b/lib/Benchmark.t index d7533c3d97..60caf434e6 100644 --- a/lib/Benchmark.t +++ b/lib/Benchmark.t @@ -8,7 +8,7 @@ BEGIN { use warnings; use strict; use vars qw($foo $bar $baz $ballast); -use Test::More tests => 159; +use Test::More tests => 173; use Benchmark qw(:all); @@ -346,7 +346,7 @@ sub check_graph { { select(OUT); my $start = times; - my $chart = cmpthese( -0.1, { a => "++\$i", b => "\$i = sqrt(\$i++)" } ) ; + my $chart = cmpthese( -0.1, { a => "++\$i", b => "\$i = sqrt(\$i++)" }, "auto" ) ; my $end = times; select(STDOUT); ok (($end - $start) > 0.05, "benchmarked code ran for over 0.05 seconds"); @@ -364,6 +364,28 @@ sub check_graph { check_graph_vs_output ($chart, $got); } +# Not giving auto should suppress timethese results. +{ + select(OUT); + my $start = times; + my $chart = cmpthese( -0.1, { a => "++\$i", b => "\$i = sqrt(\$i++)" } ) ; + my $end = times; + select(STDOUT); + ok (($end - $start) > 0.05, "benchmarked code ran for over 0.05 seconds"); + + $got = $out->read(); + # Remove any warnings about having too few iterations. + $got =~ s/\(warning:[^\)]+\)//gs; + + unlike ($got, qr/running\W+a\W+b.*?for at least 0\.1 CPU second/s, + 'should not have title'); + # Remove the title + $got =~ s/.*\.\.\.//s; + unlike ($got, $default_pattern, 'should not find default format somewhere'); + like ($got, $graph_dissassembly, "Should find the output graph somewhere"); + check_graph_vs_output ($chart, $got); +} + { $foo = $bar = 0; select(OUT); |