← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:45:08 2010
Reported on Wed Nov 17 22:11:12 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Role.pm
StatementsExecuted 14035 statements in 185ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
8166325.5ms35.5msMoose::Meta::Role::::get_method_modifier_listMoose::Meta::Role::get_method_modifier_list
1844221.9ms3.57sMoose::Meta::Role::::applyMoose::Meta::Role::apply
2543310.7ms56.1msMoose::Meta::Role::::add_override_method_modifierMoose::Meta::Role::add_override_method_modifier
1252210.0ms339msMoose::Meta::Role::::initializeMoose::Meta::Role::initialize
295337.83ms11.0msMoose::Meta::Role::::get_override_method_modifierMoose::Meta::Role::get_override_method_modifier
111117.25ms11.3msMoose::Meta::Role::::add_roleMoose::Meta::Role::add_role
209115.55ms7.79msMoose::Meta::Role::::has_override_method_modifierMoose::Meta::Role::has_override_method_modifier
42115.44ms394msMoose::Meta::Role::::createMoose::Meta::Role::create
9114.60ms264msMoose::Meta::Role::::combineMoose::Meta::Role::combine
201224.24ms82.4msMoose::Meta::Role::::find_method_by_nameMoose::Meta::Role::find_method_by_name
402723.86ms3.86msMoose::Meta::Role::::__ANON__[:295]Moose::Meta::Role::__ANON__[:295]
268422.73ms2.73msMoose::Meta::Role::::__ANON__[:89]Moose::Meta::Role::__ANON__[:89]
1112.47ms14.3msMoose::Meta::Role::::BEGIN@17Moose::Meta::Role::BEGIN@17
42112.05ms396msMoose::Meta::Role::::create_anon_roleMoose::Meta::Role::create_anon_role
22331.88ms3.63msMoose::Meta::Role::::add_required_methodsMoose::Meta::Role::add_required_methods
24221.76ms10.3msMoose::Meta::Role::::add_attributeMoose::Meta::Role::add_attribute
134321.33ms1.33msMoose::Meta::Role::::__ANON__[:340]Moose::Meta::Role::__ANON__[:340]
1111.28ms7.61msMoose::Meta::Role::::BEGIN@19Moose::Meta::Role::BEGIN@19
125221.26ms1.26msMoose::Meta::Role::::__ANON__[:392]Moose::Meta::Role::__ANON__[:392]
1111.23ms6.70msMoose::Meta::Role::::BEGIN@20Moose::Meta::Role::BEGIN@20
125111.23ms1.23msMoose::Meta::Role::::_meta_method_classMoose::Meta::Role::_meta_method_class
111111.16ms1.16msMoose::Meta::Role::::reset_package_cache_flagMoose::Meta::Role::reset_package_cache_flag
111956µs1.47msMoose::Meta::Role::::BEGIN@18Moose::Meta::Role::BEGIN@18
1222794µs1.07msMoose::Meta::Role::::calculate_all_rolesMoose::Meta::Role::calculate_all_roles (recurses: max depth 1, inclusive time 387µs)
2411486µs1.89msMoose::Meta::Role::::_attach_attributeMoose::Meta::Role::_attach_attribute
611394µs542µsMoose::Meta::Role::::does_roleMoose::Meta::Role::does_role
2011220µs220µsMoose::Meta::Role::::_role_for_combinationMoose::Meta::Role::_role_for_combination
2011133µs133µsMoose::Meta::Role::::composition_class_rolesMoose::Meta::Role::composition_class_roles
11172µs91µsMoose::Meta::Role::::BEGIN@4Moose::Meta::Role::BEGIN@4
11158µs135µsMoose::Meta::Role::::BEGIN@599Moose::Meta::Role::BEGIN@599
91151µs51µsMoose::Meta::Role::::CORE:matchMoose::Meta::Role::CORE:match (opcode)
11151µs110µsMoose::Meta::Role::::BEGIN@621Moose::Meta::Role::BEGIN@621
11148µs112µsMoose::Meta::Role::::BEGIN@636Moose::Meta::Role::BEGIN@636
11142µs875µsMoose::Meta::Role::::BEGIN@22Moose::Meta::Role::BEGIN@22
11141µs279µsMoose::Meta::Role::::BEGIN@8Moose::Meta::Role::BEGIN@8
11141µs3.01msMoose::Meta::Role::::BEGIN@6Moose::Meta::Role::BEGIN@6
11140µs894µsMoose::Meta::Role::::BEGIN@10Moose::Meta::Role::BEGIN@10
11139µs173µsMoose::Meta::Role::::BEGIN@9Moose::Meta::Role::BEGIN@9
11138µs106µsMoose::Meta::Role::::BEGIN@5Moose::Meta::Role::BEGIN@5
11137µs639µsMoose::Meta::Role::::BEGIN@25Moose::Meta::Role::BEGIN@25
11130µs30µsMoose::Meta::Role::::BEGIN@21Moose::Meta::Role::BEGIN@21
11128µs28µsMoose::Meta::Role::::BEGIN@16Moose::Meta::Role::BEGIN@16
11128µs28µsMoose::Meta::Role::::BEGIN@23Moose::Meta::Role::BEGIN@23
0000s0sMoose::Meta::Role::::DESTROYMoose::Meta::Role::DESTROY
0000s0sMoose::Meta::Role::::__ANON__[:101]Moose::Meta::Role::__ANON__[:101]
0000s0sMoose::Meta::Role::::__ANON__[:106]Moose::Meta::Role::__ANON__[:106]
0000s0sMoose::Meta::Role::::__ANON__[:111]Moose::Meta::Role::__ANON__[:111]
0000s0sMoose::Meta::Role::::__ANON__[:116]Moose::Meta::Role::__ANON__[:116]
0000s0sMoose::Meta::Role::::__ANON__[:121]Moose::Meta::Role::__ANON__[:121]
0000s0sMoose::Meta::Role::::__ANON__[:304]Moose::Meta::Role::__ANON__[:304]
0000s0sMoose::Meta::Role::::__ANON__[:312]Moose::Meta::Role::__ANON__[:312]
0000s0sMoose::Meta::Role::::__ANON__[:331]Moose::Meta::Role::__ANON__[:331]
0000s0sMoose::Meta::Role::::__ANON__[:96]Moose::Meta::Role::__ANON__[:96]
0000s0sMoose::Meta::Role::::_restore_metaobjects_fromMoose::Meta::Role::_restore_metaobjects_from
0000s0sMoose::Meta::Role::::add_conflicting_methodMoose::Meta::Role::add_conflicting_method
0000s0sMoose::Meta::Role::::consumersMoose::Meta::Role::consumers
0000s0sMoose::Meta::Role::::is_anon_roleMoose::Meta::Role::is_anon_role
0000s0sMoose::Meta::Role::::reinitializeMoose::Meta::Role::reinitialize
0000s0sMoose::Meta::Role::::update_package_cache_flagMoose::Meta::Role::update_package_cache_flag
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1
2package Moose::Meta::Role;
3
43117µs2110µs
# spent 91µs (72+19) within Moose::Meta::Role::BEGIN@4 which was called: # once (72µs+19µs) by Moose::BEGIN@27 at line 4
use strict;
# spent 91µs making 1 call to Moose::Meta::Role::BEGIN@4 # spent 19µs making 1 call to strict::import
53113µs2175µs
# spent 106µs (38+68) within Moose::Meta::Role::BEGIN@5 which was called: # once (38µs+68µs) by Moose::BEGIN@27 at line 5
use warnings;
# spent 106µs making 1 call to Moose::Meta::Role::BEGIN@5 # spent 68µs making 1 call to warnings::import
63153µs25.98ms
# spent 3.01ms (41µs+2.97) within Moose::Meta::Role::BEGIN@6 which was called: # once (41µs+2.97ms) by Moose::BEGIN@27 at line 6
use metaclass;
# spent 3.01ms making 1 call to Moose::Meta::Role::BEGIN@6 # spent 2.97ms making 1 call to metaclass::import
7
83120µs2517µs
# spent 279µs (41+238) within Moose::Meta::Role::BEGIN@8 which was called: # once (41µs+238µs) by Moose::BEGIN@27 at line 8
use Scalar::Util 'blessed';
# spent 279µs making 1 call to Moose::Meta::Role::BEGIN@8 # spent 238µs making 1 call to Exporter::import
93105µs2308µs
# spent 173µs (39+135) within Moose::Meta::Role::BEGIN@9 which was called: # once (39µs+135µs) by Moose::BEGIN@27 at line 9
use Carp 'confess';
# spent 173µs making 1 call to Moose::Meta::Role::BEGIN@9 # spent 135µs making 1 call to Exporter::import
103244µs21.75ms
# spent 894µs (40+855) within Moose::Meta::Role::BEGIN@10 which was called: # once (40µs+855µs) by Moose::BEGIN@27 at line 10
use Devel::GlobalDestruction 'in_global_destruction';
# spent 894µs making 1 call to Moose::Meta::Role::BEGIN@10 # spent 855µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
11
1215µsour $VERSION = '1.19';
13182µs$VERSION = eval $VERSION;
# spent 12µs executing statements in string eval
1413µsour $AUTHORITY = 'cpan:STEVAN';
15
16393µs128µs
# spent 28µs within Moose::Meta::Role::BEGIN@16 which was called: # once (28µs+0s) by Moose::BEGIN@27 at line 16
use Moose::Meta::Class;
# spent 28µs making 1 call to Moose::Meta::Role::BEGIN@16
173567µs114.3ms
# spent 14.3ms (2.47+11.8) within Moose::Meta::Role::BEGIN@17 which was called: # once (2.47ms+11.8ms) by Moose::BEGIN@27 at line 17
use Moose::Meta::Role::Attribute;
# spent 14.3ms making 1 call to Moose::Meta::Role::BEGIN@17
183480µs11.47ms
# spent 1.47ms (956µs+518µs) within Moose::Meta::Role::BEGIN@18 which was called: # once (956µs+518µs) by Moose::BEGIN@27 at line 18
use Moose::Meta::Role::Method;
# spent 1.47ms making 1 call to Moose::Meta::Role::BEGIN@18
193475µs17.61ms
# spent 7.61ms (1.28+6.33) within Moose::Meta::Role::BEGIN@19 which was called: # once (1.28ms+6.33ms) by Moose::BEGIN@27 at line 19
use Moose::Meta::Role::Method::Required;
# spent 7.61ms making 1 call to Moose::Meta::Role::BEGIN@19
203520µs16.70ms
# spent 6.70ms (1.23+5.47) within Moose::Meta::Role::BEGIN@20 which was called: # once (1.23ms+5.47ms) by Moose::BEGIN@27 at line 20
use Moose::Meta::Role::Method::Conflicting;
# spent 6.70ms making 1 call to Moose::Meta::Role::BEGIN@20
213116µs130µs
# spent 30µs within Moose::Meta::Role::BEGIN@21 which was called: # once (30µs+0s) by Moose::BEGIN@27 at line 21
use Moose::Meta::Method::Meta;
# spent 30µs making 1 call to Moose::Meta::Role::BEGIN@21
223132µs21.71ms
# spent 875µs (42+833) within Moose::Meta::Role::BEGIN@22 which was called: # once (42µs+833µs) by Moose::BEGIN@27 at line 22
use Moose::Util qw( ensure_all_roles );
# spent 875µs making 1 call to Moose::Meta::Role::BEGIN@22 # spent 833µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
233111µs128µs
# spent 28µs within Moose::Meta::Role::BEGIN@23 which was called: # once (28µs+0s) by Moose::BEGIN@27 at line 23
use Class::MOP::MiniTrait;
# spent 28µs making 1 call to Moose::Meta::Role::BEGIN@23
24
251602µs
# spent 639µs (37+602) within Moose::Meta::Role::BEGIN@25 which was called: # once (37µs+602µs) by Moose::BEGIN@27 at line 27
use base 'Class::MOP::Module',
# spent 602µs making 1 call to base::import
26 'Class::MOP::Mixin::HasAttributes',
2738.80ms1639µs 'Class::MOP::Mixin::HasMethods';
# spent 639µs making 1 call to Moose::Meta::Role::BEGIN@25
28
29115µs18.81msClass::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait');
# spent 8.81ms making 1 call to Class::MOP::MiniTrait::apply
30
31## ------------------------------------------------------------------
32## NOTE:
33## I normally don't do this, but I am doing
34## a whole bunch of meta-programmin in this
35## module, so it just makes sense. For a clearer
36## picture of what is going on in the next
37## several lines of code, look at the really
38## big comment at the end of this file (right
39## before the POD).
40## - SL
41## ------------------------------------------------------------------
42
43114µs189µsmy $META = __PACKAGE__->meta;
# spent 89µs making 1 call to Moose::Meta::Role::meta
44
45## ------------------------------------------------------------------
46## attributes ...
47
48# NOTE:
49# since roles are lazy, we hold all the attributes
50# of the individual role in 'statis' until which
51# time when it is applied to a class. This means
52# keeping a lot of things in hash maps, so we are
53# using a little of that meta-programmin' magic
54# here an saving lots of extra typin. And since
55# many of these attributes above require similar
56# functionality to support them, so we again use
57# the wonders of meta-programmin' to deliver a
58# very compact solution to this normally verbose
59# problem.
60# - SL
61
62139µsforeach my $action (
63 {
64 name => 'excluded_roles_map',
65 attr_reader => 'get_excluded_roles_map' ,
66 methods => {
67 add => 'add_excluded_roles',
68 get_keys => 'get_excluded_roles_list',
69 existence => 'excludes_role',
70 }
71 },
72 {
73 name => 'required_methods',
74 attr_reader => 'get_required_methods_map',
75 methods => {
76 remove => 'remove_required_methods',
77 get_values => 'get_required_method_list',
78 existence => 'requires_method',
79 }
80 },
81) {
82
8318246µs my $attr_reader = $action->{attr_reader};
84 my $methods = $action->{methods};
85
86 # create the attribute
87 $META->add_attribute($action->{name} => (
88 reader => $attr_reader,
892683.61ms
# spent 2.73ms within Moose::Meta::Role::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Role.pm:89] which was called 268 times, avg 10µs/call: # 90 times (923µs+0s) by Moose::Meta::Role::Composite::_new or Moose::Meta::Role::_new at line 11 of (eval 76)[Class/MOP/Method/Generated.pm:53], avg 10µs/call # 88 times (975µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 53 of Class/MOP/Mixin/AttributeCore.pm, avg 11µs/call # 81 times (754µs+0s) by Moose::Meta::Role::_new at line 88 of (eval 76)[Class/MOP/Method/Generated.pm:53], avg 9µs/call # 9 times (76µs+0s) by Moose::Meta::Role::Composite::_new at line 96 of (eval 76)[Class/MOP/Method/Generated.pm:53], avg 8µs/call
default => sub { {} }
9024.85ms ));
# spent 4.85ms making 2 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 2.42ms/call
91
92 # create some helper methods
93 $META->add_method($methods->{add} => sub {
9427200µs my ($self, @values) = @_;
95 $self->$attr_reader->{$_} = undef foreach @values;
961396µs }) if exists $methods->{add};
# spent 396µs making 1 call to Class::MOP::Mixin::HasMethods::add_method
97
98 $META->add_method($methods->{get_keys} => sub {
994085.34ms my ($self) = @_;
1002042.33ms keys %{$self->$attr_reader};
# spent 2.33ms making 204 calls to Moose::Meta::Role::get_excluded_roles_map, avg 11µs/call
1011328µs }) if exists $methods->{get_keys};
# spent 328µs making 1 call to Class::MOP::Mixin::HasMethods::add_method
102
103 $META->add_method($methods->{get_values} => sub {
1044085.30ms my ($self) = @_;
1052042.67ms values %{$self->$attr_reader};
# spent 2.67ms making 204 calls to Moose::Meta::Role::get_required_methods_map, avg 13µs/call
1061374µs }) if exists $methods->{get_values};
# spent 374µs making 1 call to Class::MOP::Mixin::HasMethods::add_method
107
108 $META->add_method($methods->{get} => sub {
109 my ($self, $name) = @_;
110 $self->$attr_reader->{$name}
111 }) if exists $methods->{get};
112
113 $META->add_method($methods->{existence} => sub {
1143745.43ms my ($self, $name) = @_;
1151872.53ms exists $self->$attr_reader->{$name} ? 1 : 0;
# spent 2.53ms making 187 calls to Moose::Meta::Role::get_excluded_roles_map, avg 14µs/call
1162718µs }) if exists $methods->{existence};
# spent 718µs making 2 calls to Class::MOP::Mixin::HasMethods::add_method, avg 359µs/call
117
118 $META->add_method($methods->{remove} => sub {
119 my ($self, @values) = @_;
120 delete $self->$attr_reader->{$_} foreach @values;
1211324µs }) if exists $methods->{remove};
# spent 324µs making 1 call to Class::MOP::Mixin::HasMethods::add_method
122}
123
124$META->add_attribute(
125113µs12.06ms 'method_metaclass',
# spent 2.06ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
126 reader => 'method_metaclass',
127 default => 'Moose::Meta::Role::Method',
128);
129
130114µs12.04ms$META->add_attribute(
# spent 2.04ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
131 'required_method_metaclass',
132 reader => 'required_method_metaclass',
133 default => 'Moose::Meta::Role::Method::Required',
134);
135
136117µs12.13ms$META->add_attribute(
# spent 2.13ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
137 'conflicting_method_metaclass',
138 reader => 'conflicting_method_metaclass',
139 default => 'Moose::Meta::Role::Method::Conflicting',
140);
141
142114µs12.06ms$META->add_attribute(
# spent 2.06ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
143 'application_to_class_class',
144 reader => 'application_to_class_class',
145 default => 'Moose::Meta::Role::Application::ToClass',
146);
147
148113µs12.05ms$META->add_attribute(
# spent 2.05ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
149 'application_to_role_class',
150 reader => 'application_to_role_class',
151 default => 'Moose::Meta::Role::Application::ToRole',
152);
153
154114µs11.99ms$META->add_attribute(
# spent 1.99ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
155 'application_to_instance_class',
156 reader => 'application_to_instance_class',
157 default => 'Moose::Meta::Role::Application::ToInstance',
158);
159
160# More or less copied from Moose::Meta::Class
161
# spent 339ms (10.0+329) within Moose::Meta::Role::initialize which was called 125 times, avg 2.72ms/call: # 83 times (6.20ms+65.4ms) by Moose::Role::init_meta at line 131 of Moose/Role.pm, avg 862µs/call # 42 times (3.85ms+264ms) by Moose::Meta::Role::create at line 543, avg 6.38ms/call
sub initialize {
1628759.44ms my $class = shift;
163 my $pkg = shift;
164
1651251.03ms if (defined(my $meta = Class::MOP::get_metaclass_by_name($pkg))) {
# spent 1.03ms making 125 calls to Class::MOP::get_metaclass_by_name, avg 8µs/call
166 return $meta;
167 }
168
169 my %options = @_;
170
171125327ms my $meta = $class->SUPER::initialize(
# spent 327ms making 125 calls to Class::MOP::Package::initialize, avg 2.62ms/call
172 $pkg,
173 'attribute_metaclass' => 'Moose::Meta::Role::Attribute',
174 %options,
175 );
176
177421.34ms Class::MOP::weaken_metaclass($pkg) if $options{weaken};
# spent 1.34ms making 42 calls to Class::MOP::weaken_metaclass, avg 32µs/call
178
179 return $meta;
180}
181
182sub reinitialize {
183 my $self = shift;
184 my $pkg = shift;
185
186 my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg);
187
188 my %existing_classes;
189 if ($meta) {
190 %existing_classes = map { $_ => $meta->$_() } qw(
191 attribute_metaclass
192 method_metaclass
193 wrapped_method_metaclass
194 required_method_metaclass
195 conflicting_method_metaclass
196 application_to_class_class
197 application_to_role_class
198 application_to_instance_class
199 );
200 }
201
202 my %options = @_;
203 $options{weaken} = Class::MOP::metaclass_is_weak($meta->name)
204 if !exists $options{weaken}
205 && blessed($meta)
206 && $meta->isa('Moose::Meta::Role');
207
208 # don't need to remove generated metaobjects here yet, since we don't
209 # yet generate anything in roles. this may change in the future though...
210 # keep an eye on that
211 my $new_meta = $self->SUPER::reinitialize(
212 $pkg,
213 %existing_classes,
214 %options,
215 );
216 $new_meta->_restore_metaobjects_from($meta)
217 if $meta && $meta->isa('Moose::Meta::Role');
218 return $new_meta;
219}
220
221sub _restore_metaobjects_from {
222 my $self = shift;
223 my ($old_meta) = @_;
224
225 $self->_restore_metamethods_from($old_meta);
226 $self->_restore_metaattributes_from($old_meta);
227}
228
229
# spent 10.3ms (1.76+8.50) within Moose::Meta::Role::add_attribute which was called 24 times, avg 427µs/call: # 15 times (981µs+4.62ms) by Moose::Meta::Role::Application::ToRole::apply_attributes at line 71 of Moose/Meta/Role/Application/ToRole.pm, avg 373µs/call # 9 times (775µs+3.88ms) by Moose::Role::has at line 47 of Moose/Role.pm, avg 517µs/call
sub add_attribute {
230722.22ms my $self = shift;
231
23272421µs if (blessed $_[0] && ! $_[0]->isa('Moose::Meta::Role::Attribute') ) {
# spent 281µs making 48 calls to Scalar::Util::blessed, avg 6µs/call # spent 89µs making 15 calls to UNIVERSAL::isa, avg 6µs/call # spent 51µs making 9 calls to Moose::Meta::Role::CORE:match, avg 6µs/call
233 my $class = ref $_[0];
234 Moose->throw_error( "Cannot add a $class as an attribute to a role" );
235 }
236 elsif (!blessed($_[0]) && defined($_[0]) && $_[0] =~ /^\+(.*)/) {
237 Moose->throw_error( "has '+attr' is not supported in roles" );
238 }
239
240248.08ms return $self->SUPER::add_attribute(@_);
# spent 8.08ms making 24 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 337µs/call
241}
242
243
# spent 1.89ms (486µs+1.41) within Moose::Meta::Role::_attach_attribute which was called 24 times, avg 79µs/call: # 24 times (486µs+1.41ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 28 of Class/MOP/Mixin/HasAttributes.pm, avg 79µs/call
sub _attach_attribute {
24448496µs my ( $self, $attribute ) = @_;
245
246241.41ms $attribute->attach_to_role($self);
# spent 1.41ms making 24 calls to Moose::Meta::Role::Attribute::attach_to_role, avg 59µs/call
247}
248
249
# spent 3.63ms (1.88+1.75) within Moose::Meta::Role::add_required_methods which was called 22 times, avg 165µs/call: # 9 times (1.04ms+1.34ms) by Moose::Role::requires at line 32 of Moose/Role.pm, avg 265µs/call # 9 times (581µs+284µs) by Moose::Meta::Role::Application::RoleSummation::check_required_methods at line 109 of Moose/Meta/Role/Application/RoleSummation.pm, avg 96µs/call # 4 times (260µs+128µs) by Moose::Meta::Role::Application::ToRole::check_required_methods at line 43 of Moose/Meta/Role/Application/ToRole.pm, avg 97µs/call
sub add_required_methods {
25044486µs my $self = shift;
251
252 for (@_) {
253691.42ms my $method = $_;
254431.15ms if (!blessed($method)) {
# spent 885µs making 10 calls to Moose::Meta::Role::Method::Required::new, avg 89µs/call # spent 141µs making 10 calls to Moose::Meta::Role::required_method_metaclass, avg 14µs/call # spent 123µs making 23 calls to Scalar::Util::blessed, avg 5µs/call
255 $method = $self->required_method_metaclass->new(
256 name => $method,
257 );
258 }
25946602µs $self->get_required_methods_map->{$method->name} = $method;
# spent 305µs making 23 calls to Moose::Meta::Role::Method::Required::name, avg 13µs/call # spent 297µs making 23 calls to Moose::Meta::Role::get_required_methods_map, avg 13µs/call
260 }
261}
262
263sub add_conflicting_method {
264 my $self = shift;
265
266 my $method;
267 if (@_ == 1 && blessed($_[0])) {
268 $method = shift;
269 }
270 else {
271 $method = $self->conflicting_method_metaclass->new(@_);
272 }
273
274 $self->add_required_methods($method);
275}
276
277## ------------------------------------------------------------------
278## method modifiers
279
280# NOTE:
281# the before/around/after method modifiers are
282# stored by name, but there can be many methods
283# then associated with that name. So again we have
284# lots of similar functionality, so we can do some
285# meta-programmin' and save some time.
286# - SL
287
28817µsforeach my $modifier_type (qw[ before around after ]) {
289
29015332µs my $attr_reader = "get_${modifier_type}_method_modifiers_map";
291
292 # create the attribute ...
293 $META->add_attribute("${modifier_type}_method_modifiers" => (
294 reader => $attr_reader,
2954025.07ms
# spent 3.86ms within Moose::Meta::Role::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Role.pm:295] which was called 402 times, avg 10µs/call: # 132 times (1.27ms+0s) by Class::MOP::Mixin::AttributeCore::default at line 53 of Class/MOP/Mixin/AttributeCore.pm, avg 10µs/call # 81 times (875µs+0s) by Moose::Meta::Role::_new at line 31 of (eval 76)[Class/MOP/Method/Generated.pm:53], avg 11µs/call # 81 times (790µs+0s) by Moose::Meta::Role::_new at line 55 of (eval 76)[Class/MOP/Method/Generated.pm:53], avg 10µs/call # 81 times (685µs+0s) by Moose::Meta::Role::_new at line 60 of (eval 76)[Class/MOP/Method/Generated.pm:53], avg 8µs/call # 9 times (87µs+0s) by Moose::Meta::Role::Composite::_new at line 36 of (eval 76)[Class/MOP/Method/Generated.pm:53], avg 10µs/call # 9 times (78µs+0s) by Moose::Meta::Role::Composite::_new at line 63 of (eval 76)[Class/MOP/Method/Generated.pm:53], avg 9µs/call # 9 times (75µs+0s) by Moose::Meta::Role::Composite::_new at line 68 of (eval 76)[Class/MOP/Method/Generated.pm:53], avg 8µs/call
default => sub { {} }
29636.35ms ));
# spent 6.35ms making 3 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 2.12ms/call
297
298 # and some helper methods ...
299 $META->add_method("get_${modifier_type}_method_modifiers" => sub {
300102610.5ms my ($self, $method_name) = @_;
301 #return () unless exists $self->$attr_reader->{$method_name};
3023423.73ms my $mm = $self->$attr_reader->{$method_name};
# spent 3.35ms making 310 calls to Moose::Meta::Role::get_around_method_modifiers_map, avg 11µs/call # spent 226µs making 21 calls to Moose::Meta::Role::get_before_method_modifiers_map, avg 11µs/call # spent 155µs making 11 calls to Moose::Meta::Role::get_after_method_modifiers_map, avg 14µs/call
303 $mm ? @$mm : ();
30431.06ms });
# spent 1.06ms making 3 calls to Class::MOP::Mixin::HasMethods::add_method, avg 352µs/call
305
306 $META->add_method("has_${modifier_type}_method_modifiers" => sub {
307 my ($self, $method_name) = @_;
308 # NOTE:
309 # for now we assume that if it exists,..
310 # it has at least one modifier in it
311 (exists $self->$attr_reader->{$method_name}) ? 1 : 0;
3123962µs });
# spent 962µs making 3 calls to Class::MOP::Mixin::HasMethods::add_method, avg 321µs/call
313
314 $META->add_method("add_${modifier_type}_method_modifier" => sub {
315147917.9ms my ($self, $method_name, $method) = @_;
316
3175816.24ms $self->$attr_reader->{$method_name} = []
# spent 5.78ms making 541 calls to Moose::Meta::Role::get_around_method_modifiers_map, avg 11µs/call # spent 302µs making 26 calls to Moose::Meta::Role::get_before_method_modifiers_map, avg 12µs/call # spent 159µs making 14 calls to Moose::Meta::Role::get_after_method_modifiers_map, avg 11µs/call
318 unless exists $self->$attr_reader->{$method_name};
319
3202973.19ms my $modifiers = $self->$attr_reader->{$method_name};
# spent 2.95ms making 277 calls to Moose::Meta::Role::get_around_method_modifiers_map, avg 11µs/call # spent 168µs making 13 calls to Moose::Meta::Role::get_before_method_modifiers_map, avg 13µs/call # spent 74µs making 7 calls to Moose::Meta::Role::get_after_method_modifiers_map, avg 11µs/call
321
322 # NOTE:
323 # check to see that we aren't adding the
324 # same code twice. We err in favor of the
325 # first on here, this may not be as expected
326 foreach my $modifier (@{$modifiers}) {
32713130µs return if $modifier == $method;
328 }
329
330 push @{$modifiers} => $method;
3313982µs });
# spent 982µs making 3 calls to Class::MOP::Mixin::HasMethods::add_method, avg 327µs/call
332
333}
334
335## ------------------------------------------------------------------
336## override method mofidiers
337
338$META->add_attribute('override_method_modifiers' => (
339 reader => 'get_override_method_modifiers_map',
3401341.79ms
# spent 1.33ms within Moose::Meta::Role::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Role.pm:340] which was called 134 times, avg 10µs/call: # 81 times (781µs+0s) by Moose::Meta::Role::_new at line 73 of (eval 76)[Class/MOP/Method/Generated.pm:53], avg 10µs/call # 44 times (462µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 53 of Class/MOP/Mixin/AttributeCore.pm, avg 10µs/call # 9 times (83µs+0s) by Moose::Meta::Role::Composite::_new at line 81 of (eval 76)[Class/MOP/Method/Generated.pm:53], avg 9µs/call
default => sub { {} }
341121µs12.10ms));
# spent 2.10ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
342
343# NOTE:
344# these are a little different because there
345# can only be one per name, whereas the other
346# method modifiers can have multiples.
347# - SL
348
349
# spent 56.1ms (10.7+45.4) within Moose::Meta::Role::add_override_method_modifier which was called 254 times, avg 221µs/call: # 209 times (8.76ms+42.3ms) by Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers at line 163 of Moose/Meta/Role/Application/ToRole.pm, avg 244µs/call # 41 times (1.74ms+1.92ms) by Moose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers at line 237 of Moose/Meta/Role/Application/RoleSummation.pm, avg 89µs/call # 4 times (176µs+1.23ms) by Moose::Role::override at line 77 of Moose/Role.pm, avg 352µs/call
sub add_override_method_modifier {
3507629.62ms my ($self, $method_name, $method) = @_;
35125442.4ms (!$self->has_method($method_name))
# spent 41.0ms making 213 calls to Class::MOP::Mixin::HasMethods::has_method, avg 192µs/call # spent 1.44ms making 41 calls to Moose::Meta::Role::Composite::has_method, avg 35µs/call
352 || Moose->throw_error("Cannot add an override of method '$method_name' " .
353 "because there is a local version of '$method_name'");
3542543.00ms $self->get_override_method_modifiers_map->{$method_name} = $method;
# spent 3.00ms making 254 calls to Moose::Meta::Role::get_override_method_modifiers_map, avg 12µs/call
355}
356
357
# spent 7.79ms (5.55+2.24) within Moose::Meta::Role::has_override_method_modifier which was called 209 times, avg 37µs/call: # 209 times (5.55ms+2.24ms) by Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers at line 152 of Moose/Meta/Role/Application/ToRole.pm, avg 37µs/call
sub has_override_method_modifier {
3584185.15ms my ($self, $method_name) = @_;
359 # NOTE:
360 # for now we assume that if it exists,..
361 # it has at least one modifier in it
3622092.24ms (exists $self->get_override_method_modifiers_map->{$method_name}) ? 1 : 0;
# spent 2.24ms making 209 calls to Moose::Meta::Role::get_override_method_modifiers_map, avg 11µs/call
363}
364
365
# spent 11.0ms (7.83+3.17) within Moose::Meta::Role::get_override_method_modifier which was called 295 times, avg 37µs/call: # 209 times (5.39ms+2.15ms) by Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers at line 163 of Moose/Meta/Role/Application/ToRole.pm, avg 36µs/call # 45 times (1.36ms+557µs) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 205 of Moose/Meta/Role/Application/ToClass.pm, avg 43µs/call # 41 times (1.07ms+456µs) by Moose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers at line 208 of Moose/Meta/Role/Application/RoleSummation.pm, avg 37µs/call
sub get_override_method_modifier {
3665907.25ms my ($self, $method_name) = @_;
3672953.17ms $self->get_override_method_modifiers_map->{$method_name};
# spent 3.17ms making 295 calls to Moose::Meta::Role::get_override_method_modifiers_map, avg 11µs/call
368}
369
370## general list accessor ...
371
372
# spent 35.5ms (25.5+9.97) within Moose::Meta::Role::get_method_modifier_list which was called 816 times, avg 43µs/call: # 333 times (9.89ms+3.98ms) by Moose::Meta::Role::Application::ToRole::apply_method_modifiers at line 176 of Moose/Meta/Role/Application/ToRole.pm, avg 42µs/call # 219 times (6.56ms+2.72ms) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 217 of Moose/Meta/Role/Application/ToClass.pm, avg 42µs/call # 111 times (3.95ms+1.40ms) by Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers at line 136 of Moose/Meta/Role/Application/ToRole.pm, avg 48µs/call # 73 times (2.57ms+925µs) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 195 of Moose/Meta/Role/Application/ToClass.pm, avg 48µs/call # 60 times (1.86ms+681µs) by Moose::Meta::Role::Application::RoleSummation::apply_method_modifiers at line 246 of Moose/Meta/Role/Application/RoleSummation.pm, avg 42µs/call # 20 times (675µs+261µs) by Moose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers at line 209 of Moose/Meta/Role/Application/RoleSummation.pm, avg 47µs/call
sub get_method_modifier_list {
373244824.5ms my ($self, $modifier_type) = @_;
374 my $accessor = "get_${modifier_type}_method_modifiers_map";
3758169.97ms keys %{$self->$accessor};
# spent 2.59ms making 204 calls to Moose::Meta::Role::get_override_method_modifiers_map, avg 13µs/call # spent 2.54ms making 204 calls to Moose::Meta::Role::get_after_method_modifiers_map, avg 12µs/call # spent 2.43ms making 204 calls to Moose::Meta::Role::get_before_method_modifiers_map, avg 12µs/call # spent 2.41ms making 204 calls to Moose::Meta::Role::get_around_method_modifiers_map, avg 12µs/call
376}
377
3781111.52ms
# spent 1.16ms within Moose::Meta::Role::reset_package_cache_flag which was called 111 times, avg 10µs/call: # 111 times (1.16ms+0s) by Moose::Meta::Role::add_role at line 400, avg 10µs/call
sub reset_package_cache_flag { (shift)->{'_package_cache_flag'} = undef }
379sub update_package_cache_flag {
380 my $self = shift;
381 $self->{'_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name);
382}
383
384
3851251.49ms
# spent 1.23ms within Moose::Meta::Role::_meta_method_class which was called 125 times, avg 10µs/call: # 125 times (1.23ms+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 30 of Class/MOP/Mixin/HasMethods.pm, avg 10µs/call
sub _meta_method_class { 'Moose::Meta::Method::Meta' }
386
387## ------------------------------------------------------------------
388## subroles
389
390$META->add_attribute('roles' => (
391 reader => 'get_roles',
3921251.64ms
# spent 1.26ms within Moose::Meta::Role::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Role.pm:392] which was called 125 times, avg 10µs/call: # 81 times (809µs+0s) by Moose::Meta::Role::_new at line 36 of (eval 76)[Class/MOP/Method/Generated.pm:53], avg 10µs/call # 44 times (448µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 53 of Class/MOP/Mixin/AttributeCore.pm, avg 10µs/call
default => sub { [] }
393119µs12.08ms));
# spent 2.08ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
394
395
# spent 11.3ms (7.25+4.08) within Moose::Meta::Role::add_role which was called 111 times, avg 102µs/call: # 111 times (7.25ms+4.08ms) by Moose::Meta::Role::Application::ToRole::apply at line 18 of Moose/Meta/Role/Application/ToRole.pm, avg 102µs/call
sub add_role {
3964448.25ms my ($self, $role) = @_;
3972221.52ms (blessed($role) && $role->isa('Moose::Meta::Role'))
# spent 767µs making 111 calls to Scalar::Util::blessed, avg 7µs/call # spent 749µs making 111 calls to UNIVERSAL::isa, avg 7µs/call
398 || Moose->throw_error("Roles must be instances of Moose::Meta::Role");
3991111.40ms push @{$self->get_roles} => $role;
# spent 1.40ms making 111 calls to Moose::Meta::Role::get_roles, avg 13µs/call
4001111.16ms $self->reset_package_cache_flag;
# spent 1.16ms making 111 calls to Moose::Meta::Role::reset_package_cache_flag, avg 10µs/call
401}
402
403
# spent 1.07ms (794µs+273µs) within Moose::Meta::Role::calculate_all_roles which was called 12 times, avg 89µs/call: # 6 times (513µs+555µs) by Moose::Meta::Class::calculate_all_roles at line 200 of Moose/Meta/Class.pm, avg 178µs/call # 6 times (282µs+-282µs) by Moose::Meta::Role::calculate_all_roles at line 407, avg 0s/call
sub calculate_all_roles {
40436402µs my $self = shift;
405 my %seen;
40618105µs grep {
# spent 105µs making 18 calls to Class::MOP::Package::name, avg 6µs/call
40760s !$seen{$_->name}++
# spent 387µs making 6 calls to Moose::Meta::Role::calculate_all_roles, avg 64µs/call, recursion: max depth 1, sum of overlapping time 387µs
408 } ($self, map {
409 $_->calculate_all_roles
41024455µs12168µs } @{ $self->get_roles });
# spent 168µs making 12 calls to Moose::Meta::Role::get_roles, avg 14µs/call
411}
412
413
# spent 542µs (394+148) within Moose::Meta::Role::does_role which was called 6 times, avg 90µs/call: # 6 times (394µs+148µs) by Moose::Meta::Class::does_role at line 227 of Moose/Meta/Class.pm, avg 90µs/call
sub does_role {
41436455µs my ($self, $role) = @_;
415 (defined $role)
416 || Moose->throw_error("You must supply a role name to look for");
417630µs my $role_name = blessed $role ? $role->name : $role;
# spent 30µs making 6 calls to Scalar::Util::blessed, avg 5µs/call
418 # if we are it,.. then return true
419637µs return 1 if $role_name eq $self->name;
# spent 37µs making 6 calls to Class::MOP::Package::name, avg 6µs/call
420 # otherwise.. check our children
421680µs foreach my $role (@{$self->get_roles}) {
# spent 80µs making 6 calls to Moose::Meta::Role::get_roles, avg 13µs/call
422 return 1 if $role->does_role($role_name);
423 }
424 return 0;
425}
426
4272013.92ms20178.2ms
# spent 82.4ms (4.24+78.2) within Moose::Meta::Role::find_method_by_name which was called 201 times, avg 410µs/call: # 125 times (2.61ms+32.7ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 25 of Class/MOP/Mixin/HasMethods.pm, avg 283µs/call # 76 times (1.63ms+45.5ms) by Moose::Meta::Role::Application::ToRole::check_required_methods at line 43 of Moose/Meta/Role/Application/ToRole.pm, avg 620µs/call
sub find_method_by_name { (shift)->get_method(@_) }
# spent 78.2ms making 201 calls to Class::MOP::Mixin::HasMethods::get_method, avg 389µs/call
428
429## ------------------------------------------------------------------
430## role construction
431## ------------------------------------------------------------------
432
433
# spent 3.57s (21.9ms+3.55) within Moose::Meta::Role::apply which was called 184 times, avg 19.4ms/call: # 91 times (10.8ms+2.67s) by Moose::Util::_apply_all_roles at line 137 of Moose/Util.pm, avg 29.5ms/call # 42 times (5.21ms+485ms) by MooseX::Role::Parameterized::Meta::Role::Parameterizable::apply at line 121 of MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm, avg 11.7ms/call # 42 times (4.77ms+164ms) by MooseX::Role::Parameterized::Meta::Role::Parameterizable::apply_parameterizable_role at line 127 of MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm, avg 4.01ms/call # 9 times (1.09ms+231ms) by Moose::Util::_apply_all_roles at line 140 of Moose/Util.pm, avg 25.8ms/call
sub apply {
434202423.7ms my ($self, $other, %args) = @_;
435
4361841.16ms (blessed($other))
# spent 1.16ms making 184 calls to Scalar::Util::blessed, avg 6µs/call
437 || Moose->throw_error("You must pass in an blessed instance");
438
439 my $application_class;
4404414.64ms if ($other->isa('Moose::Meta::Role')) {
# spent 1.80ms making 257 calls to UNIVERSAL::isa, avg 7µs/call # spent 1.72ms making 111 calls to Moose::Meta::Role::application_to_role_class, avg 16µs/call # spent 1.11ms making 73 calls to Moose::Meta::Role::application_to_class_class, avg 15µs/call
441 $application_class = $self->application_to_role_class;
442 }
443 elsif ($other->isa('Moose::Meta::Class')) {
444 $application_class = $self->application_to_class_class;
445 }
446 else {
447 $application_class = $self->application_to_instance_class;
448 }
449
45018427.0ms Class::MOP::load_class($application_class);
# spent 42.4ms making 184 calls to Class::MOP::load_class, avg 231µs/call, recursion: max depth 4, sum of overlapping time 15.4ms
451
452 my $deprecation_check = 0;
453
454 if ( exists $args{excludes} && !exists $args{'-excludes'} ) {
455 $args{'-excludes'} = delete $args{excludes};
456 $deprecation_check = 1;
457 }
458 if ( exists $args{alias} && !exists $args{'-alias'} ) {
459 $args{'-alias'} = delete $args{alias};
460 $deprecation_check = 1;
461 }
462
463 if ( $deprecation_check ) {
464 Moose::Deprecated::deprecated(
465 feature => 'alias or excludes',
466 message =>
467 'The alias and excludes options for role application'.
468 ' have been renamed -alias and -excludes'.
469 " (${\$other->name} is consuming ${\$self->name}".
470 " - do you need to upgrade ${\$other->name}?)"
471 );
472 }
473
474 if ( exists $args{'-excludes'} ) {
475 # I wish we had coercion here :)
476 $args{'-excludes'} = (
477 ref $args{'-excludes'} eq 'ARRAY'
478 ? $args{'-excludes'}
479 : [ $args{'-excludes'} ]
480 );
481 }
482
4833683.50s return $application_class->new(%args)->apply($self, $other, \%args);
# spent 1.90s making 111 calls to Moose::Meta::Role::Application::ToRole::apply, avg 17.1ms/call # spent 1.58s making 73 calls to Moose::Meta::Role::Application::ToClass::apply, avg 21.6ms/call # spent 23.3ms making 184 calls to Moose::Meta::Role::Application::new, avg 127µs/call
484}
485
48620224µs
# spent 133µs within Moose::Meta::Role::composition_class_roles which was called 20 times, avg 7µs/call: # 20 times (133µs+0s) by Moose::Meta::Role::Composite::new at line 50 of Moose/Meta/Role/Composite.pm, avg 7µs/call
sub composition_class_roles { }
487
488
# spent 264ms (4.60+259) within Moose::Meta::Role::combine which was called 9 times, avg 29.3ms/call: # 9 times (4.60ms+259ms) by Moose::Util::_apply_all_roles at line 140 of Moose/Util.pm, avg 29.3ms/call
sub combine {
489543.62ms my ($class, @role_specs) = @_;
490
491 require Moose::Meta::Role::Composite;
492
493 my (@roles, %role_params);
494 while (@role_specs) {
4951101.05ms my ($role, $params) = @{ splice @role_specs, 0, 1 };
49620114µs my $requested_role
# spent 114µs making 20 calls to Scalar::Util::blessed, avg 6µs/call
497 = blessed $role
498 ? $role
499 : Class::MOP::class_of($role);
500
50120220µs my $actual_role = $requested_role->_role_for_combination($params);
# spent 220µs making 20 calls to Moose::Meta::Role::_role_for_combination, avg 11µs/call
502 push @roles => $actual_role;
503
504 next unless defined $params;
5051070µs $role_params{$actual_role->name} = $params;
# spent 70µs making 10 calls to Class::MOP::Package::name, avg 7µs/call
506 }
507
50896.15ms my $c = Moose::Meta::Role::Composite->new(roles => \@roles);
# spent 6.15ms making 9 calls to Moose::Meta::Role::Composite::new, avg 683µs/call
5099252ms return $c->apply_params(\%role_params);
# spent 252ms making 9 calls to Moose::Meta::Role::Composite::apply_params, avg 28.0ms/call
510}
511
512
# spent 220µs within Moose::Meta::Role::_role_for_combination which was called 20 times, avg 11µs/call: # 20 times (220µs+0s) by Moose::Meta::Role::combine at line 501, avg 11µs/call
sub _role_for_combination {
51340294µs my ($self, $params) = @_;
514 return $self;
515}
516
517
# spent 394ms (5.44+389) within Moose::Meta::Role::create which was called 42 times, avg 9.38ms/call: # 42 times (5.44ms+389ms) by Moose::Meta::Role::create_anon_role at line 607, avg 9.38ms/call
sub create {
5185465.34ms my ( $role, $package_name, %options ) = @_;
519
520 $options{package} = $package_name;
521
522 (ref $options{attributes} eq 'HASH')
523 || confess "You must pass a HASH ref of attributes"
524 if exists $options{attributes};
525
526 (ref $options{methods} eq 'HASH')
527 || confess "You must pass a HASH ref of methods"
528 if exists $options{methods};
529
530 $options{meta_name} = 'meta'
531 unless exists $options{meta_name};
532
533 my (%initialize_options) = %options;
534 delete @initialize_options{qw(
535 package
536 attributes
537 methods
538 meta_name
539 version
540 authority
541 )};
542
54342268ms my $meta = $role->initialize( $package_name => %initialize_options );
# spent 268ms making 42 calls to Moose::Meta::Role::initialize, avg 6.38ms/call
544
545425.61ms $meta->_instantiate_module( $options{version}, $options{authority} );
# spent 5.61ms making 42 calls to Class::MOP::Module::_instantiate_module, avg 133µs/call
546
54742115ms $meta->_add_meta_method($options{meta_name})
# spent 115ms making 42 calls to Class::MOP::Mixin::HasMethods::_add_meta_method, avg 2.74ms/call
548 if defined $options{meta_name};
549
550 if (exists $options{attributes}) {
551 foreach my $attribute_name (keys %{$options{attributes}}) {
552 my $attr = $options{attributes}->{$attribute_name};
553 $meta->add_attribute(
554 $attribute_name => blessed $attr ? $attr : %{$attr} );
555 }
556 }
557
558 if (exists $options{methods}) {
559 foreach my $method_name (keys %{$options{methods}}) {
560 $meta->add_method($method_name, $options{methods}->{$method_name});
561 }
562 }
563
564 return $meta;
565}
566
567sub consumers {
568 my $self = shift;
569 my @consumers;
570 for my $meta (Class::MOP::get_all_metaclass_instances) {
571 next if $meta->name eq $self->name;
572 next unless $meta->isa('Moose::Meta::Class')
573 || $meta->isa('Moose::Meta::Role');
574 push @consumers, $meta->name
575 if $meta->does_role($self->name);
576 }
577 return @consumers;
578}
579
580# anonymous roles. most of it is copied straight out of Class::MOP::Class.
581# an intrepid hacker might find great riches if he unifies this code with that
582# code in Class::MOP::Module or Class::MOP::Package
583{
584 # NOTE:
585 # this should be sufficient, if you have a
586 # use case where it is not, write a test and
587 # I will change it.
588311µs my $ANON_ROLE_SERIAL = 0;
589
590 # NOTE:
591 # we need a sufficiently annoying prefix
592 # this should suffice for now, this is
593 # used in a couple of places below, so
594 # need to put it up here for now.
595 my $ANON_ROLE_PREFIX = 'Moose::Meta::Role::__ANON__::SERIAL::';
596
597 sub is_anon_role {
598 my $self = shift;
5993457µs2212µs
# spent 135µs (58+77) within Moose::Meta::Role::BEGIN@599 which was called: # once (58µs+77µs) by Moose::BEGIN@27 at line 599
no warnings 'uninitialized';
# spent 135µs making 1 call to Moose::Meta::Role::BEGIN@599 # spent 77µs making 1 call to warnings::unimport
600 $self->name =~ /^$ANON_ROLE_PREFIX/;
601 }
602
603
# spent 396ms (2.05+394) within Moose::Meta::Role::create_anon_role which was called 42 times, avg 9.43ms/call: # 42 times (2.05ms+394ms) by MooseX::Role::Parameterized::Meta::Role::Parameterizable::generate_role at line 85 of MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm, avg 9.43ms/call
sub create_anon_role {
6041681.98ms my ($role, %options) = @_;
605 $options{weaken} = 1 unless exists $options{weaken};
606 my $package_name = $ANON_ROLE_PREFIX . ++$ANON_ROLE_SERIAL;
60742394ms return $role->create($package_name, %options);
# spent 394ms making 42 calls to Moose::Meta::Role::create, avg 9.38ms/call
608 }
609
610 # NOTE:
611 # this will only get called for
612 # anon-roles, all other calls
613 # are assumed to occur during
614 # global destruction and so don't
615 # really need to be handled explicitly
616 sub DESTROY {
617 my $self = shift;
618
619 return if in_global_destruction(); # it'll happen soon anyway and this just makes things more complicated
620
6213229µs2170µs
# spent 110µs (51+59) within Moose::Meta::Role::BEGIN@621 which was called: # once (51µs+59µs) by Moose::BEGIN@27 at line 621
no warnings 'uninitialized';
# spent 110µs making 1 call to Moose::Meta::Role::BEGIN@621 # spent 59µs making 1 call to warnings::unimport
622 return unless $self->name =~ /^$ANON_ROLE_PREFIX/;
623
624 # XXX: is this necessary for us? I don't understand what it's doing
625 # -sartak
626
627 # Moose does a weird thing where it replaces the metaclass for
628 # class when fixing metaclass incompatibility. In that case,
629 # we don't want to clean out the namespace now. We can detect
630 # that because Moose will explicitly update the singleton
631 # cache in Class::MOP.
632 #my $current_meta = Class::MOP::get_metaclass_by_name($self->name);
633 #return if $current_meta ne $self;
634
635 my ($serial_id) = ($self->name =~ /^$ANON_ROLE_PREFIX(\d+)/);
6363551µs2176µs
# spent 112µs (48+64) within Moose::Meta::Role::BEGIN@636 which was called: # once (48µs+64µs) by Moose::BEGIN@27 at line 636
no strict 'refs';
# spent 112µs making 1 call to Moose::Meta::Role::BEGIN@636 # spent 64µs making 1 call to strict::unimport
637 foreach my $key (keys %{$ANON_ROLE_PREFIX . $serial_id}) {
638 delete ${$ANON_ROLE_PREFIX . $serial_id}{$key};
639 }
640 delete ${'main::' . $ANON_ROLE_PREFIX}{$serial_id . '::'};
641 }
642}
643
644#####################################################################
645## NOTE:
646## This is Moose::Meta::Role as defined by Moose (plus the use of
647## MooseX::AttributeHelpers module). It is here as a reference to
648## make it easier to see what is happening above with all the meta
649## programming. - SL
650#####################################################################
651#
652# has 'roles' => (
653# metaclass => 'Array',
654# reader => 'get_roles',
655# isa => 'ArrayRef[Moose::Meta::Role]',
656# default => sub { [] },
657# provides => {
658# 'push' => 'add_role',
659# }
660# );
661#
662# has 'excluded_roles_map' => (
663# metaclass => 'Hash',
664# reader => 'get_excluded_roles_map',
665# isa => 'HashRef[Str]',
666# provides => {
667# # Not exactly set, cause it sets multiple
668# 'set' => 'add_excluded_roles',
669# 'keys' => 'get_excluded_roles_list',
670# 'exists' => 'excludes_role',
671# }
672# );
673#
674# has 'required_methods' => (
675# metaclass => 'Hash',
676# reader => 'get_required_methods_map',
677# isa => 'HashRef[Moose::Meta::Role::Method::Required]',
678# provides => {
679# # not exactly set, or delete since it works for multiple
680# 'set' => 'add_required_methods',
681# 'delete' => 'remove_required_methods',
682# 'keys' => 'get_required_method_list',
683# 'exists' => 'requires_method',
684# }
685# );
686#
687# # the before, around and after modifiers are
688# # HASH keyed by method-name, with ARRAY of
689# # CODE refs to apply in that order
690#
691# has 'before_method_modifiers' => (
692# metaclass => 'Hash',
693# reader => 'get_before_method_modifiers_map',
694# isa => 'HashRef[ArrayRef[CodeRef]]',
695# provides => {
696# 'keys' => 'get_before_method_modifiers',
697# 'exists' => 'has_before_method_modifiers',
698# # This actually makes sure there is an
699# # ARRAY at the given key, and pushed onto
700# # it. It also checks for duplicates as well
701# # 'add' => 'add_before_method_modifier'
702# }
703# );
704#
705# has 'after_method_modifiers' => (
706# metaclass => 'Hash',
707# reader =>'get_after_method_modifiers_map',
708# isa => 'HashRef[ArrayRef[CodeRef]]',
709# provides => {
710# 'keys' => 'get_after_method_modifiers',
711# 'exists' => 'has_after_method_modifiers',
712# # This actually makes sure there is an
713# # ARRAY at the given key, and pushed onto
714# # it. It also checks for duplicates as well
715# # 'add' => 'add_after_method_modifier'
716# }
717# );
718#
719# has 'around_method_modifiers' => (
720# metaclass => 'Hash',
721# reader =>'get_around_method_modifiers_map',
722# isa => 'HashRef[ArrayRef[CodeRef]]',
723# provides => {
724# 'keys' => 'get_around_method_modifiers',
725# 'exists' => 'has_around_method_modifiers',
726# # This actually makes sure there is an
727# # ARRAY at the given key, and pushed onto
728# # it. It also checks for duplicates as well
729# # 'add' => 'add_around_method_modifier'
730# }
731# );
732#
733# # override is similar to the other modifiers
734# # except that it is not an ARRAY of code refs
735# # but instead just a single name->code mapping
736#
737# has 'override_method_modifiers' => (
738# metaclass => 'Hash',
739# reader =>'get_override_method_modifiers_map',
740# isa => 'HashRef[CodeRef]',
741# provides => {
742# 'keys' => 'get_override_method_modifier',
743# 'exists' => 'has_override_method_modifier',
744# 'add' => 'add_override_method_modifier', # checks for local method ..
745# }
746# );
747#
748#####################################################################
749
750
7511131µs1;
752
753__END__
 
# spent 51µs within Moose::Meta::Role::CORE:match which was called 9 times, avg 6µs/call: # 9 times (51µs+0s) by Moose::Meta::Role::add_attribute at line 232, avg 6µs/call
sub Moose::Meta::Role::CORE:match; # opcode