line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::CallCounter; |
2
|
3
|
|
|
3
|
|
41836
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
112
|
|
3
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
68
|
|
4
|
3
|
|
|
3
|
|
69
|
use 5.008001; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
152
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
20
|
use Scalar::Util 1.24 qw(set_prototype); |
|
3
|
|
|
|
|
67
|
|
|
3
|
|
|
|
|
325
|
|
8
|
3
|
|
|
3
|
|
2716
|
use Class::Method::Modifiers qw(install_modifier); |
|
3
|
|
|
|
|
4581
|
|
|
3
|
|
|
|
|
601
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $COUNTER; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
2
|
|
|
2
|
1
|
30
|
my ($class, $klass, $method) = @_; |
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
|
|
16
|
my $self = bless +{ |
16
|
|
|
|
|
|
|
class => $klass, |
17
|
|
|
|
|
|
|
method => $method, |
18
|
|
|
|
|
|
|
count => 0, |
19
|
|
|
|
|
|
|
}, $class; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
57
|
my $prototype = prototype($klass->can($method)); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
install_modifier( |
24
|
|
|
|
|
|
|
$klass, 'before', $method, sub { |
25
|
2
|
|
|
2
|
|
79
|
$self->{count}++ |
26
|
|
|
|
|
|
|
} |
27
|
2
|
|
|
|
|
38
|
); |
28
|
|
|
|
|
|
|
|
29
|
2
|
100
|
|
|
|
641
|
if (defined $prototype) { |
30
|
1
|
|
|
|
|
11
|
&set_prototype($klass->can($method), $prototype); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
8
|
return $self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
2
|
|
|
2
|
1
|
106
|
sub count { $_[0]->{count} } |
37
|
0
|
|
|
0
|
1
|
|
sub reset { $_[0]->{count} = 0 } |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
__END__ |