Filename | /usr/share/perl5/Moo/Role.pm |
Statements | Executed 1803 statements in 6.25ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 3.41ms | 3.54ms | BEGIN@5 | Moo::Role::
14 | 14 | 14 | 869µs | 4.46ms | import | Moo::Role::
84 | 4 | 1 | 362µs | 1.35ms | _install_tracked | Moo::Role::
19 | 2 | 1 | 263µs | 1.28ms | _handle_constructor | Moo::Role::
29 | 2 | 1 | 185µs | 68.9ms | _inhale_if_moose (recurses: max depth 1, inclusive time 7.72ms) | Moo::Role::
14 | 2 | 2 | 148µs | 75.2ms | apply_roles_to_package (recurses: max depth 1, inclusive time 8.34ms) | Moo::Role::
85 | 4 | 1 | 146µs | 146µs | _maybe_reset_handlemoose | Moo::Role::
19 | 2 | 1 | 102µs | 184µs | _maybe_make_accessors | Moo::Role::
10 | 1 | 1 | 64µs | 3.37ms | apply_single_role_to_package | Moo::Role::
14 | 2 | 1 | 60µs | 79µs | role_application_steps | Moo::Role::
1 | 1 | 1 | 22µs | 74µs | BEGIN@3 | Moo::Role::
4 | 1 | 1 | 20µs | 1.07ms | _install_single_modifier | Moo::Role::
1 | 1 | 1 | 9µs | 76µs | BEGIN@6 | Moo::Role::
1 | 1 | 1 | 9µs | 80µs | BEGIN@4 | Moo::Role::
1 | 1 | 1 | 7µs | 7µs | BEGIN@7 | Moo::Role::
1 | 1 | 1 | 5µs | 5µs | BEGIN@14 | Moo::Role::
0 | 0 | 0 | 0s | 0s | __ANON__[:162] | Moo::Role::
0 | 0 | 0 | 0s | 0s | __ANON__[:168] | Moo::Role::
0 | 0 | 0 | 0s | 0s | __ANON__[:181] | Moo::Role::
0 | 0 | 0 | 0s | 0s | __ANON__[:323] | Moo::Role::
0 | 0 | 0 | 0s | 0s | __ANON__[:54] | Moo::Role::
0 | 0 | 0 | 0s | 0s | __ANON__[:61] | Moo::Role::
0 | 0 | 0 | 0s | 0s | __ANON__[:66] | Moo::Role::
0 | 0 | 0 | 0s | 0s | __ANON__[:70] | Moo::Role::
0 | 0 | 0 | 0s | 0s | _composable_package_for | Moo::Role::
0 | 0 | 0 | 0s | 0s | _make_accessors | Moo::Role::
0 | 0 | 0 | 0s | 0s | _make_accessors_if_moose | Moo::Role::
0 | 0 | 0 | 0s | 0s | apply_roles_to_object | Moo::Role::
0 | 0 | 0 | 0s | 0s | create_class_with_roles | Moo::Role::
0 | 0 | 0 | 0s | 0s | meta | Moo::Role::
0 | 0 | 0 | 0s | 0s | methods_provided_by | Moo::Role::
0 | 0 | 0 | 0s | 0s | unimport | Moo::Role::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moo::Role; | ||||
2 | |||||
3 | 3 | 39µs | 3 | 125µs | # spent 74µs (22+52) within Moo::Role::BEGIN@3 which was called:
# once (22µs+52µs) by Moo::with at line 3 # spent 74µs making 1 call to Moo::Role::BEGIN@3
# spent 36µs making 1 call to strictures::import
# spent 15µs making 1 call to strictures::VERSION |
4 | 2 | 30µs | 2 | 152µs | # spent 80µs (9+71) within Moo::Role::BEGIN@4 which was called:
# once (9µs+71µs) by Moo::with at line 4 # spent 80µs making 1 call to Moo::Role::BEGIN@4
# spent 71µs making 1 call to Exporter::import |
5 | 2 | 171µs | 1 | 3.54ms | # spent 3.54ms (3.41+129µs) within Moo::Role::BEGIN@5 which was called:
# once (3.41ms+129µs) by Moo::with at line 5 # spent 3.54ms making 1 call to Moo::Role::BEGIN@5 |
6 | 2 | 32µs | 2 | 142µs | # spent 76µs (9+66) within Moo::Role::BEGIN@6 which was called:
# once (9µs+66µs) by Moo::with at line 6 # spent 76µs making 1 call to Moo::Role::BEGIN@6
# spent 66µs making 1 call to base::import |
7 | 2 | 60µs | 1 | 7µs | # spent 7µs within Moo::Role::BEGIN@7 which was called:
# once (7µs+0s) by Moo::with at line 7 # spent 7µs making 1 call to Moo::Role::BEGIN@7 |
8 | |||||
9 | 1 | 800ns | our $VERSION = '1.004002'; | ||
10 | 1 | 14µs | $VERSION = eval $VERSION; # spent 2µs executing statements in string eval | ||
11 | |||||
12 | 1 | 400ns | require Moo::sification; | ||
13 | |||||
14 | 1 | 2.42ms | 1 | 5µs | # spent 5µs within Moo::Role::BEGIN@14 which was called:
# once (5µs+0s) by Moo::with at line 14 # spent 5µs making 1 call to Moo::Role::BEGIN@14 |
15 | |||||
16 | 1 | 300ns | our %INFO; | ||
17 | 1 | 100ns | our %APPLY_DEFAULTS; | ||
18 | |||||
19 | # spent 1.35ms (362µs+993µs) within Moo::Role::_install_tracked which was called 84 times, avg 16µs/call:
# 42 times (168µs+468µs) by Moo::Role::import at line 61, avg 15µs/call
# 14 times (87µs+215µs) by Moo::Role::import at line 54, avg 22µs/call
# 14 times (54µs+160µs) by Moo::Role::import at line 66, avg 15µs/call
# 14 times (52µs+150µs) by Moo::Role::import at line 70, avg 14µs/call | ||||
20 | 84 | 40µs | my ($target, $name, $code) = @_; | ||
21 | 84 | 84µs | $INFO{$target}{exports}{$name} = $code; | ||
22 | 84 | 225µs | 84 | 993µs | _install_coderef "${target}::${name}" => "Moo::Role::${name}" => $code; # spent 993µs making 84 calls to Moo::_Utils::_install_coderef, avg 12µs/call |
23 | } | ||||
24 | |||||
25 | # spent 4.46ms (869µs+3.59) within Moo::Role::import which was called 14 times, avg 319µs/call:
# once (73µs+267µs) by Search::Elasticsearch::Role::Serializer::JSON::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Serializer/JSON.pm
# once (59µs+266µs) by Search::Elasticsearch::Role::Serializer::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Serializer.pm
# once (63µs+262µs) by Search::Elasticsearch::Role::CxnPool::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/CxnPool.pm
# once (60µs+264µs) by Search::Elasticsearch::Role::Logger::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Logger.pm
# once (67µs+257µs) by Search::Elasticsearch::Role::Cxn::HTTP::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Cxn/HTTP.pm
# once (63µs+261µs) by Search::Elasticsearch::Role::Bulk::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Bulk.pm
# once (69µs+253µs) by Search::Elasticsearch::Role::Transport::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Transport.pm
# once (60µs+260µs) by Search::Elasticsearch::Role::CxnPool::Static::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/CxnPool/Static.pm
# once (60µs+254µs) by Search::Elasticsearch::Role::Cxn::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Cxn.pm
# once (62µs+251µs) by Search::Elasticsearch::Role::Client::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Client.pm
# once (58µs+254µs) by Search::Elasticsearch::Role::API::2_0::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/API/2_0.pm
# once (58µs+250µs) by Search::Elasticsearch::Role::Client::Direct::Main::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Client/Direct/Main.pm
# once (59µs+248µs) by Search::Elasticsearch::Role::Is_Sync::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Is_Sync.pm
# once (58µs+247µs) by Search::Elasticsearch::Role::Client::Direct::BEGIN@3 at line 3 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Client/Direct.pm | ||||
26 | 14 | 12µs | my $target = caller; | ||
27 | 14 | 9µs | my ($me) = @_; | ||
28 | 14 | 23µs | 14 | 419µs | _set_loaded(caller); # spent 419µs making 14 calls to Moo::_Utils::_set_loaded, avg 30µs/call |
29 | 14 | 88µs | 14 | 1.72ms | strictures->import::into(1); # spent 1.72ms making 14 calls to import::into, avg 123µs/call |
30 | 14 | 8µs | if ($Moo::MAKERS{$target} and $Moo::MAKERS{$target}{is_class}) { | ||
31 | die "Cannot import Moo::Role into a Moo class"; | ||||
32 | } | ||||
33 | 14 | 14µs | $INFO{$target} ||= {}; | ||
34 | # get symbol table reference | ||||
35 | 14 | 23µs | 14 | 44µs | my $stash = _getstash($target); # spent 44µs making 14 calls to Moo::_Utils::_getstash, avg 3µs/call |
36 | _install_tracked $target => has => sub { | ||||
37 | 69 | 26µs | my $name_proto = shift; | ||
38 | 69 | 61µs | my @name_proto = ref $name_proto eq 'ARRAY' ? @$name_proto : $name_proto; | ||
39 | 69 | 35µs | if (@_ % 2 != 0) { | ||
40 | require Carp; | ||||
41 | Carp::croak("Invalid options for " . join(', ', map "'$_'", @name_proto) | ||||
42 | . " attribute(s): even number of arguments expected, got " . scalar @_) | ||||
43 | } | ||||
44 | 69 | 79µs | my %spec = @_; | ||
45 | 69 | 259µs | foreach my $name (@name_proto) { | ||
46 | 69 | 43µs | my $spec_ref = @name_proto > 1 ? +{%spec} : \%spec; | ||
47 | 69 | 160µs | 69 | 14.8ms | ($INFO{$target}{accessor_maker} ||= do { # spent 14.8ms making 69 calls to Method::Generate::Accessor::generate_method, avg 215µs/call |
48 | 9 | 4µs | require Method::Generate::Accessor; | ||
49 | 9 | 23µs | 9 | 38µs | Method::Generate::Accessor->new # spent 38µs making 9 calls to Moo::Object::new, avg 4µs/call |
50 | })->generate_method($target, $name, $spec_ref); | ||||
51 | 69 | 110µs | push @{$INFO{$target}{attributes}||=[]}, $name, $spec_ref; | ||
52 | 69 | 163µs | 69 | 118µs | $me->_maybe_reset_handlemoose($target); # spent 118µs making 69 calls to Moo::Role::_maybe_reset_handlemoose, avg 2µs/call |
53 | } | ||||
54 | 14 | 72µs | 14 | 302µs | }; # spent 302µs making 14 calls to Moo::Role::_install_tracked, avg 22µs/call |
55 | # install before/after/around subs | ||||
56 | 14 | 11µs | foreach my $type (qw(before after around)) { | ||
57 | _install_tracked $target => $type => sub { | ||||
58 | 4 | 116µs | require Class::Method::Modifiers; | ||
59 | 4 | 8µs | push @{$INFO{$target}{modifiers}||=[]}, [ $type => @_ ]; | ||
60 | 4 | 15µs | 4 | 6µs | $me->_maybe_reset_handlemoose($target); # spent 6µs making 4 calls to Moo::Role::_maybe_reset_handlemoose, avg 2µs/call |
61 | 42 | 141µs | 42 | 636µs | }; # spent 636µs making 42 calls to Moo::Role::_install_tracked, avg 15µs/call |
62 | } | ||||
63 | _install_tracked $target => requires => sub { | ||||
64 | 9 | 31µs | push @{$INFO{$target}{requires}||=[]}, @_; | ||
65 | 9 | 38µs | 9 | 17µs | $me->_maybe_reset_handlemoose($target); # spent 17µs making 9 calls to Moo::Role::_maybe_reset_handlemoose, avg 2µs/call |
66 | 14 | 36µs | 14 | 214µs | }; # spent 214µs making 14 calls to Moo::Role::_install_tracked, avg 15µs/call |
67 | _install_tracked $target => with => sub { | ||||
68 | 3 | 8µs | 3 | 0s | $me->apply_roles_to_package($target, @_); # spent 8.34ms making 3 calls to Moo::Role::apply_roles_to_package, avg 2.78ms/call, recursion: max depth 1, sum of overlapping time 8.34ms |
69 | 3 | 13µs | 3 | 5µs | $me->_maybe_reset_handlemoose($target); # spent 5µs making 3 calls to Moo::Role::_maybe_reset_handlemoose, avg 2µs/call |
70 | 14 | 36µs | 14 | 202µs | }; # spent 202µs making 14 calls to Moo::Role::_install_tracked, avg 14µs/call |
71 | 14 | 7µs | return if $INFO{$target}{is_role}; # already exported into this package | ||
72 | 14 | 7µs | $INFO{$target}{is_role} = 1; | ||
73 | 14 | 86µs | 28 | 58µs | *{_getglob("${target}::meta")} = $me->can('meta'); # spent 32µs making 14 calls to Moo::_Utils::_getglob, avg 2µs/call
# spent 26µs making 14 calls to UNIVERSAL::can, avg 2µs/call |
74 | # grab all *non-constant* (stash slot is not a scalarref) subs present | ||||
75 | # in the symbol table and store their refaddrs (no need to forcibly | ||||
76 | # inflate constant subs into real subs) - also add '' to here (this | ||||
77 | # is used later) with a map to the coderefs in case of copying or re-use | ||||
78 | 14 | 89µs | my @not_methods = ('', map { *$_{CODE}||() } grep !ref($_), values %$stash); | ||
79 | 14 | 85µs | @{$INFO{$target}{not_methods}={}}{@not_methods} = @not_methods; | ||
80 | # a role does itself | ||||
81 | 14 | 14µs | $Role::Tiny::APPLIED_TO{$target} = { $target => undef }; | ||
82 | |||||
83 | 14 | 67µs | if ($INC{'Moo/HandleMoose.pm'}) { | ||
84 | Moo::HandleMoose::inject_fake_metaclass_for($target); | ||||
85 | } | ||||
86 | } | ||||
87 | |||||
88 | # duplicate from Moo::Object | ||||
89 | sub meta { | ||||
90 | require Moo::HandleMoose::FakeMetaClass; | ||||
91 | my $class = ref($_[0])||$_[0]; | ||||
92 | bless({ name => $class }, 'Moo::HandleMoose::FakeMetaClass'); | ||||
93 | } | ||||
94 | |||||
95 | sub unimport { | ||||
96 | my $target = caller; | ||||
97 | _unimport_coderefs($target, $INFO{$target}); | ||||
98 | } | ||||
99 | |||||
100 | # spent 146µs within Moo::Role::_maybe_reset_handlemoose which was called 85 times, avg 2µs/call:
# 69 times (118µs+0s) by Moo::Role::has at line 52, avg 2µs/call
# 9 times (17µs+0s) by Moo::Role::requires at line 65, avg 2µs/call
# 4 times (6µs+0s) by Moo::Role::around or Moo::Role::before at line 60, avg 2µs/call
# 3 times (5µs+0s) by Moo::Role::with at line 69, avg 2µs/call | ||||
101 | 85 | 42µs | my ($class, $target) = @_; | ||
102 | 85 | 203µs | if ($INC{"Moo/HandleMoose.pm"}) { | ||
103 | Moo::HandleMoose::maybe_reinject_fake_metaclass_for($target); | ||||
104 | } | ||||
105 | } | ||||
106 | |||||
107 | sub methods_provided_by { | ||||
108 | my ($self, $role) = @_; | ||||
109 | $self->_inhale_if_moose($role); | ||||
110 | die "${role} is not a Moo::Role" unless $INFO{$role}; | ||||
111 | return $self->SUPER::methods_provided_by($role); | ||||
112 | } | ||||
113 | |||||
114 | sub _inhale_if_moose { | ||||
115 | 29 | 10µs | my ($self, $role) = @_; | ||
116 | 29 | 30µs | 29 | 68.8ms | _load_module($role); # spent 76.4ms making 29 calls to Moo::_Utils::_load_module, avg 2.63ms/call, recursion: max depth 1, sum of overlapping time 7.66ms |
117 | 29 | 4µs | my $meta; | ||
118 | 29 | 197µs | 29 | 57µs | if (!$INFO{$role} # spent 57µs making 29 calls to UNIVERSAL::can, avg 2µs/call |
119 | and ( | ||||
120 | $INC{"Moose.pm"} | ||||
121 | and $meta = Class::MOP::class_of($role) | ||||
122 | and $meta->isa('Moose::Meta::Role') | ||||
123 | ) | ||||
124 | or ( | ||||
125 | Mouse::Util->can('find_meta') | ||||
126 | and $meta = Mouse::Util::find_meta($role) | ||||
127 | and $meta->isa('Mouse::Meta::Role') | ||||
128 | ) | ||||
129 | ) { | ||||
130 | my $is_mouse = $meta->isa('Mouse::Meta::Role'); | ||||
131 | $INFO{$role}{methods} = { | ||||
132 | map +($_ => $role->can($_)), | ||||
133 | grep $role->can($_), | ||||
134 | grep !($is_mouse && $_ eq 'meta'), | ||||
135 | grep !$meta->get_method($_)->isa('Class::MOP::Method::Meta'), | ||||
136 | $meta->get_method_list | ||||
137 | }; | ||||
138 | $Role::Tiny::APPLIED_TO{$role} = { | ||||
139 | map +($_->name => 1), $meta->calculate_all_roles | ||||
140 | }; | ||||
141 | $INFO{$role}{requires} = [ $meta->get_required_method_list ]; | ||||
142 | $INFO{$role}{attributes} = [ | ||||
143 | map +($_ => do { | ||||
144 | my $attr = $meta->get_attribute($_); | ||||
145 | my $spec = { %{ $is_mouse ? $attr : $attr->original_options } }; | ||||
146 | |||||
147 | if ($spec->{isa}) { | ||||
148 | |||||
149 | my $get_constraint = do { | ||||
150 | my $pkg = $is_mouse | ||||
151 | ? 'Mouse::Util::TypeConstraints' | ||||
152 | : 'Moose::Util::TypeConstraints'; | ||||
153 | _load_module($pkg); | ||||
154 | $pkg->can('find_or_create_isa_type_constraint'); | ||||
155 | }; | ||||
156 | |||||
157 | my $tc = $get_constraint->($spec->{isa}); | ||||
158 | my $check = $tc->_compiled_type_constraint; | ||||
159 | |||||
160 | $spec->{isa} = sub { | ||||
161 | &$check or die "Type constraint failed for $_[0]" | ||||
162 | }; | ||||
163 | |||||
164 | if ($spec->{coerce}) { | ||||
165 | |||||
166 | # Mouse has _compiled_type_coercion straight on the TC object | ||||
167 | $spec->{coerce} = $tc->${\( | ||||
168 | $tc->can('coercion')||sub { $_[0] } | ||||
169 | )}->_compiled_type_coercion; | ||||
170 | } | ||||
171 | } | ||||
172 | $spec; | ||||
173 | }), $meta->get_attribute_list | ||||
174 | ]; | ||||
175 | my $mods = $INFO{$role}{modifiers} = []; | ||||
176 | foreach my $type (qw(before after around)) { | ||||
177 | # Mouse pokes its own internals so we have to fall back to doing | ||||
178 | # the same thing in the absence of the Moose API method | ||||
179 | my $map = $meta->${\( | ||||
180 | $meta->can("get_${type}_method_modifiers_map") | ||||
181 | or sub { shift->{"${type}_method_modifiers"} } | ||||
182 | )}; | ||||
183 | foreach my $method (keys %$map) { | ||||
184 | foreach my $mod (@{$map->{$method}}) { | ||||
185 | push @$mods, [ $type => $method => $mod ]; | ||||
186 | } | ||||
187 | } | ||||
188 | } | ||||
189 | require Class::Method::Modifiers if @$mods; | ||||
190 | $INFO{$role}{inhaled_from_moose} = 1; | ||||
191 | $INFO{$role}{is_role} = 1; | ||||
192 | } | ||||
193 | } | ||||
194 | |||||
195 | # spent 184µs (102+81) within Moo::Role::_maybe_make_accessors which was called 19 times, avg 10µs/call:
# 10 times (60µs+68µs) by Role::Tiny::apply_single_role_to_package at line 89 of Role/Tiny.pm, avg 13µs/call
# 9 times (43µs+14µs) by Role::Tiny::apply_roles_to_package at line 238 of Role/Tiny.pm, avg 6µs/call | ||||
196 | 19 | 8µs | my ($self, $target, $role) = @_; | ||
197 | 19 | 2µs | my $m; | ||
198 | 19 | 84µs | 19 | 81µs | if ($INFO{$role} && $INFO{$role}{inhaled_from_moose} # spent 81µs making 19 calls to Moo::_accessor_maker_for, avg 4µs/call |
199 | or $INC{"Moo.pm"} | ||||
200 | and $m = Moo->_accessor_maker_for($target) | ||||
201 | and ref($m) ne 'Method::Generate::Accessor') { | ||||
202 | $self->_make_accessors($target, $role); | ||||
203 | } | ||||
204 | } | ||||
205 | |||||
206 | sub _make_accessors_if_moose { | ||||
207 | my ($self, $target, $role) = @_; | ||||
208 | if ($INFO{$role} && $INFO{$role}{inhaled_from_moose}) { | ||||
209 | $self->_make_accessors($target, $role); | ||||
210 | } | ||||
211 | } | ||||
212 | |||||
213 | sub _make_accessors { | ||||
214 | my ($self, $target, $role) = @_; | ||||
215 | my $acc_gen = ($Moo::MAKERS{$target}{accessor} ||= do { | ||||
216 | require Method::Generate::Accessor; | ||||
217 | Method::Generate::Accessor->new | ||||
218 | }); | ||||
219 | my $con_gen = $Moo::MAKERS{$target}{constructor}; | ||||
220 | my @attrs = @{$INFO{$role}{attributes}||[]}; | ||||
221 | while (my ($name, $spec) = splice @attrs, 0, 2) { | ||||
222 | # needed to ensure we got an index for an arrayref based generator | ||||
223 | if ($con_gen) { | ||||
224 | $spec = $con_gen->all_attribute_specs->{$name}; | ||||
225 | } | ||||
226 | $acc_gen->generate_method($target, $name, $spec); | ||||
227 | } | ||||
228 | } | ||||
229 | |||||
230 | # spent 79µs (60+19) within Moo::Role::role_application_steps which was called 14 times, avg 6µs/call:
# 10 times (42µs+13µs) by Role::Tiny::apply_single_role_to_package at line 88 of Role/Tiny.pm, avg 6µs/call
# 4 times (18µs+6µs) by Role::Tiny::apply_roles_to_package at line 236 of Role/Tiny.pm, avg 6µs/call | ||||
231 | 14 | 54µs | 14 | 19µs | qw(_handle_constructor _maybe_make_accessors), # spent 19µs making 14 calls to Role::Tiny::role_application_steps, avg 1µs/call |
232 | $_[0]->SUPER::role_application_steps; | ||||
233 | } | ||||
234 | |||||
235 | # spent 75.2ms (148µs+75.1) within Moo::Role::apply_roles_to_package which was called 14 times, avg 5.37ms/call:
# 11 times (115µs+75.1ms) by Moo::with at line 38 of Moo.pm, avg 6.84ms/call
# 3 times (33µs+-33µs) by Moo::Role::with at line 68, avg 0s/call | ||||
236 | 14 | 14µs | my ($me, $to, @roles) = @_; | ||
237 | 14 | 10µs | foreach my $role (@roles) { | ||
238 | 19 | 26µs | 19 | 68.3ms | $me->_inhale_if_moose($role); # spent 75.8ms making 19 calls to Moo::Role::_inhale_if_moose, avg 3.99ms/call, recursion: max depth 1, sum of overlapping time 7.49ms |
239 | 19 | 23µs | die "${role} is not a Moo::Role" unless $INFO{$role}; | ||
240 | } | ||||
241 | 14 | 62µs | 14 | 7.59ms | $me->SUPER::apply_roles_to_package($to, @roles); # spent 7.59ms making 14 calls to Role::Tiny::apply_roles_to_package, avg 542µs/call |
242 | } | ||||
243 | |||||
244 | # spent 3.37ms (64µs+3.30) within Moo::Role::apply_single_role_to_package which was called 10 times, avg 337µs/call:
# 10 times (64µs+3.30ms) by Role::Tiny::apply_role_to_package at line 193 of Role/Tiny.pm, avg 337µs/call | ||||
245 | 10 | 4µs | my ($me, $to, $role) = @_; | ||
246 | 10 | 9µs | 10 | 593µs | $me->_inhale_if_moose($role); # spent 825µs making 10 calls to Moo::Role::_inhale_if_moose, avg 82µs/call, recursion: max depth 1, sum of overlapping time 232µs |
247 | 10 | 4µs | die "${role} is not a Moo::Role" unless $INFO{$role}; | ||
248 | 10 | 38µs | 10 | 2.48ms | $me->SUPER::apply_single_role_to_package($to, $role); # spent 2.48ms making 10 calls to Role::Tiny::apply_single_role_to_package, avg 248µs/call |
249 | } | ||||
250 | |||||
251 | sub create_class_with_roles { | ||||
252 | my ($me, $superclass, @roles) = @_; | ||||
253 | |||||
254 | my ($new_name, $compose_name) = $me->_composite_name($superclass, @roles); | ||||
255 | |||||
256 | return $new_name if $Role::Tiny::COMPOSED{class}{$new_name}; | ||||
257 | |||||
258 | foreach my $role (@roles) { | ||||
259 | $me->_inhale_if_moose($role); | ||||
260 | } | ||||
261 | |||||
262 | my $m; | ||||
263 | if ($INC{"Moo.pm"} | ||||
264 | and $m = Moo->_accessor_maker_for($superclass) | ||||
265 | and ref($m) ne 'Method::Generate::Accessor') { | ||||
266 | # old fashioned way time. | ||||
267 | *{_getglob("${new_name}::ISA")} = [ $superclass ]; | ||||
268 | $me->apply_roles_to_package($new_name, @roles); | ||||
269 | _set_loaded($new_name, (caller)[1]); | ||||
270 | return $new_name; | ||||
271 | } | ||||
272 | |||||
273 | require Sub::Quote; | ||||
274 | |||||
275 | $me->SUPER::create_class_with_roles($superclass, @roles); | ||||
276 | |||||
277 | foreach my $role (@roles) { | ||||
278 | die "${role} is not a Role::Tiny" unless $INFO{$role}; | ||||
279 | } | ||||
280 | |||||
281 | $Moo::MAKERS{$new_name} = {is_class => 1}; | ||||
282 | |||||
283 | $me->_handle_constructor($new_name, $_) for @roles; | ||||
284 | |||||
285 | _set_loaded($new_name, (caller)[1]); | ||||
286 | return $new_name; | ||||
287 | } | ||||
288 | |||||
289 | sub apply_roles_to_object { | ||||
290 | my ($me, $object, @roles) = @_; | ||||
291 | my $new = $me->SUPER::apply_roles_to_object($object, @roles); | ||||
292 | _set_loaded(ref $new, (caller)[1]); | ||||
293 | |||||
294 | my $apply_defaults = $APPLY_DEFAULTS{ref $new} ||= do { | ||||
295 | my %attrs = map { @{$INFO{$_}{attributes}||[]} } @roles; | ||||
296 | |||||
297 | if ($INC{'Moo.pm'} | ||||
298 | and keys %attrs | ||||
299 | and my $con_gen = Moo->_constructor_maker_for(ref $new) | ||||
300 | and my $m = Moo->_accessor_maker_for(ref $new)) { | ||||
301 | require Sub::Quote; | ||||
302 | |||||
303 | my $specs = $con_gen->all_attribute_specs; | ||||
304 | |||||
305 | my $assign = ''; | ||||
306 | my %captures; | ||||
307 | foreach my $name ( keys %attrs ) { | ||||
308 | my $spec = $specs->{$name}; | ||||
309 | if ($m->has_eager_default($name, $spec)) { | ||||
310 | my ($has, $has_cap) | ||||
311 | = $m->generate_simple_has('$_[0]', $name, $spec); | ||||
312 | my ($code, $pop_cap) | ||||
313 | = $m->generate_use_default('$_[0]', $name, $spec, $has); | ||||
314 | |||||
315 | $assign .= $code; | ||||
316 | @captures{keys %$has_cap, keys %$pop_cap} | ||||
317 | = (values %$has_cap, values %$pop_cap); | ||||
318 | } | ||||
319 | } | ||||
320 | Sub::Quote::quote_sub($assign, \%captures); | ||||
321 | } | ||||
322 | else { | ||||
323 | sub {}; | ||||
324 | } | ||||
325 | }; | ||||
326 | $new->$apply_defaults; | ||||
327 | return $new; | ||||
328 | } | ||||
329 | |||||
330 | sub _composable_package_for { | ||||
331 | my ($self, $role) = @_; | ||||
332 | my $composed_name = 'Role::Tiny::_COMPOSABLE::'.$role; | ||||
333 | return $composed_name if $Role::Tiny::COMPOSED{role}{$composed_name}; | ||||
334 | $self->_make_accessors_if_moose($composed_name, $role); | ||||
335 | $self->SUPER::_composable_package_for($role); | ||||
336 | } | ||||
337 | |||||
338 | # spent 1.07ms (20µs+1.06) within Moo::Role::_install_single_modifier which was called 4 times, avg 269µs/call:
# 4 times (20µs+1.06ms) by Role::Tiny::_install_modifiers at line 366 of Role/Tiny.pm, avg 269µs/call | ||||
339 | 4 | 4µs | my ($me, @args) = @_; | ||
340 | 4 | 14µs | 4 | 1.06ms | _install_modifier(@args); # spent 1.06ms making 4 calls to Moo::_Utils::_install_modifier, avg 264µs/call |
341 | } | ||||
342 | |||||
343 | # spent 1.28ms (263µs+1.02) within Moo::Role::_handle_constructor which was called 19 times, avg 68µs/call:
# 10 times (117µs+395µs) by Role::Tiny::apply_single_role_to_package at line 89 of Role/Tiny.pm, avg 51µs/call
# 9 times (146µs+626µs) by Role::Tiny::apply_roles_to_package at line 238 of Role/Tiny.pm, avg 86µs/call | ||||
344 | 19 | 10µs | my ($me, $to, $role) = @_; | ||
345 | 19 | 21µs | my $attr_info = $INFO{$role} && $INFO{$role}{attributes}; | ||
346 | 19 | 20µs | return unless $attr_info && @$attr_info; | ||
347 | 12 | 35µs | if ($INFO{$to}) { | ||
348 | push @{$INFO{$to}{attributes}||=[]}, @$attr_info; | ||||
349 | } else { | ||||
350 | # only fiddle with the constructor if the target is a Moo class | ||||
351 | 10 | 178µs | 20 | 1.02ms | if ($INC{"Moo.pm"} # spent 687µs making 10 calls to Moo::_constructor_maker_for, avg 69µs/call
# spent 334µs making 10 calls to Method::Generate::Constructor::register_attribute_specs, avg 33µs/call |
352 | and my $con = Moo->_constructor_maker_for($to)) { | ||||
353 | # shallow copy of the specs since the constructor will assign an index | ||||
354 | $con->register_attribute_specs(map ref() ? { %$_ } : $_, @$attr_info); | ||||
355 | } | ||||
356 | } | ||||
357 | } | ||||
358 | |||||
359 | 1 | 3µs | 1; | ||
360 | __END__ |