← Index
NYTProf Performance Profile   « line view »
For /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/bin/perlcritic
  Run on Sat Mar 19 22:12:22 2016
Reported on Sat Mar 19 22:14:12 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Sub/Install.pm
StatementsExecuted 154 statements in 1.31ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
61188┬Ás119┬ÁsSub::Install::::__ANON__[:100] Sub::Install::__ANON__[:100]
62177┬Ás231┬ÁsSub::Install::::__ANON__[:57] Sub::Install::__ANON__[:57]
11138┬Ás74┬ÁsSub::Install::::BEGIN@115 Sub::Install::BEGIN@115
61131┬Ás31┬ÁsSub::Install::::__ANON__[:112] Sub::Install::__ANON__[:112]
61123┬Ás36┬ÁsSub::Install::::_CODELIKE Sub::Install::_CODELIKE
33114┬Ás18┬ÁsSub::Install::::_do_with_warn Sub::Install::_do_with_warn
22212┬Ás12┬ÁsSub::Install::::exporter Sub::Install::exporter
11112┬Ás14┬ÁsSub::Install::::BEGIN@64 Sub::Install::BEGIN@64
11110┬Ás21┬ÁsData::OptList::::BEGIN@1Data::OptList::BEGIN@1
1119┬Ás15┬ÁsSub::Install::::BEGIN@174 Sub::Install::BEGIN@174
3318┬Ás8┬ÁsSub::Install::::__ANON__[:101] Sub::Install::__ANON__[:101]
1118┬Ás19┬ÁsSub::Install::::BEGIN@109 Sub::Install::BEGIN@109
1118┬Ás41┬ÁsSub::Install::::BEGIN@9 Sub::Install::BEGIN@9
2217┬Ás7┬ÁsSub::Install::::_build_public_installer Sub::Install::_build_public_installer
1117┬Ás10┬ÁsData::OptList::::BEGIN@2Data::OptList::BEGIN@2
1116┬Ás7┬ÁsSub::Install::::BEGIN@73 Sub::Install::BEGIN@73
3316┬Ás6┬ÁsSub::Install::::_installer Sub::Install::_installer
3313┬Ás3┬ÁsSub::Install::::CORE:qr Sub::Install::CORE:qr (opcode)
1113┬Ás3┬ÁsSub::Install::::BEGIN@10 Sub::Install::BEGIN@10
0000s0sSub::Install::::__ANON__[:153] Sub::Install::__ANON__[:153]
0000s0sSub::Install::::__ANON__[:171] Sub::Install::__ANON__[:171]
0000s0sSub::Install::::__ANON__[:81] Sub::Install::__ANON__[:81]
0000s0sSub::Install::::__ANON__[:98] Sub::Install::__ANON__[:98]
0000s0sSub::Install::::_name_of_code Sub::Install::_name_of_code
0000s0sSub::Install::::install_installers Sub::Install::install_installers
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1217┬Ás232┬Ás
# spent 21┬Ás (10+11) within Data::OptList::BEGIN@1 which was called: # once (10┬Ás+11┬Ás) by Data::OptList::BEGIN@11 at line 1
use strict;
# spent 21┬Ás making 1 call to Data::OptList::BEGIN@1 # spent 11┬Ás making 1 call to strict::import
2231┬Ás213┬Ás
# spent 10┬Ás (7+3) within Data::OptList::BEGIN@2 which was called: # once (7┬Ás+3┬Ás) by Data::OptList::BEGIN@11 at line 2
use warnings;
# spent 10┬Ás making 1 call to Data::OptList::BEGIN@2 # spent 3┬Ás making 1 call to warnings::import
3package Sub::Install;
4{
52900ns $Sub::Install::VERSION = '0.927';
6}
7# ABSTRACT: install subroutines into packages easily
8
9219┬Ás275┬Ás
# spent 41┬Ás (8+34) within Sub::Install::BEGIN@9 which was called: # once (8┬Ás+34┬Ás) by Data::OptList::BEGIN@11 at line 9
use Carp;
# spent 41┬Ás making 1 call to Sub::Install::BEGIN@9 # spent 34┬Ás making 1 call to Exporter::import
102307┬Ás13┬Ás
# spent 3┬Ás within Sub::Install::BEGIN@10 which was called: # once (3┬Ás+0s) by Data::OptList::BEGIN@11 at line 10
use Scalar::Util ();
# spent 3┬Ás making 1 call to Sub::Install::BEGIN@10
11
12
13sub _name_of_code {
14 my ($code) = @_;
15 require B;
16 my $name = B::svref_2object($code)->GV->NAME;
17 return $name unless $name =~ /\A__ANON__/;
18 return;
19}
20
21# See also Params::Util, to which this code was donated.
22
# spent 36┬Ás (23+13) within Sub::Install::_CODELIKE which was called 6 times, avg 6┬Ás/call: # 6 times (23┬Ás+13┬Ás) by Sub::Install::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Sub/Install.pm:57] at line 42, avg 6┬Ás/call
sub _CODELIKE {
23643┬Ás612┬Ás (Scalar::Util::reftype($_[0])||'') eq 'CODE'
# spent 12┬Ás making 6 calls to Scalar::Util::reftype, avg 2┬Ás/call
24 || Scalar::Util::blessed($_[0])
25 && (overload::Method($_[0],'&{}') ? $_[0] : undef);
26}
27
28# do the heavy lifting
29
# spent 7┬Ás within Sub::Install::_build_public_installer which was called 2 times, avg 4┬Ás/call: # once (5┬Ás+0s) by Sub::Install::BEGIN@115 at line 120 # once (2┬Ás+0s) by Sub::Install::BEGIN@115 at line 127
sub _build_public_installer {
302400ns my ($installer) = @_;
31
32
# spent 231┬Ás (77+155) within Sub::Install::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Sub/Install.pm:57] which was called 6 times, avg 39┬Ás/call: # 5 times (60┬Ás+114┬Ás) by Sub::Exporter::default_installer at line 442 of Sub/Exporter.pm, avg 35┬Ás/call # once (17┬Ás+40┬Ás) by Sub::Exporter::setup_exporter at line 198 of Sub/Exporter.pm
sub {
3361┬Ás my ($arg) = @_;
34618┬Ás my ($calling_pkg) = caller(0);
35
36 # I'd rather use ||= but I'm whoring for Devel::Cover.
371811┬Ás for (qw(into from)) { $arg->{$_} = $calling_pkg unless $arg->{$_} }
38
39 # This is the only absolutely required argument, in many cases.
4061┬Ás Carp::croak "named argument 'code' is not optional" unless $arg->{code};
41
4268┬Ás636┬Ás if (_CODELIKE($arg->{code})) {
# spent 36┬Ás making 6 calls to Sub::Install::_CODELIKE, avg 6┬Ás/call
43 $arg->{as} ||= _name_of_code($arg->{code});
44 } else {
45 Carp::croak
46 "couldn't find subroutine named $arg->{code} in package $arg->{from}"
47 unless my $code = $arg->{from}->can($arg->{code});
48
49 $arg->{as} = $arg->{code} unless $arg->{as};
50 $arg->{code} = $code;
51 }
52
536800ns Carp::croak "couldn't determine name under which to install subroutine"
54 unless $arg->{as};
55
56621┬Ás6119┬Ás $installer->(@$arg{qw(into as code) });
# spent 119┬Ás making 6 calls to Sub::Install::__ANON__[Sub/Install.pm:100], avg 20┬Ás/call
57 }
58211┬Ás}
59
60# do the ugly work
61
621100nsmy $_misc_warn_re;
6310smy $_redef_warn_re;
64
# spent 14┬Ás (12+2) within Sub::Install::BEGIN@64 which was called: # once (12┬Ás+2┬Ás) by Data::OptList::BEGIN@11 at line 70
BEGIN {
6517┬Ás11┬Ás $_misc_warn_re = qr/
# spent 1┬Ás making 1 call to Sub::Install::CORE:qr
66 Prototype\ mismatch:\ sub\ .+? |
67 Constant subroutine \S+ redefined
68 /x;
6919┬Ás1800ns $_redef_warn_re = qr/Subroutine\ \S+\ redefined/x;
# spent 800ns making 1 call to Sub::Install::CORE:qr
70129┬Ás114┬Ás}
# spent 14┬Ás making 1 call to Sub::Install::BEGIN@64
71
7210smy $eow_re;
731238┬Ás28┬Ás
# spent 7┬Ás (6+1) within Sub::Install::BEGIN@73 which was called: # once (6┬Ás+1┬Ás) by Data::OptList::BEGIN@11 at line 73
BEGIN { $eow_re = qr/ at .+? line \d+\.\Z/ };
# spent 7┬Ás making 1 call to Sub::Install::BEGIN@73 # spent 1┬Ás making 1 call to Sub::Install::CORE:qr
74
75
# spent 18┬Ás (14+4) within Sub::Install::_do_with_warn which was called 3 times, avg 6┬Ás/call: # once (6┬Ás+4┬Ás) by Sub::Install::BEGIN@115 at line 129 # once (5┬Ás+0s) by Sub::Install::BEGIN@115 at line 116 # once (3┬Ás+0s) by Sub::Install::BEGIN@115 at line 122
sub _do_with_warn {
763700ns my ($arg) = @_;
7732┬Ás my $code = delete $arg->{code};
78
# spent 8┬Ás within Sub::Install::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Sub/Install.pm:101] which was called 3 times, avg 3┬Ás/call: # once (4┬Ás+0s) by Sub::Install::_do_with_warn at line 102 # once (2┬Ás+0s) by Sub::Install::BEGIN@115 at line 120 # once (2┬Ás+0s) by Sub::Install::BEGIN@115 at line 127
my $wants_code = sub {
793400ns my $code = shift;
80
# spent 119┬Ás (88+31) within Sub::Install::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Sub/Install.pm:100] which was called 6 times, avg 20┬Ás/call: # 6 times (88┬Ás+31┬Ás) by Sub::Install::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Sub/Install.pm:57] at line 56, avg 20┬Ás/call
sub {
81614┬Ás my $warn = $SIG{__WARN__} ? $SIG{__WARN__} : sub { warn @_ }; ## no critic
82 local $SIG{__WARN__} = sub {
83 my ($error) = @_;
84 for (@{ $arg->{suppress} }) {
85 return if $error =~ $_;
86 }
87 for (@{ $arg->{croak} }) {
88 if (my ($base_error) = $error =~ /\A($_) $eow_re/x) {
89 Carp::croak $base_error;
90 }
91 }
92 for (@{ $arg->{carp} }) {
93 if (my ($base_error) = $error =~ /\A($_) $eow_re/x) {
94 return $warn->(Carp::shortmess $base_error);
95 }
96 }
97 ($arg->{default} || $warn)->($error);
98622┬Ás };
99649┬Ás631┬Ás $code->(@_);
# spent 31┬Ás making 6 calls to Sub::Install::__ANON__[Sub/Install.pm:112], avg 5┬Ás/call
100313┬Ás };
10134┬Ás };
10236┬Ás14┬Ás return $wants_code->($code) if $code;
# spent 4┬Ás making 1 call to Sub::Install::__ANON__[Sub/Install.pm:101]
10327┬Ás return $wants_code;
104}
105
106
# spent 6┬Ás within Sub::Install::_installer which was called 3 times, avg 2┬Ás/call: # once (2┬Ás+0s) by Sub::Install::BEGIN@115 at line 120 # once (2┬Ás+0s) by Sub::Install::BEGIN@115 at line 127 # once (2┬Ás+0s) by Sub::Install::BEGIN@115 at line 129
sub _installer {
107
# spent 31┬Ás within Sub::Install::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Sub/Install.pm:112] which was called 6 times, avg 5┬Ás/call: # 6 times (31┬Ás+0s) by Sub::Install::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Sub/Install.pm:100] at line 99, avg 5┬Ás/call
sub {
10862┬Ás my ($pkg, $name, $code) = @_;
1092110┬Ás230┬Ás
# spent 19┬Ás (8+11) within Sub::Install::BEGIN@109 which was called: # once (8┬Ás+11┬Ás) by Data::OptList::BEGIN@11 at line 109
no strict 'refs'; ## no critic ProhibitNoStrict
# spent 19┬Ás making 1 call to Sub::Install::BEGIN@109 # spent 11┬Ás making 1 call to strict::unimport
110619┬Ás *{"$pkg\::$name"} = $code;
111616┬Ás return $code;
112 }
113310┬Ás}
114
115
# spent 74┬Ás (38+35) within Sub::Install::BEGIN@115 which was called: # once (38┬Ás+35┬Ás) by Data::OptList::BEGIN@11 at line 133
BEGIN {
11613┬Ás15┬Ás *_ignore_warnings = _do_with_warn({
# spent 5┬Ás making 1 call to Sub::Install::_do_with_warn
117 carp => [ $_misc_warn_re, $_redef_warn_re ]
118 });
119
12013┬Ás310┬Ás *install_sub = _build_public_installer(_ignore_warnings(_installer));
# spent 5┬Ás making 1 call to Sub::Install::_build_public_installer # spent 2┬Ás making 1 call to Sub::Install::__ANON__[Sub/Install.pm:101] # spent 2┬Ás making 1 call to Sub::Install::_installer
121
12212┬Ás13┬Ás *_carp_warnings = _do_with_warn({
# spent 3┬Ás making 1 call to Sub::Install::_do_with_warn
123 carp => [ $_misc_warn_re ],
124 suppress => [ $_redef_warn_re ],
125 });
126
12713┬Ás36┬Ás *reinstall_sub = _build_public_installer(_carp_warnings(_installer));
# spent 2┬Ás making 1 call to Sub::Install::__ANON__[Sub/Install.pm:101] # spent 2┬Ás making 1 call to Sub::Install::_build_public_installer # spent 2┬Ás making 1 call to Sub::Install::_installer
128
12915┬Ás212┬Ás *_install_fatal = _do_with_warn({
# spent 10┬Ás making 1 call to Sub::Install::_do_with_warn # spent 2┬Ás making 1 call to Sub::Install::_installer
130 code => _installer,
131 croak => [ $_redef_warn_re ],
132 });
1331197┬Ás174┬Ás}
# spent 74┬Ás making 1 call to Sub::Install::BEGIN@115
134
135
136sub install_installers {
137 my ($into) = @_;
138
139 for my $method (qw(install_sub reinstall_sub)) {
140 my $code = sub {
141 my ($package, $subs) = @_;
142 my ($caller) = caller(0);
143 my $return;
144 for (my ($name, $sub) = %$subs) {
145 $return = Sub::Install->can($method)->({
146 code => $sub,
147 from => $caller,
148 into => $package,
149 as => $name
150 });
151 }
152 return $return;
153 };
154 install_sub({ code => $code, into => $into, as => $method });
155 }
156}
157
158
159
# spent 12┬Ás within Sub::Install::exporter which was called 2 times, avg 6┬Ás/call: # once (6┬Ás+0s) by Sub::Install::BEGIN@174 at line 174 # once (6┬Ás+0s) by Data::OptList::BEGIN@100 at line 101 of Data/OptList.pm
sub exporter {
1602700ns my ($arg) = @_;
161
16226┬Ás my %is_exported = map { $_ => undef } @{ $arg->{exports} };
163
164 sub {
165 my $class = shift;
166 my $target = caller;
167 for (@_) {
168 Carp::croak "'$_' is not exported by $class" if !exists $is_exported{$_};
169 install_sub({ code => $_, from => $class, into => $target });
170 }
171 }
172214┬Ás}
173
174126┬Ás221┬Ás
# spent 15┬Ás (9+6) within Sub::Install::BEGIN@174 which was called: # once (9┬Ás+6┬Ás) by Data::OptList::BEGIN@11 at line 174
BEGIN { *import = exporter({ exports => [ qw(install_sub reinstall_sub) ] }); }
# spent 15┬Ás making 1 call to Sub::Install::BEGIN@174 # spent 6┬Ás making 1 call to Sub::Install::exporter
175
176
17713┬Ás1;
178
179__END__
 
# spent 3┬Ás within Sub::Install::CORE:qr which was called 3 times, avg 1┬Ás/call: # once (1┬Ás+0s) by Sub::Install::BEGIN@64 at line 65 # once (1┬Ás+0s) by Sub::Install::BEGIN@73 at line 73 # once (800ns+0s) by Sub::Install::BEGIN@64 at line 69
sub Sub::Install::CORE:qr; # opcode