line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Benchmarks; |
2
|
7
|
|
|
7
|
|
26511
|
use strict; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
259
|
|
3
|
7
|
|
|
7
|
|
33
|
use warnings; |
|
7
|
|
|
|
|
7
|
|
|
7
|
|
|
|
|
205
|
|
4
|
7
|
|
|
7
|
|
4338
|
use Benchmark qw/ :hireswallclock /; |
|
7
|
|
|
|
|
45971
|
|
|
7
|
|
|
|
|
41
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub import { |
8
|
7
|
|
|
7
|
|
69
|
my ($class, $code, $count, $style, $title) = @_; |
9
|
|
|
|
|
|
|
|
10
|
7
|
|
|
|
|
966
|
Benchmark->export_to_level(1, $class, ':all'); |
11
|
|
|
|
|
|
|
|
12
|
7
|
100
|
|
|
|
145
|
return unless $code; |
13
|
5
|
50
|
|
|
|
18
|
return unless ref $code eq 'CODE'; |
14
|
|
|
|
|
|
|
|
15
|
5
|
|
|
|
|
14
|
my ($ret, $runtime_count, $runtime_style, $runtime_title) = $code->(); |
16
|
5
|
50
|
|
|
|
56
|
$count = defined($runtime_count) ? $runtime_count |
|
|
50
|
|
|
|
|
|
17
|
|
|
|
|
|
|
: defined($count) ? $count |
18
|
|
|
|
|
|
|
: -1; |
19
|
5
|
100
|
|
|
|
14
|
$style = defined($runtime_style) ? $runtime_style |
|
|
50
|
|
|
|
|
|
20
|
|
|
|
|
|
|
: defined($style) ? $style |
21
|
|
|
|
|
|
|
: 'auto'; |
22
|
5
|
100
|
|
|
|
15
|
$title = defined($runtime_title) ? $runtime_title |
|
|
50
|
|
|
|
|
|
23
|
|
|
|
|
|
|
: defined($title) ? $title |
24
|
|
|
|
|
|
|
: undef; |
25
|
|
|
|
|
|
|
|
26
|
5
|
|
|
|
|
12
|
_run_benchmark($count, $ret, $style, $title); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _run_benchmark { |
30
|
5
|
|
|
5
|
|
11
|
my ($count, $ret, $style, $title) = @_; |
31
|
|
|
|
|
|
|
|
32
|
5
|
|
|
|
|
6
|
my $ref_ret = ref $ret; |
33
|
|
|
|
|
|
|
|
34
|
5
|
100
|
66
|
|
|
43
|
if ( !$ref_ret || $ref_ret eq 'CODE' ) { |
|
|
50
|
|
|
|
|
|
35
|
3
|
|
|
|
|
7
|
Benchmark::timethis($count, $ret, $title, $style); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
elsif ( $ref_ret eq 'HASH' ) { |
38
|
2
|
|
|
|
|
8
|
Benchmark::cmpthese($count, $ret, $style); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else { |
41
|
0
|
|
|
|
|
|
die "The CODE returned wrong retval."; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__END__ |