Profile of Moose/Meta/Role/Composite.pm

← Index
NYTProf Performance Profile «line view»
For script/ponapi
Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:11 2016

Filename | /usr/local/lib/perl/5.18.2/Moose/Meta/Role/Composite.pm
Statements | Executed 2081 statements in 4.84ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
213 | 1 | 1 | 7.81ms | 15.1ms | Moose::Meta::Role::Composite::::add_methodMoose::Meta::Role::Composite::add_method
19 | 1 | 1 | 580µs | 2.36ms | Moose::Meta::Role::Composite::::newMoose::Meta::Role::Composite::new
19 | 1 | 1 | 309µs | 58.4ms | Moose::Meta::Role::Composite::::apply_paramsMoose::Meta::Role::Composite::apply_params
19 | 2 | 2 | 121µs | 161µs | Moose::Meta::Role::Composite::::_get_local_methodsMoose::Meta::Role::Composite::_get_local_methods
19 | 1 | 1 | 81µs | 126µs | Moose::Meta::Role::Composite::::is_overloadedMoose::Meta::Role::Composite::is_overloaded
30 | 2 | 2 | 72µs | 98µs | Moose::Meta::Role::Composite::::has_methodMoose::Meta::Role::Composite::has_method
19 | 1 | 1 | 40µs | 40µs | Moose::Meta::Role::Composite::::__ANON__[:30]Moose::Meta::Role::Composite::__ANON__[:30]
19 | 1 | 1 | 28µs | 28µs | Moose::Meta::Role::Composite::::__ANON__[:36]Moose::Meta::Role::Composite::__ANON__[:36]
1 | 1 | 1 | 12µs | 26µs | Moose::Meta::Role::Composite::::BEGIN@4Moose::Meta::Role::Composite::BEGIN@4
1 | 1 | 1 | 9µs | 36µs | Moose::Meta::Role::Composite::::BEGIN@10Moose::Meta::Role::Composite::BEGIN@10
1 | 1 | 1 | 9µs | 420µs | Moose::Meta::Role::Composite::::BEGIN@6Moose::Meta::Role::Composite::BEGIN@6
1 | 1 | 1 | 8µs | 42µs | Moose::Meta::Role::Composite::::BEGIN@8Moose::Meta::Role::Composite::BEGIN@8
1 | 1 | 1 | 8µs | 14µs | Moose::Meta::Role::Composite::::BEGIN@5Moose::Meta::Role::Composite::BEGIN@5
1 | 1 | 1 | 8µs | 169µs | Moose::Meta::Role::Composite::::BEGIN@9Moose::Meta::Role::Composite::BEGIN@9
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Composite::::add_overloaded_operatorMoose::Meta::Role::Composite::add_overloaded_operator
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Composite::::get_all_overloaded_operatorsMoose::Meta::Role::Composite::get_all_overloaded_operators
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Composite::::get_methodMoose::Meta::Role::Composite::get_method
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Composite::::get_method_listMoose::Meta::Role::Composite::get_method_list
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Composite::::get_overload_fallback_valueMoose::Meta::Role::Composite::get_overload_fallback_value
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Composite::::is_anonMoose::Meta::Role::Composite::is_anon
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Composite::::reinitializeMoose::Meta::Role::Composite::reinitialize
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Composite::::set_overload_fallback_valueMoose::Meta::Role::Composite::set_overload_fallback_value

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package Moose::Meta::Role::Composite;
2 | 1 | 600ns |  |  | our $VERSION = '2.1604';
3 |  |  |  |  |
4 | 2 | 22µs | 2 | 41µs | # spent 26µs (12+14) within Moose::Meta::Role::Composite::BEGIN@4 which was called: # once (12µs+14µs) by Moose::BEGIN@33 at line 4 use strict; # spent 26µs making 1 call to Moose::Meta::Role::Composite::BEGIN@4 # spent 14µs making 1 call to strict::import
5 | 2 | 20µs | 2 | 21µs | # spent 14µs (8+6) within Moose::Meta::Role::Composite::BEGIN@5 which was called: # once (8µs+6µs) by Moose::BEGIN@33 at line 5 use warnings; # spent 14µs making 1 call to Moose::Meta::Role::Composite::BEGIN@5 # spent 6µs making 1 call to warnings::import
6 | 2 | 31µs | 2 | 831µs | # spent 420µs (9+411) within Moose::Meta::Role::Composite::BEGIN@6 which was called: # once (9µs+411µs) by Moose::BEGIN@33 at line 6 use metaclass; # spent 420µs making 1 call to Moose::Meta::Role::Composite::BEGIN@6 # spent 411µs making 1 call to metaclass::import
7 |  |  |  |  |
8 | 2 | 24µs | 2 | 75µs | # spent 42µs (8+34) within Moose::Meta::Role::Composite::BEGIN@8 which was called: # once (8µs+34µs) by Moose::BEGIN@33 at line 8 use Scalar::Util 'blessed'; # spent 42µs making 1 call to Moose::Meta::Role::Composite::BEGIN@8 # spent 34µs making 1 call to Exporter::import
9 | 2 | 26µs | 2 | 330µs | # spent 169µs (8+161) within Moose::Meta::Role::Composite::BEGIN@9 which was called: # once (8µs+161µs) by Moose::BEGIN@33 at line 9 use Moose::Util 'throw_exception'; # spent 169µs making 1 call to Moose::Meta::Role::Composite::BEGIN@9 # spent 161µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
10 | 2 | 711µs | 2 | 63µs | # spent 36µs (9+27) within Moose::Meta::Role::Composite::BEGIN@10 which was called: # once (9µs+27µs) by Moose::BEGIN@33 at line 10 use parent 'Moose::Meta::Role'; # spent 36µs making 1 call to Moose::Meta::Role::Composite::BEGIN@10 # spent 27µs making 1 call to parent::import
11 |  |  |  |  |
12 |  |  |  |  | # NOTE:
13 |  |  |  |  | # we need to override the ->name
14 |  |  |  |  | # method from Class::MOP::Package
15 |  |  |  |  | # since we don't have an actual
16 |  |  |  |  | # package for this.
17 |  |  |  |  | # - SL
18 | 1 | 5µs | 3 | 313µs | __PACKAGE__->meta->add_attribute('name' => ( # spent 286µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 21µs making 1 call to Moose::Meta::Role::Composite::meta # spent 6µs making 1 call to Class::MOP::_definition_context
19 |  |  |  |  | reader => 'name',
20 |  |  |  |  | Class::MOP::_definition_context(),
21 |  |  |  |  | ));
22 |  |  |  |  |
23 |  |  |  |  | # NOTE:
24 |  |  |  |  | # Again, since we don't have a real
25 |  |  |  |  | # package to store our methods in,
26 |  |  |  |  | # we use a HASH ref instead.
27 |  |  |  |  | # - SL
28 |  |  |  |  | __PACKAGE__->meta->add_attribute('_methods' => (
29 |  |  |  |  | reader => '_method_map',
30 | 19 | 44µs |  |  | # spent 40µs within Moose::Meta::Role::Composite::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Meta/Role/Composite.pm:30] which was called 19 times, avg 2µs/call: # 19 times (40µs+0s) by Moose::Meta::Role::Composite::_new at line 15 of (eval 45)[Eval/Closure.pm:144], avg 2µs/call default => sub { {} },
31 | 1 | 4µs | 3 | 256µs | Class::MOP::_definition_context(), # spent 245µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µs making 1 call to Moose::Meta::Role::Composite::meta # spent 4µs making 1 call to Class::MOP::_definition_context
32 |  |  |  |  | ));
33 |  |  |  |  |
34 |  |  |  |  | __PACKAGE__->meta->add_attribute('_overloads' => (
35 |  |  |  |  | reader => '_overload_map',
36 | 19 | 41µs |  |  | # spent 28µs within Moose::Meta::Role::Composite::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Meta/Role/Composite.pm:36] which was called 19 times, avg 1µs/call: # 19 times (28µs+0s) by Moose::Meta::Role::Composite::_new at line 30 of (eval 45)[Eval/Closure.pm:144], avg 1µs/call default => sub { {} },
37 | 1 | 3µs | 3 | 252µs | Class::MOP::_definition_context(), # spent 240µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µs making 1 call to Moose::Meta::Role::Composite::meta # spent 4µs making 1 call to Class::MOP::_definition_context
38 |  |  |  |  | ));
39 |  |  |  |  |
40 | 1 | 3µs | 3 | 239µs | __PACKAGE__->meta->add_attribute('_overload_fallback' => ( # spent 228µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µs making 1 call to Moose::Meta::Role::Composite::meta # spent 4µs making 1 call to Class::MOP::_definition_context
41 |  |  |  |  | accessor => '_overload_fallback',
42 |  |  |  |  | Class::MOP::_definition_context(),
43 |  |  |  |  | ));
44 |  |  |  |  |
45 | 1 | 2µs | 3 | 243µs | __PACKAGE__->meta->add_attribute( # spent 232µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 7µs making 1 call to Moose::Meta::Role::Composite::meta # spent 4µs making 1 call to Class::MOP::_definition_context
46 |  |  |  |  | 'application_role_summation_class',
47 |  |  |  |  | reader => 'application_role_summation_class',
48 |  |  |  |  | default => 'Moose::Meta::Role::Application::RoleSummation',
49 |  |  |  |  | Class::MOP::_definition_context(),
50 |  |  |  |  | );
51 |  |  |  |  |
52 |  |  |  |  | # spent 2.36ms (580µs+1.78) within Moose::Meta::Role::Composite::new which was called 19 times, avg 124µs/call: # 19 times (580µs+1.78ms) by Moose::Meta::Role::combine at line 497 of Moose/Meta/Role.pm, avg 124µs/call sub new {
53 | 19 | 24µs |  |  | my ($class, %params) = @_;
54 |  |  |  |  |
55 |  |  |  |  | # the roles param is required ...
56 | 19 | 28µs |  |  | foreach ( @{$params{roles}} ) {
57 | 69 | 140µs | 69 | 26µs | unless ( $_->isa('Moose::Meta::Role') ) { # spent 26µs making 69 calls to UNIVERSAL::isa, avg 375ns/call
58 |  |  |  |  | throw_exception( RolesListMustBeInstancesOfMooseMetaRole => params => \%params,
59 |  |  |  |  | role => $_,
60 |  |  |  |  | class => $class
61 |  |  |  |  | );
62 |  |  |  |  | }
63 |  |  |  |  | }
64 |  |  |  |  |
65 | 69 | 60µs | 69 | 36µs | my @composition_roles = map { # spent 36µs making 69 calls to Moose::Meta::Role::composition_class_roles, avg 528ns/call
66 |  |  |  |  | $_->composition_class_roles
67 | 19 | 42µs |  |  | } @{ $params{roles} };
68 |  |  |  |  |
69 | 19 | 7µs |  |  | if (@composition_roles) {
70 |  |  |  |  | my $meta = Moose::Meta::Class->create_anon_class(
71 |  |  |  |  | superclasses => [ $class ],
72 |  |  |  |  | roles => [ @composition_roles ],
73 |  |  |  |  | cache => 1,
74 |  |  |  |  | );
75 |  |  |  |  | $class = $meta->name;
76 |  |  |  |  | }
77 |  |  |  |  |
78 |  |  |  |  | # and the name is created from the
79 |  |  |  |  | # roles if one has not been provided
80 | 88 | 209µs | 69 | 38µs | $params{name} ||= (join "|" => map { $_->name } @{$params{roles}}); # spent 38µs making 69 calls to Class::MOP::Package::name, avg 555ns/call
81 | 19 | 82µs | 19 | 1.68ms | $class->_new(\%params); # spent 1.68ms making 19 calls to Moose::Meta::Role::Composite::_new, avg 89µs/call
82 |  |  |  |  | }
83 |  |  |  |  |
84 |  |  |  |  | # There's no such thing as an anonymous composite role since composites are an
85 |  |  |  |  | # artifact of Moose's internals. However, a composite role that contains an
86 |  |  |  |  | # anon role may _look_ like an anon role since $self->name =~ /$anon_key/ can
87 |  |  |  |  | # return true if the first role in the composite is anonymous itself.
88 |  |  |  |  | sub is_anon { 0 }
89 |  |  |  |  |
90 |  |  |  |  | # This is largely a copy of what's in Moose::Meta::Role (itself
91 |  |  |  |  | # largely a copy of Class::MOP::Class). However, we can't actually
92 |  |  |  |  | # call add_package_symbol, because there's no package into which to
93 |  |  |  |  | # add the symbol.
94 |  |  |  |  | # spent 15.1ms (7.81+7.29) within Moose::Meta::Role::Composite::add_method which was called 213 times, avg 71µs/call: # 213 times (7.81ms+7.29ms) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 202 of Moose/Meta/Role/Application/RoleSummation.pm, avg 71µs/call sub add_method {
95 | 213 | 67µs |  |  | my ($self, $method_name, $method) = @_;
96 |  |  |  |  |
97 | 213 | 39µs |  |  | unless ( defined $method_name && $method_name ) {
98 |  |  |  |  | throw_exception( MustDefineAMethodName => instance => $self );
99 |  |  |  |  | }
100 |  |  |  |  |
101 | 213 | 14µs |  |  | my $body;
102 | 213 | 483µs | 213 | 117µs | if (blessed($method)) { # spent 117µs making 213 calls to Scalar::Util::blessed, avg 549ns/call
103 | 213 | 404µs | 213 | 103µs | $body = $method->body; # spent 103µs making 213 calls to Class::MOP::Method::body, avg 485ns/call
104 | 213 | 1.22ms | 1065 | 6.86ms | if ($method->package_name ne $self->name) { # spent 6.27ms making 213 calls to Class::MOP::Method::clone, avg 29µs/call # spent 384µs making 426 calls to Moose::Meta::Role::Composite::name, avg 900ns/call # spent 136µs making 213 calls to UNIVERSAL::can, avg 640ns/call # spent 72µs making 213 calls to Class::MOP::Method::package_name, avg 336ns/call
105 |  |  |  |  | $method = $method->clone(
106 |  |  |  |  | package_name => $self->name,
107 |  |  |  |  | name => $method_name
108 |  |  |  |  | ) if $method->can('clone');
109 |  |  |  |  | }
110 |  |  |  |  | }
111 |  |  |  |  | else {
112 |  |  |  |  | $body = $method;
113 |  |  |  |  | $method = $self->wrap_method_body( body => $body, name => $method_name );
114 |  |  |  |  | }
115 |  |  |  |  |
116 | 213 | 541µs | 213 | 204µs | $self->_method_map->{$method_name} = $method; # spent 204µs making 213 calls to Moose::Meta::Role::Composite::_method_map, avg 960ns/call
117 |  |  |  |  | }
118 |  |  |  |  |
119 |  |  |  |  | sub get_method_list {
120 |  |  |  |  | my $self = shift;
121 |  |  |  |  | return keys %{ $self->_method_map };
122 |  |  |  |  | }
123 |  |  |  |  |
124 |  |  |  |  | # spent 161µs (121+40) within Moose::Meta::Role::Composite::_get_local_methods which was called 19 times, avg 8µs/call: # 14 times (91µs+34µs) by Moose::Meta::Role::Application::ToClass::apply_methods at line 136 of Moose/Meta/Role/Application/ToClass.pm, avg 9µs/call # 5 times (30µs+5µs) by Moose::Meta::Role::Application::ToRole::apply_methods at line 77 of Moose/Meta/Role/Application/ToRole.pm, avg 7µs/call sub _get_local_methods {
125 | 19 | 7µs |  |  | my $self = shift;
126 | 19 | 111µs | 19 | 40µs | return values %{ $self->_method_map }; # spent 40µs making 19 calls to Moose::Meta::Role::Composite::_method_map, avg 2µs/call
127 |  |  |  |  | }
128 |  |  |  |  |
129 |  |  |  |  | # spent 98µs (72+26) within Moose::Meta::Role::Composite::has_method which was called 30 times, avg 3µs/call: # 15 times (41µs+9µs) by Moose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers at line 221 of Moose/Meta/Role/Application/RoleSummation.pm, avg 3µs/call # 15 times (31µs+17µs) by Moose::Meta::Role::add_override_method_modifier at line 363 of Moose/Meta/Role.pm, avg 3µs/call sub has_method {
130 | 30 | 5µs |  |  | my ($self, $method_name) = @_;
131 |  |  |  |  |
132 | 30 | 73µs | 30 | 26µs | return exists $self->_method_map->{$method_name}; # spent 26µs making 30 calls to Moose::Meta::Role::Composite::_method_map, avg 863ns/call
133 |  |  |  |  | }
134 |  |  |  |  |
135 |  |  |  |  | sub get_method {
136 |  |  |  |  | my ($self, $method_name) = @_;
137 |  |  |  |  |
138 |  |  |  |  | return $self->_method_map->{$method_name};
139 |  |  |  |  | }
140 |  |  |  |  |
141 |  |  |  |  | # spent 126µs (81+45) within Moose::Meta::Role::Composite::is_overloaded which was called 19 times, avg 7µs/call: # 19 times (81µs+45µs) by Moose::Meta::Role::Application::apply_overloading at line 85 of Moose/Meta/Role/Application.pm, avg 7µs/call sub is_overloaded {
142 | 19 | 6µs |  |  | my ($self) = @_;
143 | 19 | 82µs | 19 | 45µs | return keys %{ $self->_overload_map }; # spent 45µs making 19 calls to Moose::Meta::Role::Composite::_overload_map, avg 2µs/call
144 |  |  |  |  | }
145 |  |  |  |  |
146 |  |  |  |  | sub add_overloaded_operator {
147 |  |  |  |  | my ( $self, $op_name, $overload ) = @_;
148 |  |  |  |  |
149 |  |  |  |  | unless ( defined $op_name && $op_name ) {
150 |  |  |  |  | throw_exception(
151 |  |  |  |  | 'MustDefineAnOverloadOperator',
152 |  |  |  |  | instance => $self,
153 |  |  |  |  | );
154 |  |  |  |  | }
155 |  |  |  |  |
156 |  |  |  |  | $self->_overload_map->{$op_name} = $overload;
157 |  |  |  |  | }
158 |  |  |  |  |
159 |  |  |  |  | sub get_overload_fallback_value {
160 |  |  |  |  | my ($self) = @_;
161 |  |  |  |  | return $self->_overload_fallback;
162 |  |  |  |  | }
163 |  |  |  |  |
164 |  |  |  |  | sub set_overload_fallback_value {
165 |  |  |  |  | my $self = shift;
166 |  |  |  |  | $self->_overload_fallback(shift);
167 |  |  |  |  | }
168 |  |  |  |  |
169 |  |  |  |  | sub get_all_overloaded_operators {
170 |  |  |  |  | my ( $self, $method_name ) = @_;
171 |  |  |  |  | return values %{ $self->_overload_map };
172 |  |  |  |  | }
173 |  |  |  |  |
174 |  |  |  |  | # spent 58.4ms (309µs+58.1) within Moose::Meta::Role::Composite::apply_params which was called 19 times, avg 3.07ms/call: # 19 times (309µs+58.1ms) by Moose::Meta::Role::combine at line 498 of Moose/Meta/Role.pm, avg 3.07ms/call sub apply_params {
175 | 19 | 8µs |  |  | my ($self, $role_params) = @_;
176 | 19 | 67µs | 38 | 444µs | Moose::Util::_load_user_class($self->application_role_summation_class); # spent 949µs making 19 calls to Moose::Util::_load_user_class, avg 50µs/call, recursion: max depth 1, sum of overlapping time 550µs # spent 45µs making 19 calls to Moose::Meta::Role::Composite::application_role_summation_class, avg 2µs/call
177 |  |  |  |  |
178 | 19 | 135µs | 57 | 57.1ms | $self->application_role_summation_class->new( # spent 56.6ms making 19 calls to Moose::Meta::Role::Application::apply, avg 2.98ms/call # spent 489µs making 19 calls to Moose::Meta::Role::Application::new, avg 26µs/call # spent 22µs making 19 calls to Moose::Meta::Role::Composite::application_role_summation_class, avg 1µs/call
179 |  |  |  |  | role_params => $role_params,
180 |  |  |  |  | )->apply($self);
181 |  |  |  |  |
182 | 19 | 44µs |  |  | return $self;
183 |  |  |  |  | }
184 |  |  |  |  |
185 |  |  |  |  | sub reinitialize {
186 |  |  |  |  | my ( $class, $old_meta, @args ) = @_;
187 |  |  |  |  |
188 |  |  |  |  | throw_exception( CannotInitializeMooseMetaRoleComposite => old_meta => $old_meta,
189 |  |  |  |  | args => \@args,
190 |  |  |  |  | role_composite => $class
191 |  |  |  |  | )
192 |  |  |  |  | if !blessed $old_meta
193 |  |  |  |  | || !$old_meta->isa('Moose::Meta::Role::Composite');
194 |  |  |  |  |
195 |  |  |  |  | my %existing_classes = map { $_ => $old_meta->$_() } qw(
196 |  |  |  |  | application_role_summation_class
197 |  |  |  |  | );
198 |  |  |  |  |
199 |  |  |  |  | return $old_meta->meta->clone_object( $old_meta, %existing_classes, @args );
200 |  |  |  |  | }
201 |  |  |  |  |
202 | 1 | 7µs |  |  | 1;
203 |  |  |  |  |
204 |  |  |  |  | # ABSTRACT: An object to represent the set of roles
205 |  |  |  |  |
206 |  |  |  |  | __END__