← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mentat.storage.mongo.pl
  Run on Tue Jun 24 09:58:41 2014
Reported on Tue Jun 24 09:59:29 2014

Filename/usr/local/share/perl/5.14.2/Sub/Install.pm
StatementsExecuted 3665 statements in 8.98ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
199112.37ms3.23msSub::Install::::__ANON__[:100] Sub::Install::__ANON__[:100]
199532.05ms5.99msSub::Install::::__ANON__[:57] Sub::Install::__ANON__[:57]
19911855µs855µsSub::Install::::__ANON__[:112] Sub::Install::__ANON__[:112]
19911588µs705µsSub::Install::::_CODELIKE Sub::Install::_CODELIKE
11182µs184µsSub::Install::::BEGIN@115 Sub::Install::BEGIN@115
22248µs48µsSub::Install::::exporter Sub::Install::exporter
33140µs45µsSub::Install::::_do_with_warn Sub::Install::_do_with_warn
55534µs181µsSub::Install::::__ANON__[:171] Sub::Install::__ANON__[:171]
11128µs35µsSub::Install::::BEGIN@64 Sub::Install::BEGIN@64
11127µs35µsData::OptList::::BEGIN@1Data::OptList::BEGIN@1
22124µs24µsSub::Install::::_build_public_installer Sub::Install::_build_public_installer
11123µs51µsSub::Install::::BEGIN@174 Sub::Install::BEGIN@174
33120µs20µsSub::Install::::_installer Sub::Install::_installer
33118µs18µsSub::Install::::__ANON__[:101] Sub::Install::__ANON__[:101]
11116µs41µsSub::Install::::BEGIN@109 Sub::Install::BEGIN@109
11116µs111µsSub::Install::::BEGIN@9 Sub::Install::BEGIN@9
11115µs27µsData::OptList::::BEGIN@2Data::OptList::BEGIN@2
11113µs17µsSub::Install::::BEGIN@73 Sub::Install::BEGIN@73
33111µs11µsSub::Install::::CORE:qr Sub::Install::CORE:qr (opcode)
1118µs8µsSub::Install::::BEGIN@10 Sub::Install::BEGIN@10
0000s0sSub::Install::::__ANON__[:153] Sub::Install::__ANON__[:153]
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
1254µs242µs
# spent 35µs (27+8) within Data::OptList::BEGIN@1 which was called: # once (27µs+8µs) by Data::OptList::BEGIN@11 at line 1
use strict;
# spent 35µs making 1 call to Data::OptList::BEGIN@1 # spent 8µs making 1 call to strict::import
2290µs239µs
# spent 27µs (15+12) within Data::OptList::BEGIN@2 which was called: # once (15µs+12µs) by Data::OptList::BEGIN@11 at line 2
use warnings;
# spent 27µs making 1 call to Data::OptList::BEGIN@2 # spent 12µs making 1 call to warnings::import
3package Sub::Install;
4{
522µs $Sub::Install::VERSION = '0.927';
6}
7# ABSTRACT: install subroutines into packages easily
8
9254µs2207µs
# spent 111µs (16+95) within Sub::Install::BEGIN@9 which was called: # once (16µs+95µs) by Data::OptList::BEGIN@11 at line 9
use Carp;
# spent 111µs making 1 call to Sub::Install::BEGIN@9 # spent 96µs making 1 call to Exporter::import
102765µs18µs
# spent 8µs within Sub::Install::BEGIN@10 which was called: # once (8µs+0s) by Data::OptList::BEGIN@11 at line 10
use Scalar::Util ();
# spent 8µ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 705µs (588+117) within Sub::Install::_CODELIKE which was called 199 times, avg 4µs/call: # 199 times (588µs+117µs) by Sub::Install::__ANON__[/usr/local/share/perl/5.14.2/Sub/Install.pm:57] at line 42, avg 4µs/call
sub _CODELIKE {
23199844µs200117µs (Scalar::Util::reftype($_[0])||'') eq 'CODE'
# spent 116µs making 199 calls to Scalar::Util::reftype, avg 581ns/call # spent 1µs making 1 call to Scalar::Util::blessed
24 || Scalar::Util::blessed($_[0])
25 && (overload::Method($_[0],'&{}') ? $_[0] : undef);
26}
27
28# do the heavy lifting
29
# spent 24µs within Sub::Install::_build_public_installer which was called 2 times, avg 12µs/call: # once (15µs+0s) by Sub::Install::BEGIN@115 at line 120 # once (9µs+0s) by Sub::Install::BEGIN@115 at line 127
sub _build_public_installer {
3022µs my ($installer) = @_;
31
32
# spent 5.99ms (2.05+3.94) within Sub::Install::__ANON__[/usr/local/share/perl/5.14.2/Sub/Install.pm:57] which was called 199 times, avg 30µs/call: # 192 times (1.91ms+3.68ms) by Sub::Exporter::default_installer at line 442 of Sub/Exporter.pm, avg 29µs/call # 2 times (32µs+71µs) by Package::DeprecationManager::import at line 29 of Package/DeprecationManager.pm, avg 51µs/call # 2 times (27µs+57µs) by Sub::Exporter::setup_exporter at line 198 of Sub/Exporter.pm, avg 42µs/call # 2 times (22µs+42µs) by Package::DeprecationManager::import at line 37 of Package/DeprecationManager.pm, avg 32µs/call # once (57µs+89µs) by Sub::Install::__ANON__[/usr/local/share/perl/5.14.2/Sub/Install.pm:171] at line 169
sub {
3319961µs my ($arg) = @_;
34199466µs my ($calling_pkg) = caller(0);
35
36 # I'd rather use ||= but I'm whoring for Devel::Cover.
37597385µs for (qw(into from)) { $arg->{$_} = $calling_pkg unless $arg->{$_} }
38
39 # This is the only absolutely required argument, in many cases.
4019943µs Carp::croak "named argument 'code' is not optional" unless $arg->{code};
41
42199231µs199705µs if (_CODELIKE($arg->{code})) {
# spent 705µs making 199 calls to Sub::Install::_CODELIKE, avg 4µs/call
4319871µs $arg->{as} ||= _name_of_code($arg->{code});
44 } else {
45120µs14µs Carp::croak
# spent 4µs making 1 call to UNIVERSAL::can
46 "couldn't find subroutine named $arg->{code} in package $arg->{from}"
47 unless my $code = $arg->{from}->can($arg->{code});
48
4912µs $arg->{as} = $arg->{code} unless $arg->{as};
5012µs $arg->{code} = $code;
51 }
52
5319932µs Carp::croak "couldn't determine name under which to install subroutine"
54 unless $arg->{as};
55
56199534µs1993.23ms $installer->(@$arg{qw(into as code) });
# spent 3.23ms making 199 calls to Sub::Install::__ANON__[Sub/Install.pm:100], avg 16µs/call
57 }
58228µs}
59
60# do the ugly work
61
621300nsmy $_misc_warn_re;
631100nsmy $_redef_warn_re;
64
# spent 35µs (28+7) within Sub::Install::BEGIN@64 which was called: # once (28µs+7µs) by Data::OptList::BEGIN@11 at line 70
BEGIN {
65119µs14µs $_misc_warn_re = qr/
# spent 4µs making 1 call to Sub::Install::CORE:qr
66 Prototype\ mismatch:\ sub\ .+? |
67 Constant subroutine \S+ redefined
68 /x;
69112µs12µs $_redef_warn_re = qr/Subroutine\ \S+\ redefined/x;
# spent 2µs making 1 call to Sub::Install::CORE:qr
70175µs135µs}
# spent 35µs making 1 call to Sub::Install::BEGIN@64
71
721200nsmy $eow_re;
731595µs221µs
# spent 17µs (13+4) within Sub::Install::BEGIN@73 which was called: # once (13µs+4µs) by Data::OptList::BEGIN@11 at line 73
BEGIN { $eow_re = qr/ at .+? line \d+\.\Z/ };
# spent 17µs making 1 call to Sub::Install::BEGIN@73 # spent 4µs making 1 call to Sub::Install::CORE:qr
74
75
# spent 45µs (40+6) within Sub::Install::_do_with_warn which was called 3 times, avg 15µs/call: # once (14µs+6µs) by Sub::Install::BEGIN@115 at line 129 # once (18µs+0s) by Sub::Install::BEGIN@115 at line 116 # once (8µs+0s) by Sub::Install::BEGIN@115 at line 122
sub _do_with_warn {
7633µs my ($arg) = @_;
7734µs my $code = delete $arg->{code};
78
# spent 18µs within Sub::Install::__ANON__[/usr/local/share/perl/5.14.2/Sub/Install.pm:101] which was called 3 times, avg 6µs/call: # once (7µs+0s) by Sub::Install::BEGIN@115 at line 120 # once (6µs+0s) by Sub::Install::BEGIN@115 at line 127 # once (6µs+0s) by Sub::Install::_do_with_warn at line 102
my $wants_code = sub {
7932µs my $code = shift;
80
# spent 3.23ms (2.37+855µs) within Sub::Install::__ANON__[/usr/local/share/perl/5.14.2/Sub/Install.pm:100] which was called 199 times, avg 16µs/call: # 199 times (2.37ms+855µs) by Sub::Install::__ANON__[/usr/local/share/perl/5.14.2/Sub/Install.pm:57] at line 56, avg 16µs/call
sub {
81199456µ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);
98199638µs };
991991.21ms199855µs $code->(@_);
# spent 855µs making 199 calls to Sub::Install::__ANON__[Sub/Install.pm:112], avg 4µs/call
100326µs };
101318µs };
10238µs16µs return $wants_code->($code) if $code;
# spent 6µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:101]
103215µs return $wants_code;
104}
105
106
# spent 20µs within Sub::Install::_installer which was called 3 times, avg 7µs/call: # once (8µs+0s) by Sub::Install::BEGIN@115 at line 127 # once (6µs+0s) by Sub::Install::BEGIN@115 at line 120 # once (5µs+0s) by Sub::Install::BEGIN@115 at line 129
sub _installer {
107
# spent 855µs within Sub::Install::__ANON__[/usr/local/share/perl/5.14.2/Sub/Install.pm:112] which was called 199 times, avg 4µs/call: # 199 times (855µs+0s) by Sub::Install::__ANON__[/usr/local/share/perl/5.14.2/Sub/Install.pm:100] at line 99, avg 4µs/call
sub {
108199103µs my ($pkg, $name, $code) = @_;
1092310µs266µs
# spent 41µs (16+25) within Sub::Install::BEGIN@109 which was called: # once (16µs+25µs) by Data::OptList::BEGIN@11 at line 109
no strict 'refs'; ## no critic ProhibitNoStrict
# spent 41µs making 1 call to Sub::Install::BEGIN@109 # spent 25µs making 1 call to strict::unimport
110398534µs *{"$pkg\::$name"} = $code;
111199470µs return $code;
112 }
113330µs}
114
115
# spent 184µs (82+102) within Sub::Install::BEGIN@115 which was called: # once (82µs+102µs) by Data::OptList::BEGIN@11 at line 133
BEGIN {
11617µs118µs *_ignore_warnings = _do_with_warn({
# spent 18µs making 1 call to Sub::Install::_do_with_warn
117 carp => [ $_misc_warn_re, $_redef_warn_re ]
118 });
119
12018µs329µs *install_sub = _build_public_installer(_ignore_warnings(_installer));
# spent 15µs making 1 call to Sub::Install::_build_public_installer # spent 7µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:101] # spent 6µs making 1 call to Sub::Install::_installer
121
12215µs18µs *_carp_warnings = _do_with_warn({
# spent 8µs making 1 call to Sub::Install::_do_with_warn
123 carp => [ $_misc_warn_re ],
124 suppress => [ $_redef_warn_re ],
125 });
126
12717µs323µs *reinstall_sub = _build_public_installer(_carp_warnings(_installer));
# spent 9µs making 1 call to Sub::Install::_build_public_installer # spent 8µs making 1 call to Sub::Install::_installer # spent 6µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:101]
128
129122µs224µs *_install_fatal = _do_with_warn({
# spent 20µs making 1 call to Sub::Install::_do_with_warn # spent 5µs making 1 call to Sub::Install::_installer
130 code => _installer,
131 croak => [ $_redef_warn_re ],
132 });
1331547µs1184µs}
# spent 184µ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 48µs within Sub::Install::exporter which was called 2 times, avg 24µs/call: # once (28µs+0s) by Sub::Install::BEGIN@174 at line 174 # once (20µs+0s) by Data::OptList::BEGIN@100 at line 101 of Data/OptList.pm
sub exporter {
16023µs my ($arg) = @_;
161
162820µs my %is_exported = map { $_ => undef } @{ $arg->{exports} };
163
164
# spent 181µs (34+146) within Sub::Install::__ANON__[/usr/local/share/perl/5.14.2/Sub/Install.pm:171] which was called 5 times, avg 36µs/call: # once (21µs+146µs) by Class::Load::BEGIN@8 at line 8 of Class/Load.pm # once (4µs+0s) by Package::DeprecationManager::BEGIN@12 at line 12 of Package/DeprecationManager.pm # once (3µs+0s) by Class::MOP::BEGIN@20 at line 20 of Class/MOP.pm # once (3µs+0s) by Moose::Meta::Class::BEGIN@16 at line 16 of Moose/Meta/Class.pm # once (3µs+0s) by Moose::Util::BEGIN@13 at line 13 of Moose/Util.pm
sub {
16553µs my $class = shift;
16653µs my $target = caller;
167524µs for (@_) {
16811µs Carp::croak "'$_' is not exported by $class" if !exists $is_exported{$_};
16919µs1146µs install_sub({ code => $_, from => $class, into => $target });
# spent 146µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:57]
170 }
171 }
172238µs}
173
174160µs279µs
# spent 51µs (23+28) within Sub::Install::BEGIN@174 which was called: # once (23µs+28µs) by Data::OptList::BEGIN@11 at line 174
BEGIN { *import = exporter({ exports => [ qw(install_sub reinstall_sub) ] }); }
# spent 51µs making 1 call to Sub::Install::BEGIN@174 # spent 28µs making 1 call to Sub::Install::exporter
175
176
17717µs1;
178
179__END__
 
# spent 11µs within Sub::Install::CORE:qr which was called 3 times, avg 4µs/call: # once (4µs+0s) by Sub::Install::BEGIN@64 at line 65 # once (4µs+0s) by Sub::Install::BEGIN@73 at line 73 # once (2µs+0s) by Sub::Install::BEGIN@64 at line 69
sub Sub::Install::CORE:qr; # opcode