← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:45:08 2010
Reported on Wed Nov 17 22:13:13 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Install.pm
StatementsExecuted 32390 statements in 425ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
201642155ms415msSub::Install::::__ANON__[:132]Sub::Install::__ANON__[:132]
201611149ms211msSub::Install::::__ANON__[:175]Sub::Install::__ANON__[:175]
20161161.3ms62.5msSub::Install::::__ANON__[:187]Sub::Install::__ANON__[:187]
20161138.1ms48.8msSub::Install::::_CODELIKESub::Install::_CODELIKE
2011811µs1.15msSub::Install::::__ANON__[:173]Sub::Install::__ANON__[:173]
2011220µs220µsSub::Install::::CORE:matchSub::Install::CORE:match (opcode)
111186µs440µsSub::Install::::BEGIN@190Sub::Install::BEGIN@190
2011122µs122µsSub::Install::::CORE:regcompSub::Install::CORE:regcomp (opcode)
33196µs118µsSub::Install::::_do_with_warnSub::Install::_do_with_warn
44491µs91µsSub::Install::::__ANON__[:284]Sub::Install::__ANON__[:284]
11171µs145µsSub::Install::::BEGIN@3Sub::Install::BEGIN@3
11168µs113µsSub::Install::::BEGIN@139Sub::Install::BEGIN@139
22267µs67µsSub::Install::::exporterSub::Install::exporter
33166µs66µsSub::Install::::__ANON__[:176]Sub::Install::__ANON__[:176]
11154µs87µsSub::Install::::BEGIN@287Sub::Install::BEGIN@287
33153µs53µsSub::Install::::CORE:qrSub::Install::CORE:qr (opcode)
22148µs48µsSub::Install::::_build_public_installerSub::Install::_build_public_installer
33144µs44µsSub::Install::::_installerSub::Install::_installer
11140µs115µsSub::Install::::BEGIN@184Sub::Install::BEGIN@184
11136µs243µsSub::Install::::BEGIN@6Sub::Install::BEGIN@6
11136µs52µsSub::Install::::BEGIN@4Sub::Install::BEGIN@4
11130µs39µsSub::Install::::BEGIN@148Sub::Install::BEGIN@148
11119µs19µsSub::Install::::BEGIN@7Sub::Install::BEGIN@7
0000s0sSub::Install::::__ANON__[:156]Sub::Install::__ANON__[:156]
0000s0sSub::Install::::__ANON__[:250]Sub::Install::__ANON__[:250]
0000s0sSub::Install::::_name_of_codeSub::Install::_name_of_code
0000s0sSub::Install::::install_installersSub::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
1package Sub::Install;
2
33104µs2218µs
# spent 145µs (71+73) within Sub::Install::BEGIN@3 which was called: # once (71µs+73µs) by Data::OptList::BEGIN@8 at line 3
use warnings;
# spent 145µs making 1 call to Sub::Install::BEGIN@3 # spent 73µs making 1 call to warnings::import
4392µs268µs
# spent 52µs (36+16) within Sub::Install::BEGIN@4 which was called: # once (36µs+16µs) by Data::OptList::BEGIN@8 at line 4
use strict;
# spent 52µs making 1 call to Sub::Install::BEGIN@4 # spent 16µs making 1 call to strict::import
5
6399µs2449µs
# spent 243µs (36+206) within Sub::Install::BEGIN@6 which was called: # once (36µs+206µs) by Data::OptList::BEGIN@8 at line 6
use Carp;
# spent 243µs making 1 call to Sub::Install::BEGIN@6 # spent 206µs making 1 call to Exporter::import
731.57ms119µs
# spent 19µs within Sub::Install::BEGIN@7 which was called: # once (19µs+0s) by Data::OptList::BEGIN@8 at line 7
use Scalar::Util ();
# spent 19µs making 1 call to Sub::Install::BEGIN@7
8
9=head1 NAME
10
- -
1914µsour $VERSION = '0.925';
20
21=head1 SYNOPSIS
22
- -
88sub _name_of_code {
89 my ($code) = @_;
90 require B;
91 my $name = B::svref_2object($code)->GV->NAME;
92 return $name unless $name =~ /\A__ANON__/;
93 return;
94}
95
96# See also Params::Util, to which this code was donated.
97
# spent 48.8ms (38.1+10.6) within Sub::Install::_CODELIKE which was called 2016 times, avg 24µs/call: # 2016 times (38.1ms+10.6ms) by Sub::Install::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Install.pm:132] at line 117, avg 24µs/call
sub _CODELIKE {
98201653.8ms201610.6ms (Scalar::Util::reftype($_[0])||'') eq 'CODE'
# spent 10.6ms making 2016 calls to Scalar::Util::reftype, avg 5µs/call
99 || Scalar::Util::blessed($_[0])
100 && (overload::Method($_[0],'&{}') ? $_[0] : undef);
101}
102
103# do the heavy lifting
104
# spent 48µs within Sub::Install::_build_public_installer which was called 2 times, avg 24µs/call: # once (30µs+0s) by Sub::Install::BEGIN@190 at line 195 # once (17µs+0s) by Sub::Install::BEGIN@190 at line 202
sub _build_public_installer {
10527µs my ($installer) = @_;
106
107
# spent 415ms (155+260) within Sub::Install::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Install.pm:132] which was called 2016 times, avg 206µs/call: # 2010 times (155ms+259ms) by Sub::Exporter::default_installer at line 896 of Sub/Exporter.pm, avg 206µs/call # 2 times (189µs+311µs) by Sub::Exporter::setup_exporter at line 607 of Sub/Exporter.pm, avg 250µs/call # 2 times (143µs+352µs) by Package::DeprecationManager::import at line 37 of Package/DeprecationManager.pm, avg 247µs/call # 2 times (179µs+303µs) by Package::DeprecationManager::import at line 29 of Package/DeprecationManager.pm, avg 241µs/call
sub {
10820165.90ms my ($arg) = @_;
109201630.9ms my ($calling_pkg) = caller(0);
110
111 # I'd rather use ||= but I'm whoring for Devel::Cover.
112604838.1ms for (qw(into from)) { $arg->{$_} = $calling_pkg unless $arg->{$_} }
113
114 # This is the only absolutely required argument, in many cases.
11520164.91ms Carp::croak "named argument 'code' is not optional" unless $arg->{code};
116
117201622.9ms201648.8ms if (_CODELIKE($arg->{code})) {
# spent 48.8ms making 2016 calls to Sub::Install::_CODELIKE, avg 24µs/call
118 $arg->{as} ||= _name_of_code($arg->{code});
119 } else {
120 Carp::croak
121 "couldn't find subroutine named $arg->{code} in package $arg->{from}"
122 unless my $code = $arg->{from}->can($arg->{code});
123
124 $arg->{as} = $arg->{code} unless $arg->{as};
125 $arg->{code} = $code;
126 }
127
12820164.39ms Carp::croak "couldn't determine name under which to install subroutine"
129 unless $arg->{as};
130
131201640.6ms2016211ms $installer->(@$arg{qw(into as code) });
# spent 211ms making 2016 calls to Sub::Install::__ANON__[Sub/Install.pm:175], avg 105µs/call
132 }
133252µs}
134
135# do the ugly work
136
13712µsmy $_misc_warn_re;
13812µsmy $_redef_warn_re;
139
# spent 113µs (68+45) within Sub::Install::BEGIN@139 which was called: # once (68µs+45µs) by Data::OptList::BEGIN@8 at line 145
BEGIN {
140155µs124µs $_misc_warn_re = qr/
# spent 24µs making 1 call to Sub::Install::CORE:qr
141 Prototype\ mismatch:\ sub\ .+? |
142 Constant subroutine \S+ redefined
143 /x;
144148µs121µs $_redef_warn_re = qr/Subroutine\ \S+\ redefined/x;
# spent 21µs making 1 call to Sub::Install::CORE:qr
1451133µs1113µs}
# spent 113µs making 1 call to Sub::Install::BEGIN@139
146
14712µsmy $eow_re;
14811.07ms247µs
# spent 39µs (30+8) within Sub::Install::BEGIN@148 which was called: # once (30µs+8µs) by Data::OptList::BEGIN@8 at line 148
BEGIN { $eow_re = qr/ at .+? line \d+\.\Z/ };
# spent 39µs making 1 call to Sub::Install::BEGIN@148 # spent 8µs making 1 call to Sub::Install::CORE:qr
149
150
# spent 118µs (96+23) within Sub::Install::_do_with_warn which was called 3 times, avg 39µs/call: # once (45µs+23µs) by Sub::Install::BEGIN@190 at line 204 # once (28µs+0s) by Sub::Install::BEGIN@190 at line 191 # once (23µs+0s) by Sub::Install::BEGIN@190 at line 197
sub _do_with_warn {
15139µs my ($arg) = @_;
152310µs my $code = delete $arg->{code};
153
# spent 66µs within Sub::Install::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Install.pm:176] which was called 3 times, avg 22µs/call: # once (27µs+0s) by Sub::Install::BEGIN@190 at line 195 # once (23µs+0s) by Sub::Install::_do_with_warn at line 177 # once (16µs+0s) by Sub::Install::BEGIN@190 at line 202
my $wants_code = sub {
15438µs my $code = shift;
155
# spent 211ms (149+62.5) within Sub::Install::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Install.pm:175] which was called 2016 times, avg 105µs/call: # 2016 times (149ms+62.5ms) by Sub::Install::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Install.pm:132] at line 131, avg 105µs/call
sub {
156201633.6ms my $warn = $SIG{__WARN__} ? $SIG{__WARN__} : sub { warn @_ }; ## no critic
157
# spent 1.15ms (811µs+341µs) within Sub::Install::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Install.pm:173] which was called 20 times, avg 58µs/call: # 20 times (811µs+341µs) by Sub::Install::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Install.pm:187] at line 185, avg 58µs/call
local $SIG{__WARN__} = sub {
1582085µs my ($error) = @_;
15920103µs for (@{ $arg->{suppress} }) {
160201.02ms40341µs return if $error =~ $_;
# spent 220µs making 20 calls to Sub::Install::CORE:match, avg 11µs/call # spent 122µs making 20 calls to Sub::Install::CORE:regcomp, avg 6µs/call
161 }
162 for (@{ $arg->{croak} }) {
163 if (my ($base_error) = $error =~ /\A($_) $eow_re/x) {
164 Carp::croak $base_error;
165 }
166 }
167 for (@{ $arg->{carp} }) {
168 if (my ($base_error) = $error =~ /\A($_) $eow_re/x) {
169 return $warn->(Carp::shortmess $base_error);
170 }
171 }
172 ($arg->{default} || $warn)->($error);
173201641.1ms };
174201671.5ms201662.5ms $code->(@_);
# spent 62.5ms making 2016 calls to Sub::Install::__ANON__[Sub/Install.pm:187], avg 31µs/call
175378µs };
176334µs };
177324µs123µs return $wants_code->($code) if $code;
# spent 23µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:176]
178232µs return $wants_code;
179}
180
181
# spent 44µs within Sub::Install::_installer which was called 3 times, avg 15µs/call: # once (19µs+0s) by Sub::Install::BEGIN@190 at line 202 # once (14µs+0s) by Sub::Install::BEGIN@190 at line 195 # once (12µs+0s) by Sub::Install::BEGIN@190 at line 204
sub _installer {
182
# spent 62.5ms (61.3+1.15) within Sub::Install::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Install.pm:187] which was called 2016 times, avg 31µs/call: # 2016 times (61.3ms+1.15ms) by Sub::Install::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Install.pm:175] at line 174, avg 31µs/call
sub {
18320168.29ms my ($pkg, $name, $code) = @_;
1843474µs2190µs
# spent 115µs (40+75) within Sub::Install::BEGIN@184 which was called: # once (40µs+75µs) by Data::OptList::BEGIN@8 at line 184
no strict 'refs'; ## no critic ProhibitNoStrict
# spent 115µs making 1 call to Sub::Install::BEGIN@184 # spent 75µs making 1 call to strict::unimport
185201634.1ms201.15ms *{"$pkg\::$name"} = $code;
# spent 1.15ms making 20 calls to Sub::Install::__ANON__[Sub/Install.pm:173], avg 58µs/call
186201628.7ms return $code;
187 }
188362µs}
189
190
# spent 440µs (186+254) within Sub::Install::BEGIN@190 which was called: # once (186µs+254µs) by Data::OptList::BEGIN@8 at line 208
BEGIN {
191117µs128µs *_ignore_warnings = _do_with_warn({
# spent 28µs making 1 call to Sub::Install::_do_with_warn
192 carp => [ $_misc_warn_re, $_redef_warn_re ]
193 });
194
195127µs371µs *install_sub = _build_public_installer(_ignore_warnings(_installer));
# spent 30µs making 1 call to Sub::Install::_build_public_installer # spent 27µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:176] # spent 14µs making 1 call to Sub::Install::_installer
196
197116µs123µs *_carp_warnings = _do_with_warn({
# spent 23µs making 1 call to Sub::Install::_do_with_warn
198 carp => [ $_misc_warn_re ],
199 suppress => [ $_redef_warn_re ],
200 });
201
202125µs352µs *reinstall_sub = _build_public_installer(_carp_warnings(_installer));
# spent 19µs making 1 call to Sub::Install::_installer # spent 17µs making 1 call to Sub::Install::_build_public_installer # spent 16µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:176]
203
204138µs280µs *_install_fatal = _do_with_warn({
# spent 68µs making 1 call to Sub::Install::_do_with_warn # spent 12µs making 1 call to Sub::Install::_installer
205 code => _installer,
206 croak => [ $_redef_warn_re ],
207 });
2081989µs1440µs}
# spent 440µs making 1 call to Sub::Install::BEGIN@190
209
210=head2 install_installers
211
- -
233sub install_installers {
234 my ($into) = @_;
235
236 for my $method (qw(install_sub reinstall_sub)) {
237 my $code = sub {
238 my ($package, $subs) = @_;
239 my ($caller) = caller(0);
240 my $return;
241 for (my ($name, $sub) = %$subs) {
242 $return = Sub::Install->can($method)->({
243 code => $sub,
244 from => $caller,
245 into => $package,
246 as => $name
247 });
248 }
249 return $return;
250 };
251 install_sub({ code => $code, into => $into, as => $method });
252 }
253}
254
255=head1 EXPORTS
256
- -
272
# spent 67µs within Sub::Install::exporter which was called 2 times, avg 34µs/call: # once (35µs+0s) by Data::OptList::BEGIN@214 at line 215 of Data/OptList.pm # once (32µs+0s) by Sub::Install::BEGIN@287 at line 287
sub exporter {
27328µs my ($arg) = @_;
274
275227µs my %is_exported = map { $_ => undef } @{ $arg->{exports} };
276
277
# spent 91µs within Sub::Install::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Install.pm:284] which was called 4 times, avg 23µs/call: # once (24µs+0s) by Class::MOP::BEGIN@13 at line 13 of Class/MOP.pm # once (24µs+0s) by Moose::Meta::Class::BEGIN@10 at line 10 of Moose/Meta/Class.pm # once (22µs+0s) by Moose::Util::BEGIN@6 at line 6 of Moose/Util.pm # once (21µs+0s) by Package::DeprecationManager::BEGIN@12 at line 12 of Package/DeprecationManager.pm
sub {
278417µs my $class = shift;
279417µs my $target = caller;
280497µs for (@_) {
281 Carp::croak "'$_' is not exported by $class" if !exists $is_exported{$_};
282 install_sub({ code => $_, from => $class, into => $target });
283 }
284 }
285273µs}
286
2871135µs2119µs
# spent 87µs (54+32) within Sub::Install::BEGIN@287 which was called: # once (54µs+32µs) by Data::OptList::BEGIN@8 at line 287
BEGIN { *import = exporter({ exports => [ qw(install_sub reinstall_sub) ] }); }
# spent 87µs making 1 call to Sub::Install::BEGIN@287 # spent 32µs making 1 call to Sub::Install::exporter
288
289=head1 SEE ALSO
290
- -
329112µs1;
 
# spent 220µs within Sub::Install::CORE:match which was called 20 times, avg 11µs/call: # 20 times (220µs+0s) by Sub::Install::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Install.pm:173] at line 160, avg 11µs/call
sub Sub::Install::CORE:match; # opcode
# spent 53µs within Sub::Install::CORE:qr which was called 3 times, avg 18µs/call: # once (24µs+0s) by Sub::Install::BEGIN@139 at line 140 # once (21µs+0s) by Sub::Install::BEGIN@139 at line 144 # once (8µs+0s) by Sub::Install::BEGIN@148 at line 148
sub Sub::Install::CORE:qr; # opcode
# spent 122µs within Sub::Install::CORE:regcomp which was called 20 times, avg 6µs/call: # 20 times (122µs+0s) by Sub::Install::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Install.pm:173] at line 160, avg 6µs/call
sub Sub::Install::CORE:regcomp; # opcode