| Filename | /home/doy/coding/src/Moose/blib/lib//Moose/Meta/Class.pm |
| Statements | Executed 7217 statements in 138ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 196 | 7 | 3 | 14.0ms | 219ms | Moose::Meta::Class::superclasses (recurses: max depth 1, inclusive time 13.2ms) |
| 123 | 2 | 2 | 12.5ms | 2.34s | Moose::Meta::Class::add_attribute (recurses: max depth 1, inclusive time 34.4ms) |
| 73 | 2 | 1 | 11.1ms | 16.6ms | Moose::Meta::Class::_base_metaclasses |
| 1 | 1 | 1 | 9.53ms | 13.4ms | Moose::Meta::Class::BEGIN@26 |
| 105 | 1 | 1 | 7.14ms | 62.8ms | Moose::Meta::Class::_inline_init_attr_from_constructor |
| 111 | 1 | 1 | 7.10ms | 130ms | Moose::Meta::Class::_inline_slot_initializer |
| 111 | 1 | 1 | 6.94ms | 10.9ms | Moose::Meta::Class::_inline_check_required_attr |
| 111 | 2 | 1 | 5.92ms | 39.0ms | Moose::Meta::Class::_inline_init_attr_from_default |
| 114 | 1 | 1 | 5.86ms | 552ms | Moose::Meta::Class::_process_new_attribute |
| 116 | 1 | 1 | 5.81ms | 578ms | Moose::Meta::Class::_process_attribute |
| 21 | 1 | 1 | 5.05ms | 28.6ms | Moose::Meta::Class::excludes_role |
| 24 | 1 | 1 | 4.92ms | 20.1ms | Moose::Meta::Class::_inline_triggers |
| 39 | 2 | 1 | 4.81ms | 6.68ms | Moose::Meta::Class::CORE:sort (opcode) |
| 438 | 1 | 1 | 4.10ms | 4.10ms | Moose::Meta::Class::CORE:subst (opcode) |
| 1 | 1 | 1 | 2.81ms | 3.94ms | Moose::Meta::Class::BEGIN@24 |
| 6 | 2 | 2 | 2.66ms | 31.1ms | Moose::Meta::Class::new_object |
| 1 | 1 | 1 | 2.09ms | 3.30ms | Moose::Meta::Class::BEGIN@23 |
| 34 | 3 | 3 | 2.04ms | 140ms | Moose::Meta::Class::initialize |
| 24 | 1 | 1 | 1.92ms | 14.7ms | Moose::Meta::Class::_inline_BUILDARGS |
| 1 | 1 | 1 | 1.61ms | 2.33ms | Moose::Meta::Class::BEGIN@22 |
| 1 | 1 | 1 | 1.59ms | 13.9ms | Moose::Meta::Class::BEGIN@21 |
| 1 | 1 | 1 | 1.53ms | 2.14ms | Moose::Meta::Class::BEGIN@20 |
| 1 | 1 | 1 | 1.30ms | 14.4ms | Moose::Meta::Class::BEGIN@19 |
| 1 | 1 | 1 | 1.21ms | 1.86ms | Moose::Meta::Class::BEGIN@25 |
| 15 | 2 | 2 | 1.19ms | 383ms | Moose::Meta::Class::create_anon_class |
| 21 | 1 | 1 | 1.08ms | 1.61ms | Moose::Meta::Class::add_role_application |
| 21 | 1 | 1 | 1.08ms | 1.68ms | Moose::Meta::Class::add_role |
| 24 | 1 | 1 | 998µs | 4.24ms | Moose::Meta::Class::_immutable_options |
| 15 | 1 | 1 | 905µs | 20.6ms | Moose::Meta::Class::add_override_method_modifier |
| 24 | 1 | 1 | 883µs | 15.0ms | Moose::Meta::Class::_inline_BUILDALL |
| 24 | 1 | 1 | 858µs | 36.0ms | Moose::Meta::Class::_inline_extra_init |
| 50 | 2 | 1 | 827µs | 827µs | Moose::Meta::Class::_inline_throw_error |
| 24 | 1 | 1 | 737µs | 15.5ms | Moose::Meta::Class::_inline_params |
| 116 | 1 | 1 | 706µs | 706µs | Moose::Meta::Class::CORE:match (opcode) |
| 8 | 1 | 1 | 630µs | 381ms | Moose::Meta::Class::create |
| 15 | 1 | 1 | 456µs | 518µs | Moose::Meta::Class::_anon_cache_key |
| 24 | 1 | 1 | 418µs | 418µs | Moose::Meta::Class::_generate_fallback_constructor |
| 34 | 1 | 1 | 394µs | 394µs | Moose::Meta::Class::__ANON__[:40] |
| 34 | 1 | 1 | 359µs | 359µs | Moose::Meta::Class::__ANON__[:35] |
| 34 | 1 | 1 | 333µs | 333µs | Moose::Meta::Class::_meta_method_class |
| 2 | 1 | 1 | 181µs | 19.1ms | Moose::Meta::Class::_process_inherited_attribute |
| 2 | 1 | 1 | 174µs | 589µs | Moose::Meta::Class::calculate_all_roles |
| 1 | 1 | 1 | 66µs | 84µs | Moose::Meta::Class::BEGIN@4 |
| 1 | 1 | 1 | 63µs | 283µs | Moose::Meta::Class::BEGIN@12 |
| 1 | 1 | 1 | 48µs | 249µs | Moose::Meta::Class::BEGIN@13 |
| 1 | 1 | 1 | 41µs | 176µs | Moose::Meta::Class::BEGIN@11 |
| 1 | 1 | 1 | 38µs | 61µs | Moose::Meta::Class::BEGIN@10 |
| 1 | 1 | 1 | 37µs | 102µs | Moose::Meta::Class::BEGIN@5 |
| 1 | 1 | 1 | 35µs | 194µs | Moose::Meta::Class::BEGIN@9 |
| 1 | 1 | 1 | 35µs | 300µs | Moose::Meta::Class::BEGIN@29 |
| 1 | 1 | 1 | 29µs | 29µs | Moose::Meta::Class::BEGIN@27 |
| 1 | 1 | 1 | 24µs | 24µs | Moose::Meta::Class::BEGIN@7 |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_find_next_method_by_name_which_is_not_overridden |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_fix_class_metaclass_incompatibility |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_fix_single_metaclass_incompatibility |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_replace_self |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::add_augment_method_modifier |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::calculate_all_roles_with_inheritance |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::create_error |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::does_role |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::raise_error |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::reinitialize |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::role_applications |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::throw_error |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | package Moose::Meta::Class; | ||||
| 3 | |||||
| 4 | 3 | 93µs | 2 | 101µs | # spent 84µs (66+17) within Moose::Meta::Class::BEGIN@4 which was called:
# once (66µs+17µs) by Moose::BEGIN@19 at line 4 # spent 84µs making 1 call to Moose::Meta::Class::BEGIN@4
# spent 17µs making 1 call to strict::import |
| 5 | 3 | 92µs | 2 | 167µs | # spent 102µs (37+65) within Moose::Meta::Class::BEGIN@5 which was called:
# once (37µs+65µs) by Moose::BEGIN@19 at line 5 # spent 102µs making 1 call to Moose::Meta::Class::BEGIN@5
# spent 65µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 3 | 93µs | 1 | 24µs | # spent 24µs within Moose::Meta::Class::BEGIN@7 which was called:
# once (24µs+0s) by Moose::BEGIN@19 at line 7 # spent 24µs making 1 call to Moose::Meta::Class::BEGIN@7 |
| 8 | |||||
| 9 | 3 | 97µs | 2 | 352µs | # spent 194µs (35+158) within Moose::Meta::Class::BEGIN@9 which was called:
# once (35µs+158µs) by Moose::BEGIN@19 at line 9 # spent 194µs making 1 call to Moose::Meta::Class::BEGIN@9
# spent 158µs making 1 call to Exporter::import |
| 10 | 3 | 171µs | 2 | 83µs | # spent 61µs (38+22) within Moose::Meta::Class::BEGIN@10 which was called:
# once (38µs+22µs) by Moose::BEGIN@19 at line 10 # spent 61µs making 1 call to Moose::Meta::Class::BEGIN@10
# spent 22µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:284] |
| 11 | 3 | 136µs | 2 | 312µs | # spent 176µs (41+135) within Moose::Meta::Class::BEGIN@11 which was called:
# once (41µs+135µs) by Moose::BEGIN@19 at line 11 # spent 176µs making 1 call to Moose::Meta::Class::BEGIN@11
# spent 135µs making 1 call to Exporter::import |
| 12 | 3 | 136µs | 2 | 503µs | # spent 283µs (63+220) within Moose::Meta::Class::BEGIN@12 which was called:
# once (63µs+220µs) by Moose::BEGIN@19 at line 12 # spent 283µs making 1 call to Moose::Meta::Class::BEGIN@12
# spent 220µs making 1 call to Exporter::import |
| 13 | 3 | 245µs | 2 | 450µs | # spent 249µs (48+201) within Moose::Meta::Class::BEGIN@13 which was called:
# once (48µs+201µs) by Moose::BEGIN@19 at line 13 # spent 249µs making 1 call to Moose::Meta::Class::BEGIN@13
# spent 201µs making 1 call to Exporter::import |
| 14 | |||||
| 15 | 1 | 4µs | our $VERSION = '1.19'; | ||
| 16 | 1 | 74µs | $VERSION = eval $VERSION; # spent 11µs executing statements in string eval | ||
| 17 | 1 | 4µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 18 | |||||
| 19 | 3 | 477µs | 1 | 14.4ms | # spent 14.4ms (1.30+13.1) within Moose::Meta::Class::BEGIN@19 which was called:
# once (1.30ms+13.1ms) by Moose::BEGIN@19 at line 19 # spent 14.4ms making 1 call to Moose::Meta::Class::BEGIN@19 |
| 20 | 3 | 530µs | 1 | 2.14ms | # spent 2.14ms (1.53+606µs) within Moose::Meta::Class::BEGIN@20 which was called:
# once (1.53ms+606µs) by Moose::BEGIN@19 at line 20 # spent 2.14ms making 1 call to Moose::Meta::Class::BEGIN@20 |
| 21 | 3 | 448µs | 1 | 13.9ms | # spent 13.9ms (1.59+12.3) within Moose::Meta::Class::BEGIN@21 which was called:
# once (1.59ms+12.3ms) by Moose::BEGIN@19 at line 21 # spent 13.9ms making 1 call to Moose::Meta::Class::BEGIN@21 |
| 22 | 3 | 527µs | 1 | 2.33ms | # spent 2.33ms (1.61+720µs) within Moose::Meta::Class::BEGIN@22 which was called:
# once (1.61ms+720µs) by Moose::BEGIN@19 at line 22 # spent 2.33ms making 1 call to Moose::Meta::Class::BEGIN@22 |
| 23 | 3 | 575µs | 1 | 3.30ms | # spent 3.30ms (2.09+1.20) within Moose::Meta::Class::BEGIN@23 which was called:
# once (2.09ms+1.20ms) by Moose::BEGIN@19 at line 23 # spent 3.30ms making 1 call to Moose::Meta::Class::BEGIN@23 |
| 24 | 3 | 479µs | 1 | 3.94ms | # spent 3.94ms (2.81+1.13) within Moose::Meta::Class::BEGIN@24 which was called:
# once (2.81ms+1.13ms) by Moose::BEGIN@19 at line 24 # spent 3.94ms making 1 call to Moose::Meta::Class::BEGIN@24 |
| 25 | 3 | 462µs | 1 | 1.86ms | # spent 1.86ms (1.21+657µs) within Moose::Meta::Class::BEGIN@25 which was called:
# once (1.21ms+657µs) by Moose::BEGIN@19 at line 25 # spent 1.86ms making 1 call to Moose::Meta::Class::BEGIN@25 |
| 26 | 3 | 462µs | 2 | 14.0ms | # spent 13.4ms (9.53+3.91) within Moose::Meta::Class::BEGIN@26 which was called:
# once (9.53ms+3.91ms) by Moose::BEGIN@19 at line 26 # spent 13.4ms making 1 call to Moose::Meta::Class::BEGIN@26
# spent 603µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756] |
| 27 | 3 | 98µs | 1 | 29µs | # spent 29µs within Moose::Meta::Class::BEGIN@27 which was called:
# once (29µs+0s) by Moose::BEGIN@19 at line 27 # spent 29µs making 1 call to Moose::Meta::Class::BEGIN@27 |
| 28 | |||||
| 29 | 3 | 11.4ms | 2 | 566µs | # spent 300µs (35+265) within Moose::Meta::Class::BEGIN@29 which was called:
# once (35µs+265µs) by Moose::BEGIN@19 at line 29 # spent 300µs making 1 call to Moose::Meta::Class::BEGIN@29
# spent 265µs making 1 call to base::import |
| 30 | |||||
| 31 | 1 | 16µs | 1 | 9.00ms | Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait'); # spent 9.00ms making 1 call to Class::MOP::MiniTrait::apply |
| 32 | |||||
| 33 | __PACKAGE__->meta->add_attribute('roles' => ( | ||||
| 34 | reader => 'roles', | ||||
| 35 | 34 | 448µs | # spent 359µs within Moose::Meta::Class::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Meta/Class.pm:35] which was called 34 times, avg 11µs/call:
# 34 times (359µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 43 of Class/MOP/Mixin/AttributeCore.pm, avg 11µs/call | ||
| 36 | 1 | 66µs | 2 | 2.68ms | )); # spent 2.60ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 79µs making 1 call to Class::MOP::Object::meta |
| 37 | |||||
| 38 | __PACKAGE__->meta->add_attribute('role_applications' => ( | ||||
| 39 | reader => '_get_role_applications', | ||||
| 40 | 34 | 474µs | # spent 394µs within Moose::Meta::Class::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Meta/Class.pm:40] which was called 34 times, avg 12µs/call:
# 34 times (394µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 43 of Class/MOP/Mixin/AttributeCore.pm, avg 12µs/call | ||
| 41 | 1 | 32µs | 2 | 2.13ms | )); # spent 2.05ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 85µs making 1 call to Class::MOP::Object::meta |
| 42 | |||||
| 43 | 1 | 41µs | 3 | 1.96ms | __PACKAGE__->meta->add_attribute( # spent 1.75ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 126µs making 1 call to Class::MOP::Attribute::new
# spent 86µ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 | |||||
| 50 | 1 | 40µs | 2 | 1.93ms | __PACKAGE__->meta->add_attribute('constructor_class' => ( # spent 1.83ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 100µs making 1 call to Class::MOP::Object::meta |
| 51 | accessor => 'constructor_class', | ||||
| 52 | default => 'Moose::Meta::Method::Constructor', | ||||
| 53 | )); | ||||
| 54 | |||||
| 55 | 1 | 25µs | 2 | 1.99ms | __PACKAGE__->meta->add_attribute('destructor_class' => ( # spent 1.90ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 89µs making 1 call to Class::MOP::Object::meta |
| 56 | accessor => 'destructor_class', | ||||
| 57 | default => 'Moose::Meta::Method::Destructor', | ||||
| 58 | )); | ||||
| 59 | |||||
| 60 | 1 | 25µs | 2 | 2.12ms | __PACKAGE__->meta->add_attribute('error_class' => ( # spent 2.04ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 84µs making 1 call to Class::MOP::Object::meta |
| 61 | accessor => 'error_class', | ||||
| 62 | default => 'Moose::Error::Default', | ||||
| 63 | )); | ||||
| 64 | |||||
| 65 | # spent 140ms (2.04+138) within Moose::Meta::Class::initialize which was called 34 times, avg 4.13ms/call:
# 25 times (1.48ms+98.6ms) by Moose::init_meta at line 199 of Moose.pm, avg 4.00ms/call
# 8 times (412µs+31.0ms) by Class::MOP::Class::create at line 513 of Class/MOP/Class.pm, avg 3.93ms/call
# once (146µs+8.73ms) by metaclass::import at line 45 of metaclass.pm | ||||
| 66 | 34 | 137µs | my $class = shift; | ||
| 67 | 34 | 103µs | my $pkg = shift; | ||
| 68 | 34 | 1.70ms | 68 | 138ms | return Class::MOP::get_metaclass_by_name($pkg) # spent 138ms making 34 calls to Class::MOP::Class::initialize, avg 4.06ms/call
# spent 314µ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 381ms (630µs+380) within Moose::Meta::Class::create which was called 8 times, avg 47.6ms/call:
# 8 times (630µs+380ms) by Class::MOP::Class::create_anon_class at line 441 of Class/MOP/Class.pm, avg 47.6ms/call | ||||
| 78 | 8 | 63µs | my ($class, $package_name, %options) = @_; | ||
| 79 | |||||
| 80 | 8 | 50µs | (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 | 8 | 30µs | my $roles = delete $options{roles}; | ||
| 84 | |||||
| 85 | 8 | 201µs | 8 | 114ms | my $new_meta = $class->SUPER::create($package_name, %options); # spent 114ms making 8 calls to Class::MOP::Class::create, avg 14.3ms/call |
| 86 | |||||
| 87 | 8 | 131µs | 8 | 266ms | if ($roles) { # spent 266ms making 8 calls to Moose::Util::apply_all_roles, avg 33.3ms/call |
| 88 | Moose::Util::apply_all_roles( $new_meta, @$roles ); | ||||
| 89 | } | ||||
| 90 | |||||
| 91 | 8 | 138µs | return $new_meta; | ||
| 92 | } | ||||
| 93 | |||||
| 94 | 1 | 2µs | my %ANON_CLASSES; | ||
| 95 | |||||
| 96 | # spent 383ms (1.19+382) within Moose::Meta::Class::create_anon_class which was called 15 times, avg 25.5ms/call:
# 10 times (765µs+257ms) by Moose::Meta::Attribute::Native::Trait::_native_accessor_class_for at line 173 of Moose/Meta/Attribute/Native/Trait.pm, avg 25.7ms/call
# 5 times (424µs+125ms) by Moose::Meta::Attribute::interpolate_class at line 129 of Moose/Meta/Attribute.pm, avg 25.1ms/call | ||||
| 97 | 15 | 135µs | my ($self, %options) = @_; | ||
| 98 | |||||
| 99 | 15 | 72µs | my $cache_ok = delete $options{cache}; | ||
| 100 | |||||
| 101 | 15 | 187µs | 15 | 518µs | my $cache_key # spent 518µs making 15 calls to Moose::Meta::Class::_anon_cache_key, avg 35µs/call |
| 102 | = _anon_cache_key( $options{superclasses}, $options{roles} ); | ||||
| 103 | |||||
| 104 | 15 | 152µs | if ($cache_ok && defined $ANON_CLASSES{$cache_key}) { | ||
| 105 | return $ANON_CLASSES{$cache_key}; | ||||
| 106 | } | ||||
| 107 | |||||
| 108 | 8 | 45µs | $options{weaken} = !$cache_ok | ||
| 109 | unless exists $options{weaken}; | ||||
| 110 | |||||
| 111 | 8 | 278µs | 8 | 381ms | my $new_class = $self->SUPER::create_anon_class(%options); # spent 381ms making 8 calls to Class::MOP::Class::create_anon_class, avg 47.7ms/call |
| 112 | |||||
| 113 | 8 | 37µs | if ($cache_ok) { | ||
| 114 | 8 | 55µs | $ANON_CLASSES{$cache_key} = $new_class; | ||
| 115 | 8 | 157µs | 8 | 52µs | weaken($ANON_CLASSES{$cache_key}); # spent 52µs making 8 calls to Scalar::Util::weaken, avg 6µs/call |
| 116 | } | ||||
| 117 | |||||
| 118 | 8 | 139µs | return $new_class; | ||
| 119 | } | ||||
| 120 | |||||
| 121 | 34 | 446µs | # spent 333µs within Moose::Meta::Class::_meta_method_class which was called 34 times, avg 10µs/call:
# 34 times (333µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 28 of Class/MOP/Mixin/HasMethods.pm, avg 10µs/call | ||
| 122 | |||||
| 123 | # spent 518µs (456+62) within Moose::Meta::Class::_anon_cache_key which was called 15 times, avg 35µs/call:
# 15 times (456µs+62µs) by Moose::Meta::Class::create_anon_class at line 101, avg 35µs/call | ||||
| 124 | # Makes something like Super::Class|Super::Class::2=Role|Role::1 | ||||
| 125 | return join '=' => ( | ||||
| 126 | join( '|', @{ $_[0] || [] } ), | ||||
| 127 | 15 | 553µs | 15 | 62µs | join( '|', sort @{ $_[1] || [] } ), # spent 62µs making 15 calls to Moose::Meta::Class::CORE:sort, avg 4µs/call |
| 128 | ); | ||||
| 129 | } | ||||
| 130 | |||||
| 131 | sub 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.68ms (1.08+603µs) within Moose::Meta::Class::add_role which was called 21 times, avg 80µs/call:
# 21 times (1.08ms+603µs) by Moose::Meta::Role::Application::ToClass::apply at line 33 of Moose/Meta/Role/Application/ToClass.pm, avg 80µs/call | ||||
| 178 | 21 | 73µs | my ($self, $role) = @_; | ||
| 179 | 21 | 766µs | 42 | 285µs | (blessed($role) && $role->isa('Moose::Meta::Role')) # spent 158µs making 21 calls to Scalar::Util::blessed, avg 8µs/call
# spent 127µs making 21 calls to UNIVERSAL::isa, avg 6µs/call |
| 180 | || $self->throw_error("Roles must be instances of Moose::Meta::Role", data => $role); | ||||
| 181 | 21 | 520µs | 21 | 318µs | push @{$self->roles} => $role; # spent 318µs making 21 calls to Moose::Meta::Class::roles, avg 15µs/call |
| 182 | } | ||||
| 183 | |||||
| 184 | sub role_applications { | ||||
| 185 | my ($self) = @_; | ||||
| 186 | |||||
| 187 | return @{$self->_get_role_applications}; | ||||
| 188 | } | ||||
| 189 | |||||
| 190 | # spent 1.61ms (1.08+532µs) within Moose::Meta::Class::add_role_application which was called 21 times, avg 77µs/call:
# 21 times (1.08ms+532µs) by Moose::Meta::Role::Application::ToClass::apply at line 34 of Moose/Meta/Role/Application/ToClass.pm, avg 77µs/call | ||||
| 191 | 21 | 74µs | my ($self, $application) = @_; | ||
| 192 | 21 | 667µs | 42 | 230µs | (blessed($application) && $application->isa('Moose::Meta::Role::Application::ToClass')) # spent 116µs making 21 calls to UNIVERSAL::isa, avg 6µs/call
# spent 114µ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); | ||||
| 194 | 21 | 485µs | 21 | 301µs | push @{$self->_get_role_applications} => $application; # spent 301µs making 21 calls to Moose::Meta::Class::_get_role_applications, avg 14µs/call |
| 195 | } | ||||
| 196 | |||||
| 197 | # spent 589µs (174+415) within Moose::Meta::Class::calculate_all_roles which was called 2 times, avg 294µs/call:
# 2 times (174µs+415µs) by Moose::Meta::Attribute::Native::Trait::_build_native_type at line 184 of Moose/Meta/Attribute/Native/Trait.pm, avg 294µs/call | ||||
| 198 | 2 | 6µs | my $self = shift; | ||
| 199 | 2 | 4µs | my %seen; | ||
| 200 | 8 | 175µs | 8 | 415µs | grep { !$seen{$_->name}++ } map { $_->calculate_all_roles } @{ $self->roles }; # spent 367µs making 2 calls to Moose::Meta::Role::calculate_all_roles, avg 184µs/call
# spent 26µs making 2 calls to Moose::Meta::Class::roles, avg 13µs/call
# spent 21µs making 4 calls to Class::MOP::Package::name, avg 5µs/call |
| 201 | } | ||||
| 202 | |||||
| 203 | sub 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 | |||||
| 213 | sub 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 28.6ms (5.05+23.6) within Moose::Meta::Class::excludes_role which was called 21 times, avg 1.36ms/call:
# 21 times (5.05ms+23.6ms) by Moose::Meta::Role::Application::ToClass::check_role_exclusions at line 39 of Moose/Meta/Role/Application/ToClass.pm, avg 1.36ms/call | ||||
| 234 | 21 | 97µs | my ($self, $role_name) = @_; | ||
| 235 | |||||
| 236 | 21 | 51µs | (defined $role_name) | ||
| 237 | || $self->throw_error("You must supply a role name to look for"); | ||||
| 238 | |||||
| 239 | 21 | 670µs | 21 | 18.5ms | foreach my $class ($self->class_precedence_list) { # spent 18.5ms making 21 calls to Class::MOP::Class::class_precedence_list, avg 882µs/call |
| 240 | 134 | 1.30ms | 134 | 3.65ms | my $meta = Class::MOP::class_of($class); # spent 3.65ms 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. | ||||
| 245 | 134 | 2.48ms | 134 | 871µs | next unless $meta && $meta->can('roles'); # spent 871µs making 134 calls to UNIVERSAL::can, avg 6µs/call |
| 246 | 35 | 601µs | 35 | 524µs | foreach my $role (@{$meta->roles}) { # spent 524µs making 35 calls to Moose::Meta::Class::roles, avg 15µs/call |
| 247 | return 1 if $role->excludes_role($role_name); | ||||
| 248 | } | ||||
| 249 | } | ||||
| 250 | 21 | 262µs | return 0; | ||
| 251 | } | ||||
| 252 | |||||
| 253 | # spent 31.1ms (2.66+28.4) within Moose::Meta::Class::new_object which was called 6 times, avg 5.18ms/call:
# 5 times (2.33ms+22.6ms) by Moose::Meta::Attribute::_new at line 4 of generated method (unknown origin), avg 4.99ms/call
# once (329µs+5.78ms) by Moose::Object::new at line 26 of Moose/Object.pm | ||||
| 254 | 6 | 21µs | my $self = shift; | ||
| 255 | 6 | 21µs | my $params = @_ == 1 ? $_[0] : {@_}; | ||
| 256 | 6 | 158µs | 6 | 23.8ms | my $object = $self->SUPER::new_object($params); # spent 23.8ms making 6 calls to Class::MOP::Class::new_object, avg 3.96ms/call |
| 257 | |||||
| 258 | 6 | 425µs | 6 | 3.58ms | foreach my $attr ( $self->get_all_attributes() ) { # spent 3.58ms making 6 calls to Class::MOP::Class::get_all_attributes, avg 597µs/call |
| 259 | |||||
| 260 | 152 | 2.48ms | 164 | 909µs | next unless $attr->can('has_trigger') && $attr->has_trigger; # spent 791µs making 152 calls to UNIVERSAL::can, avg 5µs/call
# spent 118µs making 12 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 10µ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 | |||||
| 278 | 6 | 280µs | 7 | 154µs | $object->BUILDALL($params) if $object->can('BUILDALL'); # spent 117µs making 6 calls to UNIVERSAL::can, avg 20µs/call
# spent 36µs making 1 call to Moose::Object::BUILDALL |
| 279 | |||||
| 280 | 6 | 87µs | return $object; | ||
| 281 | } | ||||
| 282 | |||||
| 283 | # spent 418µs within Moose::Meta::Class::_generate_fallback_constructor which was called 24 times, avg 17µs/call:
# 24 times (418µs+0s) by Class::MOP::Class::_inline_fallback_constructor at line 607 of Class/MOP/Class.pm, avg 17µs/call | ||||
| 284 | 24 | 63µs | my $self = shift; | ||
| 285 | 24 | 75µs | my ($class) = @_; | ||
| 286 | 24 | 379µs | return $class . '->Moose::Object::new(@_)' | ||
| 287 | } | ||||
| 288 | |||||
| 289 | # spent 15.5ms (737µs+14.7) within Moose::Meta::Class::_inline_params which was called 24 times, avg 645µs/call:
# 24 times (737µs+14.7ms) by Class::MOP::Class::_inline_new_object at line 591 of Class/MOP/Class.pm, avg 645µs/call | ||||
| 290 | 24 | 78µs | my $self = shift; | ||
| 291 | 24 | 99µs | my ($params, $class) = @_; | ||
| 292 | return ( | ||||
| 293 | 24 | 536µs | 24 | 14.7ms | 'my ' . $params . ' = ', # spent 14.7ms making 24 calls to Moose::Meta::Class::_inline_BUILDARGS, avg 614µs/call |
| 294 | $self->_inline_BUILDARGS($class, '@_'), | ||||
| 295 | ';', | ||||
| 296 | ); | ||||
| 297 | } | ||||
| 298 | |||||
| 299 | # spent 14.7ms (1.92+12.8) within Moose::Meta::Class::_inline_BUILDARGS which was called 24 times, avg 614µs/call:
# 24 times (1.92ms+12.8ms) by Moose::Meta::Class::_inline_params at line 293, avg 614µs/call | ||||
| 300 | 24 | 68µs | my $self = shift; | ||
| 301 | 24 | 91µs | my ($class, $args) = @_; | ||
| 302 | |||||
| 303 | 24 | 300µs | 24 | 12.2ms | my $buildargs = $self->find_method_by_name("BUILDARGS"); # spent 12.2ms making 24 calls to Class::MOP::Class::find_method_by_name, avg 510µs/call |
| 304 | |||||
| 305 | 24 | 1.53ms | 48 | 588µs | if ($args eq '@_' # spent 432µs making 24 calls to Moose::Meta::Class::_inline_throw_error, avg 18µs/call
# spent 156µs making 24 calls to Class::MOP::Method::body, avg 6µs/call |
| 306 | && (!$buildargs or $buildargs->body == \&Moose::Object::BUILDARGS)) { | ||||
| 307 | return ( | ||||
| 308 | 'do {', | ||||
| 309 | 'my $params;', | ||||
| 310 | 'if (scalar @_ == 1) {', | ||||
| 311 | 'if (!defined($_[0]) || ref($_[0]) ne \'HASH\') {', | ||||
| 312 | $self->_inline_throw_error( | ||||
| 313 | '"Single parameters to new() must be a HASH ref"', | ||||
| 314 | 'data => $_[0]', | ||||
| 315 | ) . ';', | ||||
| 316 | '}', | ||||
| 317 | '$params = { %{ $_[0] } };', | ||||
| 318 | '}', | ||||
| 319 | 'elsif (@_ % 2) {', | ||||
| 320 | 'Carp::carp(', | ||||
| 321 | '"The new() method for ' . $class . ' expects a ' | ||||
| 322 | . 'hash reference or a key/value list. You passed an ' | ||||
| 323 | . 'odd number of arguments"', | ||||
| 324 | ');', | ||||
| 325 | '$params = {@_, undef};', | ||||
| 326 | '}', | ||||
| 327 | 'else {', | ||||
| 328 | '$params = {@_};', | ||||
| 329 | '}', | ||||
| 330 | '$params;', | ||||
| 331 | '}', | ||||
| 332 | ); | ||||
| 333 | } | ||||
| 334 | else { | ||||
| 335 | return $class . '->BUILDARGS(' . $args . ')'; | ||||
| 336 | } | ||||
| 337 | } | ||||
| 338 | |||||
| 339 | # spent 130ms (7.10+123) within Moose::Meta::Class::_inline_slot_initializer which was called 111 times, avg 1.17ms/call:
# 111 times (7.10ms+123ms) by Class::MOP::Class::_inline_slot_initializers at line 645 of Class/MOP/Class.pm, avg 1.17ms/call | ||||
| 340 | 111 | 318µs | my $self = shift; | ||
| 341 | 111 | 325µs | my ($attr, $idx) = @_; | ||
| 342 | |||||
| 343 | return ( | ||||
| 344 | 111 | 6.65ms | 333 | 123ms | '## ' . $attr->name, # spent 111ms making 111 calls to Class::MOP::Class::_inline_slot_initializer, avg 1.00ms/call
# spent 10.9ms making 111 calls to Moose::Meta::Class::_inline_check_required_attr, avg 98µs/call
# spent 575µs making 111 calls to Class::MOP::Mixin::AttributeCore::name, avg 5µs/call |
| 345 | $self->_inline_check_required_attr($attr), | ||||
| 346 | $self->SUPER::_inline_slot_initializer(@_), | ||||
| 347 | ); | ||||
| 348 | } | ||||
| 349 | |||||
| 350 | # spent 10.9ms (6.94+3.96) within Moose::Meta::Class::_inline_check_required_attr which was called 111 times, avg 98µs/call:
# 111 times (6.94ms+3.96ms) by Moose::Meta::Class::_inline_slot_initializer at line 344, avg 98µs/call | ||||
| 351 | 111 | 297µs | my $self = shift; | ||
| 352 | 111 | 272µs | my ($attr) = @_; | ||
| 353 | |||||
| 354 | 111 | 2.11ms | 111 | 589µs | return unless defined $attr->init_arg; # spent 589µs making 111 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 5µs/call |
| 355 | 105 | 3.58ms | 210 | 2.16ms | return unless $attr->can('is_required') && $attr->is_required; # spent 1.34ms making 105 calls to Moose::Meta::Mixin::AttributeCore::is_required, avg 13µs/call
# spent 819µs making 105 calls to UNIVERSAL::can, avg 8µs/call |
| 356 | 26 | 590µs | 52 | 582µs | return if $attr->has_default || $attr->has_builder; # spent 326µs making 26 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 13µs/call
# spent 255µs making 26 calls to Class::MOP::Mixin::AttributeCore::has_builder, avg 10µs/call |
| 357 | |||||
| 358 | return ( | ||||
| 359 | 26 | 1.40ms | 78 | 629µs | 'if (!exists $params->{\'' . $attr->init_arg . '\'}) {', # spent 395µs making 26 calls to Moose::Meta::Class::_inline_throw_error, avg 15µs/call
# spent 124µs making 26 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 5µs/call
# spent 110µs making 26 calls to Class::MOP::Mixin::AttributeCore::name, avg 4µs/call |
| 360 | $self->_inline_throw_error( | ||||
| 361 | '"Attribute (' . quotemeta($attr->name) . ') is required"' | ||||
| 362 | ) . ';', | ||||
| 363 | '}', | ||||
| 364 | ); | ||||
| 365 | } | ||||
| 366 | |||||
| 367 | # XXX: these two are duplicated from cmop, because we have to pass the tc stuff | ||||
| 368 | # through to _inline_set_value - this should probably be fixed, but i'm not | ||||
| 369 | # quite sure how. -doy | ||||
| 370 | # spent 62.8ms (7.14+55.6) within Moose::Meta::Class::_inline_init_attr_from_constructor which was called 105 times, avg 598µs/call:
# 105 times (7.14ms+55.6ms) by Class::MOP::Class::_inline_slot_initializer at line 654 of Class/MOP/Class.pm, avg 598µs/call | ||||
| 371 | 105 | 304µs | my $self = shift; | ||
| 372 | 105 | 281µs | my ($attr, $idx) = @_; | ||
| 373 | |||||
| 374 | 105 | 3.53ms | 210 | 54.5ms | my @initial_value = $attr->_inline_set_value( # spent 54.0ms making 105 calls to Moose::Meta::Attribute::_inline_set_value, avg 514µs/call
# spent 479µs making 105 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 5µs/call |
| 375 | '$instance', | ||||
| 376 | '$params->{\'' . $attr->init_arg . '\'}', | ||||
| 377 | '$type_constraint_bodies[' . $idx . ']', | ||||
| 378 | '$type_constraints[' . $idx . ']', | ||||
| 379 | 'for constructor', | ||||
| 380 | ); | ||||
| 381 | |||||
| 382 | 105 | 1.27ms | 105 | 1.16ms | push @initial_value, ( # spent 1.16ms making 105 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 11µs/call |
| 383 | '$attrs->[' . $idx . ']->set_initial_value(', | ||||
| 384 | '$instance,', | ||||
| 385 | $attr->_inline_instance_get('$instance'), | ||||
| 386 | ');', | ||||
| 387 | ) if $attr->has_initializer; | ||||
| 388 | |||||
| 389 | 105 | 1.75ms | return @initial_value; | ||
| 390 | } | ||||
| 391 | |||||
| 392 | # spent 39.0ms (5.92+33.1) within Moose::Meta::Class::_inline_init_attr_from_default which was called 111 times, avg 351µs/call:
# 105 times (5.39ms+29.7ms) by Class::MOP::Class::_inline_slot_initializer at line 659 of Class/MOP/Class.pm, avg 335µs/call
# 6 times (535µs+3.35ms) by Class::MOP::Class::_inline_slot_initializer at line 653 of Class/MOP/Class.pm, avg 647µs/call | ||||
| 393 | 111 | 332µs | my $self = shift; | ||
| 394 | 111 | 351µs | my ($attr, $idx) = @_; | ||
| 395 | |||||
| 396 | 111 | 1.31ms | 111 | 7.64ms | my $default = $self->_inline_default_value($attr, $idx); # spent 7.64ms making 111 calls to Class::MOP::Class::_inline_default_value, avg 69µs/call |
| 397 | 111 | 737µs | return unless $default; | ||
| 398 | |||||
| 399 | 51 | 1.08ms | 51 | 24.9ms | my @initial_value = ( # spent 24.9ms making 51 calls to Moose::Meta::Attribute::_inline_set_value, avg 488µs/call |
| 400 | 'my $default = ' . $default . ';', | ||||
| 401 | $attr->_inline_set_value( | ||||
| 402 | '$instance', | ||||
| 403 | '$default', | ||||
| 404 | '$type_constraint_bodies[' . $idx . ']', | ||||
| 405 | '$type_constraints[' . $idx . ']', | ||||
| 406 | 'for constructor', | ||||
| 407 | ), | ||||
| 408 | ); | ||||
| 409 | |||||
| 410 | 51 | 661µs | 51 | 572µs | push @initial_value, ( # spent 572µs making 51 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 11µs/call |
| 411 | '$attrs->[' . $idx . ']->set_initial_value(', | ||||
| 412 | '$instance,', | ||||
| 413 | $attr->_inline_instance_get('$instance'), | ||||
| 414 | ');', | ||||
| 415 | ) if $attr->has_initializer; | ||||
| 416 | |||||
| 417 | 51 | 917µs | return @initial_value; | ||
| 418 | } | ||||
| 419 | |||||
| 420 | # spent 36.0ms (858µs+35.1) within Moose::Meta::Class::_inline_extra_init which was called 24 times, avg 1.50ms/call:
# 24 times (858µs+35.1ms) by Class::MOP::Class::_inline_new_object at line 591 of Class/MOP/Class.pm, avg 1.50ms/call | ||||
| 421 | 24 | 78µs | my $self = shift; | ||
| 422 | return ( | ||||
| 423 | 24 | 678µs | 48 | 35.1ms | $self->_inline_triggers, # spent 20.1ms making 24 calls to Moose::Meta::Class::_inline_triggers, avg 838µs/call
# spent 15.0ms making 24 calls to Moose::Meta::Class::_inline_BUILDALL, avg 627µs/call |
| 424 | $self->_inline_BUILDALL, | ||||
| 425 | ); | ||||
| 426 | } | ||||
| 427 | |||||
| 428 | # spent 20.1ms (4.92+15.2) within Moose::Meta::Class::_inline_triggers which was called 24 times, avg 838µs/call:
# 24 times (4.92ms+15.2ms) by Moose::Meta::Class::_inline_extra_init at line 423, avg 838µs/call | ||||
| 429 | 24 | 68µs | my $self = shift; | ||
| 430 | 24 | 45µs | my @trigger_calls; | ||
| 431 | |||||
| 432 | 211 | 7.16ms | 422 | 15.0ms | my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes; # spent 6.62ms making 24 calls to Moose::Meta::Class::CORE:sort, avg 276µs/call
# spent 6.55ms making 24 calls to Class::MOP::Class::get_all_attributes, avg 273µs/call
# spent 1.87ms making 374 calls to Class::MOP::Mixin::AttributeCore::name, avg 5µs/call |
| 433 | 24 | 682µs | for my $i (0 .. $#attrs) { | ||
| 434 | 111 | 334µs | my $attr = $attrs[$i]; | ||
| 435 | |||||
| 436 | 111 | 3.35ms | 222 | 2.02ms | next unless $attr->can('has_trigger') && $attr->has_trigger; # spent 1.21ms making 111 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 11µs/call
# spent 805µs making 111 calls to UNIVERSAL::can, avg 7µs/call |
| 437 | |||||
| 438 | my $init_arg = $attr->init_arg; | ||||
| 439 | next unless defined $init_arg; | ||||
| 440 | |||||
| 441 | push @trigger_calls, | ||||
| 442 | 'if (exists $params->{\'' . $init_arg . '\'}) {', | ||||
| 443 | '$attrs->[' . $i . ']->trigger->(', | ||||
| 444 | '$instance,', | ||||
| 445 | $attr->_inline_instance_get('$instance') . ',', | ||||
| 446 | ');', | ||||
| 447 | '}'; | ||||
| 448 | } | ||||
| 449 | |||||
| 450 | 24 | 332µs | return @trigger_calls; | ||
| 451 | } | ||||
| 452 | |||||
| 453 | # spent 15.0ms (883µs+14.2) within Moose::Meta::Class::_inline_BUILDALL which was called 24 times, avg 627µs/call:
# 24 times (883µs+14.2ms) by Moose::Meta::Class::_inline_extra_init at line 423, avg 627µs/call | ||||
| 454 | 24 | 74µs | my $self = shift; | ||
| 455 | |||||
| 456 | 24 | 313µs | 24 | 14.2ms | my @methods = reverse $self->find_all_methods_by_name('BUILD'); # spent 14.2ms making 24 calls to Class::MOP::Class::find_all_methods_by_name, avg 590µs/call |
| 457 | 24 | 42µs | my @BUILD_calls; | ||
| 458 | |||||
| 459 | 24 | 128µs | foreach my $method (@methods) { | ||
| 460 | 2 | 28µs | push @BUILD_calls, | ||
| 461 | '$instance->' . $method->{class} . '::BUILD($params);'; | ||||
| 462 | } | ||||
| 463 | |||||
| 464 | 24 | 286µs | return @BUILD_calls; | ||
| 465 | } | ||||
| 466 | |||||
| 467 | # spent 219ms (14.0+205) within Moose::Meta::Class::superclasses which was called 196 times, avg 1.12ms/call:
# 68 times (4.17ms+6.08ms) by Class::MOP::Class::_check_metaclass_compatibility at line 201 of Class/MOP/Class.pm, avg 151µs/call
# 50 times (4.50ms+134ms) by Moose::init_meta at line 218 of Moose.pm, avg 2.77ms/call
# 34 times (1.84ms+4.50ms) by Class::MOP::Class::class_precedence_list at line 1070 of Class/MOP/Class.pm, avg 186µs/call
# 34 times (2.10ms+-2.10ms) by Class::MOP::Class::_superclasses_updated at line 1011 of Class/MOP/Class.pm, avg 0s/call
# 8 times (1.25ms+57.2ms) by Class::MOP::Class::create at line 520 of Class/MOP/Class.pm, avg 7.30ms/call
# once (117µs+5.37ms) by Moose::extends at line 54 of Moose.pm
# once (50µs+195µs) by Class::MOP::Class:::around at line 27 of Class/MOP/Class/Immutable/Trait.pm | ||||
| 468 | 196 | 568µs | my $self = shift; | ||
| 469 | 196 | 2.46ms | 196 | 7.86ms | my $supers = Data::OptList::mkopt(\@_); # spent 7.86ms making 196 calls to Data::OptList::mkopt, avg 40µs/call |
| 470 | 196 | 1.18ms | foreach my $super (@{ $supers }) { | ||
| 471 | 39 | 185µs | my ($name, $opts) = @{ $super }; | ||
| 472 | 39 | 441µs | 39 | 8.25ms | Class::MOP::load_class($name, $opts); # spent 9.12ms making 39 calls to Class::MOP::load_class, avg 234µs/call, recursion: max depth 1, sum of overlapping time 877µs |
| 473 | 39 | 557µs | 39 | 1.47ms | my $meta = Class::MOP::class_of($name); # spent 1.47ms making 39 calls to Class::MOP::class_of, avg 38µs/call |
| 474 | 39 | 1.31ms | 38 | 505µs | $self->throw_error("You cannot inherit from a Moose Role ($name)") # spent 505µs making 38 calls to UNIVERSAL::isa, avg 13µs/call |
| 475 | if $meta && $meta->isa('Moose::Meta::Role') | ||||
| 476 | } | ||||
| 477 | 196 | 7.53ms | 196 | 193ms | return $self->SUPER::superclasses(map { $_->[0] } @{ $supers }); # spent 199ms making 196 calls to Class::MOP::Class::superclasses, avg 1.02ms/call, recursion: max depth 1, sum of overlapping time 6.88ms |
| 478 | } | ||||
| 479 | |||||
| 480 | ### --------------------------------------------- | ||||
| 481 | |||||
| 482 | # spent 2.34s (12.5ms+2.32) within Moose::Meta::Class::add_attribute which was called 123 times, avg 19.0ms/call:
# 116 times (11.9ms+2.30s) by Moose::has at line 70 of Moose.pm, avg 20.0ms/call
# 7 times (666µs+20.3ms) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 142 of Moose/Meta/Role/Application/ToClass.pm, avg 3.00ms/call | ||||
| 483 | 123 | 401µs | my $self = shift; | ||
| 484 | 123 | 4.67ms | 246 | 578ms | my $attr = # spent 578ms making 116 calls to Moose::Meta::Class::_process_attribute, avg 4.98ms/call
# spent 653µs making 123 calls to Scalar::Util::blessed, avg 5µs/call
# spent 50µs making 7 calls to UNIVERSAL::isa, avg 7µs/call |
| 485 | (blessed $_[0] && $_[0]->isa('Class::MOP::Attribute') | ||||
| 486 | ? $_[0] | ||||
| 487 | : $self->_process_attribute(@_)); | ||||
| 488 | 123 | 3.21ms | 123 | 1.78s | $self->SUPER::add_attribute($attr); # spent 1.78s making 123 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 14.4ms/call |
| 489 | # it may be a Class::MOP::Attribute, theoretically, which doesn't have | ||||
| 490 | # 'bare' and doesn't implement this method | ||||
| 491 | 123 | 3.90ms | 246 | 4.81ms | if ($attr->can('_check_associated_methods')) { # spent 3.66ms making 123 calls to Moose::Meta::Attribute::_check_associated_methods, avg 30µs/call
# spent 1.15ms making 123 calls to UNIVERSAL::can, avg 9µs/call |
| 492 | $attr->_check_associated_methods; | ||||
| 493 | } | ||||
| 494 | 123 | 1.47ms | return $attr; | ||
| 495 | } | ||||
| 496 | |||||
| 497 | # spent 20.6ms (905µs+19.7) within Moose::Meta::Class::add_override_method_modifier which was called 15 times, avg 1.37ms/call:
# 15 times (905µs+19.7ms) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 208 of Moose/Meta/Role/Application/ToClass.pm, avg 1.37ms/call | ||||
| 498 | 15 | 86µs | my ($self, $name, $method, $_super_package) = @_; | ||
| 499 | |||||
| 500 | 15 | 144µs | 15 | 2.00ms | (!$self->has_method($name)) # spent 2.00ms making 15 calls to Class::MOP::Mixin::HasMethods::has_method, avg 134µs/call |
| 501 | || $self->throw_error("Cannot add an override method if a local method is already present"); | ||||
| 502 | |||||
| 503 | 15 | 557µs | 30 | 17.7ms | $self->add_method($name => Moose::Meta::Method::Overridden->new( # spent 11.3ms making 15 calls to Moose::Meta::Method::Overridden::new, avg 756µs/call
# spent 6.31ms making 15 calls to Class::MOP::Mixin::HasMethods::add_method, avg 421µs/call |
| 504 | method => $method, | ||||
| 505 | class => $self, | ||||
| 506 | package => $_super_package, # need this for roles | ||||
| 507 | name => $name, | ||||
| 508 | )); | ||||
| 509 | } | ||||
| 510 | |||||
| 511 | sub add_augment_method_modifier { | ||||
| 512 | my ($self, $name, $method) = @_; | ||||
| 513 | (!$self->has_method($name)) | ||||
| 514 | || $self->throw_error("Cannot add an augment method if a local method is already present"); | ||||
| 515 | |||||
| 516 | $self->add_method($name => Moose::Meta::Method::Augmented->new( | ||||
| 517 | method => $method, | ||||
| 518 | class => $self, | ||||
| 519 | name => $name, | ||||
| 520 | )); | ||||
| 521 | } | ||||
| 522 | |||||
| 523 | ## Private Utility methods ... | ||||
| 524 | |||||
| 525 | sub _find_next_method_by_name_which_is_not_overridden { | ||||
| 526 | my ($self, $name) = @_; | ||||
| 527 | foreach my $method ($self->find_all_methods_by_name($name)) { | ||||
| 528 | return $method->{code} | ||||
| 529 | if blessed($method->{code}) && !$method->{code}->isa('Moose::Meta::Method::Overridden'); | ||||
| 530 | } | ||||
| 531 | return undef; | ||||
| 532 | } | ||||
| 533 | |||||
| 534 | ## Metaclass compatibility | ||||
| 535 | |||||
| 536 | # spent 16.6ms (11.1+5.47) within Moose::Meta::Class::_base_metaclasses which was called 73 times, avg 227µs/call:
# 39 times (6.09ms+2.91ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 331 of Class/MOP/Class.pm, avg 231µs/call
# 34 times (5.04ms+2.56ms) by Class::MOP::Class::_check_metaclass_compatibility at line 206 of Class/MOP/Class.pm, avg 224µs/call | ||||
| 537 | 73 | 230µs | my $self = shift; | ||
| 538 | 73 | 2.67ms | 73 | 1.38ms | my %metaclasses = $self->SUPER::_base_metaclasses; # spent 1.38ms making 73 calls to Class::MOP::Class::_base_metaclasses, avg 19µs/call |
| 539 | 73 | 805µs | for my $class (keys %metaclasses) { | ||
| 540 | 438 | 9.67ms | 438 | 4.10ms | $metaclasses{$class} =~ s/^Class::MOP/Moose::Meta/; # spent 4.10ms making 438 calls to Moose::Meta::Class::CORE:subst, avg 9µs/call |
| 541 | } | ||||
| 542 | return ( | ||||
| 543 | 73 | 1.80ms | %metaclasses, | ||
| 544 | error_class => 'Moose::Error::Default', | ||||
| 545 | ); | ||||
| 546 | } | ||||
| 547 | |||||
| 548 | sub _fix_class_metaclass_incompatibility { | ||||
| 549 | my $self = shift; | ||||
| 550 | my ($super_meta) = @_; | ||||
| 551 | |||||
| 552 | $self->SUPER::_fix_class_metaclass_incompatibility(@_); | ||||
| 553 | |||||
| 554 | if ($self->_class_metaclass_can_be_made_compatible($super_meta)) { | ||||
| 555 | ($self->is_pristine) | ||||
| 556 | || confess "Can't fix metaclass incompatibility for " | ||||
| 557 | . $self->name | ||||
| 558 | . " because it is not pristine."; | ||||
| 559 | my $super_meta_name = $super_meta->_real_ref_name; | ||||
| 560 | my $class_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass(blessed($self), $super_meta_name); | ||||
| 561 | my $new_self = $class_meta_subclass_meta_name->reinitialize( | ||||
| 562 | $self->name, | ||||
| 563 | ); | ||||
| 564 | |||||
| 565 | $self->_replace_self( $new_self, $class_meta_subclass_meta_name ); | ||||
| 566 | } | ||||
| 567 | } | ||||
| 568 | |||||
| 569 | sub _fix_single_metaclass_incompatibility { | ||||
| 570 | my $self = shift; | ||||
| 571 | my ($metaclass_type, $super_meta) = @_; | ||||
| 572 | |||||
| 573 | $self->SUPER::_fix_single_metaclass_incompatibility(@_); | ||||
| 574 | |||||
| 575 | if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) { | ||||
| 576 | ($self->is_pristine) | ||||
| 577 | || confess "Can't fix metaclass incompatibility for " | ||||
| 578 | . $self->name | ||||
| 579 | . " because it is not pristine."; | ||||
| 580 | my $super_meta_name = $super_meta->_real_ref_name; | ||||
| 581 | my $class_specific_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass($self->$metaclass_type, $super_meta->$metaclass_type); | ||||
| 582 | my $new_self = $super_meta->reinitialize( | ||||
| 583 | $self->name, | ||||
| 584 | $metaclass_type => $class_specific_meta_subclass_meta_name, | ||||
| 585 | ); | ||||
| 586 | |||||
| 587 | $self->_replace_self( $new_self, $super_meta_name ); | ||||
| 588 | } | ||||
| 589 | } | ||||
| 590 | |||||
| 591 | sub _replace_self { | ||||
| 592 | my $self = shift; | ||||
| 593 | my ( $new_self, $new_class) = @_; | ||||
| 594 | |||||
| 595 | %$self = %$new_self; | ||||
| 596 | bless $self, $new_class; | ||||
| 597 | |||||
| 598 | # We need to replace the cached metaclass instance or else when it goes | ||||
| 599 | # out of scope Class::MOP::Class destroy's the namespace for the | ||||
| 600 | # metaclass's class, causing much havoc. | ||||
| 601 | my $weaken = Class::MOP::metaclass_is_weak( $self->name ); | ||||
| 602 | Class::MOP::store_metaclass_by_name( $self->name, $self ); | ||||
| 603 | Class::MOP::weaken_metaclass( $self->name ) if $weaken; | ||||
| 604 | } | ||||
| 605 | |||||
| 606 | # spent 578ms (5.81+572) within Moose::Meta::Class::_process_attribute which was called 116 times, avg 4.98ms/call:
# 116 times (5.81ms+572ms) by Moose::Meta::Class::add_attribute at line 484, avg 4.98ms/call | ||||
| 607 | 116 | 1.27ms | my ( $self, $name, @args ) = @_; | ||
| 608 | |||||
| 609 | 116 | 390µs | @args = %{$args[0]} if scalar @args == 1 && ref($args[0]) eq 'HASH'; | ||
| 610 | |||||
| 611 | 116 | 2.01ms | 116 | 706µs | if (($name || '') =~ /^\+(.*)/) { # spent 706µs making 116 calls to Moose::Meta::Class::CORE:match, avg 6µs/call |
| 612 | 2 | 51µs | 2 | 19.1ms | return $self->_process_inherited_attribute($1, @args); # spent 19.1ms making 2 calls to Moose::Meta::Class::_process_inherited_attribute, avg 9.53ms/call |
| 613 | } | ||||
| 614 | else { | ||||
| 615 | 114 | 2.85ms | 114 | 552ms | return $self->_process_new_attribute($name, @args); # spent 552ms making 114 calls to Moose::Meta::Class::_process_new_attribute, avg 4.84ms/call |
| 616 | } | ||||
| 617 | } | ||||
| 618 | |||||
| 619 | # spent 552ms (5.86+546) within Moose::Meta::Class::_process_new_attribute which was called 114 times, avg 4.84ms/call:
# 114 times (5.86ms+546ms) by Moose::Meta::Class::_process_attribute at line 615, avg 4.84ms/call | ||||
| 620 | 114 | 1.27ms | my ( $self, $name, @args ) = @_; | ||
| 621 | |||||
| 622 | 114 | 5.33ms | 228 | 546ms | $self->attribute_metaclass->interpolate_class_and_new($name, @args); # spent 545ms making 114 calls to Moose::Meta::Attribute::interpolate_class_and_new, avg 4.78ms/call
# spent 816µs making 114 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 7µs/call |
| 623 | } | ||||
| 624 | |||||
| 625 | # spent 19.1ms (181µs+18.9) within Moose::Meta::Class::_process_inherited_attribute which was called 2 times, avg 9.53ms/call:
# 2 times (181µs+18.9ms) by Moose::Meta::Class::_process_attribute at line 612, avg 9.53ms/call | ||||
| 626 | 2 | 26µs | my ($self, $attr_name, %options) = @_; | ||
| 627 | 2 | 46µs | 2 | 720µs | my $inherited_attr = $self->find_attribute_by_name($attr_name); # spent 720µs making 2 calls to Class::MOP::Class::find_attribute_by_name, avg 360µs/call |
| 628 | (defined $inherited_attr) | ||||
| 629 | 2 | 4µs | || $self->throw_error("Could not find an attribute by the name of '$attr_name' to inherit from in ${\$self->name}", data => $attr_name); | ||
| 630 | 2 | 110µs | 4 | 18.2ms | if ($inherited_attr->isa('Moose::Meta::Attribute')) { # spent 18.1ms making 2 calls to Moose::Meta::Attribute::clone_and_inherit_options, avg 9.07ms/call
# spent 16µs making 2 calls to UNIVERSAL::isa, avg 8µs/call |
| 631 | return $inherited_attr->clone_and_inherit_options(%options); | ||||
| 632 | } | ||||
| 633 | else { | ||||
| 634 | # NOTE: | ||||
| 635 | # kind of a kludge to handle Class::MOP::Attributes | ||||
| 636 | return $inherited_attr->Moose::Meta::Attribute::clone_and_inherit_options(%options); | ||||
| 637 | } | ||||
| 638 | } | ||||
| 639 | |||||
| 640 | ## Immutability | ||||
| 641 | |||||
| 642 | # spent 4.24ms (998µs+3.24) within Moose::Meta::Class::_immutable_options which was called 24 times, avg 177µs/call:
# 24 times (998µs+3.24ms) by Class::MOP::Class::make_immutable at line 1321 of Class/MOP/Class.pm, avg 177µs/call | ||||
| 643 | 24 | 88µs | my ( $self, @args ) = @_; | ||
| 644 | |||||
| 645 | 24 | 902µs | 24 | 3.24ms | $self->SUPER::_immutable_options( # spent 3.24ms making 24 calls to Class::MOP::Class::_immutable_options, avg 135µs/call |
| 646 | inline_destructor => 1, | ||||
| 647 | |||||
| 648 | # Moose always does this when an attribute is created | ||||
| 649 | inline_accessors => 0, | ||||
| 650 | |||||
| 651 | @args, | ||||
| 652 | ); | ||||
| 653 | } | ||||
| 654 | |||||
| 655 | ## ------------------------------------------------- | ||||
| 656 | |||||
| 657 | 1 | 2µs | our $error_level; | ||
| 658 | |||||
| 659 | sub throw_error { | ||||
| 660 | my ( $self, @args ) = @_; | ||||
| 661 | local $error_level = ($error_level || 0) + 1; | ||||
| 662 | $self->raise_error($self->create_error(@args)); | ||||
| 663 | } | ||||
| 664 | |||||
| 665 | sub _inline_throw_error { | ||||
| 666 | 50 | 214µs | my ( $self, $msg, $args ) = @_; | ||
| 667 | 50 | 788µs | "\$meta->throw_error($msg" . ($args ? ", $args" : "") . ")"; # FIXME makes deparsing *REALLY* hard | ||
| 668 | } | ||||
| 669 | |||||
| 670 | sub raise_error { | ||||
| 671 | my ( $self, @args ) = @_; | ||||
| 672 | die @args; | ||||
| 673 | } | ||||
| 674 | |||||
| 675 | sub create_error { | ||||
| 676 | my ( $self, @args ) = @_; | ||||
| 677 | |||||
| 678 | require Carp::Heavy; | ||||
| 679 | |||||
| 680 | local $error_level = ($error_level || 0 ) + 1; | ||||
| 681 | |||||
| 682 | if ( @args % 2 == 1 ) { | ||||
| 683 | unshift @args, "message"; | ||||
| 684 | } | ||||
| 685 | |||||
| 686 | my %args = ( metaclass => $self, last_error => $@, @args ); | ||||
| 687 | |||||
| 688 | $args{depth} += $error_level; | ||||
| 689 | |||||
| 690 | my $class = ref $self ? $self->error_class : "Moose::Error::Default"; | ||||
| 691 | |||||
| 692 | Class::MOP::load_class($class); | ||||
| 693 | |||||
| 694 | $class->new( | ||||
| 695 | Carp::caller_info($args{depth}), | ||||
| 696 | %args | ||||
| 697 | ); | ||||
| 698 | } | ||||
| 699 | |||||
| 700 | 1 | 64µs | 1; | ||
| 701 | |||||
| 702 | __END__ | ||||
# spent 706µs within Moose::Meta::Class::CORE:match which was called 116 times, avg 6µs/call:
# 116 times (706µs+0s) by Moose::Meta::Class::_process_attribute at line 611, avg 6µs/call | |||||
sub Moose::Meta::Class::CORE:sort; # opcode | |||||
# spent 4.10ms within Moose::Meta::Class::CORE:subst which was called 438 times, avg 9µs/call:
# 438 times (4.10ms+0s) by Moose::Meta::Class::_base_metaclasses at line 540, avg 9µs/call |