← 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:04:51 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Class.pm
StatementsExecuted 4239 statements in 87.6ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1967314.2ms241msMoose::Meta::Class::::superclassesMoose::Meta::Class::superclasses (recurses: max depth 1, inclusive time 18.0ms)
1232212.6ms4.18sMoose::Meta::Class::::add_attributeMoose::Meta::Class::add_attribute (recurses: max depth 1, inclusive time 31.4ms)
732110.7ms16.0msMoose::Meta::Class::::_base_metaclassesMoose::Meta::Class::_base_metaclasses
1118.81ms12.6msMoose::Meta::Class::::BEGIN@26Moose::Meta::Class::BEGIN@26
1116.20ms7.21msMoose::Meta::Class::::BEGIN@23Moose::Meta::Class::BEGIN@23
114116.12ms2.85sMoose::Meta::Class::::_process_new_attributeMoose::Meta::Class::_process_new_attribute
116115.84ms2.88sMoose::Meta::Class::::_process_attributeMoose::Meta::Class::_process_attribute
21114.98ms32.1msMoose::Meta::Class::::excludes_roleMoose::Meta::Class::excludes_role
438114.00ms4.00msMoose::Meta::Class::::CORE:substMoose::Meta::Class::CORE:subst (opcode)
1112.66ms3.61msMoose::Meta::Class::::BEGIN@24Moose::Meta::Class::BEGIN@24
6222.63ms31.8msMoose::Meta::Class::::new_objectMoose::Meta::Class::new_object
34331.90ms146msMoose::Meta::Class::::initializeMoose::Meta::Class::initialize
1111.60ms15.6msMoose::Meta::Class::::BEGIN@21Moose::Meta::Class::BEGIN@21
1111.59ms2.67msMoose::Meta::Class::::BEGIN@22Moose::Meta::Class::BEGIN@22
1111.41ms1.93msMoose::Meta::Class::::BEGIN@20Moose::Meta::Class::BEGIN@20
1111.34ms16.2msMoose::Meta::Class::::BEGIN@19Moose::Meta::Class::BEGIN@19
21111.23ms1.83msMoose::Meta::Class::::add_roleMoose::Meta::Class::add_role
15221.22ms448msMoose::Meta::Class::::create_anon_classMoose::Meta::Class::create_anon_class
1111.20ms1.86msMoose::Meta::Class::::BEGIN@25Moose::Meta::Class::BEGIN@25
24111.02ms4.34msMoose::Meta::Class::::_immutable_optionsMoose::Meta::Class::_immutable_options
2111974µs1.48msMoose::Meta::Class::::add_role_applicationMoose::Meta::Class::add_role_application
1711944µs27.4msMoose::Meta::Class::::add_override_method_modifierMoose::Meta::Class::add_override_method_modifier
11611677µs677µsMoose::Meta::Class::::CORE:matchMoose::Meta::Class::CORE:match (opcode)
811654µs446msMoose::Meta::Class::::createMoose::Meta::Class::create
1511405µs465µsMoose::Meta::Class::::_anon_cache_keyMoose::Meta::Class::_anon_cache_key
3411385µs385µsMoose::Meta::Class::::__ANON__[:40]Moose::Meta::Class::__ANON__[:40]
3411377µs377µsMoose::Meta::Class::::__ANON__[:35]Moose::Meta::Class::__ANON__[:35]
3411364µs364µsMoose::Meta::Class::::_meta_method_classMoose::Meta::Class::_meta_method_class
211184µs19.4msMoose::Meta::Class::::_process_inherited_attributeMoose::Meta::Class::_process_inherited_attribute
211169µs584µsMoose::Meta::Class::::calculate_all_rolesMoose::Meta::Class::calculate_all_roles
11167µs85µsMoose::Meta::Class::::BEGIN@4Moose::Meta::Class::BEGIN@4
151159µs59µsMoose::Meta::Class::::CORE:sortMoose::Meta::Class::CORE:sort (opcode)
11152µs180µsMoose::Meta::Class::::BEGIN@11Moose::Meta::Class::BEGIN@11
11139µs108µsMoose::Meta::Class::::BEGIN@5Moose::Meta::Class::BEGIN@5
11138µs60µsMoose::Meta::Class::::BEGIN@10Moose::Meta::Class::BEGIN@10
11137µs301µsMoose::Meta::Class::::BEGIN@29Moose::Meta::Class::BEGIN@29
11136µs190µsMoose::Meta::Class::::BEGIN@13Moose::Meta::Class::BEGIN@13
11135µs241µsMoose::Meta::Class::::BEGIN@12Moose::Meta::Class::BEGIN@12
11135µs198µsMoose::Meta::Class::::BEGIN@9Moose::Meta::Class::BEGIN@9
11129µs29µsMoose::Meta::Class::::BEGIN@27Moose::Meta::Class::BEGIN@27
11125µs25µsMoose::Meta::Class::::BEGIN@7Moose::Meta::Class::BEGIN@7
0000s0sMoose::Meta::Class::::_find_next_method_by_name_which_is_not_overriddenMoose::Meta::Class::_find_next_method_by_name_which_is_not_overridden
0000s0sMoose::Meta::Class::::_fix_class_metaclass_incompatibilityMoose::Meta::Class::_fix_class_metaclass_incompatibility
0000s0sMoose::Meta::Class::::_fix_single_metaclass_incompatibilityMoose::Meta::Class::_fix_single_metaclass_incompatibility
0000s0sMoose::Meta::Class::::_replace_selfMoose::Meta::Class::_replace_self
0000s0sMoose::Meta::Class::::add_augment_method_modifierMoose::Meta::Class::add_augment_method_modifier
0000s0sMoose::Meta::Class::::calculate_all_roles_with_inheritanceMoose::Meta::Class::calculate_all_roles_with_inheritance
0000s0sMoose::Meta::Class::::create_errorMoose::Meta::Class::create_error
0000s0sMoose::Meta::Class::::does_roleMoose::Meta::Class::does_role
0000s0sMoose::Meta::Class::::raise_errorMoose::Meta::Class::raise_error
0000s0sMoose::Meta::Class::::reinitializeMoose::Meta::Class::reinitialize
0000s0sMoose::Meta::Class::::role_applicationsMoose::Meta::Class::role_applications
0000s0sMoose::Meta::Class::::throw_errorMoose::Meta::Class::throw_error
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::Class;
3
4396µs2103µs
# spent 85µs (67+18) within Moose::Meta::Class::BEGIN@4 which was called: # once (67µs+18µs) by Moose::BEGIN@19 at line 4
use strict;
# spent 85µs making 1 call to Moose::Meta::Class::BEGIN@4 # spent 18µs making 1 call to strict::import
53291µs2177µs
# spent 108µs (39+69) within Moose::Meta::Class::BEGIN@5 which was called: # once (39µs+69µs) by Moose::BEGIN@19 at line 5
use warnings;
# spent 108µs making 1 call to Moose::Meta::Class::BEGIN@5 # spent 69µs making 1 call to warnings::import
6
7398µs125µs
# spent 25µs within Moose::Meta::Class::BEGIN@7 which was called: # once (25µs+0s) by Moose::BEGIN@19 at line 7
use Class::MOP;
# spent 25µs making 1 call to Moose::Meta::Class::BEGIN@7
8
9396µs2361µs
# spent 198µs (35+163) within Moose::Meta::Class::BEGIN@9 which was called: # once (35µs+163µs) by Moose::BEGIN@19 at line 9
use Carp qw( confess );
# spent 198µs making 1 call to Moose::Meta::Class::BEGIN@9 # spent 163µs making 1 call to Exporter::import
10396µs282µs
# spent 60µs (38+22) within Moose::Meta::Class::BEGIN@10 which was called: # once (38µs+22µs) by Moose::BEGIN@19 at line 10
use Data::OptList;
# spent 60µs making 1 call to Moose::Meta::Class::BEGIN@10 # spent 22µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:284]
113105µs2308µs
# spent 180µs (52+128) within Moose::Meta::Class::BEGIN@11 which was called: # once (52µs+128µs) by Moose::BEGIN@19 at line 11
use List::Util qw( first );
# spent 180µs making 1 call to Moose::Meta::Class::BEGIN@11 # spent 128µs making 1 call to Exporter::import
123105µs2446µs
# spent 241µs (35+206) within Moose::Meta::Class::BEGIN@12 which was called: # once (35µs+206µs) by Moose::BEGIN@19 at line 12
use List::MoreUtils qw( any all uniq first_index );
# spent 241µs making 1 call to Moose::Meta::Class::BEGIN@12 # spent 206µs making 1 call to Exporter::import
133210µs2344µs
# spent 190µs (36+154) within Moose::Meta::Class::BEGIN@13 which was called: # once (36µs+154µs) by Moose::BEGIN@19 at line 13
use Scalar::Util 'weaken', 'blessed';
# spent 190µs making 1 call to Moose::Meta::Class::BEGIN@13 # spent 154µs making 1 call to Exporter::import
14
1514µsour $VERSION = '1.19';
16180µs$VERSION = eval $VERSION;
# spent 12µs executing statements in string eval
1714µsour $AUTHORITY = 'cpan:STEVAN';
18
193483µs116.2ms
# spent 16.2ms (1.34+14.9) within Moose::Meta::Class::BEGIN@19 which was called: # once (1.34ms+14.9ms) by Moose::BEGIN@19 at line 19
use Moose::Meta::Method::Overridden;
# spent 16.2ms making 1 call to Moose::Meta::Class::BEGIN@19
203456µs11.93ms
# spent 1.93ms (1.41+525µs) within Moose::Meta::Class::BEGIN@20 which was called: # once (1.41ms+525µs) by Moose::BEGIN@19 at line 20
use Moose::Meta::Method::Augmented;
# spent 1.93ms making 1 call to Moose::Meta::Class::BEGIN@20
213450µs115.6ms
# spent 15.6ms (1.60+14.0) within Moose::Meta::Class::BEGIN@21 which was called: # once (1.60ms+14.0ms) by Moose::BEGIN@19 at line 21
use Moose::Error::Default;
# spent 15.6ms making 1 call to Moose::Meta::Class::BEGIN@21
223482µs12.67ms
# spent 2.67ms (1.59+1.07) within Moose::Meta::Class::BEGIN@22 which was called: # once (1.59ms+1.07ms) by Moose::BEGIN@19 at line 22
use Moose::Meta::Class::Immutable::Trait;
# spent 2.67ms making 1 call to Moose::Meta::Class::BEGIN@22
233577µs17.21ms
# spent 7.21ms (6.20+1.01) within Moose::Meta::Class::BEGIN@23 which was called: # once (6.20ms+1.01ms) by Moose::BEGIN@19 at line 23
use Moose::Meta::Method::Constructor;
# spent 7.21ms making 1 call to Moose::Meta::Class::BEGIN@23
243491µs13.61ms
# spent 3.61ms (2.66+946µs) within Moose::Meta::Class::BEGIN@24 which was called: # once (2.66ms+946µs) by Moose::BEGIN@19 at line 24
use Moose::Meta::Method::Destructor;
# spent 3.61ms making 1 call to Moose::Meta::Class::BEGIN@24
253454µs11.86ms
# spent 1.86ms (1.20+652µs) within Moose::Meta::Class::BEGIN@25 which was called: # once (1.20ms+652µs) by Moose::BEGIN@19 at line 25
use Moose::Meta::Method::Meta;
# spent 1.86ms making 1 call to Moose::Meta::Class::BEGIN@25
263451µs213.2ms
# spent 12.6ms (8.81+3.81) within Moose::Meta::Class::BEGIN@26 which was called: # once (8.81ms+3.81ms) by Moose::BEGIN@19 at line 26
use Moose::Util;
# spent 12.6ms making 1 call to Moose::Meta::Class::BEGIN@26 # spent 627µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
273103µs129µs
# spent 29µs within Moose::Meta::Class::BEGIN@27 which was called: # once (29µs+0s) by Moose::BEGIN@19 at line 27
use Class::MOP::MiniTrait;
# spent 29µs making 1 call to Moose::Meta::Class::BEGIN@27
28
2937.89ms2565µs
# spent 301µs (37+264) within Moose::Meta::Class::BEGIN@29 which was called: # once (37µs+264µs) by Moose::BEGIN@19 at line 29
use base 'Class::MOP::Class';
# spent 301µs making 1 call to Moose::Meta::Class::BEGIN@29 # spent 264µs making 1 call to base::import
30
31115µs112.1msClass::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait');
# spent 12.1ms making 1 call to Class::MOP::MiniTrait::apply
32
33__PACKAGE__->meta->add_attribute('roles' => (
34 reader => 'roles',
3534469µs
# spent 377µs within Moose::Meta::Class::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Class.pm:35] which was called 34 times, avg 11µs/call: # 34 times (377µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 53 of Class/MOP/Mixin/AttributeCore.pm, avg 11µs/call
default => sub { [] }
36169µs22.88ms));
# spent 2.80ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 80µs making 1 call to Class::MOP::Object::meta
37
38__PACKAGE__->meta->add_attribute('role_applications' => (
39 reader => '_get_role_applications',
4034529µs
# spent 385µs within Moose::Meta::Class::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Class.pm:40] which was called 34 times, avg 11µs/call: # 34 times (385µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 53 of Class/MOP/Mixin/AttributeCore.pm, avg 11µs/call
default => sub { [] }
41133µs22.30ms));
# spent 2.22ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 86µs making 1 call to Class::MOP::Object::meta
42
43141µs32.11ms__PACKAGE__->meta->add_attribute(
# spent 1.90ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 122µs making 1 call to Class::MOP::Attribute::new # spent 85µs making 1 call to Class::MOP::Object::meta
44 Class::MOP::Attribute->new('immutable_trait' => (
45 accessor => "immutable_trait",
46 default => 'Moose::Meta::Class::Immutable::Trait',
47 ))
48);
49
50126µs22.10ms__PACKAGE__->meta->add_attribute('constructor_class' => (
# spent 2.01ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 84µs making 1 call to Class::MOP::Object::meta
51 accessor => 'constructor_class',
52 default => 'Moose::Meta::Method::Constructor',
53));
54
55125µs22.14ms__PACKAGE__->meta->add_attribute('destructor_class' => (
# spent 2.06ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 85µs making 1 call to Class::MOP::Object::meta
56 accessor => 'destructor_class',
57 default => 'Moose::Meta::Method::Destructor',
58));
59
60124µs22.15ms__PACKAGE__->meta->add_attribute('error_class' => (
# spent 2.07ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 85µs making 1 call to Class::MOP::Object::meta
61 accessor => 'error_class',
62 default => 'Moose::Error::Default',
63));
64
65
# spent 146ms (1.90+144) within Moose::Meta::Class::initialize which was called 34 times, avg 4.29ms/call: # 25 times (1.37ms+104ms) by Moose::init_meta at line 199 of Moose.pm, avg 4.20ms/call # 8 times (422µs+33.8ms) by Class::MOP::Class::create at line 525 of Class/MOP/Class.pm, avg 4.28ms/call # once (107µs+6.58ms) by metaclass::import at line 45 of metaclass.pm
sub initialize {
661021.87ms my $class = shift;
67 my $pkg = shift;
6868144ms return Class::MOP::get_metaclass_by_name($pkg)
# spent 144ms making 34 calls to Class::MOP::Class::initialize, avg 4.23ms/call # spent 294µs making 34 calls to Class::MOP::get_metaclass_by_name, avg 9µs/call
69 || $class->SUPER::initialize($pkg,
70 'attribute_metaclass' => 'Moose::Meta::Attribute',
71 'method_metaclass' => 'Moose::Meta::Method',
72 'instance_metaclass' => 'Moose::Meta::Instance',
73 @_
74 );
75}
76
77
# spent 446ms (654µs+446) within Moose::Meta::Class::create which was called 8 times, avg 55.8ms/call: # 8 times (654µs+446ms) by Class::MOP::Class::create_anon_class at line 453 of Class/MOP/Class.pm, avg 55.8ms/call
sub create {
7848642µs my ($class, $package_name, %options) = @_;
79
80 (ref $options{roles} eq 'ARRAY')
81 || $class->throw_error("You must pass an ARRAY ref of roles", data => $options{roles})
82 if exists $options{roles};
83 my $roles = delete $options{roles};
84
858123ms my $new_meta = $class->SUPER::create($package_name, %options);
# spent 123ms making 8 calls to Class::MOP::Class::create, avg 15.4ms/call
86
878322ms if ($roles) {
# spent 322ms making 8 calls to Moose::Util::apply_all_roles, avg 40.3ms/call
88 Moose::Util::apply_all_roles( $new_meta, @$roles );
89 }
90
91 return $new_meta;
92}
93
9412µsmy %ANON_CLASSES;
95
96
# spent 448ms (1.22+447) within Moose::Meta::Class::create_anon_class which was called 15 times, avg 29.9ms/call: # 10 times (755µs+319ms) by Moose::Meta::Attribute::Native::Trait::_native_accessor_class_for at line 172 of Moose/Meta/Attribute/Native/Trait.pm, avg 32.0ms/call # 5 times (467µs+128ms) by Moose::Meta::Attribute::interpolate_class at line 124 of Moose/Meta/Attribute.pm, avg 25.8ms/call
sub create_anon_class {
971081.29ms my ($self, %options) = @_;
98
99 my $cache_ok = delete $options{cache};
100
10115465µs my $cache_key
# spent 465µs making 15 calls to Moose::Meta::Class::_anon_cache_key, avg 31µs/call
102 = _anon_cache_key( $options{superclasses}, $options{roles} );
103
104 if ($cache_ok && defined $ANON_CLASSES{$cache_key}) {
105 return $ANON_CLASSES{$cache_key};
106 }
107
108 $options{weaken} = !$cache_ok
109 unless exists $options{weaken};
110
1118447ms my $new_class = $self->SUPER::create_anon_class(%options);
# spent 447ms making 8 calls to Class::MOP::Class::create_anon_class, avg 55.8ms/call
112
113 if ($cache_ok) {
114 $ANON_CLASSES{$cache_key} = $new_class;
115848µs weaken($ANON_CLASSES{$cache_key});
# spent 48µs making 8 calls to Scalar::Util::weaken, avg 6µs/call
116 }
117
118 return $new_class;
119}
120
12134477µs
# spent 364µs within Moose::Meta::Class::_meta_method_class which was called 34 times, avg 11µs/call: # 34 times (364µ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' }
122
123
# spent 465µs (405+59) within Moose::Meta::Class::_anon_cache_key which was called 15 times, avg 31µs/call: # 15 times (405µs+59µs) by Moose::Meta::Class::create_anon_class at line 101, avg 31µs/call
sub _anon_cache_key {
124 # Makes something like Super::Class|Super::Class::2=Role|Role::1
125 return join '=' => (
126 join( '|', @{ $_[0] || [] } ),
12715500µs1559µs join( '|', sort @{ $_[1] || [] } ),
# spent 59µs making 15 calls to Moose::Meta::Class::CORE:sort, avg 4µs/call
128 );
129}
130
131sub reinitialize {
132 my $self = shift;
133 my $pkg = shift;
134
135 my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg);
136
137 my $cache_key;
138
139 my %existing_classes;
140 if ($meta) {
141 %existing_classes = map { $_ => $meta->$_() } qw(
142 attribute_metaclass
143 method_metaclass
144 wrapped_method_metaclass
145 instance_metaclass
146 constructor_class
147 destructor_class
148 error_class
149 );
150
151 $cache_key = _anon_cache_key(
152 [ $meta->superclasses ],
153 [ map { $_->name } @{ $meta->roles } ],
154 ) if $meta->is_anon_class;
155 }
156
157 my $new_meta = $self->SUPER::reinitialize(
158 $pkg,
159 %existing_classes,
160 @_,
161 );
162
163 return $new_meta unless defined $cache_key;
164
165 my $new_cache_key = _anon_cache_key(
166 [ $meta->superclasses ],
167 [ map { $_->name } @{ $meta->roles } ],
168 );
169
170 delete $ANON_CLASSES{$cache_key};
171 $ANON_CLASSES{$new_cache_key} = $new_meta;
172 weaken($ANON_CLASSES{$new_cache_key});
173
174 return $new_meta;
175}
176
177
# spent 1.83ms (1.23+603µs) within Moose::Meta::Class::add_role which was called 21 times, avg 87µs/call: # 21 times (1.23ms+603µs) by Moose::Meta::Role::Application::ToClass::apply at line 33 of Moose/Meta/Role/Application/ToClass.pm, avg 87µs/call
sub add_role {
178631.54ms my ($self, $role) = @_;
17942332µs (blessed($role) && $role->isa('Moose::Meta::Role'))
# spent 192µs making 21 calls to Scalar::Util::blessed, avg 9µs/call # spent 140µs making 21 calls to UNIVERSAL::isa, avg 7µs/call
180 || $self->throw_error("Roles must be instances of Moose::Meta::Role", data => $role);
18121271µs push @{$self->roles} => $role;
# spent 271µs making 21 calls to Moose::Meta::Class::roles, avg 13µs/call
182}
183
184sub role_applications {
185 my ($self) = @_;
186
187 return @{$self->_get_role_applications};
188}
189
190
# spent 1.48ms (974µs+502µs) within Moose::Meta::Class::add_role_application which was called 21 times, avg 70µs/call: # 21 times (974µs+502µs) by Moose::Meta::Role::Application::ToClass::apply at line 34 of Moose/Meta/Role/Application/ToClass.pm, avg 70µs/call
sub add_role_application {
191631.18ms my ($self, $application) = @_;
19242219µs (blessed($application) && $application->isa('Moose::Meta::Role::Application::ToClass'))
# spent 113µs making 21 calls to UNIVERSAL::isa, avg 5µs/call # spent 106µs making 21 calls to Scalar::Util::blessed, avg 5µs/call
193 || $self->throw_error("Role applications must be instances of Moose::Meta::Role::Application::ToClass", data => $application);
19421283µs push @{$self->_get_role_applications} => $application;
# spent 283µs making 21 calls to Moose::Meta::Class::_get_role_applications, avg 13µs/call
195}
196
197
# spent 584µs (169+415) within Moose::Meta::Class::calculate_all_roles which was called 2 times, avg 292µs/call: # 2 times (169µs+415µs) by Moose::Meta::Attribute::Native::Trait::_build_native_type at line 183 of Moose/Meta/Attribute/Native/Trait.pm, avg 292µs/call
sub calculate_all_roles {
19812180µs my $self = shift;
199 my %seen;
2008415µs grep { !$seen{$_->name}++ } map { $_->calculate_all_roles } @{ $self->roles };
# spent 371µs making 2 calls to Moose::Meta::Role::calculate_all_roles, avg 185µs/call # spent 25µs making 2 calls to Moose::Meta::Class::roles, avg 13µs/call # spent 19µs making 4 calls to Class::MOP::Package::name, avg 5µs/call
201}
202
203sub calculate_all_roles_with_inheritance {
204 my $self = shift;
205 my %seen;
206 grep { !$seen{$_->name}++ }
207 map { Class::MOP::class_of($_)->can('calculate_all_roles')
208 ? Class::MOP::class_of($_)->calculate_all_roles
209 : () }
210 $self->linearized_isa;
211}
212
213sub does_role {
214 my ($self, $role_name) = @_;
215
216 (defined $role_name)
217 || $self->throw_error("You must supply a role name to look for");
218
219 foreach my $class ($self->class_precedence_list) {
220 my $meta = Class::MOP::class_of($class);
221 # when a Moose metaclass is itself extended with a role,
222 # this check needs to be done since some items in the
223 # class_precedence_list might in fact be Class::MOP
224 # based still.
225 next unless $meta && $meta->can('roles');
226 foreach my $role (@{$meta->roles}) {
227 return 1 if $role->does_role($role_name);
228 }
229 }
230 return 0;
231}
232
233
# spent 32.1ms (4.98+27.1) within Moose::Meta::Class::excludes_role which was called 21 times, avg 1.53ms/call: # 21 times (4.98ms+27.1ms) by Moose::Meta::Role::Application::ToClass::check_role_exclusions at line 39 of Moose/Meta/Role/Application/ToClass.pm, avg 1.53ms/call
sub excludes_role {
2343875.54ms my ($self, $role_name) = @_;
235
236 (defined $role_name)
237 || $self->throw_error("You must supply a role name to look for");
238
2392122.2ms foreach my $class ($self->class_precedence_list) {
# spent 22.2ms making 21 calls to Class::MOP::Class::class_precedence_list, avg 1.06ms/call
2401343.57ms my $meta = Class::MOP::class_of($class);
# spent 3.57ms making 134 calls to Class::MOP::class_of, avg 27µs/call
241 # when a Moose metaclass is itself extended with a role,
242 # this check needs to be done since some items in the
243 # class_precedence_list might in fact be Class::MOP
244 # based still.
245134892µs next unless $meta && $meta->can('roles');
# spent 892µs making 134 calls to UNIVERSAL::can, avg 7µs/call
24635455µs foreach my $role (@{$meta->roles}) {
# spent 455µs making 35 calls to Moose::Meta::Class::roles, avg 13µs/call
247 return 1 if $role->excludes_role($role_name);
248 }
249 }
250 return 0;
251}
252
253
# spent 31.8ms (2.63+29.2) within Moose::Meta::Class::new_object which was called 6 times, avg 5.31ms/call: # 5 times (2.30ms+23.3ms) by Moose::Meta::Attribute::_new at line 4 of (eval 74)[Class/MOP/Method/Generated.pm:53], avg 5.12ms/call # once (326µs+5.91ms) by Moose::Object::new at line 26 of Moose/Object.pm
sub new_object {
2541883.45ms my $self = shift;
255 my $params = @_ == 1 ? $_[0] : {@_};
256624.3ms my $object = $self->SUPER::new_object($params);
# spent 24.3ms making 6 calls to Class::MOP::Class::new_object, avg 4.05ms/call
257
25863.86ms foreach my $attr ( $self->get_all_attributes() ) {
# spent 3.86ms making 6 calls to Class::MOP::Class::get_all_attributes, avg 643µs/call
259
260164894µs next unless $attr->can('has_trigger') && $attr->has_trigger;
# spent 785µs making 152 calls to UNIVERSAL::can, avg 5µs/call # spent 109µs making 12 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 9µs/call
261
262 my $init_arg = $attr->init_arg;
263
264 next unless defined $init_arg;
265
266 next unless exists $params->{$init_arg};
267
268 $attr->trigger->(
269 $object,
270 (
271 $attr->should_coerce
272 ? $attr->get_read_method_ref->($object)
273 : $params->{$init_arg}
274 ),
275 );
276 }
277
2787155µs $object->BUILDALL($params) if $object->can('BUILDALL');
# spent 115µs making 6 calls to UNIVERSAL::can, avg 19µs/call # spent 40µs making 1 call to Moose::Object::BUILDALL
279
280 return $object;
281}
282
283
# spent 241ms (14.2+227) within Moose::Meta::Class::superclasses which was called 196 times, avg 1.23ms/call: # 68 times (4.18ms+11.0ms) by Class::MOP::Class::_check_metaclass_compatibility at line 213 of Class/MOP/Class.pm, avg 223µs/call # 50 times (4.49ms+142ms) by Moose::init_meta at line 218 of Moose.pm, avg 2.93ms/call # 34 times (2.03ms+6.82ms) by Class::MOP::Class::class_precedence_list at line 929 of Class/MOP/Class.pm, avg 260µs/call # 34 times (2.16ms+-2.16ms) by Class::MOP::Class::_superclasses_updated at line 870 of Class/MOP/Class.pm, avg 0s/call # 8 times (1.17ms+63.2ms) by Class::MOP::Class::create at line 532 of Class/MOP/Class.pm, avg 8.04ms/call # once (118µs+5.74ms) by Moose::extends at line 54 of Moose.pm # once (52µs+262µs) by Class::MOP::Class:::around at line 27 of Class/MOP/Class/Immutable/Trait.pm
sub superclasses {
28494013.9ms my $self = shift;
2851967.52ms my $supers = Data::OptList::mkopt(\@_);
# spent 7.52ms making 196 calls to Data::OptList::mkopt, avg 38µs/call
286 foreach my $super (@{ $supers }) {
287 my ($name, $opts) = @{ $super };
288397.66ms Class::MOP::load_class($name, $opts);
# spent 8.53ms making 39 calls to Class::MOP::load_class, avg 219µs/call, recursion: max depth 1, sum of overlapping time 868µs
289391.27ms my $meta = Class::MOP::class_of($name);
# spent 1.27ms making 39 calls to Class::MOP::class_of, avg 33µs/call
29038466µs $self->throw_error("You cannot inherit from a Moose Role ($name)")
# spent 466µs making 38 calls to UNIVERSAL::isa, avg 12µs/call
291 if $meta && $meta->isa('Moose::Meta::Role')
292 }
293196216ms return $self->SUPER::superclasses(map { $_->[0] } @{ $supers });
# spent 227ms making 196 calls to Class::MOP::Class::superclasses, avg 1.16ms/call, recursion: max depth 1, sum of overlapping time 11.6ms
294}
295
296### ---------------------------------------------
297
298
# spent 4.18s (12.6ms+4.17) within Moose::Meta::Class::add_attribute which was called 123 times, avg 34.0ms/call: # 116 times (11.9ms+4.15s) by Moose::has at line 70 of Moose.pm, avg 35.8ms/call # 7 times (685µs+18.9ms) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 142 of Moose/Meta/Role/Application/ToClass.pm, avg 2.80ms/call
sub add_attribute {
29961513.8ms my $self = shift;
3002462.88s my $attr =
# spent 2.88s making 116 calls to Moose::Meta::Class::_process_attribute, avg 24.8ms/call # spent 618µs making 123 calls to Scalar::Util::blessed, avg 5µs/call # spent 53µs making 7 calls to UNIVERSAL::isa, avg 8µs/call
301 (blessed $_[0] && $_[0]->isa('Class::MOP::Attribute')
302 ? $_[0]
303 : $self->_process_attribute(@_));
3041231.31s $self->SUPER::add_attribute($attr);
# spent 1.31s making 123 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 10.7ms/call
305 # it may be a Class::MOP::Attribute, theoretically, which doesn't have
306 # 'bare' and doesn't implement this method
3072466.01ms if ($attr->can('_check_associated_methods')) {
# spent 4.74ms making 123 calls to Moose::Meta::Attribute::_check_associated_methods, avg 39µs/call # spent 1.26ms making 123 calls to UNIVERSAL::can, avg 10µs/call
308 $attr->_check_associated_methods;
309 }
310 return $attr;
311}
312
313
# spent 27.4ms (944µs+26.5) within Moose::Meta::Class::add_override_method_modifier which was called 17 times, avg 1.61ms/call: # 17 times (944µs+26.5ms) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 208 of Moose/Meta/Role/Application/ToClass.pm, avg 1.61ms/call
sub add_override_method_modifier {
31451853µs my ($self, $name, $method, $_super_package) = @_;
315
316173.19ms (!$self->has_method($name))
# spent 3.19ms making 17 calls to Class::MOP::Mixin::HasMethods::has_method, avg 188µs/call
317 || $self->throw_error("Cannot add an override method if a local method is already present");
318
3193423.3ms $self->add_method($name => Moose::Meta::Method::Overridden->new(
# spent 15.2ms making 17 calls to Moose::Meta::Method::Overridden::new, avg 896µs/call # spent 8.06ms making 17 calls to Class::MOP::Mixin::HasMethods::add_method, avg 474µs/call
320 method => $method,
321 class => $self,
322 package => $_super_package, # need this for roles
323 name => $name,
324 ));
325}
326
327sub add_augment_method_modifier {
328 my ($self, $name, $method) = @_;
329 (!$self->has_method($name))
330 || $self->throw_error("Cannot add an augment method if a local method is already present");
331
332 $self->add_method($name => Moose::Meta::Method::Augmented->new(
333 method => $method,
334 class => $self,
335 name => $name,
336 ));
337}
338
339## Private Utility methods ...
340
341sub _find_next_method_by_name_which_is_not_overridden {
342 my ($self, $name) = @_;
343 foreach my $method ($self->find_all_methods_by_name($name)) {
344 return $method->{code}
345 if blessed($method->{code}) && !$method->{code}->isa('Moose::Meta::Method::Overridden');
346 }
347 return undef;
348}
349
350## Metaclass compatibility
351
352
# spent 16.0ms (10.7+5.37) within Moose::Meta::Class::_base_metaclasses which was called 73 times, avg 220µs/call: # 39 times (5.70ms+2.92ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 343 of Class/MOP/Class.pm, avg 221µs/call # 34 times (4.96ms+2.45ms) by Class::MOP::Class::_check_metaclass_compatibility at line 218 of Class/MOP/Class.pm, avg 218µs/call
sub _base_metaclasses {
35373014.5ms my $self = shift;
354731.36ms my %metaclasses = $self->SUPER::_base_metaclasses;
# spent 1.36ms making 73 calls to Class::MOP::Class::_base_metaclasses, avg 19µs/call
355 for my $class (keys %metaclasses) {
3564384.00ms $metaclasses{$class} =~ s/^Class::MOP/Moose::Meta/;
# spent 4.00ms making 438 calls to Moose::Meta::Class::CORE:subst, avg 9µs/call
357 }
358 return (
359 %metaclasses,
360 error_class => 'Moose::Error::Default',
361 );
362}
363
364sub _fix_class_metaclass_incompatibility {
365 my $self = shift;
366 my ($super_meta) = @_;
367
368 $self->SUPER::_fix_class_metaclass_incompatibility(@_);
369
370 if ($self->_class_metaclass_can_be_made_compatible($super_meta)) {
371 ($self->is_pristine)
372 || confess "Can't fix metaclass incompatibility for "
373 . $self->name
374 . " because it is not pristine.";
375 my $super_meta_name = $super_meta->_real_ref_name;
376 my $class_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass(blessed($self), $super_meta_name);
377 my $new_self = $class_meta_subclass_meta_name->reinitialize(
378 $self->name,
379 );
380
381 $self->_replace_self( $new_self, $class_meta_subclass_meta_name );
382 }
383}
384
385sub _fix_single_metaclass_incompatibility {
386 my $self = shift;
387 my ($metaclass_type, $super_meta) = @_;
388
389 $self->SUPER::_fix_single_metaclass_incompatibility(@_);
390
391 if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) {
392 ($self->is_pristine)
393 || confess "Can't fix metaclass incompatibility for "
394 . $self->name
395 . " because it is not pristine.";
396 my $super_meta_name = $super_meta->_real_ref_name;
397 my $class_specific_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass($self->$metaclass_type, $super_meta->$metaclass_type);
398 my $new_self = $super_meta->reinitialize(
399 $self->name,
400 $metaclass_type => $class_specific_meta_subclass_meta_name,
401 );
402
403 $self->_replace_self( $new_self, $super_meta_name );
404 }
405}
406
407sub _replace_self {
408 my $self = shift;
409 my ( $new_self, $new_class) = @_;
410
411 %$self = %$new_self;
412 bless $self, $new_class;
413
414 # We need to replace the cached metaclass instance or else when it goes
415 # out of scope Class::MOP::Class destroy's the namespace for the
416 # metaclass's class, causing much havoc.
417 my $weaken = Class::MOP::metaclass_is_weak( $self->name );
418 Class::MOP::store_metaclass_by_name( $self->name, $self );
419 Class::MOP::weaken_metaclass( $self->name ) if $weaken;
420}
421
422
# spent 2.88s (5.84ms+2.87) within Moose::Meta::Class::_process_attribute which was called 116 times, avg 24.8ms/call: # 116 times (5.84ms+2.87s) by Moose::Meta::Class::add_attribute at line 300, avg 24.8ms/call
sub _process_attribute {
4234646.84ms my ( $self, $name, @args ) = @_;
424
425 @args = %{$args[0]} if scalar @args == 1 && ref($args[0]) eq 'HASH';
426
427116677µs if (($name || '') =~ /^\+(.*)/) {
# spent 677µs making 116 calls to Moose::Meta::Class::CORE:match, avg 6µs/call
428219.4ms return $self->_process_inherited_attribute($1, @args);
# spent 19.4ms making 2 calls to Moose::Meta::Class::_process_inherited_attribute, avg 9.70ms/call
429 }
430 else {
4311142.85s return $self->_process_new_attribute($name, @args);
# spent 2.85s making 114 calls to Moose::Meta::Class::_process_new_attribute, avg 25.0ms/call
432 }
433}
434
435
# spent 2.85s (6.12ms+2.85) within Moose::Meta::Class::_process_new_attribute which was called 114 times, avg 25.0ms/call: # 114 times (6.12ms+2.85s) by Moose::Meta::Class::_process_attribute at line 431, avg 25.0ms/call
sub _process_new_attribute {
4362285.39ms my ( $self, $name, @args ) = @_;
437
4382282.85s $self->attribute_metaclass->interpolate_class_and_new($name, @args);
# spent 2.84s making 114 calls to Moose::Meta::Attribute::interpolate_class_and_new, avg 25.0ms/call # spent 1.43ms making 114 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 13µs/call
439}
440
441
# spent 19.4ms (184µs+19.2) within Moose::Meta::Class::_process_inherited_attribute which was called 2 times, avg 9.70ms/call: # 2 times (184µs+19.2ms) by Moose::Meta::Class::_process_attribute at line 428, avg 9.70ms/call
sub _process_inherited_attribute {
4428188µs my ($self, $attr_name, %options) = @_;
4432769µs my $inherited_attr = $self->find_attribute_by_name($attr_name);
# spent 769µs making 2 calls to Class::MOP::Class::find_attribute_by_name, avg 384µs/call
444 (defined $inherited_attr)
445 || $self->throw_error("Could not find an attribute by the name of '$attr_name' to inherit from in ${\$self->name}", data => $attr_name);
446418.4ms if ($inherited_attr->isa('Moose::Meta::Attribute')) {
# spent 18.4ms making 2 calls to Moose::Meta::Attribute::clone_and_inherit_options, avg 9.22ms/call # spent 15µs making 2 calls to UNIVERSAL::isa, avg 8µs/call
447 return $inherited_attr->clone_and_inherit_options(%options);
448 }
449 else {
450 # NOTE:
451 # kind of a kludge to handle Class::MOP::Attributes
452 return $inherited_attr->Moose::Meta::Attribute::clone_and_inherit_options(%options);
453 }
454}
455
456## Immutability
457
458
# spent 4.34ms (1.02+3.32) within Moose::Meta::Class::_immutable_options which was called 24 times, avg 181µs/call: # 24 times (1.02ms+3.32ms) by Class::MOP::Class::make_immutable at line 1180 of Class/MOP/Class.pm, avg 181µs/call
sub _immutable_options {
459481.04ms my ( $self, @args ) = @_;
460
461243.32ms $self->SUPER::_immutable_options(
# spent 3.32ms making 24 calls to Class::MOP::Class::_immutable_options, avg 138µs/call
462 inline_destructor => 1,
463
464 # Moose always does this when an attribute is created
465 inline_accessors => 0,
466
467 @args,
468 );
469}
470
471## -------------------------------------------------
472
47312µsour $error_level;
474
475sub throw_error {
476 my ( $self, @args ) = @_;
477 local $error_level = ($error_level || 0) + 1;
478 $self->raise_error($self->create_error(@args));
479}
480
481sub raise_error {
482 my ( $self, @args ) = @_;
483 die @args;
484}
485
486sub create_error {
487 my ( $self, @args ) = @_;
488
489 require Carp::Heavy;
490
491 local $error_level = ($error_level || 0 ) + 1;
492
493 if ( @args % 2 == 1 ) {
494 unshift @args, "message";
495 }
496
497 my %args = ( metaclass => $self, last_error => $@, @args );
498
499 $args{depth} += $error_level;
500
501 my $class = ref $self ? $self->error_class : "Moose::Error::Default";
502
503 Class::MOP::load_class($class);
504
505 $class->new(
506 Carp::caller_info($args{depth}),
507 %args
508 );
509}
510
511196µs1;
512
513__END__
 
# spent 677µs within Moose::Meta::Class::CORE:match which was called 116 times, avg 6µs/call: # 116 times (677µs+0s) by Moose::Meta::Class::_process_attribute at line 427, avg 6µs/call
sub Moose::Meta::Class::CORE:match; # opcode
# spent 59µs within Moose::Meta::Class::CORE:sort which was called 15 times, avg 4µs/call: # 15 times (59µs+0s) by Moose::Meta::Class::_anon_cache_key at line 127, avg 4µs/call
sub Moose::Meta::Class::CORE:sort; # opcode
# spent 4.00ms within Moose::Meta::Class::CORE:subst which was called 438 times, avg 9µs/call: # 438 times (4.00ms+0s) by Moose::Meta::Class::_base_metaclasses at line 356, avg 9µs/call
sub Moose::Meta::Class::CORE:subst; # opcode