← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:39:01 2010
Reported on Wed Nov 17 22:07:52 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 7831 statements in 109ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
3846312.0ms16.9msMoose::Meta::Role::::get_method_modifier_listMoose::Meta::Role::get_method_modifier_list
72218.82ms1.68sMoose::Meta::Role::::applyMoose::Meta::Role::apply
178337.20ms38.1msMoose::Meta::Role::::add_override_method_modifierMoose::Meta::Role::add_override_method_modifier
32335.29ms12.0msMoose::Meta::Role::::add_required_methodsMoose::Meta::Role::add_required_methods
69114.99ms48.5msMoose::Meta::Role::::initializeMoose::Meta::Role::initialize
191334.90ms6.92msMoose::Meta::Role::::get_override_method_modifierMoose::Meta::Role::get_override_method_modifier
140113.75ms5.31msMoose::Meta::Role::::has_override_method_modifierMoose::Meta::Role::has_override_method_modifier
51113.27ms5.23msMoose::Meta::Role::::add_roleMoose::Meta::Role::add_role
131222.70ms52.8msMoose::Meta::Role::::find_method_by_nameMoose::Meta::Role::find_method_by_name
1112.50ms16.4msMoose::Meta::Role::::BEGIN@17Moose::Meta::Role::BEGIN@17
237612.20ms2.20msMoose::Meta::Role::::__ANON__[:295]Moose::Meta::Role::__ANON__[:295]
10111.72ms273msMoose::Meta::Role::::combineMoose::Meta::Role::combine
158311.58ms1.58msMoose::Meta::Role::::__ANON__[:89]Moose::Meta::Role::__ANON__[:89]
1111.32ms7.76msMoose::Meta::Role::::BEGIN@19Moose::Meta::Role::BEGIN@19
15331.28ms8.05msMoose::Meta::Role::::add_attributeMoose::Meta::Role::add_attribute
1111.23ms6.78msMoose::Meta::Role::::BEGIN@20Moose::Meta::Role::BEGIN@20
111986µs1.59msMoose::Meta::Role::::BEGIN@18Moose::Meta::Role::BEGIN@18
7921820µs820µsMoose::Meta::Role::::__ANON__[:340]Moose::Meta::Role::__ANON__[:340]
6911792µs792µsMoose::Meta::Role::::_meta_method_classMoose::Meta::Role::_meta_method_class
6911690µs690µsMoose::Meta::Role::::__ANON__[:392]Moose::Meta::Role::__ANON__[:392]
5111589µs589µsMoose::Meta::Role::::reset_package_cache_flagMoose::Meta::Role::reset_package_cache_flag
1511457µs1.62msMoose::Meta::Role::::_attach_attributeMoose::Meta::Role::_attach_attribute
422289µs371µsMoose::Meta::Role::::calculate_all_rolesMoose::Meta::Role::calculate_all_roles (recurses: max depth 1, inclusive time 134µs)
2411250µs250µsMoose::Meta::Role::::_role_for_combinationMoose::Meta::Role::_role_for_combination
2411163µs163µsMoose::Meta::Role::::composition_class_rolesMoose::Meta::Role::composition_class_roles
11170µs89µsMoose::Meta::Role::::BEGIN@4Moose::Meta::Role::BEGIN@4
11159µs3.04msMoose::Meta::Role::::BEGIN@6Moose::Meta::Role::BEGIN@6
11158µs137µsMoose::Meta::Role::::BEGIN@599Moose::Meta::Role::BEGIN@599
11145µs107µsMoose::Meta::Role::::BEGIN@621Moose::Meta::Role::BEGIN@621
11142µs203µsMoose::Meta::Role::::BEGIN@8Moose::Meta::Role::BEGIN@8
71141µs41µsMoose::Meta::Role::::CORE:matchMoose::Meta::Role::CORE:match (opcode)
11138µs101µsMoose::Meta::Role::::BEGIN@636Moose::Meta::Role::BEGIN@636
11138µs884µsMoose::Meta::Role::::BEGIN@10Moose::Meta::Role::BEGIN@10
11138µs106µsMoose::Meta::Role::::BEGIN@5Moose::Meta::Role::BEGIN@5
11138µs629µsMoose::Meta::Role::::BEGIN@25Moose::Meta::Role::BEGIN@25
11137µs966µsMoose::Meta::Role::::BEGIN@22Moose::Meta::Role::BEGIN@22
11137µs206µsMoose::Meta::Role::::BEGIN@9Moose::Meta::Role::BEGIN@9
11128µs28µsMoose::Meta::Role::::BEGIN@16Moose::Meta::Role::BEGIN@16
11128µs28µsMoose::Meta::Role::::BEGIN@21Moose::Meta::Role::BEGIN@21
11127µs27µ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::::createMoose::Meta::Role::create
0000s0sMoose::Meta::Role::::create_anon_roleMoose::Meta::Role::create_anon_role
0000s0sMoose::Meta::Role::::does_roleMoose::Meta::Role::does_role
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
4398µs2108µs
# spent 89µs (70+19) within Moose::Meta::Role::BEGIN@4 which was called: # once (70µs+19µs) by Moose::BEGIN@27 at line 4
use strict;
# spent 89µs making 1 call to Moose::Meta::Role::BEGIN@4 # spent 19µs making 1 call to strict::import
5392µs2175µs
# spent 106µs (38+69) within Moose::Meta::Role::BEGIN@5 which was called: # once (38µs+69µs) by Moose::BEGIN@27 at line 5
use warnings;
# spent 106µs making 1 call to Moose::Meta::Role::BEGIN@5 # spent 69µs making 1 call to warnings::import
63154µs26.02ms
# spent 3.04ms (59µs+2.98) within Moose::Meta::Role::BEGIN@6 which was called: # once (59µs+2.98ms) by Moose::BEGIN@27 at line 6
use metaclass;
# spent 3.04ms making 1 call to Moose::Meta::Role::BEGIN@6 # spent 2.98ms making 1 call to metaclass::import
7
83108µs2363µs
# spent 203µs (42+161) within Moose::Meta::Role::BEGIN@8 which was called: # once (42µs+161µs) by Moose::BEGIN@27 at line 8
use Scalar::Util 'blessed';
# spent 203µs making 1 call to Moose::Meta::Role::BEGIN@8 # spent 161µs making 1 call to Exporter::import
93106µs2376µs
# spent 206µs (37+169) within Moose::Meta::Role::BEGIN@9 which was called: # once (37µs+169µs) by Moose::BEGIN@27 at line 9
use Carp 'confess';
# spent 206µs making 1 call to Moose::Meta::Role::BEGIN@9 # spent 169µs making 1 call to Exporter::import
103243µs21.73ms
# spent 884µs (38+846) within Moose::Meta::Role::BEGIN@10 which was called: # once (38µs+846µs) by Moose::BEGIN@27 at line 10
use Devel::GlobalDestruction 'in_global_destruction';
# spent 884µs making 1 call to Moose::Meta::Role::BEGIN@10 # spent 846µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
11
1215µsour $VERSION = '1.19';
13178µs$VERSION = eval $VERSION;
# spent 11µs executing statements in string eval
1413µsour $AUTHORITY = 'cpan:STEVAN';
15
16392µ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
173506µs116.4ms
# spent 16.4ms (2.50+13.9) within Moose::Meta::Role::BEGIN@17 which was called: # once (2.50ms+13.9ms) by Moose::BEGIN@27 at line 17
use Moose::Meta::Role::Attribute;
# spent 16.4ms making 1 call to Moose::Meta::Role::BEGIN@17
183506µs11.59ms
# spent 1.59ms (986µs+608µs) within Moose::Meta::Role::BEGIN@18 which was called: # once (986µs+608µs) by Moose::BEGIN@27 at line 18
use Moose::Meta::Role::Method;
# spent 1.59ms making 1 call to Moose::Meta::Role::BEGIN@18
193471µs17.76ms
# spent 7.76ms (1.32+6.44) within Moose::Meta::Role::BEGIN@19 which was called: # once (1.32ms+6.44ms) by Moose::BEGIN@27 at line 19
use Moose::Meta::Role::Method::Required;
# spent 7.76ms making 1 call to Moose::Meta::Role::BEGIN@19
203508µs16.78ms
# spent 6.78ms (1.23+5.55) within Moose::Meta::Role::BEGIN@20 which was called: # once (1.23ms+5.55ms) by Moose::BEGIN@27 at line 20
use Moose::Meta::Role::Method::Conflicting;
# spent 6.78ms making 1 call to Moose::Meta::Role::BEGIN@20
213100µs128µs
# spent 28µs within Moose::Meta::Role::BEGIN@21 which was called: # once (28µs+0s) by Moose::BEGIN@27 at line 21
use Moose::Meta::Method::Meta;
# spent 28µs making 1 call to Moose::Meta::Role::BEGIN@21
223143µs21.90ms
# spent 966µs (37+929) within Moose::Meta::Role::BEGIN@22 which was called: # once (37µs+929µs) by Moose::BEGIN@27 at line 22
use Moose::Util qw( ensure_all_roles );
# spent 966µs making 1 call to Moose::Meta::Role::BEGIN@22 # spent 929µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
233113µs127µs
# spent 27µs within Moose::Meta::Role::BEGIN@23 which was called: # once (27µs+0s) by Moose::BEGIN@27 at line 23
use Class::MOP::MiniTrait;
# spent 27µs making 1 call to Moose::Meta::Role::BEGIN@23
24
25125µs1591µs
# spent 629µs (38+591) within Moose::Meta::Role::BEGIN@25 which was called: # once (38µs+591µs) by Moose::BEGIN@27 at line 27
use base 'Class::MOP::Module',
# spent 591µs making 1 call to base::import
26 'Class::MOP::Mixin::HasAttributes',
2728.51ms1629µs 'Class::MOP::Mixin::HasMethods';
# spent 629µs making 1 call to Moose::Meta::Role::BEGIN@25
28
29115µs18.76msClass::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait');
# spent 8.76ms 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µs192µsmy $META = __PACKAGE__->meta;
# spent 92µ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
62168µ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
83212µs my $attr_reader = $action->{attr_reader};
8426µs my $methods = $action->{methods};
85
86 # create the attribute
87 $META->add_attribute($action->{name} => (
88 reader => $attr_reader,
891582.16ms
# spent 1.58ms 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 158 times, avg 10µs/call: # 79 times (851µs+0s) by Moose::Meta::Role::Composite::_new or Moose::Meta::Role::_new at line 11 of (eval 74)[Class/MOP/Method/Generated.pm:53], avg 11µs/call # 69 times (645µs+0s) by Moose::Meta::Role::_new at line 88 of (eval 74)[Class/MOP/Method/Generated.pm:53], avg 9µs/call # 10 times (83µs+0s) by Moose::Meta::Role::Composite::_new at line 96 of (eval 74)[Class/MOP/Method/Generated.pm:53], avg 8µs/call
default => sub { {} }
902352µs24.87ms ));
# spent 4.87ms making 2 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 2.43ms/call
91
92 # create some helper methods
93 $META->add_method($methods->{add} => sub {
941040µs my ($self, @values) = @_;
9520184µs $self->$attr_reader->{$_} = undef foreach @values;
96232µs1353µs }) if exists $methods->{add};
# spent 353µs making 1 call to Class::MOP::Mixin::HasMethods::add_method
97
98 $META->add_method($methods->{get_keys} => sub {
9996309µs my ($self) = @_;
100962.10ms961.11ms keys %{$self->$attr_reader};
# spent 1.11ms making 96 calls to Moose::Meta::Role::get_excluded_roles_map, avg 12µs/call
101257µs1337µs }) if exists $methods->{get_keys};
# spent 337µs making 1 call to Class::MOP::Mixin::HasMethods::add_method
102
103 $META->add_method($methods->{get_values} => sub {
10496283µs my ($self) = @_;
105962.32ms961.15ms values %{$self->$attr_reader};
# spent 1.15ms making 96 calls to Moose::Meta::Role::get_required_methods_map, avg 12µs/call
106229µs1337µs }) if exists $methods->{get_values};
# spent 337µ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}
11126µs }) if exists $methods->{get};
112
113 $META->add_method($methods->{existence} => sub {
11451234µs my ($self, $name) = @_;
115511.27ms51730µs exists $self->$attr_reader->{$name} ? 1 : 0;
# spent 730µs making 51 calls to Moose::Meta::Role::get_excluded_roles_map, avg 14µs/call
116253µs2769µs }) if exists $methods->{existence};
# spent 769µs making 2 calls to Class::MOP::Mixin::HasMethods::add_method, avg 384µs/call
117
118 $META->add_method($methods->{remove} => sub {
119 my ($self, @values) = @_;
120 delete $self->$attr_reader->{$_} foreach @values;
121253µs1390µs }) if exists $methods->{remove};
# spent 390µ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
130115µs12.07ms$META->add_attribute(
# spent 2.07ms 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
136113µs12.11ms$META->add_attribute(
# spent 2.11ms 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
142113µs12.10ms$META->add_attribute(
# spent 2.10ms 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.04ms$META->add_attribute(
# spent 2.04ms 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µs12.00ms$META->add_attribute(
# spent 2.00ms 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 48.5ms (4.99+43.5) within Moose::Meta::Role::initialize which was called 69 times, avg 702µs/call: # 69 times (4.99ms+43.5ms) by Moose::Role::init_meta at line 131 of Moose/Role.pm, avg 702µs/call
sub initialize {
16269259µs my $class = shift;
16369213µs my $pkg = shift;
164
16569693µs69575µs if (defined(my $meta = Class::MOP::get_metaclass_by_name($pkg))) {
# spent 575µs making 69 calls to Class::MOP::get_metaclass_by_name, avg 8µs/call
166 return $meta;
167 }
168
16969297µs my %options = @_;
170
171692.25ms6942.9ms my $meta = $class->SUPER::initialize(
# spent 42.9ms making 69 calls to Class::MOP::Package::initialize, avg 622µs/call
172 $pkg,
173 'attribute_metaclass' => 'Moose::Meta::Role::Attribute',
174 %options,
175 );
176
17769205µs Class::MOP::weaken_metaclass($pkg) if $options{weaken};
178
17969934µs 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 8.05ms (1.28+6.77) within Moose::Meta::Role::add_attribute which was called 15 times, avg 537µs/call: # 7 times (745µs+3.89ms) by Moose::Role::has at line 47 of Moose/Role.pm, avg 662µs/call # 6 times (396µs+2.15ms) by Moose::Meta::Role::Application::ToRole::apply_attributes at line 71 of Moose/Meta/Role/Application/ToRole.pm, avg 424µs/call # 2 times (140µs+732µs) by Moose::Meta::Role::Application::RoleSummation::apply_attributes at line 148 of Moose/Meta/Role/Application/RoleSummation.pm, avg 436µs/call
sub add_attribute {
2301544µs my $self = shift;
231
23215759µs45242µs if (blessed $_[0] && ! $_[0]->isa('Moose::Meta::Role::Attribute') ) {
# spent 151µs making 30 calls to Scalar::Util::blessed, avg 5µs/call # spent 50µs making 8 calls to UNIVERSAL::isa, avg 6µs/call # spent 41µs making 7 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
24015728µs156.53ms return $self->SUPER::add_attribute(@_);
# spent 6.53ms making 15 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 435µs/call
241}
242
243
# spent 1.62ms (457µs+1.17) within Moose::Meta::Role::_attach_attribute which was called 15 times, avg 108µs/call: # 15 times (457µs+1.17ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 28 of Class/MOP/Mixin/HasAttributes.pm, avg 108µs/call
sub _attach_attribute {
2441555µs my ( $self, $attribute ) = @_;
245
24615277µs151.17ms $attribute->attach_to_role($self);
# spent 1.17ms making 15 calls to Moose::Meta::Role::Attribute::attach_to_role, avg 78µs/call
247}
248
249
# spent 12.0ms (5.29+6.69) within Moose::Meta::Role::add_required_methods which was called 32 times, avg 375µs/call: # 15 times (4.00ms+6.01ms) by Moose::Role::requires at line 32 of Moose/Role.pm, avg 667µs/call # 10 times (882µs+482µs) by Moose::Meta::Role::Application::RoleSummation::check_required_methods at line 109 of Moose/Meta/Role/Application/RoleSummation.pm, avg 136µs/call # 7 times (412µs+204µs) by Moose::Meta::Role::Application::ToRole::check_required_methods at line 43 of Moose/Meta/Role/Application/ToRole.pm, avg 88µs/call
sub add_required_methods {
2503298µs my $self = shift;
251
25232506µs for (@_) {
25373214µs my $method = $_;
254732.20ms1754.88ms if (!blessed($method)) {
# spent 3.82ms making 51 calls to Moose::Meta::Role::Method::Required::new, avg 75µs/call # spent 682µs making 51 calls to Moose::Meta::Role::required_method_metaclass, avg 13µs/call # spent 382µs making 73 calls to Scalar::Util::blessed, avg 5µs/call
255 $method = $self->required_method_metaclass->new(
256 name => $method,
257 );
258 }
259732.00ms1461.81ms $self->get_required_methods_map->{$method->name} = $method;
# spent 916µs making 73 calls to Moose::Meta::Role::Method::Required::name, avg 13µs/call # spent 895µs making 73 calls to Moose::Meta::Role::get_required_methods_map, avg 12µ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
290319µ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,
2952372.91ms
# spent 2.20ms 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 237 times, avg 9µs/call: # 69 times (695µs+0s) by Moose::Meta::Role::_new at line 31 of (eval 74)[Class/MOP/Method/Generated.pm:53], avg 10µs/call # 69 times (636µs+0s) by Moose::Meta::Role::_new at line 55 of (eval 74)[Class/MOP/Method/Generated.pm:53], avg 9µs/call # 69 times (608µs+0s) by Moose::Meta::Role::_new at line 60 of (eval 74)[Class/MOP/Method/Generated.pm:53], avg 9µs/call # 10 times (95µs+0s) by Moose::Meta::Role::Composite::_new at line 36 of (eval 74)[Class/MOP/Method/Generated.pm:53], avg 10µs/call # 10 times (86µs+0s) by Moose::Meta::Role::Composite::_new at line 63 of (eval 74)[Class/MOP/Method/Generated.pm:53], avg 9µs/call # 10 times (83µs+0s) by Moose::Meta::Role::Composite::_new at line 68 of (eval 74)[Class/MOP/Method/Generated.pm:53], avg 8µs/call
default => sub { {} }
296361µs36.36ms ));
# spent 6.36ms 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 {
3002491.01ms my ($self, $method_name) = @_;
301 #return () unless exists $self->$attr_reader->{$method_name};
3022492.84ms2492.50ms my $mm = $self->$attr_reader->{$method_name};
# spent 2.37ms making 237 calls to Moose::Meta::Role::get_around_method_modifiers_map, avg 10µs/call # spent 85µs making 8 calls to Moose::Meta::Role::get_before_method_modifiers_map, avg 11µs/call # spent 41µs making 4 calls to Moose::Meta::Role::get_after_method_modifiers_map, avg 10µs/call
3032493.36ms $mm ? @$mm : ();
304384µs31.09ms });
# spent 1.09ms making 3 calls to Class::MOP::Mixin::HasMethods::add_method, avg 362µ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;
312378µs31.01ms });
# spent 1.01ms making 3 calls to Class::MOP::Mixin::HasMethods::add_method, avg 336µs/call
313
314 $META->add_method("add_${modifier_type}_method_modifier" => sub {
315239975µs my ($self, $method_name, $method) = @_;
316
3172395.60ms4674.85ms $self->$attr_reader->{$method_name} = []
# spent 4.65ms making 449 calls to Moose::Meta::Role::get_around_method_modifiers_map, avg 10µs/call # spent 132µs making 12 calls to Moose::Meta::Role::get_before_method_modifiers_map, avg 11µs/call # spent 65µs making 6 calls to Moose::Meta::Role::get_after_method_modifiers_map, avg 11µs/call
318 unless exists $self->$attr_reader->{$method_name};
319
3202392.75ms2392.57ms my $modifiers = $self->$attr_reader->{$method_name};
# spent 2.48ms making 230 calls to Moose::Meta::Role::get_around_method_modifiers_map, avg 11µs/call # spent 65µs making 6 calls to Moose::Meta::Role::get_before_method_modifiers_map, avg 11µs/call # spent 31µs making 3 calls to Moose::Meta::Role::get_after_method_modifiers_map, avg 10µ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
3262391.21ms foreach my $modifier (@{$modifiers}) {
3271198µs return if $modifier == $method;
328 }
329
3302353.43ms push @{$modifiers} => $method;
331394µs31.02ms });
# spent 1.02ms making 3 calls to Class::MOP::Mixin::HasMethods::add_method, avg 340µ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',
340791.09ms
# spent 820µs 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 79 times, avg 10µs/call: # 69 times (705µs+0s) by Moose::Meta::Role::_new at line 73 of (eval 74)[Class/MOP/Method/Generated.pm:53], avg 10µs/call # 10 times (116µs+0s) by Moose::Meta::Role::Composite::_new at line 81 of (eval 74)[Class/MOP/Method/Generated.pm:53], avg 12µs/call
default => sub { {} }
341119µs12.14ms));
# spent 2.14ms 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 38.1ms (7.20+30.9) within Moose::Meta::Role::add_override_method_modifier which was called 178 times, avg 214µs/call: # 140 times (5.65ms+28.1ms) by Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers at line 163 of Moose/Meta/Role/Application/ToRole.pm, avg 241µs/call # 34 times (1.36ms+1.54ms) by Moose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers at line 237 of Moose/Meta/Role/Application/RoleSummation.pm, avg 85µs/call # 4 times (198µs+1.23ms) by Moose::Role::override at line 77 of Moose/Role.pm, avg 356µs/call
sub add_override_method_modifier {
350178701µs my ($self, $method_name, $method) = @_;
3511781.76ms17828.9ms (!$self->has_method($method_name))
# spent 27.7ms making 144 calls to Class::MOP::Mixin::HasMethods::has_method, avg 192µs/call # spent 1.16ms making 34 calls to Moose::Meta::Role::Composite::has_method, avg 34µs/call
352 || Moose->throw_error("Cannot add an override of method '$method_name' " .
353 "because there is a local version of '$method_name'");
3541783.91ms1782.02ms $self->get_override_method_modifiers_map->{$method_name} = $method;
# spent 2.02ms making 178 calls to Moose::Meta::Role::get_override_method_modifiers_map, avg 11µs/call
355}
356
357
# spent 5.31ms (3.75+1.55) within Moose::Meta::Role::has_override_method_modifier which was called 140 times, avg 38µs/call: # 140 times (3.75ms+1.55ms) by Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers at line 152 of Moose/Meta/Role/Application/ToRole.pm, avg 38µs/call
sub has_override_method_modifier {
358140555µs my ($self, $method_name) = @_;
359 # NOTE:
360 # for now we assume that if it exists,..
361 # it has at least one modifier in it
3621402.86ms1401.55ms (exists $self->get_override_method_modifiers_map->{$method_name}) ? 1 : 0;
# spent 1.55ms making 140 calls to Moose::Meta::Role::get_override_method_modifiers_map, avg 11µs/call
363}
364
365
# spent 6.92ms (4.90+2.02) within Moose::Meta::Role::get_override_method_modifier which was called 191 times, avg 36µs/call: # 140 times (3.56ms+1.45ms) by Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers at line 163 of Moose/Meta/Role/Application/ToRole.pm, avg 36µs/call # 34 times (838µs+346µs) by Moose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers at line 208 of Moose/Meta/Role/Application/RoleSummation.pm, avg 35µs/call # 17 times (501µs+222µ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
sub get_override_method_modifier {
366191735µs my ($self, $method_name) = @_;
3671913.89ms1912.02ms $self->get_override_method_modifiers_map->{$method_name};
# spent 2.02ms making 191 calls to Moose::Meta::Role::get_override_method_modifiers_map, avg 11µs/call
368}
369
370## general list accessor ...
371
372
# spent 16.9ms (12.0+4.84) within Moose::Meta::Role::get_method_modifier_list which was called 384 times, avg 44µs/call: # 153 times (4.64ms+1.84ms) by Moose::Meta::Role::Application::ToRole::apply_method_modifiers at line 176 of Moose/Meta/Role/Application/ToRole.pm, avg 42µs/call # 72 times (2.12ms+807µs) by Moose::Meta::Role::Application::RoleSummation::apply_method_modifiers at line 246 of Moose/Meta/Role/Application/RoleSummation.pm, avg 41µs/call # 63 times (1.88ms+837µs) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 217 of Moose/Meta/Role/Application/ToClass.pm, avg 43µs/call # 51 times (1.89ms+749µs) by Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers at line 136 of Moose/Meta/Role/Application/ToRole.pm, avg 52µs/call # 24 times (796µs+335µ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 # 21 times (710µs+272µs) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 195 of Moose/Meta/Role/Application/ToClass.pm, avg 47µs/call
sub get_method_modifier_list {
3733841.21ms my ($self, $modifier_type) = @_;
3743841.31ms my $accessor = "get_${modifier_type}_method_modifiers_map";
3753849.36ms3844.84ms keys %{$self->$accessor};
# spent 1.36ms making 96 calls to Moose::Meta::Role::get_override_method_modifiers_map, avg 14µs/call # spent 1.17ms making 96 calls to Moose::Meta::Role::get_around_method_modifiers_map, avg 12µs/call # spent 1.16ms making 96 calls to Moose::Meta::Role::get_before_method_modifiers_map, avg 12µs/call # spent 1.15ms making 96 calls to Moose::Meta::Role::get_after_method_modifiers_map, avg 12µs/call
376}
377
37851748µs
# spent 589µs within Moose::Meta::Role::reset_package_cache_flag which was called 51 times, avg 12µs/call: # 51 times (589µs+0s) by Moose::Meta::Role::add_role at line 400, avg 12µ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
38569936µs
# spent 792µs within Moose::Meta::Role::_meta_method_class which was called 69 times, avg 11µs/call: # 69 times (792µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 30 of Class/MOP/Mixin/HasMethods.pm, avg 11µs/call
sub _meta_method_class { 'Moose::Meta::Method::Meta' }
386
387## ------------------------------------------------------------------
388## subroles
389
390$META->add_attribute('roles' => (
391 reader => 'get_roles',
39269911µs
# spent 690µs 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 69 times, avg 10µs/call: # 69 times (690µs+0s) by Moose::Meta::Role::_new at line 36 of (eval 74)[Class/MOP/Method/Generated.pm:53], avg 10µs/call
default => sub { [] }
393121µs12.04ms));
# spent 2.04ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
394
395
# spent 5.23ms (3.27+1.96) within Moose::Meta::Role::add_role which was called 51 times, avg 103µs/call: # 51 times (3.27ms+1.96ms) by Moose::Meta::Role::Application::ToRole::apply at line 18 of Moose/Meta/Role/Application/ToRole.pm, avg 103µs/call
sub add_role {
39651178µs my ($self, $role) = @_;
397511.89ms102729µs (blessed($role) && $role->isa('Moose::Meta::Role'))
# spent 372µs making 51 calls to Scalar::Util::blessed, avg 7µs/call # spent 357µs making 51 calls to UNIVERSAL::isa, avg 7µs/call
398 || Moose->throw_error("Roles must be instances of Moose::Meta::Role");
39951692µs51642µs push @{$self->get_roles} => $role;
# spent 642µs making 51 calls to Moose::Meta::Role::get_roles, avg 13µs/call
400511.01ms51589µs $self->reset_package_cache_flag;
# spent 589µs making 51 calls to Moose::Meta::Role::reset_package_cache_flag, avg 12µs/call
401}
402
403
# spent 371µs (289+82) within Moose::Meta::Role::calculate_all_roles which was called 4 times, avg 93µs/call: # 2 times (189µs+182µs) by Moose::Meta::Class::calculate_all_roles at line 200 of Moose/Meta/Class.pm, avg 185µs/call # 2 times (100µs+-100µs) by Moose::Meta::Role::calculate_all_roles at line 407, avg 0s/call
sub calculate_all_roles {
404411µs my $self = shift;
40547µs my %seen;
4066145µs639µs grep {
# spent 39µs making 6 calls to Class::MOP::Package::name, avg 6µs/call
407225µs20s !$seen{$_->name}++
# spent 134µs making 2 calls to Moose::Meta::Role::calculate_all_roles, avg 67µs/call, recursion: max depth 1, sum of overlapping time 134µs
408 } ($self, map {
409 $_->calculate_all_roles
4104128µs443µs } @{ $self->get_roles });
# spent 43µs making 4 calls to Moose::Meta::Role::get_roles, avg 11µs/call
411}
412
413sub does_role {
414 my ($self, $role) = @_;
415 (defined $role)
416 || Moose->throw_error("You must supply a role name to look for");
417 my $role_name = blessed $role ? $role->name : $role;
418 # if we are it,.. then return true
419 return 1 if $role_name eq $self->name;
420 # otherwise.. check our children
421 foreach my $role (@{$self->get_roles}) {
422 return 1 if $role->does_role($role_name);
423 }
424 return 0;
425}
426
4271312.61ms13150.1ms
# spent 52.8ms (2.70+50.1) within Moose::Meta::Role::find_method_by_name which was called 131 times, avg 403µs/call: # 69 times (1.38ms+13.5ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 25 of Class/MOP/Mixin/HasMethods.pm, avg 216µs/call # 62 times (1.32ms+36.6ms) by Moose::Meta::Role::Application::ToRole::check_required_methods at line 43 of Moose/Meta/Role/Application/ToRole.pm, avg 611µs/call
sub find_method_by_name { (shift)->get_method(@_) }
# spent 50.1ms making 131 calls to Class::MOP::Mixin::HasMethods::get_method, avg 382µs/call
428
429## ------------------------------------------------------------------
430## role construction
431## ------------------------------------------------------------------
432
433
# spent 1.68s (8.82ms+1.67) within Moose::Meta::Role::apply which was called 72 times, avg 23.3ms/call: # 62 times (7.63ms+1.42s) by Moose::Util::_apply_all_roles at line 137 of Moose/Util.pm, avg 23.1ms/call # 10 times (1.19ms+245ms) by Moose::Util::_apply_all_roles at line 140 of Moose/Util.pm, avg 24.6ms/call
sub apply {
43472436µs my ($self, $other, %args) = @_;
435
436721.27ms72429µs (blessed($other))
# spent 429µs making 72 calls to Scalar::Util::blessed, avg 6µs/call
437 || Moose->throw_error("You must pass in an blessed instance");
438
43972145µs my $application_class;
440722.61ms1651.72ms if ($other->isa('Moose::Meta::Role')) {
# spent 766µs making 51 calls to Moose::Meta::Role::application_to_role_class, avg 15µs/call # spent 614µs making 93 calls to UNIVERSAL::isa, avg 7µs/call # spent 336µs making 21 calls to Moose::Meta::Role::application_to_class_class, avg 16µ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
45072758µs724.16ms Class::MOP::load_class($application_class);
# spent 16.3ms making 72 calls to Class::MOP::load_class, avg 227µs/call, recursion: max depth 4, sum of overlapping time 12.2ms
451
45272183µs my $deprecation_check = 0;
453
45472229µs if ( exists $args{excludes} && !exists $args{'-excludes'} ) {
455 $args{'-excludes'} = delete $args{excludes};
456 $deprecation_check = 1;
457 }
45872191µs if ( exists $args{alias} && !exists $args{'-alias'} ) {
459 $args{'-alias'} = delete $args{alias};
460 $deprecation_check = 1;
461 }
462
46372137µs 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
47472415µs 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
483724.84ms1441.65s return $application_class->new(%args)->apply($self, $other, \%args);
# spent 1.19s making 51 calls to Moose::Meta::Role::Application::ToRole::apply, avg 23.4ms/call # spent 449ms making 21 calls to Moose::Meta::Role::Application::ToClass::apply, avg 21.4ms/call # spent 8.75ms making 72 calls to Moose::Meta::Role::Application::new, avg 122µs/call
484}
485
48624244µs
# spent 163µs within Moose::Meta::Role::composition_class_roles which was called 24 times, avg 7µs/call: # 24 times (163µ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 273ms (1.72+271) within Moose::Meta::Role::combine which was called 10 times, avg 27.3ms/call: # 10 times (1.72ms+271ms) by Moose::Util::_apply_all_roles at line 140 of Moose/Util.pm, avg 27.3ms/call
sub combine {
4891055µs my ($class, @role_specs) = @_;
490
4911040µs require Moose::Meta::Role::Composite;
492
4931027µs my (@roles, %role_params);
4941080µs while (@role_specs) {
49524109µs my ($role, $params) = @{ splice @role_specs, 0, 1 };
49624410µs24137µs my $requested_role
# spent 137µs making 24 calls to Scalar::Util::blessed, avg 6µs/call
497 = blessed $role
498 ? $role
499 : Class::MOP::class_of($role);
500
50124242µs24250µs my $actual_role = $requested_role->_role_for_combination($params);
# spent 250µs making 24 calls to Moose::Meta::Role::_role_for_combination, avg 10µs/call
5022471µs push @roles => $actual_role;
503
5042469µs next unless defined $params;
5059247µs966µs $role_params{$actual_role->name} = $params;
# spent 66µs making 9 calls to Class::MOP::Package::name, avg 7µs/call
506 }
507
50810178µs107.15ms my $c = Moose::Meta::Role::Composite->new(roles => \@roles);
# spent 7.15ms making 10 calls to Moose::Meta::Role::Composite::new, avg 715µs/call
50910251µs10263ms return $c->apply_params(\%role_params);
# spent 263ms making 10 calls to Moose::Meta::Role::Composite::apply_params, avg 26.3ms/call
510}
511
512
# spent 250µs within Moose::Meta::Role::_role_for_combination which was called 24 times, avg 10µs/call: # 24 times (250µs+0s) by Moose::Meta::Role::combine at line 501, avg 10µs/call
sub _role_for_combination {
5132470µs my ($self, $params) = @_;
51424301µs return $self;
515}
516
517sub create {
518 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
543 my $meta = $role->initialize( $package_name => %initialize_options );
544
545 $meta->_instantiate_module( $options{version}, $options{authority} );
546
547 $meta->_add_meta_method($options{meta_name})
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.
58827µ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.
59514µs my $ANON_ROLE_PREFIX = 'Moose::Meta::Role::__ANON__::SERIAL::';
596
597 sub is_anon_role {
598 my $self = shift;
5993478µs2215µs
# spent 137µs (58+79) within Moose::Meta::Role::BEGIN@599 which was called: # once (58µs+79µs) by Moose::BEGIN@27 at line 599
no warnings 'uninitialized';
# spent 137µs making 1 call to Moose::Meta::Role::BEGIN@599 # spent 79µs making 1 call to warnings::unimport
600 $self->name =~ /^$ANON_ROLE_PREFIX/;
601 }
602
603 sub create_anon_role {
604 my ($role, %options) = @_;
605 $options{weaken} = 1 unless exists $options{weaken};
606 my $package_name = $ANON_ROLE_PREFIX . ++$ANON_ROLE_SERIAL;
607 return $role->create($package_name, %options);
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
6213227µs2168µs
# spent 107µs (45+62) within Moose::Meta::Role::BEGIN@621 which was called: # once (45µs+62µs) by Moose::BEGIN@27 at line 621
no warnings 'uninitialized';
# spent 107µs making 1 call to Moose::Meta::Role::BEGIN@621 # spent 62µ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+)/);
6363523µs2164µs
# spent 101µs (38+63) within Moose::Meta::Role::BEGIN@636 which was called: # once (38µs+63µs) by Moose::BEGIN@27 at line 636
no strict 'refs';
# spent 101µs making 1 call to Moose::Meta::Role::BEGIN@636 # spent 63µ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
7511129µs1;
752
753__END__
 
# spent 41µs within Moose::Meta::Role::CORE:match which was called 7 times, avg 6µs/call: # 7 times (41µs+0s) by Moose::Meta::Role::add_attribute at line 232, avg 6µs/call
sub Moose::Meta::Role::CORE:match; # opcode