line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Devel::XRay; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
135247
|
use warnings; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
336
|
|
4
|
5
|
|
|
5
|
|
28
|
use strict; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
221
|
|
5
|
5
|
|
|
5
|
|
6710
|
use Filter::Simple; |
|
5
|
|
|
|
|
169151
|
|
|
5
|
|
|
|
|
40
|
|
6
|
5
|
|
|
5
|
|
362
|
use Carp qw(croak); |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
503
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.95'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
BEGIN { |
11
|
5
|
|
|
5
|
|
27
|
use constant DEBUG => 0; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
3640
|
|
12
|
|
|
|
|
|
|
|
13
|
5
|
50
|
|
5
|
|
35
|
unless ( exists $INC{'Time/HiRes.pm'} ) { |
14
|
5
|
|
|
|
|
9
|
eval { require Time::HiRes; }; |
|
5
|
|
|
|
|
5979
|
|
15
|
|
|
|
|
|
|
} |
16
|
5
|
50
|
|
|
|
11669
|
our $timing = |
17
|
|
|
|
|
|
|
exists $INC{'Time/HiRes.pm'} |
18
|
|
|
|
|
|
|
? 'sprintf("%.6f", &Time::HiRes::time())' |
19
|
|
|
|
|
|
|
: 'sprintf("%d", time)'; |
20
|
|
|
|
|
|
|
|
21
|
5
|
|
|
|
|
44
|
our %operations = ( |
22
|
|
|
|
|
|
|
only => \&_only, |
23
|
|
|
|
|
|
|
ignore => \&_ignore, |
24
|
|
|
|
|
|
|
all => \&_all, |
25
|
|
|
|
|
|
|
none => \&_none, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
5
|
|
|
|
|
12
|
our $operation; |
29
|
5
|
|
|
|
|
13
|
our $subs = ''; |
30
|
5
|
|
|
|
|
17
|
our $trace = ' print STDERR "[" . ' . $timing |
31
|
|
|
|
|
|
|
. ' . "] " . (caller(0))[3] . "\\n";'; |
32
|
5
|
|
|
|
|
28
|
our $all_regex = qr/(sub\s+\w.+?{)/s; |
33
|
5
|
|
|
|
|
9
|
our $regex = ''; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub import { |
36
|
|
|
|
|
|
|
( undef, $operation, my (@subs) ) = @_; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
if ($operation) { |
39
|
|
|
|
|
|
|
croak "unknown import operation: $operation" |
40
|
|
|
|
|
|
|
unless exists $operations{$operation}; |
41
|
|
|
|
|
|
|
croak "sub list required for operation: $operation\n" |
42
|
|
|
|
|
|
|
unless $operation eq 'all' || $operation eq 'none' || @subs; |
43
|
|
|
|
|
|
|
$regex = '(sub\s+(?:' . join( '|', @subs ) . ')\s*\{)'; |
44
|
|
|
|
|
|
|
$regex = $regex . quotemeta($trace) if $operation eq 'ignore'; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
#warn "regex: $regex\n"; |
47
|
|
|
|
|
|
|
$regex = qr/$regex/s; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
else { |
50
|
|
|
|
|
|
|
$operation = 'all'; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
1
|
|
3
|
sub _only { s/$regex/$1$trace/g; } |
55
|
1
|
|
|
1
|
|
5
|
sub _ignore { _all($_); s/$regex/$1/g; } |
|
1
|
|
|
|
|
2
|
|
56
|
7
|
|
|
7
|
|
30
|
sub _all { s/$all_regex/$1$trace/g; } |
57
|
1
|
|
|
1
|
|
2
|
sub _none { } |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
FILTER { |
60
|
9
|
50
|
|
|
|
4628
|
return unless $_; |
61
|
9
|
|
|
|
|
13
|
warn "performing operation: $operation\n" if DEBUG; |
62
|
9
|
|
|
|
|
282
|
$operations{$operation}->($_); |
63
|
9
|
|
|
|
|
20
|
warn $_ . "\n" if DEBUG; |
64
|
|
|
|
|
|
|
} |
65
|
5
|
|
|
|
|
49
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |