Filename | /usr/share/perl5/Moo.pm |
Statements | Executed 881 statements in 5.29ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
34 | 3 | 2 | 4.65ms | 7.11ms | _accessor_maker_for | Moo::
1 | 1 | 1 | 2.32ms | 3.77ms | BEGIN@5 | Moo::
11 | 11 | 11 | 2.29ms | 5.28ms | import | Moo::
1 | 1 | 1 | 1.90ms | 6.21ms | BEGIN@4 | Moo::
16 | 3 | 3 | 1.80ms | 12.7ms | _constructor_maker_for (recurses: max depth 1, inclusive time 7.03ms) | Moo::
1 | 1 | 1 | 660µs | 807µs | BEGIN@3 | Moo::
1 | 1 | 1 | 660µs | 964µs | BEGIN@6 | Moo::
1 | 1 | 1 | 411µs | 459µs | BEGIN@7 | Moo::
66 | 4 | 1 | 280µs | 1.06ms | _install_tracked | Moo::
16 | 2 | 1 | 32µs | 32µs | _maybe_reset_handlemoose | Moo::
1 | 1 | 1 | 11µs | 22µs | BEGIN@110 | Moo::
1 | 1 | 1 | 8µs | 21µs | BEGIN@75 | Moo::
0 | 0 | 0 | 0s | 0s | __ANON__[:187] | Moo::
0 | 0 | 0 | 0s | 0s | __ANON__[:35] | Moo::
0 | 0 | 0 | 0s | 0s | __ANON__[:40] | Moo::
0 | 0 | 0 | 0s | 0s | __ANON__[:61] | Moo::
0 | 0 | 0 | 0s | 0s | __ANON__[:67] | Moo::
0 | 0 | 0 | 0s | 0s | _concrete_methods_of | Moo::
0 | 0 | 0 | 0s | 0s | _set_superclasses | Moo::
0 | 0 | 0 | 0s | 0s | unimport | Moo::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moo; | ||||
2 | |||||
3 | 3 | 114µs | 3 | 866µs | # spent 807µs (660+147) within Moo::BEGIN@3 which was called:
# once (660µs+147µs) by Search::Elasticsearch::BEGIN@3 at line 3 # spent 807µs making 1 call to Moo::BEGIN@3
# spent 40µs making 1 call to strictures::import
# spent 19µs making 1 call to strictures::VERSION |
4 | 2 | 119µs | 2 | 6.27ms | # spent 6.21ms (1.90+4.31) within Moo::BEGIN@4 which was called:
# once (1.90ms+4.31ms) by Search::Elasticsearch::BEGIN@3 at line 4 # spent 6.21ms making 1 call to Moo::BEGIN@4
# spent 64µs making 1 call to Exporter::import |
5 | 2 | 125µs | 2 | 4.45ms | # spent 3.77ms (2.32+1.46) within Moo::BEGIN@5 which was called:
# once (2.32ms+1.46ms) by Search::Elasticsearch::BEGIN@3 at line 5 # spent 3.77ms making 1 call to Moo::BEGIN@5
# spent 677µs making 1 call to Exporter::import |
6 | 2 | 114µs | 1 | 964µs | # spent 964µs (660+304) within Moo::BEGIN@6 which was called:
# once (660µs+304µs) by Search::Elasticsearch::BEGIN@3 at line 6 # spent 964µs making 1 call to Moo::BEGIN@6 |
7 | 2 | 639µs | 1 | 459µs | # spent 459µs (411+48) within Moo::BEGIN@7 which was called:
# once (411µs+48µs) by Search::Elasticsearch::BEGIN@3 at line 7 # spent 459µs making 1 call to Moo::BEGIN@7 |
8 | |||||
9 | 1 | 700ns | our $VERSION = '1.004002'; | ||
10 | 1 | 13µs | $VERSION = eval $VERSION; # spent 2µs executing statements in string eval | ||
11 | |||||
12 | 1 | 79µs | require Moo::sification; | ||
13 | |||||
14 | 1 | 200ns | our %MAKERS; | ||
15 | |||||
16 | # spent 1.06ms (280µs+782µs) within Moo::_install_tracked which was called 66 times, avg 16µs/call:
# 33 times (121µs+363µs) by Moo::import at line 67, avg 15µs/call
# 11 times (73µs+187µs) by Moo::import at line 35, avg 24µs/call
# 11 times (44µs+119µs) by Moo::import at line 40, avg 15µs/call
# 11 times (41µs+113µs) by Moo::import at line 61, avg 14µs/call | ||||
17 | 66 | 31µs | my ($target, $name, $code) = @_; | ||
18 | 66 | 62µs | $MAKERS{$target}{exports}{$name} = $code; | ||
19 | 66 | 181µs | 66 | 782µs | _install_coderef "${target}::${name}" => "Moo::${name}" => $code; # spent 782µs making 66 calls to Moo::_Utils::_install_coderef, avg 12µs/call |
20 | } | ||||
21 | |||||
22 | # spent 5.28ms (2.29+2.99) within Moo::import which was called 11 times, avg 480µs/call:
# once (924µs+246µs) by Search::Elasticsearch::Cxn::Factory::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Cxn/Factory.pm
# once (734µs+396µs) by Search::Elasticsearch::Util::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Util.pm
# once (103µs+348µs) by Search::Elasticsearch::Serializer::JSON::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Serializer/JSON.pm
# once (74µs+259µs) by Search::Elasticsearch::Bulk::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Bulk.pm
# once (77µs+253µs) by Method::Generate::Constructor::BEGIN@197 at line 197 of Method/Generate/Constructor.pm
# once (68µs+248µs) by Search::Elasticsearch::Client::2_0::Direct::BEGIN@5 at line 5 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Client/2_0/Direct.pm
# once (64µs+249µs) by Search::Elasticsearch::CxnPool::Static::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/CxnPool/Static.pm
# once (60µs+249µs) by Search::Elasticsearch::Cxn::HTTPTiny::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Cxn/HTTPTiny.pm
# once (61µs+248µs) by Search::Elasticsearch::Transport::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Transport.pm
# once (63µs+245µs) by Search::Elasticsearch::Client::2_0::Direct::Indices::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Client/2_0/Direct/Indices.pm
# once (60µs+247µs) by Search::Elasticsearch::Logger::LogAny::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Logger/LogAny.pm | ||||
23 | 11 | 12µs | my $target = caller; | ||
24 | 11 | 5µs | my $class = shift; | ||
25 | 11 | 23µs | 11 | 373µs | _set_loaded(caller); # spent 373µs making 11 calls to Moo::_Utils::_set_loaded, avg 34µs/call |
26 | 11 | 75µs | 11 | 1.44ms | strictures->import::into(1); # spent 1.44ms making 11 calls to import::into, avg 131µs/call |
27 | 11 | 6µs | if ($Role::Tiny::INFO{$target} and $Role::Tiny::INFO{$target}{is_role}) { | ||
28 | die "Cannot import Moo into a role"; | ||||
29 | } | ||||
30 | 11 | 14µs | $MAKERS{$target} ||= {}; | ||
31 | _install_tracked $target => extends => sub { | ||||
32 | $class->_set_superclasses($target, @_); | ||||
33 | $class->_maybe_reset_handlemoose($target); | ||||
34 | return; | ||||
35 | 11 | 40µs | 11 | 260µs | }; # spent 260µs making 11 calls to Moo::_install_tracked, avg 24µs/call |
36 | _install_tracked $target => with => sub { | ||||
37 | 11 | 96µs | require Moo::Role; | ||
38 | 11 | 24µs | 11 | 75.2ms | Moo::Role->apply_roles_to_package($target, @_); # spent 75.2ms making 11 calls to Moo::Role::apply_roles_to_package, avg 6.84ms/call |
39 | 11 | 52µs | 11 | 18µs | $class->_maybe_reset_handlemoose($target); # spent 18µs making 11 calls to Moo::_maybe_reset_handlemoose, avg 2µs/call |
40 | 11 | 33µs | 11 | 163µs | }; # spent 163µs making 11 calls to Moo::_install_tracked, avg 15µs/call |
41 | _install_tracked $target => has => sub { | ||||
42 | 5 | 2µs | my $name_proto = shift; | ||
43 | 5 | 5µs | my @name_proto = ref $name_proto eq 'ARRAY' ? @$name_proto : $name_proto; | ||
44 | 5 | 4µs | if (@_ % 2 != 0) { | ||
45 | require Carp; | ||||
46 | Carp::croak("Invalid options for " . join(', ', map "'$_'", @name_proto) | ||||
47 | . " attribute(s): even number of arguments expected, got " . scalar @_) | ||||
48 | } | ||||
49 | 5 | 9µs | my %spec = @_; | ||
50 | 5 | 3µs | foreach my $name (@name_proto) { | ||
51 | # Note that when multiple attributes specified, each attribute | ||||
52 | # needs a separate \%specs hashref | ||||
53 | 5 | 4µs | my $spec_ref = @name_proto > 1 ? +{%spec} : \%spec; | ||
54 | 5 | 17µs | 10 | 12.0ms | $class->_constructor_maker_for($target) # spent 12.0ms making 5 calls to Moo::_constructor_maker_for, avg 2.40ms/call
# spent 44µs making 5 calls to Method::Generate::Constructor::register_attribute_specs, avg 9µs/call |
55 | ->register_attribute_specs($name, $spec_ref); | ||||
56 | 5 | 14µs | 10 | 5.69ms | $class->_accessor_maker_for($target) # spent 5.68ms making 5 calls to Method::Generate::Accessor::generate_method, avg 1.14ms/call
# spent 11µs making 5 calls to Moo::_accessor_maker_for, avg 2µs/call |
57 | ->generate_method($target, $name, $spec_ref); | ||||
58 | 5 | 17µs | 5 | 14µs | $class->_maybe_reset_handlemoose($target); # spent 14µs making 5 calls to Moo::_maybe_reset_handlemoose, avg 3µs/call |
59 | } | ||||
60 | 5 | 18µs | return; | ||
61 | 11 | 44µs | 11 | 154µs | }; # spent 154µs making 11 calls to Moo::_install_tracked, avg 14µs/call |
62 | 11 | 10µs | foreach my $type (qw(before after around)) { | ||
63 | _install_tracked $target => $type => sub { | ||||
64 | require Class::Method::Modifiers; | ||||
65 | _install_modifier($target, $type, @_); | ||||
66 | return; | ||||
67 | 33 | 110µs | 33 | 485µs | }; # spent 485µs making 33 calls to Moo::_install_tracked, avg 15µs/call |
68 | } | ||||
69 | 11 | 6µs | return if $MAKERS{$target}{is_class}; # already exported into this package | ||
70 | 11 | 14µs | 11 | 23µs | my $stash = _getstash($target); # spent 23µs making 11 calls to Moo::_Utils::_getstash, avg 2µs/call |
71 | 11 | 79µs | my @not_methods = map { *$_{CODE}||() } grep !ref($_), values %$stash; | ||
72 | 11 | 926µs | @{$MAKERS{$target}{not_methods}={}}{@not_methods} = @not_methods; | ||
73 | 11 | 8µs | $MAKERS{$target}{is_class} = 1; | ||
74 | { | ||||
75 | 13 | 313µs | 2 | 34µs | # spent 21µs (8+13) within Moo::BEGIN@75 which was called:
# once (8µs+13µs) by Search::Elasticsearch::BEGIN@3 at line 75 # spent 21µs making 1 call to Moo::BEGIN@75
# spent 13µs making 1 call to strict::unimport |
76 | @{"${target}::ISA"} = do { | ||||
77 | 20 | 94µs | require Moo::Object; ('Moo::Object'); | ||
78 | 11 | 112µs | } unless @{"${target}::ISA"}; | ||
79 | } | ||||
80 | 11 | 62µs | if ($INC{'Moo/HandleMoose.pm'}) { | ||
81 | Moo::HandleMoose::inject_fake_metaclass_for($target); | ||||
82 | } | ||||
83 | } | ||||
84 | |||||
85 | sub unimport { | ||||
86 | my $target = caller; | ||||
87 | _unimport_coderefs($target, $MAKERS{$target}); | ||||
88 | } | ||||
89 | |||||
90 | sub _set_superclasses { | ||||
91 | my $class = shift; | ||||
92 | my $target = shift; | ||||
93 | foreach my $superclass (@_) { | ||||
94 | _load_module($superclass); | ||||
95 | if ($INC{"Role/Tiny.pm"} && $Role::Tiny::INFO{$superclass}) { | ||||
96 | require Carp; | ||||
97 | Carp::croak("Can't extend role '$superclass'"); | ||||
98 | } | ||||
99 | } | ||||
100 | # Can't do *{...} = \@_ or 5.10.0's mro.pm stops seeing @ISA | ||||
101 | @{*{_getglob("${target}::ISA")}{ARRAY}} = @_; | ||||
102 | if (my $old = delete $Moo::MAKERS{$target}{constructor}) { | ||||
103 | delete _getstash($target)->{new}; | ||||
104 | Moo->_constructor_maker_for($target) | ||||
105 | ->register_attribute_specs(%{$old->all_attribute_specs}); | ||||
106 | } | ||||
107 | elsif (!$target->isa('Moo::Object')) { | ||||
108 | Moo->_constructor_maker_for($target); | ||||
109 | } | ||||
110 | 2 | 743µs | 2 | 33µs | # spent 22µs (11+11) within Moo::BEGIN@110 which was called:
# once (11µs+11µs) by Search::Elasticsearch::BEGIN@3 at line 110 # spent 22µs making 1 call to Moo::BEGIN@110
# spent 11µs making 1 call to warnings::unimport |
111 | $Moo::HandleMoose::MOUSE{$target} = [ | ||||
112 | grep defined, map Mouse::Util::find_meta($_), @_ | ||||
113 | ] if Mouse::Util->can('find_meta'); | ||||
114 | } | ||||
115 | |||||
116 | sub _maybe_reset_handlemoose { | ||||
117 | 16 | 8µs | my ($class, $target) = @_; | ||
118 | 16 | 34µs | if ($INC{"Moo/HandleMoose.pm"}) { | ||
119 | Moo::HandleMoose::maybe_reinject_fake_metaclass_for($target); | ||||
120 | } | ||||
121 | } | ||||
122 | |||||
123 | # spent 7.11ms (4.65+2.46) within Moo::_accessor_maker_for which was called 34 times, avg 209µs/call:
# 19 times (64µs+17µs) by Moo::Role::_maybe_make_accessors at line 198 of Moo/Role.pm, avg 4µs/call
# 10 times (4.58ms+2.45ms) by Moo::_constructor_maker_for at line 199, avg 702µs/call
# 5 times (11µs+0s) by Moo::has at line 56, avg 2µs/call | ||||
124 | 34 | 11µs | my ($class, $target) = @_; | ||
125 | 34 | 18µs | return unless $MAKERS{$target}; | ||
126 | 31 | 79µs | $MAKERS{$target}{accessor} ||= do { | ||
127 | 10 | 7µs | my $maker_class = do { | ||
128 | 10 | 5µs | if (my $m = do { | ||
129 | 10 | 67µs | 20 | 37µs | if (my $defer_target = # spent 22µs making 10 calls to Sub::Defer::defer_info, avg 2µs/call
# spent 15µs making 10 calls to UNIVERSAL::can, avg 1µs/call |
130 | (Sub::Defer::defer_info($target->can('new'))||[])->[0] | ||||
131 | ) { | ||||
132 | my ($pkg) = ($defer_target =~ /^(.*)::[^:]+$/); | ||||
133 | $MAKERS{$pkg} && $MAKERS{$pkg}{accessor}; | ||||
134 | } else { | ||||
135 | 10 | 3µs | undef; | ||
136 | } | ||||
137 | }) { | ||||
138 | ref($m); | ||||
139 | } else { | ||||
140 | 10 | 100µs | require Method::Generate::Accessor; | ||
141 | 10 | 2µs | 'Method::Generate::Accessor' | ||
142 | } | ||||
143 | }; | ||||
144 | 10 | 28µs | 10 | 66µs | $maker_class->new; # spent 66µs making 10 calls to Moo::Object::new, avg 7µs/call |
145 | } | ||||
146 | } | ||||
147 | |||||
148 | # spent 12.7ms (1.80+10.9) within Moo::_constructor_maker_for which was called 16 times, avg 793µs/call:
# 10 times (199µs+488µs) by Moo::Role::_handle_constructor at line 351 of Moo/Role.pm, avg 69µs/call
# 5 times (1.54ms+10.5ms) by Moo::has at line 54, avg 2.40ms/call
# once (59µs+-59µs) by Moo::_constructor_maker_for at line 198 of Method/Generate/Constructor.pm | ||||
149 | 16 | 8µs | my ($class, $target, $select_super) = @_; | ||
150 | 16 | 7µs | return unless $MAKERS{$target}; | ||
151 | 16 | 50µs | $MAKERS{$target}{constructor} ||= do { | ||
152 | 10 | 96µs | require Method::Generate::Constructor; | ||
153 | 10 | 3µs | require Sub::Defer; | ||
154 | 10 | 1µs | my ($moo_constructor, $con); | ||
155 | |||||
156 | 10 | 5µs | if ($select_super && $MAKERS{$select_super}) { | ||
157 | $moo_constructor = 1; | ||||
158 | $con = $MAKERS{$select_super}{constructor}; | ||||
159 | } else { | ||||
160 | 10 | 87µs | 10 | 24µs | my $t_new = $target->can('new'); # spent 24µs making 10 calls to UNIVERSAL::can, avg 2µs/call |
161 | 10 | 5µs | if ($t_new) { | ||
162 | 10 | 46µs | 10 | 10µs | if ($t_new == Moo::Object->can('new')) { # spent 10µs making 10 calls to UNIVERSAL::can, avg 950ns/call |
163 | $moo_constructor = 1; | ||||
164 | } elsif (my $defer_target = (Sub::Defer::defer_info($t_new)||[])->[0]) { | ||||
165 | my ($pkg) = ($defer_target =~ /^(.*)::[^:]+$/); | ||||
166 | if ($MAKERS{$pkg}) { | ||||
167 | $moo_constructor = 1; | ||||
168 | $con = $MAKERS{$pkg}{constructor}; | ||||
169 | } | ||||
170 | } | ||||
171 | } else { | ||||
172 | $moo_constructor = 1; # no other constructor, make a Moo one | ||||
173 | } | ||||
174 | } | ||||
175 | ($con ? ref($con) : 'Method::Generate::Constructor') | ||||
176 | ->new( | ||||
177 | package => $target, | ||||
178 | accessor_generator => $class->_accessor_maker_for($target), | ||||
179 | $moo_constructor ? ( | ||||
180 | $con ? (construction_string => $con->construction_string) : () | ||||
181 | ) : ( | ||||
182 | construction_builder => sub { | ||||
183 | '$class->'.$target.'::SUPER::new(' | ||||
184 | .($target->can('FOREIGNBUILDARGS') ? | ||||
185 | '$class->FOREIGNBUILDARGS(@_)' : '@_') | ||||
186 | .')' | ||||
187 | }, | ||||
188 | ), | ||||
189 | subconstructor_handler => ( | ||||
190 | ' if ($Moo::MAKERS{$class}) {'."\n" | ||||
191 | .' '.$class.'->_constructor_maker_for($class,'.perlstring($target).');'."\n" | ||||
192 | .' return $class->new(@_)'.";\n" | ||||
193 | .' } elsif ($INC{"Moose.pm"} and my $meta = Class::MOP::get_metaclass_by_name($class)) {'."\n" | ||||
194 | .' return $meta->new_object($class->BUILDARGS(@_));'."\n" | ||||
195 | .' }'."\n" | ||||
196 | ), | ||||
197 | ) | ||||
198 | ->install_delayed | ||||
199 | 10 | 148µs | 50 | 8.57ms | ->register_attribute_specs(%{$con?$con->all_attribute_specs:{}}) # spent 7.02ms making 10 calls to Moo::_accessor_maker_for, avg 702µs/call
# spent 1.12ms making 9 calls to Method::Generate::Constructor::new, avg 124µs/call
# spent 343µs making 10 calls to Method::Generate::Constructor::install_delayed, avg 34µs/call
# spent 44µs making 10 calls to Method::Generate::Constructor::register_attribute_specs, avg 4µs/call
# spent 30µs making 10 calls to B::perlstring, avg 3µs/call
# spent 17µs making 1 call to Moo::Object::new |
200 | } | ||||
201 | } | ||||
202 | |||||
203 | sub _concrete_methods_of { | ||||
204 | my ($me, $role) = @_; | ||||
205 | my $makers = $MAKERS{$role}; | ||||
206 | # grab role symbol table | ||||
207 | my $stash = _getstash($role); | ||||
208 | # reverse so our keys become the values (captured coderefs) in case | ||||
209 | # they got copied or re-used since | ||||
210 | my $not_methods = { reverse %{$makers->{not_methods}||{}} }; | ||||
211 | +{ | ||||
212 | # grab all code entries that aren't in the not_methods list | ||||
213 | map { | ||||
214 | my $code = *{$stash->{$_}}{CODE}; | ||||
215 | ( ! $code or exists $not_methods->{$code} ) ? () : ($_ => $code) | ||||
216 | } grep !ref($stash->{$_}), keys %$stash | ||||
217 | }; | ||||
218 | } | ||||
219 | |||||
220 | 1 | 3µs | 1; | ||
221 | __END__ |