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

Filename/usr/local/lib/perl/5.18.2/Moose/Meta/Class.pm
StatementsExecuted 14859 statements in 39.6ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
281112.0ms26.6msMoose::Meta::Class::::_eval_environmentMoose::Meta::Class::_eval_environment
132118.07ms11.9msMoose::Meta::Class::::_anon_cache_keyMoose::Meta::Class::_anon_cache_key
261732.17ms607msMoose::Meta::Class::::superclassesMoose::Meta::Class::superclasses (recurses: max depth 2, inclusive time 21.8ms)
112211.82ms2.67msMoose::Meta::Class::::_base_metaclassesMoose::Meta::Class::_base_metaclasses
186111.64ms2.35msMoose::Meta::Class::::_inline_check_required_attrMoose::Meta::Class::_inline_check_required_attr
186211.57ms10.0msMoose::Meta::Class::::_inline_init_attr_from_defaultMoose::Meta::Class::_inline_init_attr_from_default
109221.49ms563msMoose::Meta::Class::::add_attributeMoose::Meta::Class::add_attribute (recurses: max depth 1, inclusive time 1.70ms)
169111.43ms34.7msMoose::Meta::Class::::_inline_init_attr_from_constructorMoose::Meta::Class::_inline_init_attr_from_constructor
32111.43ms3.86msMoose::Meta::Class::::_call_all_triggersMoose::Meta::Class::_call_all_triggers
186111.18ms50.2msMoose::Meta::Class::::_inline_slot_initializerMoose::Meta::Class::_inline_slot_initializer
2811981µs4.81msMoose::Meta::Class::::excludes_roleMoose::Meta::Class::excludes_role
2811882µs3.15msMoose::Meta::Class::::_inline_triggersMoose::Meta::Class::_inline_triggers
111543µs765µsMoose::Meta::Class::::BEGIN@17Moose::Meta::Class::BEGIN@17
4033475µs1.54msMoose::Meta::Class::::calculate_all_rolesMoose::Meta::Class::calculate_all_roles
3933432µs23.9msMoose::Meta::Class::::initializeMoose::Meta::Class::initialize
2811409µs2.81msMoose::Meta::Class::::_inline_BUILDARGSMoose::Meta::Class::_inline_BUILDARGS
4911404µs68.3msMoose::Meta::Class::::_process_attributeMoose::Meta::Class::_process_attribute
4811381µs66.6msMoose::Meta::Class::::_process_new_attributeMoose::Meta::Class::_process_new_attribute
3211327µs27.0msMoose::Meta::Class::::new_objectMoose::Meta::Class::new_object
111316µs552µsMoose::Meta::Class::::BEGIN@15Moose::Meta::Class::BEGIN@15
111303µs504µsMoose::Meta::Class::::BEGIN@16Moose::Meta::Class::BEGIN@16
111288µs6.57msMoose::Meta::Class::::BEGIN@13Moose::Meta::Class::BEGIN@13
111280µs448µsMoose::Meta::Class::::BEGIN@14Moose::Meta::Class::BEGIN@14
2811240µs360µsMoose::Meta::Class::::add_roleMoose::Meta::Class::add_role
2811235µs346µsMoose::Meta::Class::::add_role_applicationMoose::Meta::Class::add_role_application
111205µs263µsMoose::Meta::Class::::BEGIN@18Moose::Meta::Class::BEGIN@18
2522190µs4.24msMoose::Meta::Class::::add_override_method_modifierMoose::Meta::Class::add_override_method_modifier
411185µs1.01msMoose::Meta::Class::::calculate_all_roles_with_inheritanceMoose::Meta::Class::calculate_all_roles_with_inheritance
1011181µs81.5msMoose::Meta::Class::::createMoose::Meta::Class::create
7921177µs177µsMoose::Meta::Class::::_inline_throw_exceptionMoose::Meta::Class::_inline_throw_exception
2811166µs7.60msMoose::Meta::Class::::_inline_BUILDALLMoose::Meta::Class::_inline_BUILDALL
2811149µs10.9msMoose::Meta::Class::::_inline_extra_initMoose::Meta::Class::_inline_extra_init
2811144µs2.96msMoose::Meta::Class::::_inline_paramsMoose::Meta::Class::_inline_params
2811136µs6.05msMoose::Meta::Class::::_immutable_optionsMoose::Meta::Class::_immutable_options
281174µs74µsMoose::Meta::Class::::_generate_fallback_constructorMoose::Meta::Class::_generate_fallback_constructor
391168µs68µsMoose::Meta::Class::::__ANON__[:34]Moose::Meta::Class::__ANON__[:34]
391157µs57µsMoose::Meta::Class::::__ANON__[:28]Moose::Meta::Class::__ANON__[:28]
391148µs48µsMoose::Meta::Class::::_meta_method_classMoose::Meta::Class::_meta_method_class
11120µs1.22msMoose::Meta::Class::::_process_inherited_attributeMoose::Meta::Class::_process_inherited_attribute
11114µs62µsMoose::Meta::Class::::BEGIN@9Moose::Meta::Class::BEGIN@9
101114µs14µsMoose::Meta::Class::::_anon_package_prefixMoose::Meta::Class::_anon_package_prefix
1119µs18µsMoose::Meta::Class::::BEGIN@4Moose::Meta::Class::BEGIN@4
1117µs12µsMoose::Meta::Class::::BEGIN@8Moose::Meta::Class::BEGIN@8
1117µs26µsMoose::Meta::Class::::BEGIN@22Moose::Meta::Class::BEGIN@22
1116µs28µsMoose::Meta::Class::::BEGIN@10Moose::Meta::Class::BEGIN@10
1116µs26µsMoose::Meta::Class::::BEGIN@11Moose::Meta::Class::BEGIN@11
1116µs9µsMoose::Meta::Class::::BEGIN@5Moose::Meta::Class::BEGIN@5
1115µs101µsMoose::Meta::Class::::BEGIN@19Moose::Meta::Class::BEGIN@19
1114µs4µsMoose::Meta::Class::::BEGIN@20Moose::Meta::Class::BEGIN@20
1113µs3µsMoose::Meta::Class::::BEGIN@7Moose::Meta::Class::BEGIN@7
0000s0sMoose::Meta::Class::::__ANON__[:110]Moose::Meta::Class::__ANON__[:110]
0000s0sMoose::Meta::Class::::__ANON__[:535]Moose::Meta::Class::__ANON__[:535]
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::::_fixup_attributes_after_reblessMoose::Meta::Class::_fixup_attributes_after_rebless
0000s0sMoose::Meta::Class::::_replace_selfMoose::Meta::Class::_replace_self
0000s0sMoose::Meta::Class::::_restore_metaobjects_fromMoose::Meta::Class::_restore_metaobjects_from
0000s0sMoose::Meta::Class::::_roles_with_inheritanceMoose::Meta::Class::_roles_with_inheritance
0000s0sMoose::Meta::Class::::add_augment_method_modifierMoose::Meta::Class::add_augment_method_modifier
0000s0sMoose::Meta::Class::::does_roleMoose::Meta::Class::does_role
0000s0sMoose::Meta::Class::::reinitializeMoose::Meta::Class::reinitialize
0000s0sMoose::Meta::Class::::role_applicationsMoose::Meta::Class::role_applications
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Moose::Meta::Class;
21700nsour $VERSION = '2.1604';
3
4220µs227µs
# spent 18µs (9+9) within Moose::Meta::Class::BEGIN@4 which was called: # once (9µs+9µs) by Moose::BEGIN@24 at line 4
use strict;
# spent 18µs making 1 call to Moose::Meta::Class::BEGIN@4 # spent 9µs making 1 call to strict::import
5221µs212µs
# spent 9µs (6+3) within Moose::Meta::Class::BEGIN@5 which was called: # once (6µs+3µs) by Moose::BEGIN@24 at line 5
use warnings;
# spent 9µs making 1 call to Moose::Meta::Class::BEGIN@5 # spent 3µs making 1 call to warnings::import
6
7217µs13µs
# spent 3µs within Moose::Meta::Class::BEGIN@7 which was called: # once (3µs+0s) by Moose::BEGIN@24 at line 7
use Class::MOP;
# spent 3µs making 1 call to Moose::Meta::Class::BEGIN@7
8225µs217µs
# spent 12µs (7+5) within Moose::Meta::Class::BEGIN@8 which was called: # once (7µs+5µs) by Moose::BEGIN@24 at line 8
use Data::OptList;
# spent 12µs making 1 call to Moose::Meta::Class::BEGIN@8 # spent 5µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:270]
9339µs380µs
# spent 62µs (14+47) within Moose::Meta::Class::BEGIN@9 which was called: # once (14µs+47µs) by Moose::BEGIN@24 at line 9
use List::Util 1.33 qw( any first );
# spent 62µs making 1 call to Moose::Meta::Class::BEGIN@9 # spent 10µs making 1 call to UNIVERSAL::VERSION # spent 8µs making 1 call to List::Util::import
10224µs250µs
# spent 28µs (6+22) within Moose::Meta::Class::BEGIN@10 which was called: # once (6µs+22µs) by Moose::BEGIN@24 at line 10
use List::MoreUtils qw( uniq first_index );
# spent 28µs making 1 call to Moose::Meta::Class::BEGIN@10 # spent 22µs making 1 call to Exporter::import
11221µs246µs
# spent 26µs (6+20) within Moose::Meta::Class::BEGIN@11 which was called: # once (6µs+20µs) by Moose::BEGIN@24 at line 11
use Scalar::Util 'blessed';
# spent 26µs making 1 call to Moose::Meta::Class::BEGIN@11 # spent 20µs making 1 call to Exporter::import
12
132102µs16.57ms
# spent 6.57ms (288µs+6.28) within Moose::Meta::Class::BEGIN@13 which was called: # once (288µs+6.28ms) by Moose::BEGIN@24 at line 13
use Moose::Meta::Method::Overridden;
# spent 6.57ms making 1 call to Moose::Meta::Class::BEGIN@13
14287µs1448µs
# spent 448µs (280+169) within Moose::Meta::Class::BEGIN@14 which was called: # once (280µs+169µs) by Moose::BEGIN@24 at line 14
use Moose::Meta::Method::Augmented;
# spent 448µs making 1 call to Moose::Meta::Class::BEGIN@14
15288µs1552µs
# spent 552µs (316+236) within Moose::Meta::Class::BEGIN@15 which was called: # once (316µs+236µs) by Moose::BEGIN@24 at line 15
use Moose::Meta::Class::Immutable::Trait;
# spent 552µs making 1 call to Moose::Meta::Class::BEGIN@15
16285µs1504µs
# spent 504µs (303+201) within Moose::Meta::Class::BEGIN@16 which was called: # once (303µs+201µs) by Moose::BEGIN@24 at line 16
use Moose::Meta::Method::Constructor;
# spent 504µs making 1 call to Moose::Meta::Class::BEGIN@16
17288µs1765µs
# spent 765µs (543+222) within Moose::Meta::Class::BEGIN@17 which was called: # once (543µs+222µs) by Moose::BEGIN@24 at line 17
use Moose::Meta::Method::Destructor;
# spent 765µs making 1 call to Moose::Meta::Class::BEGIN@17
18284µs1263µs
# spent 263µs (205+59) within Moose::Meta::Class::BEGIN@18 which was called: # once (205µs+59µs) by Moose::BEGIN@24 at line 18
use Moose::Meta::Method::Meta;
# spent 263µs making 1 call to Moose::Meta::Class::BEGIN@18
19222µs2196µs
# spent 101µs (5+95) within Moose::Meta::Class::BEGIN@19 which was called: # once (5µs+95µs) by Moose::BEGIN@24 at line 19
use Moose::Util 'throw_exception';
# spent 101µs making 1 call to Moose::Meta::Class::BEGIN@19 # spent 95µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
20219µs14µs
# spent 4µs within Moose::Meta::Class::BEGIN@20 which was called: # once (4µs+0s) by Moose::BEGIN@24 at line 20
use Class::MOP::MiniTrait;
# spent 4µs making 1 call to Moose::Meta::Class::BEGIN@20
21
2223.17ms245µs
# spent 26µs (7+19) within Moose::Meta::Class::BEGIN@22 which was called: # once (7µs+19µs) by Moose::BEGIN@24 at line 22
use parent 'Class::MOP::Class';
# spent 26µs making 1 call to Moose::Meta::Class::BEGIN@22 # spent 19µs making 1 call to parent::import
23
2413µs11.40msClass::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait');
# spent 1.40ms making 1 call to Class::MOP::MiniTrait::apply
25
26__PACKAGE__->meta->add_attribute('roles' => (
27 reader => 'roles',
283980µs
# spent 57µs within Moose::Meta::Class::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Meta/Class.pm:28] which was called 39 times, avg 1µs/call: # 39 times (57µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 40 of Class/MOP/Mixin/AttributeCore.pm, avg 1µs/call
default => sub { [] },
29114µs3398µs Class::MOP::_definition_context(),
# spent 381µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 10µs making 1 call to Class::MOP::Object::meta # spent 8µs making 1 call to Class::MOP::_definition_context
30));
31
32__PACKAGE__->meta->add_attribute('role_applications' => (
33 reader => '_get_role_applications',
343992µs
# spent 68µs within Moose::Meta::Class::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Meta/Class.pm:34] which was called 39 times, avg 2µs/call: # 39 times (68µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 40 of Class/MOP/Mixin/AttributeCore.pm, avg 2µs/call
default => sub { [] },
3515µs3261µs Class::MOP::_definition_context(),
# spent 248µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 9µs making 1 call to Class::MOP::Object::meta # spent 4µs making 1 call to Class::MOP::_definition_context
36));
37
3815µs4297µs__PACKAGE__->meta->add_attribute(
# spent 269µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 16µs making 1 call to Class::MOP::Attribute::new # spent 8µs making 1 call to Class::MOP::Object::meta # spent 4µs making 1 call to Class::MOP::_definition_context
39 Class::MOP::Attribute->new('immutable_trait' => (
40 accessor => "immutable_trait",
41 default => 'Moose::Meta::Class::Immutable::Trait',
42 Class::MOP::_definition_context(),
43 ))
44);
45
4614µs3250µs__PACKAGE__->meta->add_attribute('constructor_class' => (
# spent 236µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 9µs making 1 call to Class::MOP::Object::meta # spent 5µs making 1 call to Class::MOP::_definition_context
47 accessor => 'constructor_class',
48 default => 'Moose::Meta::Method::Constructor',
49 Class::MOP::_definition_context(),
50));
51
5214µs3249µs__PACKAGE__->meta->add_attribute('destructor_class' => (
# spent 236µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µs making 1 call to Class::MOP::Object::meta # spent 5µs making 1 call to Class::MOP::_definition_context
53 accessor => 'destructor_class',
54 default => 'Moose::Meta::Method::Destructor',
55 Class::MOP::_definition_context(),
56));
57
58
# spent 23.9ms (432µs+23.5) within Moose::Meta::Class::initialize which was called 39 times, avg 613µs/call: # 28 times (312µs+13.9ms) by Moose::init_meta at line 203 of Moose.pm, avg 508µs/call # 10 times (107µs+8.81ms) by Class::MOP::Package::create at line 67 of Class/MOP/Package.pm, avg 892µs/call # once (13µs+765µs) by metaclass::import at line 38 of metaclass.pm
sub initialize {
593919µs my $class = shift;
603922µs my @args = @_;
613947µs unshift @args, 'package' if @args % 2;
623940µs my %opts = @args;
633934µs my $package = delete $opts{package};
6439245µs7823.5ms return Class::MOP::get_metaclass_by_name($package)
# spent 23.4ms making 39 calls to Class::MOP::Class::initialize, avg 601µs/call # spent 36µs making 39 calls to Class::MOP::get_metaclass_by_name, avg 926ns/call
65 || $class->SUPER::initialize($package,
66 'attribute_metaclass' => 'Moose::Meta::Attribute',
67 'method_metaclass' => 'Moose::Meta::Method',
68 'instance_metaclass' => 'Moose::Meta::Instance',
69 %opts,
70 );
71}
72
73
# spent 81.5ms (181µs+81.3) within Moose::Meta::Class::create which was called 10 times, avg 8.15ms/call: # 10 times (181µs+81.3ms) by Class::MOP::Package::create_anon at line 120 of Class/MOP/Package.pm, avg 8.15ms/call
sub create {
74103µs my $class = shift;
751011µs my @args = @_;
76
771016µs unshift @args, 'package' if @args % 2 == 1;
781015µs my %options = @args;
79
801012µs (ref $options{roles} eq 'ARRAY')
81 || throw_exception( RolesInCreateTakesAnArrayRef => params => \%options )
82 if exists $options{roles};
83
84108µs my $package = delete $options{package};
85105µs my $roles = delete $options{roles};
86
871035µs1021.7ms my $new_meta = $class->SUPER::create($package, %options);
# spent 21.7ms making 10 calls to Class::MOP::Class::create, avg 2.17ms/call
88
891029µs1023.6ms if ($roles) {
# spent 59.6ms making 10 calls to Moose::Util::apply_all_roles, avg 5.96ms/call, recursion: max depth 1, sum of overlapping time 36.0ms
90 Moose::Util::apply_all_roles( $new_meta, @$roles );
91 }
92
931041µs return $new_meta;
94}
95
963987µs
# spent 48µs within Moose::Meta::Class::_meta_method_class which was called 39 times, avg 1µs/call: # 39 times (48µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 24 of Class/MOP/Mixin/HasMethods.pm, avg 1µs/call
sub _meta_method_class { 'Moose::Meta::Method::Meta' }
97
981031µs
# spent 14µs within Moose::Meta::Class::_anon_package_prefix which was called 10 times, avg 1µs/call: # 10 times (14µs+0s) by Class::MOP::Package::create_anon at line 118 of Class/MOP/Package.pm, avg 1µs/call
sub _anon_package_prefix { 'Moose::Meta::Class::__ANON__::SERIAL::' }
99
100
# spent 11.9ms (8.07+3.80) within Moose::Meta::Class::_anon_cache_key which was called 132 times, avg 90µs/call: # 132 times (8.07ms+3.80ms) by Class::MOP::Package::create_anon at line 108 of Class/MOP/Package.pm, avg 90µs/call
sub _anon_cache_key {
10113243µs my $class = shift;
102132128µs my %options = @_;
103
104 my $superclass_key = join('|',
105132600µs1322.09ms map { $_->[0] } @{ Data::OptList::mkopt($options{superclasses} || []) }
# spent 2.09ms making 132 calls to Data::OptList::mkopt, avg 16µs/call
106 );
107
108 my $roles = Data::OptList::mkopt(($options{roles} || []), {
109 moniker => 'role',
110 val_test => sub { ref($_[0]) eq 'HASH' },
111132689µs1321.56ms });
# spent 1.56ms making 132 calls to Data::OptList::mkopt, avg 12µs/call
112
11313222µs my @role_keys;
114132116µs for my $role_spec (@$roles) {
11513274µs my ($role, $params) = @$role_spec;
11613223µs $params = { %$params } if $params;
117
118132372µs13289µs my $key = blessed($role) ? $role->name : $role;
# spent 89µs making 132 calls to Scalar::Util::blessed, avg 677ns/call
119
12013216µs if ($params && %$params) {
121 my $alias = delete $params->{'-alias'}
122 || delete $params->{'alias'}
123 || {};
124 my $excludes = delete $params->{'-excludes'}
125 || delete $params->{'excludes'}
126 || [];
127 $excludes = [$excludes] unless ref($excludes) eq 'ARRAY';
128
129 if (%$params) {
130 warn "Roles with parameters cannot be cached. Consider "
131 . "applying the parameters before calling "
132 . "create_anon_class, or using 'weaken => 0' instead";
133 return;
134 }
135
136 my $alias_key = join('%',
137 map { $_ => $alias->{$_} } sort keys %$alias
138 );
139 my $excludes_key = join('%',
140 sort @$excludes
141 );
142 $key .= '<' . join('+', 'a', $alias_key, 'e', $excludes_key) . '>';
143 }
144
145132131µs push @role_keys, $key;
146 }
147
148132340µs13254µs my $role_key = join('|', sort @role_keys);
# spent 54µs making 132 calls to Moose::Meta::Class::CORE:sort, avg 405ns/call
149
150 # Makes something like Super::Class|Super::Class::2=Role|Role::1
151132444µs return join('=', $superclass_key, $role_key);
152}
153
154sub reinitialize {
155 my $self = shift;
156 my $pkg = shift;
157
158 my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg);
159
160 my %existing_classes;
161 if ($meta) {
162 %existing_classes = map { $_ => $meta->$_() } qw(
163 attribute_metaclass
164 method_metaclass
165 wrapped_method_metaclass
166 instance_metaclass
167 constructor_class
168 destructor_class
169 );
170 }
171
172 return $self->SUPER::reinitialize(
173 $pkg,
174 %existing_classes,
175 @_,
176 );
177}
178
179
# spent 360µs (240+120) within Moose::Meta::Class::add_role which was called 28 times, avg 13µs/call: # 28 times (240µs+120µs) by Moose::Meta::Role::Application::ToClass::apply at line 33 of Moose/Meta/Role/Application/ToClass.pm, avg 13µs/call
sub add_role {
1802810µs my ($self, $role) = @_;
18128165µs5653µs (blessed($role) && $role->isa('Moose::Meta::Role'))
# spent 27µs making 28 calls to Scalar::Util::blessed, avg 950ns/call # spent 26µs making 28 calls to UNIVERSAL::isa, avg 929ns/call
182 || throw_exception( AddRoleTakesAMooseMetaRoleInstance => role_to_be_added => $role,
183 class_name => $self->name,
184 );
18528121µs2867µs push @{$self->roles} => $role;
# spent 67µs making 28 calls to Moose::Meta::Class::roles, avg 2µs/call
186}
187
188sub role_applications {
189 my ($self) = @_;
190
191 return @{$self->_get_role_applications};
192}
193
194
# spent 346µs (235+112) within Moose::Meta::Class::add_role_application which was called 28 times, avg 12µs/call: # 28 times (235µs+112µs) by Moose::Meta::Role::Application::ToClass::apply at line 34 of Moose/Meta/Role/Application/ToClass.pm, avg 12µs/call
sub add_role_application {
195289µs my ($self, $application) = @_;
196
19728144µs5645µs (blessed($application) && $application->isa('Moose::Meta::Role::Application::ToClass'))
# spent 25µs making 28 calls to UNIVERSAL::isa, avg 886ns/call # spent 20µs making 28 calls to Scalar::Util::blessed, avg 718ns/call
198 || throw_exception( InvalidRoleApplication => class_name => $self->name,
199 application => $application,
200 );
201
20228113µs2867µs push @{$self->_get_role_applications} => $application;
# spent 67µs making 28 calls to Moose::Meta::Class::_get_role_applications, avg 2µs/call
203}
204
205
# spent 1.54ms (475µs+1.07) within Moose::Meta::Class::calculate_all_roles which was called 40 times, avg 39µs/call: # 32 times (360µs+784µs) by Moose::Meta::Attribute::Native::Trait::_build_native_type at line 147 of Moose/Meta/Attribute/Native/Trait.pm, avg 36µs/call # 4 times (86µs+254µs) by Class::MOP::Class:::around at line 19 of Moose/Meta/Class/Immutable/Trait.pm, avg 85µs/call # 4 times (29µs+29µs) by Moose::Meta::Class::calculate_all_roles_with_inheritance at line 224, avg 14µs/call
sub calculate_all_roles {
2064018µs my $self = shift;
207409µs my %seen;
208154442µs1541.07ms grep { !$seen{$_->name}++ } map { $_->calculate_all_roles } @{ $self->roles };
# spent 926µs making 36 calls to Moose::Meta::Role::calculate_all_roles, avg 26µs/call # spent 116µs making 40 calls to Moose::Meta::Class::roles, avg 3µs/call # spent 22µs making 75 calls to Class::MOP::Package::name, avg 299ns/call # spent 3µs making 3 calls to Moose::Meta::Role::Composite::name, avg 1µs/call
209}
210
211sub _roles_with_inheritance {
212 my $self = shift;
213 my %seen;
214 grep { !$seen{$_->name}++ }
215 map { Class::MOP::class_of($_)->can('roles')
216 ? @{ Class::MOP::class_of($_)->roles }
217 : () }
218 $self->linearized_isa;
219}
220
221
# spent 1.01ms (185µs+829µs) within Moose::Meta::Class::calculate_all_roles_with_inheritance which was called 4 times, avg 253µs/call: # 4 times (185µs+829µs) by Class::MOP::Class:::around at line 25 of Moose/Meta/Class/Immutable/Trait.pm, avg 253µs/call
sub calculate_all_roles_with_inheritance {
22242µs my $self = shift;
22341µs my %seen;
22422119µs46610µs grep { !$seen{$_->name}++ }
# spent 448µs making 4 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::calculate_all_roles, avg 112µs/call # spent 76µs making 16 calls to Class::MOP::class_of, avg 5µs/call # spent 58µs making 4 calls to Moose::Meta::Class::calculate_all_roles, avg 14µs/call # spent 13µs making 8 calls to UNIVERSAL::can, avg 2µs/call # spent 8µs making 3 calls to Moose::Meta::Role::Composite::name, avg 3µs/call # spent 8µs making 11 calls to Class::MOP::Package::name, avg 691ns/call
225440µs4219µs map { Class::MOP::class_of($_)->can('calculate_all_roles')
# spent 219µs making 4 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::linearized_isa, avg 55µs/call
226 ? Class::MOP::class_of($_)->calculate_all_roles
227 : () }
228 $self->linearized_isa;
229}
230
231sub does_role {
232 my ($self, $role_name) = @_;
233
234 (defined $role_name)
235 || throw_exception( RoleNameRequired => class_name => $self->name );
236
237 foreach my $class ($self->class_precedence_list) {
238 my $meta = Class::MOP::class_of($class);
239 # when a Moose metaclass is itself extended with a role,
240 # this check needs to be done since some items in the
241 # class_precedence_list might in fact be Class::MOP
242 # based still.
243 next unless $meta && $meta->can('roles');
244 foreach my $role (@{$meta->roles}) {
245 return 1 if $role->does_role($role_name);
246 }
247 }
248 return 0;
249}
250
251
# spent 4.81ms (981µs+3.83) within Moose::Meta::Class::excludes_role which was called 28 times, avg 172µs/call: # 28 times (981µs+3.83ms) by Moose::Meta::Role::Application::ToClass::check_role_exclusions at line 39 of Moose/Meta/Role/Application/ToClass.pm, avg 172µs/call
sub excludes_role {
2522814µs my ($self, $role_name) = @_;
253
2542817µs (defined $role_name)
255 || throw_exception( RoleNameRequired => class_name => $self->name );
256
25728121µs283.03ms foreach my $class ($self->class_precedence_list) {
# spent 3.03ms making 28 calls to Class::MOP::Class::class_precedence_list, avg 108µs/call
258226143µs226555µs my $meta = Class::MOP::class_of($class);
# spent 555µs making 226 calls to Class::MOP::class_of, avg 2µs/call
259 # when a Moose metaclass is itself extended with a role,
260 # this check needs to be done since some items in the
261 # class_precedence_list might in fact be Class::MOP
262 # based still.
263226472µs226135µs next unless $meta && $meta->can('roles');
# spent 135µs making 226 calls to UNIVERSAL::can, avg 599ns/call
26456111µs56103µs foreach my $role (@{$meta->roles}) {
# spent 103µs making 56 calls to Moose::Meta::Class::roles, avg 2µs/call
265 return 1 if $role->excludes_role($role_name);
266 }
267 }
2682865µs return 0;
269}
270
271
# spent 27.0ms (327µs+26.7) within Moose::Meta::Class::new_object which was called 32 times, avg 845µs/call: # 32 times (327µs+26.7ms) by Moose::Meta::Attribute::_new at line 7 of (eval 45)[Eval/Closure.pm:144], avg 845µs/call
sub new_object {
2723212µs my $self = shift;
2733221µs my $params = @_ == 1 ? $_[0] : {@_};
2743259µs3222.8ms my $object = $self->SUPER::new_object($params);
# spent 22.8ms making 32 calls to Class::MOP::Class::new_object, avg 713µs/call
275
2763262µs323.86ms $self->_call_all_triggers($object, $params);
# spent 3.86ms making 32 calls to Moose::Meta::Class::_call_all_triggers, avg 121µs/call
277
27832100µs3232µs $object->BUILDALL($params) if $object->can('BUILDALL');
# spent 32µs making 32 calls to UNIVERSAL::can, avg 988ns/call
279
2803263µs return $object;
281}
282
283
# spent 3.86ms (1.43+2.44) within Moose::Meta::Class::_call_all_triggers which was called 32 times, avg 121µs/call: # 32 times (1.43ms+2.44ms) by Moose::Meta::Class::new_object at line 276, avg 121µs/call
sub _call_all_triggers {
2843211µs my ($self, $object, $params) = @_;
285
28632183µs322.00ms foreach my $attr ( $self->get_all_attributes() ) {
# spent 2.00ms making 32 calls to Class::MOP::Class::get_all_attributes, avg 62µs/call
287
2889281.58ms960438µs next unless $attr->can('has_trigger') && $attr->has_trigger;
# spent 385µs making 928 calls to UNIVERSAL::can, avg 415ns/call # spent 53µs making 32 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 2µs/call
289
290 my $init_arg = $attr->init_arg;
291 next unless defined $init_arg;
292 next unless exists $params->{$init_arg};
293
294 $attr->trigger->(
295 $object,
296 (
297 $attr->should_coerce
298 ? $attr->get_read_method_ref->($object)
299 : $params->{$init_arg}
300 ),
301 );
302 }
303}
304
305
# spent 74µs within Moose::Meta::Class::_generate_fallback_constructor which was called 28 times, avg 3µs/call: # 28 times (74µs+0s) by Class::MOP::Class::_inline_fallback_constructor at line 554 of Class/MOP/Class.pm, avg 3µs/call
sub _generate_fallback_constructor {
3062810µs my $self = shift;
307289µs my ($class) = @_;
3082874µs return $class . '->Moose::Object::new(@_)'
309}
310
311
# spent 2.96ms (144µs+2.81) within Moose::Meta::Class::_inline_params which was called 28 times, avg 106µs/call: # 28 times (144µs+2.81ms) by Class::MOP::Class::_inline_new_object at line 538 of Class/MOP/Class.pm, avg 106µs/call
sub _inline_params {
3122810µs my $self = shift;
3132816µs my ($params, $class) = @_;
314 return (
31528112µs282.81ms 'my ' . $params . ' = ',
# spent 2.81ms making 28 calls to Moose::Meta::Class::_inline_BUILDARGS, avg 100µs/call
316 $self->_inline_BUILDARGS($class, '@_'),
317 ';',
318 );
319}
320
321
# spent 2.81ms (409µs+2.40) within Moose::Meta::Class::_inline_BUILDARGS which was called 28 times, avg 100µs/call: # 28 times (409µs+2.40ms) by Moose::Meta::Class::_inline_params at line 315, avg 100µs/call
sub _inline_BUILDARGS {
322285µs my $self = shift;
3232812µs my ($class, $args) = @_;
324
3252865µs282.32ms my $buildargs = $self->find_method_by_name("BUILDARGS");
# spent 2.32ms making 28 calls to Class::MOP::Class::find_method_by_name, avg 83µs/call
326
32728268µs7081µs if ($args eq '@_'
# spent 44µs making 14 calls to Moose::Meta::Class::_inline_throw_exception, avg 3µs/call # spent 21µs making 28 calls to Class::MOP::Method::__ANON__[Class/MOP/Method.pm:16], avg 736ns/call # spent 17µs making 28 calls to Class::MOP::Method::body, avg 593ns/call
328 && (!$buildargs or $buildargs->body == \&Moose::Object::BUILDARGS)) {
329 return (
330 'do {',
331 'my $params;',
332 'if (scalar @_ == 1) {',
333 'if (!defined($_[0]) || ref($_[0]) ne \'HASH\') {',
334 $self->_inline_throw_exception(
335 'SingleParamsToNewMustBeHashRef'
336 ) . ';',
337 '}',
338 '$params = { %{ $_[0] } };',
339 '}',
340 'elsif (@_ % 2) {',
341 'Carp::carp(',
342 '"The new() method for ' . $class . ' expects a '
343 . 'hash reference or a key/value list. You passed an '
344 . 'odd number of arguments"',
345 ');',
346 '$params = {@_, undef};',
347 '}',
348 'else {',
349 '$params = {@_};',
350 '}',
351 '$params;',
352 '}',
353 );
354 }
355 else {
3561441µs return $class . '->BUILDARGS(' . $args . ')';
357 }
358}
359
360
# spent 50.2ms (1.18+49.0) within Moose::Meta::Class::_inline_slot_initializer which was called 186 times, avg 270µs/call: # 186 times (1.18ms+49.0ms) by Class::MOP::Class::_inline_slot_initializers at line 592 of Class/MOP/Class.pm, avg 270µs/call
sub _inline_slot_initializer {
36118634µs my $self = shift;
36218637µs my ($attr, $idx) = @_;
363
364 return (
3651861.01ms55849.0ms '## ' . $attr->name,
# spent 46.6ms making 186 calls to Class::MOP::Class::_inline_slot_initializer, avg 250µs/call # spent 2.35ms making 186 calls to Moose::Meta::Class::_inline_check_required_attr, avg 13µs/call # spent 76µs making 186 calls to Class::MOP::Mixin::AttributeCore::name, avg 411ns/call
366 $self->_inline_check_required_attr($attr),
367 $self->SUPER::_inline_slot_initializer(@_),
368 );
369}
370
371
# spent 2.35ms (1.64+706µs) within Moose::Meta::Class::_inline_check_required_attr which was called 186 times, avg 13µs/call: # 186 times (1.64ms+706µs) by Moose::Meta::Class::_inline_slot_initializer at line 365, avg 13µs/call
sub _inline_check_required_attr {
37218630µs my $self = shift;
37318632µs my ($attr) = @_;
374
375186432µs18682µs return unless defined $attr->init_arg;
# spent 82µs making 186 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 440ns/call
376169662µs338339µs return unless $attr->can('is_required') && $attr->is_required;
# spent 207µs making 169 calls to Moose::Meta::Mixin::AttributeCore::is_required, avg 1µs/call # spent 131µs making 169 calls to UNIVERSAL::can, avg 777ns/call
37765106µs130112µs return if $attr->has_default || $attr->has_builder;
# spent 57µs making 65 calls to Class::MOP::Mixin::AttributeCore::has_builder, avg 874ns/call # spent 56µs making 65 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 855ns/call
378
379 return (
38065458µs195173µs 'if (!exists $params->{\'' . $attr->init_arg . '\'}) {',
# spent 133µs making 65 calls to Moose::Meta::Class::_inline_throw_exception, avg 2µs/call # spent 20µs making 65 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 314ns/call # spent 19µs making 65 calls to Class::MOP::Mixin::AttributeCore::name, avg 298ns/call
381 $self->_inline_throw_exception(
382 AttributeIsRequired =>
383 'params => $params, '.
384 'class_name => $class_name, '.
385 'attribute_name => "'.quotemeta($attr->name).'"'
386 ).';',
387 '}',
388 );
389}
390
391# XXX: these two are duplicated from cmop, because we have to pass the tc stuff
392# through to _inline_set_value - this should probably be fixed, but i'm not
393# quite sure how. -doy
394
# spent 34.7ms (1.43+33.3) within Moose::Meta::Class::_inline_init_attr_from_constructor which was called 169 times, avg 205µs/call: # 169 times (1.43ms+33.3ms) by Class::MOP::Class::_inline_slot_initializer at line 601 of Class/MOP/Class.pm, avg 205µs/call
sub _inline_init_attr_from_constructor {
39516927µs my $self = shift;
39616932µs my ($attr, $idx) = @_;
397
398169657µs33833.1ms my @initial_value = $attr->_inline_set_value(
# spent 33.1ms making 169 calls to Moose::Meta::Attribute::_inline_set_value, avg 196µs/call # spent 37µs making 169 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 217ns/call
399 '$instance',
400 '$params->{\'' . $attr->init_arg . '\'}',
401 '$type_constraint_bodies[' . $idx . ']',
402 '$type_coercions[' . $idx . ']',
403 '$type_constraint_messages[' . $idx . ']',
404 'for constructor',
405 );
406
407169150µs169168µs push @initial_value, (
# spent 168µs making 169 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 991ns/call
408 '$attrs->[' . $idx . ']->set_initial_value(',
409 '$instance,',
410 $attr->_inline_instance_get('$instance'),
411 ');',
412 ) if $attr->has_initializer;
413
414169427µs return @initial_value;
415}
416
417
# spent 10.0ms (1.57+8.44) within Moose::Meta::Class::_inline_init_attr_from_default which was called 186 times, avg 54µs/call: # 169 times (1.42ms+7.67ms) by Class::MOP::Class::_inline_slot_initializer at line 606 of Class/MOP/Class.pm, avg 54µs/call # 17 times (142µs+775µs) by Class::MOP::Class::_inline_slot_initializer at line 600 of Class/MOP/Class.pm, avg 54µs/call
sub _inline_init_attr_from_default {
41818635µs my $self = shift;
41918637µs my ($attr, $idx) = @_;
420
421186580µs372315µs return if $attr->can('is_lazy') && $attr->is_lazy;
# spent 186µs making 186 calls to Moose::Meta::Mixin::AttributeCore::is_lazy, avg 1µs/call # spent 129µs making 186 calls to UNIVERSAL::can, avg 692ns/call
422171181µs1711.18ms my $default = $self->_inline_default_value($attr, $idx);
# spent 1.18ms making 171 calls to Class::MOP::Class::_inline_default_value, avg 7µs/call
423171164µs return unless $default;
424
42570169µs706.88ms my @initial_value = (
# spent 6.88ms making 70 calls to Moose::Meta::Attribute::_inline_set_value, avg 98µs/call
426 'my $default = ' . $default . ';',
427 $attr->_inline_set_value(
428 '$instance',
429 '$default',
430 '$type_constraint_bodies[' . $idx . ']',
431 '$type_coercions[' . $idx . ']',
432 '$type_constraint_messages[' . $idx . ']',
433 'for constructor',
434 ),
435 );
436
4377062µs7064µs push @initial_value, (
# spent 64µs making 70 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 909ns/call
438 '$attrs->[' . $idx . ']->set_initial_value(',
439 '$instance,',
440 $attr->_inline_instance_get('$instance'),
441 ');',
442 ) if $attr->has_initializer;
443
44470218µs return @initial_value;
445}
446
447
# spent 10.9ms (149µs+10.7) within Moose::Meta::Class::_inline_extra_init which was called 28 times, avg 389µs/call: # 28 times (149µs+10.7ms) by Class::MOP::Class::_inline_new_object at line 538 of Class/MOP/Class.pm, avg 389µs/call
sub _inline_extra_init {
448289µs my $self = shift;
449 return (
45028126µs5610.7ms $self->_inline_triggers,
# spent 7.60ms making 28 calls to Moose::Meta::Class::_inline_BUILDALL, avg 271µs/call # spent 3.15ms making 28 calls to Moose::Meta::Class::_inline_triggers, avg 112µs/call
451 $self->_inline_BUILDALL,
452 );
453}
454
455
# spent 3.15ms (882µs+2.26) within Moose::Meta::Class::_inline_triggers which was called 28 times, avg 112µs/call: # 28 times (882µs+2.26ms) by Moose::Meta::Class::_inline_extra_init at line 450, avg 112µs/call
sub _inline_triggers {
4562811µs my $self = shift;
457285µs my @trigger_calls;
458
4594021.21ms8042.20ms my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes;
# spent 1.11ms making 28 calls to Moose::Meta::Class::CORE:sort, avg 40µs/call # spent 903µs making 28 calls to Class::MOP::Class::get_all_attributes, avg 32µs/call # spent 192µs making 748 calls to Class::MOP::Mixin::AttributeCore::name, avg 257ns/call
4602883µs for my $i (0 .. $#attrs) {
46118638µs my $attr = $attrs[$i];
462
463186525µs372253µs next unless $attr->can('has_trigger') && $attr->has_trigger;
# spent 145µs making 186 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 777ns/call # spent 109µs making 186 calls to UNIVERSAL::can, avg 584ns/call
464
465 my $init_arg = $attr->init_arg;
466 next unless defined $init_arg;
467
468 push @trigger_calls,
469 'if (exists $params->{\'' . $init_arg . '\'}) {',
470 '$triggers->[' . $i . ']->(',
471 '$instance,',
472 $attr->_inline_instance_get('$instance') . ',',
473 ');',
474 '}';
475 }
476
4772865µs return @trigger_calls;
478}
479
480
# spent 7.60ms (166µs+7.43) within Moose::Meta::Class::_inline_BUILDALL which was called 28 times, avg 271µs/call: # 28 times (166µs+7.43ms) by Moose::Meta::Class::_inline_extra_init at line 450, avg 271µs/call
sub _inline_BUILDALL {
4812812µs my $self = shift;
482
4832870µs287.43ms my @methods = reverse $self->find_all_methods_by_name('BUILD');
# spent 7.43ms making 28 calls to Class::MOP::Class::find_all_methods_by_name, avg 265µs/call
484284µs my @BUILD_calls;
485
4862814µs foreach my $method (@methods) {
4871214µs push @BUILD_calls,
488 '$instance->' . $method->{class} . '::BUILD($params);';
489 }
490
4912856µs return @BUILD_calls;
492}
493
494
# spent 26.6ms (12.0+14.5) within Moose::Meta::Class::_eval_environment which was called 28 times, avg 949µs/call: # 28 times (12.0ms+14.5ms) by Class::MOP::Method::Constructor::_eval_environment at line 86 of Class/MOP/Method/Constructor.pm, avg 949µs/call
sub _eval_environment {
495289µs my $self = shift;
496
4973994.55ms7985.41ms my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes;
# spent 4.45ms making 28 calls to Moose::Meta::Class::CORE:sort, avg 159µs/call # spent 786µs making 28 calls to Class::MOP::Class::get_all_attributes, avg 28µs/call # spent 174µs making 742 calls to Class::MOP::Mixin::AttributeCore::name, avg 235ns/call
498
499186462µs372229µs my $triggers = [
# spent 129µs making 186 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 694ns/call # spent 100µs making 186 calls to UNIVERSAL::can, avg 539ns/call
5002891µs map { $_->can('has_trigger') && $_->has_trigger ? $_->trigger : undef }
501 @attrs
502 ];
503
504 # We need to check if the attribute ->can('type_constraint')
505 # since we may be trying to immutabilize a Moose meta class,
506 # which in turn has attributes which are Class::MOP::Attribute
507 # objects, rather than Moose::Meta::Attribute. And
508 # Class::MOP::Attribute attributes have no type constraints.
509 # However we need to make sure we leave an undef value there
510 # because the inlined code is using the index of the attributes
511 # to determine where to find the type constraint
512
513186425µs372222µs my @type_constraints = map {
# spent 137µs making 186 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 735ns/call # spent 85µs making 186 calls to UNIVERSAL::can, avg 456ns/call
5142875µs $_->can('type_constraint') ? $_->type_constraint : undef
515 } @attrs;
516
517186175µs186199µs my @type_constraint_bodies = map {
# spent 199µs making 186 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 1µs/call
5182872µs defined $_ ? $_->_compiled_type_constraint : undef;
519 } @type_constraints;
520
521186181µs188155µs my @type_coercions = map {
# spent 153µs making 186 calls to Moose::Meta::TypeConstraint::has_coercion, avg 820ns/call # spent 2µs making 1 call to Moose::Meta::TypeCoercion::_compiled_type_coercion # spent 1µs making 1 call to Moose::Meta::TypeConstraint::coercion
5222875µs defined $_ && $_->has_coercion
523 ? $_->coercion->_compiled_type_coercion
524 : undef
525 } @type_constraints;
526
527186313µs372319µs my @type_constraint_messages = map {
# spent 168µs making 186 calls to Moose::Meta::TypeConstraint::_default_message, avg 904ns/call # spent 151µs making 186 calls to Moose::Meta::TypeConstraint::has_message, avg 812ns/call
5282880µs defined $_
529 ? ($_->has_message ? $_->message : $_->_default_message)
530 : undef
531 } @type_constraints;
532
533 return {
534 %{ $self->SUPER::_eval_environment },
535372410µs3721.99ms ((any { defined && $_->has_initializer } @attrs)
# spent 1.33ms making 173 calls to Moose::Meta::TypeConstraint::inline_environment, avg 8µs/call # spent 532µs making 13 calls to Moose::Meta::TypeConstraint::Parameterized::inline_environment, avg 41µs/call # spent 129µs making 186 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 695ns/call
536 ? ('$attrs' => \[@attrs])
537 : ()),
538 '$triggers' => \$triggers,
539 '@type_coercions' => \@type_coercions,
540 '@type_constraint_bodies' => \@type_constraint_bodies,
541 '@type_constraint_messages' => \@type_constraint_messages,
542214579µs846.32ms ( map { defined($_) ? %{ $_->inline_environment } : () }
# spent 5.79ms making 28 calls to Class::MOP::Class::_eval_environment, avg 207µs/call # spent 513µs making 28 calls to List::Util::any, avg 18µs/call # spent 20µs making 28 calls to Class::MOP::Package::name, avg 696ns/call
543 @type_constraints ),
544 # pretty sure this is only going to be closed over if you use a custom
545 # error class at this point, but we should still get rid of this
546 # at some point
547 '$meta' => \$self,
548 '$class_name' => \($self->name),
549 };
550}
551
552
# spent 607ms (2.17+605) within Moose::Meta::Class::superclasses which was called 261 times, avg 2.33ms/call: # 91 times (644µs+536µs) by Class::MOP::Class::_check_metaclass_compatibility at line 197 of Class/MOP/Class.pm, avg 13µs/call # 56 times (559µs+14.4ms) by Moose::init_meta at line 225 of Moose.pm, avg 268µs/call # 52 times (288µs+-288µs) by Class::MOP::Class::_superclasses_updated at line 979 of Class/MOP/Class.pm, avg 0s/call # 37 times (238µs+168µs) by Class::MOP::Class::class_precedence_list at line 1038 of Class/MOP/Class.pm, avg 11µs/call # 14 times (253µs+590ms) by Moose::extends at line 55 of Moose.pm, avg 42.2ms/call # 10 times (184µs+-184µs) by Class::MOP::Class::create at line 449 of Class/MOP/Class.pm, avg 0s/call # once (5µs+23µs) by Class::MOP::Class:::around at line 34 of Class/MOP/Class/Immutable/Trait.pm
sub superclasses {
55326146µs my $self = shift;
554261325µs2611.90ms my $supers = Data::OptList::mkopt(\@_);
# spent 1.90ms making 261 calls to Data::OptList::mkopt, avg 7µs/call
555261178µs foreach my $super (@{ $supers }) {
5566035µs my ($name, $opts) = @{ $super };
5576095µs60584ms Moose::Util::_load_user_class($name, $opts);
# spent 585ms making 60 calls to Moose::Util::_load_user_class, avg 9.75ms/call, recursion: max depth 1, sum of overlapping time 1.11ms
5586085µs60271µs my $meta = Class::MOP::class_of($name);
# spent 271µs making 60 calls to Class::MOP::class_of, avg 5µs/call
55960306µs60121µs throw_exception( CanExtendOnlyClasses => role_name => $meta->name )
# spent 121µs making 60 calls to UNIVERSAL::isa, avg 2µs/call
560 if $meta && $meta->isa('Moose::Meta::Role')
561 }
562261983µs26138.3ms return $self->SUPER::superclasses(map { $_->[0] } @{ $supers });
# spent 39.5ms making 261 calls to Class::MOP::Class::superclasses, avg 151µs/call, recursion: max depth 1, sum of overlapping time 1.15ms
563}
564
565### ---------------------------------------------
566
567
# spent 563ms (1.49+561) within Moose::Meta::Class::add_attribute which was called 109 times, avg 5.16ms/call: # 60 times (772µs+188ms) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 126 of Moose/Meta/Role/Application/ToClass.pm, avg 3.14ms/call # 49 times (718µs+373ms) by Moose::has at line 76 of Moose.pm, avg 7.63ms/call
sub add_attribute {
56810934µs my $self = shift;
569109620µs21868.4ms my $attr =
# spent 68.3ms making 49 calls to Moose::Meta::Class::_process_attribute, avg 1.39ms/call # spent 72µs making 109 calls to Scalar::Util::blessed, avg 664ns/call # spent 46µs making 60 calls to UNIVERSAL::isa, avg 772ns/call
570 (blessed $_[0] && $_[0]->isa('Class::MOP::Attribute')
571 ? $_[0]
572 : $self->_process_attribute(@_));
573109208µs109494ms $self->SUPER::add_attribute($attr);
# spent 494ms making 109 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 4.53ms/call
574 # it may be a Class::MOP::Attribute, theoretically, which doesn't have
575 # 'bare' and doesn't implement this method
576109528µs218653µs if ($attr->can('_check_associated_methods')) {
# spent 489µs making 109 calls to Moose::Meta::Attribute::_check_associated_methods, avg 4µs/call # spent 163µs making 109 calls to UNIVERSAL::can, avg 1µs/call
577 $attr->_check_associated_methods;
578 }
579109251µs return $attr;
580}
581
582
# spent 4.24ms (190µs+4.05) within Moose::Meta::Class::add_override_method_modifier which was called 25 times, avg 170µs/call: # 24 times (179µs+3.77ms) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 194 of Moose/Meta/Role/Application/ToClass.pm, avg 165µs/call # once (11µs+280µs) by Moose::override at line 109 of Moose.pm
sub add_override_method_modifier {
5832512µs my ($self, $name, $method, $_super_package) = @_;
584
5852522µs25358µs my $existing_method = $self->get_method($name);
# spent 358µs making 25 calls to Class::MOP::Mixin::HasMethods::get_method, avg 14µs/call
586255µs (!$existing_method)
587 || throw_exception( CannotOverrideLocalMethodIsPresent => class_name => $self->name,
588 method => $existing_method,
589 );
59025108µs503.69ms $self->add_method($name => Moose::Meta::Method::Overridden->new(
# spent 2.43ms making 25 calls to Moose::Meta::Method::Overridden::new, avg 97µs/call # spent 1.26ms making 25 calls to Class::MOP::Mixin::HasMethods::add_method, avg 50µs/call
591 method => $method,
592 class => $self,
593 package => $_super_package, # need this for roles
594 name => $name,
595 ));
596}
597
598sub add_augment_method_modifier {
599 my ($self, $name, $method) = @_;
600 my $existing_method = $self->get_method($name);
601 throw_exception( CannotAugmentIfLocalMethodPresent => class_name => $self->name,
602 method => $existing_method,
603 )
604 if( $existing_method );
605
606 $self->add_method($name => Moose::Meta::Method::Augmented->new(
607 method => $method,
608 class => $self,
609 name => $name,
610 ));
611}
612
613## Private Utility methods ...
614
615sub _find_next_method_by_name_which_is_not_overridden {
616 my ($self, $name) = @_;
617 foreach my $method ($self->find_all_methods_by_name($name)) {
618 return $method->{code}
619 if blessed($method->{code}) && !$method->{code}->isa('Moose::Meta::Method::Overridden');
620 }
621 return undef;
622}
623
624## Metaclass compatibility
625
626
# spent 2.67ms (1.82+847µs) within Moose::Meta::Class::_base_metaclasses which was called 112 times, avg 24µs/call: # 60 times (1.09ms+523µs) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 324 of Class/MOP/Class.pm, avg 27µs/call # 52 times (729µs+324µs) by Class::MOP::Class::_check_metaclass_compatibility at line 202 of Class/MOP/Class.pm, avg 20µs/call
sub _base_metaclasses {
62711227µs my $self = shift;
628112296µs112242µs my %metaclasses = $self->SUPER::_base_metaclasses;
# spent 242µs making 112 calls to Class::MOP::Class::_base_metaclasses, avg 2µs/call
629112125µs for my $class (keys %metaclasses) {
6306721.57ms672606µs $metaclasses{$class} =~ s/^Class::MOP/Moose::Meta/;
# spent 606µs making 672 calls to Moose::Meta::Class::CORE:subst, avg 901ns/call
631 }
632 return (
6331124.51ms %metaclasses,
634 );
635}
636
637sub _fix_class_metaclass_incompatibility {
638 my $self = shift;
639 my ($super_meta) = @_;
640
641 $self->SUPER::_fix_class_metaclass_incompatibility(@_);
642
643 if ($self->_class_metaclass_can_be_made_compatible($super_meta)) {
644 ($self->is_pristine)
645 || throw_exception( CannotFixMetaclassCompatibility => class => $self,
646 superclass => $super_meta
647 );
648 my $super_meta_name = $super_meta->_real_ref_name;
649 my $class_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass(blessed($self), $super_meta_name);
650 my $new_self = $class_meta_subclass_meta_name->reinitialize(
651 $self->name,
652 );
653
654 $self->_replace_self( $new_self, $class_meta_subclass_meta_name );
655 }
656}
657
658sub _fix_single_metaclass_incompatibility {
659 my $self = shift;
660 my ($metaclass_type, $super_meta) = @_;
661
662 $self->SUPER::_fix_single_metaclass_incompatibility(@_);
663
664 if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) {
665 ($self->is_pristine)
666 || throw_exception( CannotFixMetaclassCompatibility => class => $self,
667 superclass => $super_meta,
668 metaclass_type => $metaclass_type
669 );
670 my $super_meta_name = $super_meta->_real_ref_name;
671 my $class_specific_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass($self->$metaclass_type, $super_meta->$metaclass_type);
672 my $new_self = $super_meta->reinitialize(
673 $self->name,
674 $metaclass_type => $class_specific_meta_subclass_meta_name,
675 );
676
677 $self->_replace_self( $new_self, $super_meta_name );
678 }
679}
680
681sub _replace_self {
682 my $self = shift;
683 my ( $new_self, $new_class) = @_;
684
685 %$self = %$new_self;
686 bless $self, $new_class;
687
688 # We need to replace the cached metaclass instance or else when it goes
689 # out of scope Class::MOP::Class destroy's the namespace for the
690 # metaclass's class, causing much havoc.
691 my $weaken = Class::MOP::metaclass_is_weak( $self->name );
692 Class::MOP::store_metaclass_by_name( $self->name, $self );
693 Class::MOP::weaken_metaclass( $self->name ) if $weaken;
694}
695
696
# spent 68.3ms (404µs+67.9) within Moose::Meta::Class::_process_attribute which was called 49 times, avg 1.39ms/call: # 49 times (404µs+67.9ms) by Moose::Meta::Class::add_attribute at line 569, avg 1.39ms/call
sub _process_attribute {
6974972µs my ( $self, $name, @args ) = @_;
698
6994927µs @args = %{$args[0]} if scalar @args == 1 && ref($args[0]) eq 'HASH';
700
70149145µs4939µs if (($name || '') =~ /^\+(.*)/) {
# spent 39µs making 49 calls to Moose::Meta::Class::CORE:match, avg 798ns/call
70215µs11.22ms return $self->_process_inherited_attribute($1, @args);
# spent 1.22ms making 1 call to Moose::Meta::Class::_process_inherited_attribute
703 }
704 else {
70548201µs4866.6ms return $self->_process_new_attribute($name, @args);
# spent 66.6ms making 48 calls to Moose::Meta::Class::_process_new_attribute, avg 1.39ms/call
706 }
707}
708
709
# spent 66.6ms (381µs+66.2) within Moose::Meta::Class::_process_new_attribute which was called 48 times, avg 1.39ms/call: # 48 times (381µs+66.2ms) by Moose::Meta::Class::_process_attribute at line 705, avg 1.39ms/call
sub _process_new_attribute {
7104864µs my ( $self, $name, @args ) = @_;
711
71248374µs9666.2ms $self->attribute_metaclass->interpolate_class_and_new($name, @args);
# spent 66.2ms making 48 calls to Moose::Meta::Attribute::interpolate_class_and_new, avg 1.38ms/call # spent 57µs making 48 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 1µs/call
713}
714
715
# spent 1.22ms (20µs+1.20) within Moose::Meta::Class::_process_inherited_attribute which was called: # once (20µs+1.20ms) by Moose::Meta::Class::_process_attribute at line 702
sub _process_inherited_attribute {
71613µs my ($self, $attr_name, %options) = @_;
717
71817µs146µs my $inherited_attr = $self->find_attribute_by_name($attr_name);
# spent 46µs making 1 call to Class::MOP::Class::find_attribute_by_name
7191200ns (defined $inherited_attr)
720 || throw_exception( NoAttributeFoundInSuperClass => class_name => $self->name,
721 attribute_name => $attr_name,
722 params => \%options
723 );
724111µs21.15ms if ($inherited_attr->isa('Moose::Meta::Attribute')) {
# spent 1.15ms making 1 call to Moose::Meta::Attribute::clone_and_inherit_options # spent 1µs making 1 call to UNIVERSAL::isa
725 return $inherited_attr->clone_and_inherit_options(%options);
726 }
727 else {
728 # NOTE:
729 # kind of a kludge to handle Class::MOP::Attributes
730 return $inherited_attr->Moose::Meta::Attribute::clone_and_inherit_options(%options);
731 }
732}
733
734# reinitialization support
735
736sub _restore_metaobjects_from {
737 my $self = shift;
738 my ($old_meta) = @_;
739
740 $self->SUPER::_restore_metaobjects_from($old_meta);
741
742 for my $role ( @{ $old_meta->roles } ) {
743 $self->add_role($role);
744 }
745
746 for my $application ( @{ $old_meta->_get_role_applications } ) {
747 $application->class($self);
748 $self->add_role_application ($application);
749 }
750}
751
752## Immutability
753
754
# spent 6.05ms (136µs+5.91) within Moose::Meta::Class::_immutable_options which was called 28 times, avg 216µs/call: # 28 times (136µs+5.91ms) by Class::MOP::Class::make_immutable at line 1297 of Class/MOP/Class.pm, avg 216µs/call
sub _immutable_options {
7552811µs my ( $self, @args ) = @_;
756
75728114µs285.91ms $self->SUPER::_immutable_options(
# spent 5.91ms making 28 calls to Class::MOP::Class::_immutable_options, avg 211µs/call
758 inline_destructor => 1,
759
760 # Moose always does this when an attribute is created
761 inline_accessors => 0,
762
763 @args,
764 );
765}
766
767sub _fixup_attributes_after_rebless {
768 my $self = shift;
769 my ($instance, $rebless_from, %params) = @_;
770
771 $self->SUPER::_fixup_attributes_after_rebless(
772 $instance,
773 $rebless_from,
774 %params
775 );
776
777 $self->_call_all_triggers( $instance, \%params );
778}
779
780## -------------------------------------------------
781
7821100nsour $error_level;
783
784
# spent 177µs within Moose::Meta::Class::_inline_throw_exception which was called 79 times, avg 2µs/call: # 65 times (133µs+0s) by Moose::Meta::Class::_inline_check_required_attr at line 380, avg 2µs/call # 14 times (44µs+0s) by Moose::Meta::Class::_inline_BUILDARGS at line 327, avg 3µs/call
sub _inline_throw_exception {
7857936µs my ( $self, $exception_type, $throw_args ) = @_;
78679222µs return 'die Module::Runtime::use_module("Moose::Exception::' . $exception_type . '")->new(' . ($throw_args || '') . ')';
787}
788
789110µs1;
790
791# ABSTRACT: The Moose metaclass
792
793__END__