line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Evo::Benchmark; |
2
|
7
|
|
|
7
|
|
2112
|
use Evo; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
29
|
|
3
|
7
|
|
|
7
|
|
2431
|
use parent 'Exporter'; |
|
7
|
|
|
|
|
1508
|
|
|
7
|
|
|
|
|
33
|
|
4
|
7
|
|
|
7
|
|
3613
|
use Test::More; |
|
7
|
|
|
|
|
88593
|
|
|
7
|
|
|
|
|
48
|
|
5
|
7
|
|
|
7
|
|
1587
|
use Carp 'croak'; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
354
|
|
6
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
3084
|
use Benchmark 'timeit'; |
|
7
|
|
|
|
|
32412
|
|
|
7
|
|
|
|
|
37
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw(faster_ok); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub faster_ok { |
12
|
0
|
|
|
0
|
0
|
|
my %args = @_; |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
0
|
|
|
|
$args{$_} or croak "define $_ option" for qw(iters fn expect); |
15
|
0
|
|
|
|
|
|
my ($iters, $fn, $expect, $diag) = @args{qw(iters fn expect diag)}; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my $t = timeit($iters, $fn); |
19
|
0
|
|
|
|
|
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
20
|
|
|
|
|
|
|
|
21
|
0
|
0
|
|
|
|
|
if ($t->cpu_a) { |
22
|
0
|
|
|
|
|
|
my $perf = $iters / $t->cpu_a; |
23
|
0
|
0
|
|
|
|
|
do { diag timestr $t; diag $perf } if $diag; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
ok $perf > $expect, "$perf > $expect"; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
else { |
27
|
0
|
|
|
|
|
|
fail "too few itreations $iters"; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
$t; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__END__ |