← 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
StatementsExecuted 2081 statements in 4.84ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
213117.81ms15.1msMoose::Meta::Role::Composite::::add_methodMoose::Meta::Role::Composite::add_method
1911580µs2.36msMoose::Meta::Role::Composite::::newMoose::Meta::Role::Composite::new
1911309µs58.4msMoose::Meta::Role::Composite::::apply_paramsMoose::Meta::Role::Composite::apply_params
1922121µs161µsMoose::Meta::Role::Composite::::_get_local_methodsMoose::Meta::Role::Composite::_get_local_methods
191181µs126µsMoose::Meta::Role::Composite::::is_overloadedMoose::Meta::Role::Composite::is_overloaded
302272µs98µsMoose::Meta::Role::Composite::::has_methodMoose::Meta::Role::Composite::has_method
191140µs40µsMoose::Meta::Role::Composite::::__ANON__[:30]Moose::Meta::Role::Composite::__ANON__[:30]
191128µs28µsMoose::Meta::Role::Composite::::__ANON__[:36]Moose::Meta::Role::Composite::__ANON__[:36]
11112µs26µsMoose::Meta::Role::Composite::::BEGIN@4Moose::Meta::Role::Composite::BEGIN@4
1119µs36µsMoose::Meta::Role::Composite::::BEGIN@10Moose::Meta::Role::Composite::BEGIN@10
1119µs420µsMoose::Meta::Role::Composite::::BEGIN@6Moose::Meta::Role::Composite::BEGIN@6
1118µs42µsMoose::Meta::Role::Composite::::BEGIN@8Moose::Meta::Role::Composite::BEGIN@8
1118µs14µsMoose::Meta::Role::Composite::::BEGIN@5Moose::Meta::Role::Composite::BEGIN@5
1118µs169µsMoose::Meta::Role::Composite::::BEGIN@9Moose::Meta::Role::Composite::BEGIN@9
0000s0sMoose::Meta::Role::Composite::::add_overloaded_operatorMoose::Meta::Role::Composite::add_overloaded_operator
0000s0sMoose::Meta::Role::Composite::::get_all_overloaded_operatorsMoose::Meta::Role::Composite::get_all_overloaded_operators
0000s0sMoose::Meta::Role::Composite::::get_methodMoose::Meta::Role::Composite::get_method
0000s0sMoose::Meta::Role::Composite::::get_method_listMoose::Meta::Role::Composite::get_method_list
0000s0sMoose::Meta::Role::Composite::::get_overload_fallback_valueMoose::Meta::Role::Composite::get_overload_fallback_value
0000s0sMoose::Meta::Role::Composite::::is_anonMoose::Meta::Role::Composite::is_anon
0000s0sMoose::Meta::Role::Composite::::reinitializeMoose::Meta::Role::Composite::reinitialize
0000s0sMoose::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
1package Moose::Meta::Role::Composite;
21600nsour $VERSION = '2.1604';
3
4222µs241µ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
5220µs221µ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
6231µs2831µ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
8224µs275µ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
9226µs2330µ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]
102711µs263µ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
1815µs3313µ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',
301944µ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 { {} },
3114µs3256µ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',
361941µ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 { {} },
3713µs3252µ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
4013µs3239µ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
4512µs3243µ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 {
531924µs my ($class, %params) = @_;
54
55 # the roles param is required ...
561928µs foreach ( @{$params{roles}} ) {
5769140µs6926µ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
656960µs6936µ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
671942µs } @{ $params{roles} };
68
69197µ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
8088209µs6938µs $params{name} ||= (join "|" => map { $_->name } @{$params{roles}});
# spent 38µs making 69 calls to Class::MOP::Package::name, avg 555ns/call
811982µs191.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.
88sub 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 {
9521367µs my ($self, $method_name, $method) = @_;
96
9721339µs unless ( defined $method_name && $method_name ) {
98 throw_exception( MustDefineAMethodName => instance => $self );
99 }
100
10121314µs my $body;
102213483µs213117µs if (blessed($method)) {
# spent 117µs making 213 calls to Scalar::Util::blessed, avg 549ns/call
103213404µs213103µs $body = $method->body;
# spent 103µs making 213 calls to Class::MOP::Method::body, avg 485ns/call
1042131.22ms10656.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
116213541µs213204µ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
119sub 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 {
125197µs my $self = shift;
12619111µs1940µ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 {
130305µs my ($self, $method_name) = @_;
131
1323073µs3026µ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
135sub 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 {
142196µs my ($self) = @_;
1431982µs1945µ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
146sub 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
159sub get_overload_fallback_value {
160 my ($self) = @_;
161 return $self->_overload_fallback;
162}
163
164sub set_overload_fallback_value {
165 my $self = shift;
166 $self->_overload_fallback(shift);
167}
168
169sub 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 {
175198µs my ($self, $role_params) = @_;
1761967µs38444µ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
17819135µs5757.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
1821944µs return $self;
183}
184
185sub 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
20217µs1;
203
204# ABSTRACT: An object to represent the set of roles
205
206__END__