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

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Install.pm
StatementsExecuted 14701 statements in 194ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
9144271.3ms187msSub::Install::::__ANON__[:132]Sub::Install::__ANON__[:132]
9141167.0ms93.4msSub::Install::::__ANON__[:175]Sub::Install::__ANON__[:175]
9141126.3ms26.4msSub::Install::::__ANON__[:187]Sub::Install::__ANON__[:187]
9141117.6ms22.3msSub::Install::::_CODELIKESub::Install::_CODELIKE
111281µs521µsSub::Install::::BEGIN@190Sub::Install::BEGIN@190
33190µs105µsSub::Install::::_do_with_warnSub::Install::_do_with_warn
44488µs88µsSub::Install::::__ANON__[:284]Sub::Install::__ANON__[:284]
22283µs83µsSub::Install::::exporterSub::Install::exporter
11178µs150µsSub::Install::::BEGIN@3Sub::Install::BEGIN@3
11160µs82µsSub::Install::::__ANON__[:173]Sub::Install::__ANON__[:173]
11158µs87µsSub::Install::::BEGIN@139Sub::Install::BEGIN@139
22153µs53µsSub::Install::::_build_public_installerSub::Install::_build_public_installer
33149µs49µsSub::Install::::__ANON__[:176]Sub::Install::__ANON__[:176]
11149µs80µsSub::Install::::BEGIN@287Sub::Install::BEGIN@287
33148µs48µsSub::Install::::_installerSub::Install::_installer
11142µs117µsSub::Install::::BEGIN@184Sub::Install::BEGIN@184
11137µs238µsSub::Install::::BEGIN@6Sub::Install::BEGIN@6
33136µs36µsSub::Install::::CORE:qrSub::Install::CORE:qr (opcode)
11136µs50µsSub::Install::::BEGIN@4Sub::Install::BEGIN@4
11127µs35µsSub::Install::::BEGIN@148Sub::Install::BEGIN@148
11120µs20µsSub::Install::::BEGIN@7Sub::Install::BEGIN@7
11116µs16µsSub::Install::::CORE:matchSub::Install::CORE:match (opcode)
1115µs5µsSub::Install::::CORE:regcompSub::Install::CORE:regcomp (opcode)
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
33102µs2223µs
# spent 150µs (78+72) within Sub::Install::BEGIN@3 which was called: # once (78µs+72µs) by Package::DeprecationManager::BEGIN@12 at line 3
use warnings;
# spent 150µs making 1 call to Sub::Install::BEGIN@3 # spent 72µs making 1 call to warnings::import
4391µs265µs
# spent 50µs (36+15) within Sub::Install::BEGIN@4 which was called: # once (36µs+15µs) by Package::DeprecationManager::BEGIN@12 at line 4
use strict;
# spent 50µs making 1 call to Sub::Install::BEGIN@4 # spent 15µs making 1 call to strict::import
5
63134µs2438µs
# spent 238µs (37+201) within Sub::Install::BEGIN@6 which was called: # once (37µs+201µs) by Package::DeprecationManager::BEGIN@12 at line 6
use Carp;
# spent 238µs making 1 call to Sub::Install::BEGIN@6 # spent 201µs making 1 call to Exporter::import
731.36ms120µs
# spent 20µs within Sub::Install::BEGIN@7 which was called: # once (20µs+0s) by Package::DeprecationManager::BEGIN@12 at line 7
use Scalar::Util ();
# spent 20µ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 22.3ms (17.6+4.77) within Sub::Install::_CODELIKE which was called 914 times, avg 24µs/call: # 914 times (17.6ms+4.77ms) 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 {
9891424.6ms9144.77ms (Scalar::Util::reftype($_[0])||'') eq 'CODE'
# spent 4.77ms making 914 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 53µs within Sub::Install::_build_public_installer which was called 2 times, avg 26µs/call: # once (32µs+0s) by Sub::Install::BEGIN@190 at line 202 # once (21µs+0s) by Sub::Install::BEGIN@190 at line 195
sub _build_public_installer {
10527µs my ($installer) = @_;
106
107
# spent 187ms (71.3+116) 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 914 times, avg 205µs/call: # 906 times (70.4ms+114ms) by Sub::Exporter::default_installer at line 896 of Sub/Exporter.pm, avg 204µs/call # 3 times (382µs+640µs) by Package::DeprecationManager::import at line 29 of Package/DeprecationManager.pm, avg 341µs/call # 3 times (364µs+519µs) by Package::DeprecationManager::import at line 37 of Package/DeprecationManager.pm, avg 294µs/call # 2 times (187µs+294µs) by Sub::Exporter::setup_exporter at line 607 of Sub/Exporter.pm, avg 240µs/call
sub {
1089142.78ms my ($arg) = @_;
10991414.6ms my ($calling_pkg) = caller(0);
110
111 # I'd rather use ||= but I'm whoring for Devel::Cover.
112274216.9ms for (qw(into from)) { $arg->{$_} = $calling_pkg unless $arg->{$_} }
113
114 # This is the only absolutely required argument, in many cases.
1159142.22ms Carp::croak "named argument 'code' is not optional" unless $arg->{code};
116
11791410.5ms91422.3ms if (_CODELIKE($arg->{code})) {
# spent 22.3ms making 914 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
1289142.03ms Carp::croak "couldn't determine name under which to install subroutine"
129 unless $arg->{as};
130
13191418.6ms91493.4ms $installer->(@$arg{qw(into as code) });
# spent 93.4ms making 914 calls to Sub::Install::__ANON__[Sub/Install.pm:175], avg 102µs/call
132 }
133257µs}
134
135# do the ugly work
136
13712µsmy $_misc_warn_re;
13812µsmy $_redef_warn_re;
139
# spent 87µs (58+29) within Sub::Install::BEGIN@139 which was called: # once (58µs+29µs) by Package::DeprecationManager::BEGIN@12 at line 145
BEGIN {
140150µs122µs $_misc_warn_re = qr/
# spent 22µs making 1 call to Sub::Install::CORE:qr
141 Prototype\ mismatch:\ sub\ .+? |
142 Constant subroutine \S+ redefined
143 /x;
144131µs17µs $_redef_warn_re = qr/Subroutine\ \S+\ redefined/x;
# spent 7µs making 1 call to Sub::Install::CORE:qr
1451116µs187µs}
# spent 87µs making 1 call to Sub::Install::BEGIN@139
146
14712µsmy $eow_re;
14811.09ms242µs
# spent 35µs (27+7) within Sub::Install::BEGIN@148 which was called: # once (27µs+7µs) by Package::DeprecationManager::BEGIN@12 at line 148
BEGIN { $eow_re = qr/ at .+? line \d+\.\Z/ };
# spent 35µs making 1 call to Sub::Install::BEGIN@148 # spent 7µs making 1 call to Sub::Install::CORE:qr
149
150
# spent 105µs (90+15) within Sub::Install::_do_with_warn which was called 3 times, avg 35µs/call: # once (36µs+15µs) by Sub::Install::BEGIN@190 at line 204 # once (31µ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 {
151310µs my ($arg) = @_;
152311µs my $code = delete $arg->{code};
153
# spent 49µ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 16µs/call: # once (18µs+0s) by Sub::Install::BEGIN@190 at line 195 # once (16µs+0s) by Sub::Install::BEGIN@190 at line 202 # once (15µs+0s) by Sub::Install::_do_with_warn at line 177
my $wants_code = sub {
15438µs my $code = shift;
155
# spent 93.4ms (67.0+26.4) 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 914 times, avg 102µs/call: # 914 times (67.0ms+26.4ms) 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 102µs/call
sub {
15691414.8ms my $warn = $SIG{__WARN__} ? $SIG{__WARN__} : sub { warn @_ }; ## no critic
157
# spent 82µs (60+22) 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: # once (60µs+22µ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
local $SIG{__WARN__} = sub {
15814µs my ($error) = @_;
15916µs for (@{ $arg->{suppress} }) {
1601102µs222µs return if $error =~ $_;
# spent 16µs making 1 call to Sub::Install::CORE:match # spent 5µs making 1 call to Sub::Install::CORE:regcomp
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);
17391418.5ms };
17491432.4ms91426.4ms $code->(@_);
# spent 26.4ms making 914 calls to Sub::Install::__ANON__[Sub/Install.pm:187], avg 29µs/call
175358µs };
176326µs };
177323µs115µs return $wants_code->($code) if $code;
# spent 15µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:176]
178252µs return $wants_code;
179}
180
181
# spent 48µs within Sub::Install::_installer which was called 3 times, avg 16µs/call: # once (22µs+0s) by Sub::Install::BEGIN@190 at line 204 # once (13µs+0s) by Sub::Install::BEGIN@190 at line 195 # once (12µs+0s) by Sub::Install::BEGIN@190 at line 202
sub _installer {
182
# spent 26.4ms (26.3+81µs) 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 914 times, avg 29µs/call: # 914 times (26.3ms+81µs) 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 29µs/call
sub {
1839143.85ms my ($pkg, $name, $code) = @_;
1843527µs2192µs
# spent 117µs (42+75) within Sub::Install::BEGIN@184 which was called: # once (42µs+75µs) by Package::DeprecationManager::BEGIN@12 at line 184
no strict 'refs'; ## no critic ProhibitNoStrict
# spent 117µs making 1 call to Sub::Install::BEGIN@184 # spent 75µs making 1 call to strict::unimport
18591413.9ms182µs *{"$pkg\::$name"} = $code;
# spent 82µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:173]
18691413.3ms return $code;
187 }
188366µs}
189
190
# spent 521µs (281+240) within Sub::Install::BEGIN@190 which was called: # once (281µs+240µs) by Package::DeprecationManager::BEGIN@12 at line 208
BEGIN {
191127µs131µs *_ignore_warnings = _do_with_warn({
# spent 31µs making 1 call to Sub::Install::_do_with_warn
192 carp => [ $_misc_warn_re, $_redef_warn_re ]
193 });
194
195128µs352µs *install_sub = _build_public_installer(_ignore_warnings(_installer));
# spent 21µs making 1 call to Sub::Install::_build_public_installer # spent 18µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:176] # spent 13µ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µs360µs *reinstall_sub = _build_public_installer(_carp_warnings(_installer));
# spent 32µs making 1 call to Sub::Install::_build_public_installer # spent 16µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:176] # spent 12µs making 1 call to Sub::Install::_installer
203
204138µs273µs *_install_fatal = _do_with_warn({
# spent 51µs making 1 call to Sub::Install::_do_with_warn # spent 22µs making 1 call to Sub::Install::_installer
205 code => _installer,
206 croak => [ $_redef_warn_re ],
207 });
2081947µs1521µs}
# spent 521µ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 83µs within Sub::Install::exporter which was called 2 times, avg 41µs/call: # once (51µs+0s) by Data::OptList::BEGIN@214 at line 215 of Data/OptList.pm # once (31µs+0s) by Sub::Install::BEGIN@287 at line 287
sub exporter {
27327µs my ($arg) = @_;
274
275229µs my %is_exported = map { $_ => undef } @{ $arg->{exports} };
276
277
# spent 88µ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 22µs/call: # once (23µs+0s) by Class::MOP::BEGIN@13 at line 13 of Class/MOP.pm # once (22µs+0s) by Moose::Meta::Class::BEGIN@10 at line 10 of Moose/Meta/Class.pm # once (21µ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;
280485µs for (@_) {
281 Carp::croak "'$_' is not exported by $class" if !exists $is_exported{$_};
282 install_sub({ code => $_, from => $class, into => $target });
283 }
284 }
285259µs}
286
2871134µs2111µs
# spent 80µs (49+31) within Sub::Install::BEGIN@287 which was called: # once (49µs+31µs) by Package::DeprecationManager::BEGIN@12 at line 287
BEGIN { *import = exporter({ exports => [ qw(install_sub reinstall_sub) ] }); }
# spent 80µs making 1 call to Sub::Install::BEGIN@287 # spent 31µs making 1 call to Sub::Install::exporter
288
289=head1 SEE ALSO
290
- -
329113µs1;
 
# spent 16µs within Sub::Install::CORE:match which was called: # once (16µ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
sub Sub::Install::CORE:match; # opcode
# spent 36µs within Sub::Install::CORE:qr which was called 3 times, avg 12µs/call: # once (22µs+0s) by Sub::Install::BEGIN@139 at line 140 # once (7µs+0s) by Sub::Install::BEGIN@148 at line 148 # once (7µs+0s) by Sub::Install::BEGIN@139 at line 144
sub Sub::Install::CORE:qr; # opcode
# spent 5µs within Sub::Install::CORE:regcomp which was called: # once (5µ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
sub Sub::Install::CORE:regcomp; # opcode