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