line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Evo::Benchmark; |
2
|
7
|
|
|
7
|
|
3035
|
use Evo; |
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
39
|
|
3
|
7
|
|
|
7
|
|
3483
|
use parent 'Exporter'; |
|
7
|
|
|
|
|
2029
|
|
|
7
|
|
|
|
|
39
|
|
4
|
7
|
|
|
7
|
|
4507
|
use Test::More; |
|
7
|
|
|
|
|
121805
|
|
|
7
|
|
|
|
|
81
|
|
5
|
7
|
|
|
7
|
|
2455
|
use Carp 'croak'; |
|
7
|
|
|
|
|
25
|
|
|
7
|
|
|
|
|
549
|
|
6
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
4784
|
use Benchmark 'timeit'; |
|
7
|
|
|
|
|
44490
|
|
|
7
|
|
|
|
|
62
|
|
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__ |