| Filename | /home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Class.pm |
| Statements | Executed 123254 statements in 1.49s |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 6665 | 25 | 13 | 222ms | 969ms | Class::MOP::Class::initialize (recurses: max depth 1, inclusive time 23.1ms) |
| 730 | 10 | 7 | 135ms | 314ms | Class::MOP::Class::get_all_attributes |
| 390 | 2 | 1 | 113ms | 938ms | Class::MOP::Class::_construct_instance |
| 1141 | 1 | 1 | 106ms | 193ms | Class::MOP::Class::_single_metaclass_is_compatible |
| 1399 | 1 | 1 | 101ms | 206ms | Class::MOP::Class::_single_metaclass_can_be_made_compatible |
| 286 | 2 | 1 | 66.6ms | 763ms | Class::MOP::Class::_check_metaclass_compatibility (recurses: max depth 1, inclusive time 3.19ms) |
| 1405 | 7 | 2 | 42.8ms | 66.5ms | Class::MOP::Class::linearized_isa |
| 206 | 1 | 1 | 38.0ms | 311ms | Class::MOP::Class::_can_fix_metaclass_incompatibility |
| 277 | 6 | 6 | 31.6ms | 202ms | Class::MOP::Class::find_method_by_name |
| 1141 | 1 | 1 | 30.6ms | 223ms | Class::MOP::Class::_check_single_metaclass_compatibility |
| 266 | 3 | 3 | 29.2ms | 157ms | Class::MOP::Class::find_next_method_by_name |
| 399 | 2 | 2 | 27.5ms | 239ms | Class::MOP::Class::_inline_slot_initializer |
| 294 | 4 | 3 | 25.1ms | 99.5ms | Class::MOP::Class::class_precedence_list (recurses: max depth 4, inclusive time 74.6ms) |
| 175 | 1 | 1 | 21.3ms | 708ms | Class::MOP::Class::_construct_class_instance (recurses: max depth 1, inclusive time 715µs) |
| 73 | 1 | 1 | 18.8ms | 27.3ms | Class::MOP::Class::CORE:sort (opcode) |
| 399 | 2 | 2 | 16.2ms | 25.0ms | Class::MOP::Class::_inline_default_value |
| 256 | 1 | 1 | 14.6ms | 80.1ms | Class::MOP::Class::_inline_init_attr_from_constructor |
| 131 | 3 | 1 | 14.4ms | 218ms | Class::MOP::Class::__ANON__[:1108] |
| 279 | 5 | 5 | 13.7ms | 562ms | Class::MOP::Class::new_object |
| 185 | 1 | 1 | 12.9ms | 335ms | Class::MOP::Class::_fix_metaclass_incompatibility (recurses: max depth 1, inclusive time 2.32ms) |
| 188 | 1 | 1 | 12.4ms | 2.27s | Class::MOP::Class::_post_add_attribute |
| 784 | 11 | 5 | 11.9ms | 148ms | Class::MOP::Class::get_meta_instance |
| 81 | 2 | 2 | 11.0ms | 61.9ms | Class::MOP::Class::find_all_methods_by_name |
| 382 | 4 | 1 | 10.8ms | 17.1ms | Class::MOP::Class::_real_ref_name |
| 73 | 1 | 1 | 10.7ms | 907ms | Class::MOP::Class::_inline_constructor |
| 267 | 2 | 1 | 10.2ms | 42.9ms | Class::MOP::Class::_inline_init_attr_from_default |
| 94 | 1 | 1 | 10.1ms | 307ms | Class::MOP::Class::_immutable_metaclass (recurses: max depth 1, inclusive time 1.57ms) |
| 138 | 1 | 1 | 9.75ms | 136ms | Class::MOP::Class::_create_meta_instance |
| 103 | 3 | 3 | 9.64ms | 32.6ms | Class::MOP::Class::find_attribute_by_name |
| 73 | 1 | 1 | 9.45ms | 323ms | Class::MOP::Class::_inline_slot_initializers |
| 163 | 1 | 1 | 8.99ms | 22.5ms | Class::MOP::Class::_class_metaclass_is_compatible |
| 42 | 1 | 1 | 8.91ms | 555ms | Class::MOP::Class::reinitialize |
| 188 | 1 | 1 | 8.41ms | 2.23s | Class::MOP::Class::__ANON__[:932] |
| 111 | 1 | 1 | 8.24ms | 38.8ms | Class::MOP::Class::_superclasses_updated |
| 94 | 48 | 46 | 7.96ms | 1.68s | Class::MOP::Class::make_immutable (recurses: max depth 1, inclusive time 5.76ms) |
| 206 | 1 | 1 | 7.65ms | 29.3ms | Class::MOP::Class::_class_metaclass_can_be_made_compatible |
| 188 | 1 | 1 | 7.53ms | 9.87ms | Class::MOP::Class::invalidate_meta_instances |
| 391 | 3 | 2 | 7.24ms | 7.24ms | Class::MOP::Class::_base_metaclasses |
| 43 | 1 | 1 | 7.08ms | 190ms | Class::MOP::Class::_inline_destructor |
| 94 | 2 | 2 | 6.81ms | 9.98ms | Class::MOP::Class::_immutable_options |
| 73 | 1 | 1 | 6.52ms | 491ms | Class::MOP::Class::_inline_new_object |
| 94 | 1 | 1 | 6.15ms | 1.35s | Class::MOP::Class::_install_inlined_code |
| 114 | 3 | 3 | 6.04ms | 219ms | Class::MOP::Class::add_around_method_modifier |
| 94 | 1 | 1 | 5.37ms | 1.35s | Class::MOP::Class::_initialize_immutable |
| 1 | 1 | 1 | 5.18ms | 5.88ms | Class::MOP::Class::BEGIN@7 |
| 1 | 1 | 1 | 4.84ms | 36.3ms | Class::MOP::Class::BEGIN@9 |
| 188 | 1 | 1 | 4.53ms | 16.2ms | Class::MOP::Class::_attach_attribute |
| 163 | 1 | 1 | 4.44ms | 27.0ms | Class::MOP::Class::_check_class_metaclass_compatibility |
| 94 | 1 | 1 | 4.41ms | 311ms | Class::MOP::Class::_rebless_as_immutable (recurses: max depth 1, inclusive time 1.77ms) |
| 1 | 1 | 1 | 4.27ms | 5.12ms | Class::MOP::Class::BEGIN@8 |
| 25 | 2 | 2 | 4.25ms | 329ms | Class::MOP::Class::create |
| 64 | 1 | 1 | 4.07ms | 4.07ms | Class::MOP::Class::_new |
| 73 | 1 | 1 | 3.18ms | 4.93ms | Class::MOP::Class::_inline_fallback_constructor |
| 32 | 1 | 1 | 3.06ms | 243ms | Class::MOP::Class::_inline_accessors |
| 1 | 1 | 1 | 2.92ms | 7.37ms | Class::MOP::Class::BEGIN@10 |
| 73 | 1 | 1 | 2.83ms | 24.2ms | Class::MOP::Class::_inline_create_instance |
| 73 | 1 | 1 | 2.58ms | 4.98ms | Class::MOP::Class::_inline_preserve_weak_metaclasses |
| 320 | 1 | 1 | 2.41ms | 2.41ms | Class::MOP::Class::is_immutable |
| 188 | 1 | 1 | 2.34ms | 2.34ms | Class::MOP::Class::invalidate_meta_instance |
| 73 | 1 | 1 | 2.29ms | 26.5ms | Class::MOP::Class::_inline_generate_instance |
| 112 | 2 | 1 | 2.22ms | 2.22ms | Class::MOP::Class::_add_inlined_method |
| 42 | 1 | 1 | 2.03ms | 2.75ms | Class::MOP::Class::DESTROY |
| 1 | 1 | 1 | 2.03ms | 4.58ms | Class::MOP::Class::BEGIN@18 |
| 111 | 1 | 1 | 1.91ms | 1.91ms | Class::MOP::Class::_superclass_metas |
| 9 | 1 | 1 | 1.83ms | 17.3ms | Class::MOP::Class::get_all_methods |
| 42 | 1 | 1 | 1.81ms | 177ms | Class::MOP::Class::_restore_metaobjects_from |
| 42 | 1 | 1 | 1.40ms | 1.81ms | Class::MOP::Class::is_anon_class |
| 111 | 1 | 1 | 1.30ms | 1.30ms | Class::MOP::Class::update_meta_instance_dependencies |
| 42 | 1 | 1 | 1.25ms | 2.65ms | Class::MOP::Class::_remove_generated_metaobjects |
| 1 | 1 | 1 | 1.19ms | 4.90ms | Class::MOP::Class::BEGIN@16 |
| 1 | 1 | 1 | 1.09ms | 1.28ms | Class::MOP::Class::BEGIN@11 |
| 22 | 1 | 1 | 1.01ms | 995ms | Class::MOP::Class::create_anon_class |
| 125 | 3 | 3 | 868µs | 868µs | Class::MOP::Class::is_mutable |
| 11 | 1 | 1 | 587µs | 19.2ms | Class::MOP::Class::add_before_method_modifier |
| 31 | 1 | 1 | 561µs | 561µs | Class::MOP::Class::_inline_params |
| 31 | 1 | 1 | 553µs | 553µs | Class::MOP::Class::_generate_fallback_constructor |
| 6 | 1 | 1 | 343µs | 5.35ms | Class::MOP::Class::add_after_method_modifier |
| 1 | 1 | 1 | 343µs | 1.07ms | Class::MOP::Class::_clone_instance |
| 84 | 2 | 1 | 292µs | 292µs | Class::MOP::Class::CORE:match (opcode) |
| 31 | 1 | 1 | 233µs | 233µs | Class::MOP::Class::_inline_extra_init |
| 1 | 1 | 1 | 99µs | 1.20ms | Class::MOP::Class::clone_object |
| 1 | 1 | 1 | 98µs | 117µs | Class::MOP::Class::BEGIN@4 |
| 1 | 1 | 1 | 88µs | 164µs | Class::MOP::Class::BEGIN@433 |
| 2 | 2 | 1 | 69µs | 69µs | Class::MOP::Class::CORE:regcomp (opcode) |
| 1 | 1 | 1 | 52µs | 118µs | Class::MOP::Class::BEGIN@468 |
| 1 | 1 | 1 | 46µs | 18.1ms | Class::MOP::Class::BEGIN@24 |
| 1 | 1 | 1 | 43µs | 103µs | Class::MOP::Class::BEGIN@455 |
| 1 | 1 | 1 | 43µs | 248µs | Class::MOP::Class::BEGIN@17 |
| 1 | 1 | 1 | 40µs | 202µs | Class::MOP::Class::BEGIN@13 |
| 1 | 1 | 1 | 39µs | 108µs | Class::MOP::Class::BEGIN@5 |
| 1 | 1 | 1 | 39µs | 219µs | Class::MOP::Class::BEGIN@14 |
| 1 | 1 | 1 | 36µs | 165µs | Class::MOP::Class::BEGIN@15 |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::__ANON__[:214] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::__ANON__[:936] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_fix_class_metaclass_incompatibility |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_fix_single_metaclass_incompatibility |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_fixup_attributes_after_rebless |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_force_rebless_instance |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_inline_clear_mop_slot |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_inline_get_mop_slot |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_inline_rebless_instance |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_inline_set_mop_slot |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_inlined_methods |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_rebless_as_mutable |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_remove_inlined_code |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::add_dependent_meta_instance |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::add_meta_instance_dependencies |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::direct_subclasses |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::get_all_method_names |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::immutable_options |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::is_pristine |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::make_mutable |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::rebless_instance |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::rebless_instance_away |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::rebless_instance_back |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::remove_attribute |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::remove_dependent_meta_instance |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::remove_meta_instance_dependencies |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::subclasses |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | package Class::MOP::Class; | ||||
| 3 | |||||
| 4 | 3 | 101µs | 2 | 136µs | # spent 117µs (98+19) within Class::MOP::Class::BEGIN@4 which was called:
# once (98µs+19µs) by Class::MOP::BEGIN@19 at line 4 # spent 117µs making 1 call to Class::MOP::Class::BEGIN@4
# spent 19µs making 1 call to strict::import |
| 5 | 3 | 98µs | 2 | 177µs | # spent 108µs (39+69) within Class::MOP::Class::BEGIN@5 which was called:
# once (39µs+69µs) by Class::MOP::BEGIN@19 at line 5 # spent 108µs making 1 call to Class::MOP::Class::BEGIN@5
# spent 69µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 3 | 456µs | 1 | 5.88ms | # spent 5.88ms (5.18+701µs) within Class::MOP::Class::BEGIN@7 which was called:
# once (5.18ms+701µs) by Class::MOP::BEGIN@19 at line 7 # spent 5.88ms making 1 call to Class::MOP::Class::BEGIN@7 |
| 8 | 3 | 535µs | 1 | 5.12ms | # spent 5.12ms (4.27+854µs) within Class::MOP::Class::BEGIN@8 which was called:
# once (4.27ms+854µs) by Class::MOP::BEGIN@19 at line 8 # spent 5.12ms making 1 call to Class::MOP::Class::BEGIN@8 |
| 9 | 3 | 455µs | 1 | 36.3ms | # spent 36.3ms (4.84+31.5) within Class::MOP::Class::BEGIN@9 which was called:
# once (4.84ms+31.5ms) by Class::MOP::BEGIN@19 at line 9 # spent 36.3ms making 1 call to Class::MOP::Class::BEGIN@9 |
| 10 | 3 | 455µs | 1 | 7.37ms | # spent 7.37ms (2.92+4.44) within Class::MOP::Class::BEGIN@10 which was called:
# once (2.92ms+4.44ms) by Class::MOP::BEGIN@19 at line 10 # spent 7.37ms making 1 call to Class::MOP::Class::BEGIN@10 |
| 11 | 3 | 467µs | 1 | 1.28ms | # spent 1.28ms (1.09+195µs) within Class::MOP::Class::BEGIN@11 which was called:
# once (1.09ms+195µs) by Class::MOP::BEGIN@19 at line 11 # spent 1.28ms making 1 call to Class::MOP::Class::BEGIN@11 |
| 12 | |||||
| 13 | 3 | 118µs | 2 | 364µs | # spent 202µs (40+162) within Class::MOP::Class::BEGIN@13 which was called:
# once (40µs+162µs) by Class::MOP::BEGIN@19 at line 13 # spent 202µs making 1 call to Class::MOP::Class::BEGIN@13
# spent 162µs making 1 call to Exporter::import |
| 14 | 3 | 116µs | 2 | 400µs | # spent 219µs (39+181) within Class::MOP::Class::BEGIN@14 which was called:
# once (39µs+181µs) by Class::MOP::BEGIN@19 at line 14 # spent 219µs making 1 call to Class::MOP::Class::BEGIN@14
# spent 181µs making 1 call to Exporter::import |
| 15 | 3 | 103µs | 2 | 294µs | # spent 165µs (36+129) within Class::MOP::Class::BEGIN@15 which was called:
# once (36µs+129µs) by Class::MOP::BEGIN@19 at line 15 # spent 165µs making 1 call to Class::MOP::Class::BEGIN@15
# spent 129µs making 1 call to Exporter::import |
| 16 | 3 | 637µs | 2 | 5.70ms | # spent 4.90ms (1.19+3.70) within Class::MOP::Class::BEGIN@16 which was called:
# once (1.19ms+3.70ms) by Class::MOP::BEGIN@19 at line 16 # spent 4.90ms making 1 call to Class::MOP::Class::BEGIN@16
# spent 807µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756] |
| 17 | 3 | 113µs | 2 | 453µs | # spent 248µs (43+205) within Class::MOP::Class::BEGIN@17 which was called:
# once (43µs+205µs) by Class::MOP::BEGIN@19 at line 17 # spent 248µs making 1 call to Class::MOP::Class::BEGIN@17
# spent 205µs making 1 call to Exporter::import |
| 18 | 3 | 756µs | 2 | 5.17ms | # spent 4.58ms (2.03+2.55) within Class::MOP::Class::BEGIN@18 which was called:
# once (2.03ms+2.55ms) by Class::MOP::BEGIN@19 at line 18 # spent 4.58ms making 1 call to Class::MOP::Class::BEGIN@18
# spent 588µs making 1 call to Exporter::import |
| 19 | |||||
| 20 | 1 | 5µs | our $VERSION = '1.11'; | ||
| 21 | 1 | 88µs | $VERSION = eval $VERSION; # spent 12µs executing statements in string eval | ||
| 22 | 1 | 4µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 23 | |||||
| 24 | 1 | 0s | # spent 18.1ms (46µs+18.1) within Class::MOP::Class::BEGIN@24 which was called:
# once (46µs+18.1ms) by Class::MOP::BEGIN@19 at line 26 # spent 18.1ms making 1 call to base::import, recursion: max depth 1, sum of overlapping time 18.1ms | ||
| 25 | 'Class::MOP::Mixin::HasAttributes', | ||||
| 26 | 3 | 5.85ms | 1 | 18.1ms | 'Class::MOP::Mixin::HasMethods'; # spent 18.1ms making 1 call to Class::MOP::Class::BEGIN@24 |
| 27 | |||||
| 28 | # Creation | ||||
| 29 | |||||
| 30 | # spent 969ms (222+747) within Class::MOP::Class::initialize which was called 6665 times, avg 145µs/call:
# 3137 times (97.9ms+13.3ms) by Class::MOP::Class::get_all_attributes at line 968, avg 35µs/call
# 752 times (24.9ms+6.95ms) by Class::MOP::Class::find_method_by_name at line 1159, avg 42µs/call
# 641 times (22.6ms+19.2ms) by Class::MOP::Class::__ANON__::SERIAL::11::meta or Class::MOP::Class::__ANON__::SERIAL::15::meta or Class::MOP::Class::__ANON__::SERIAL::19::meta or Class::MOP::Class::__ANON__::SERIAL::1::meta or Class::MOP::Class::__ANON__::SERIAL::2::meta or Class::MOP::Class::__ANON__::SERIAL::5::meta or Class::MOP::Class::__ANON__::SERIAL::8::meta or Class::MOP::Mixin::meta or Class::MOP::Object::meta or Markdent::Dialect::Standard::BlockParser::meta or Markdent::Dialect::Standard::SpanParser::meta or Markdent::Event::AutoLink::meta or Markdent::Event::EndBlockquote::meta or Markdent::Event::EndCode::meta or Markdent::Event::EndDocument::meta or Markdent::Event::EndEmphasis::meta or Markdent::Event::EndHTMLTag::meta or Markdent::Event::EndHeader::meta or Markdent::Event::EndLink::meta or Markdent::Event::EndListItem::meta or Markdent::Event::EndOrderedList::meta or Markdent::Event::EndParagraph::meta or Markdent::Event::EndStrong::meta or Markdent::Event::EndUnorderedList::meta or Markdent::Event::HTMLBlock::meta or Markdent::Event::HTMLComment::meta or Markdent::Event::HTMLCommentBlock::meta or Markdent::Event::HTMLEntity::meta or Markdent::Event::HTMLTag::meta or Markdent::Event::HorizontalRule::meta or Markdent::Event::Image::meta or Markdent::Event::Preformatted::meta or Markdent::Event::StartBlockquote::meta or Markdent::Event::StartCode::meta or Markdent::Event::StartDocument::meta or Markdent::Event::StartEmphasis::meta or Markdent::Event::StartHTMLTag::meta or Markdent::Event::StartHeader::meta or Markdent::Event::StartLink::meta or Markdent::Event::StartListItem::meta or Markdent::Event::StartOrderedList::meta or Markdent::Event::StartParagraph::meta or Markdent::Event::StartStrong::meta or Markdent::Event::StartUnorderedList::meta or Markdent::Event::Text::meta or Markdent::Handler::HTMLStream::Document::meta or Markdent::Parser::meta or Moose::Meta::Role::Application::RoleSummation::meta or Moose::Meta::Role::Application::ToClass::meta or Moose::Meta::Role::Application::ToInstance::meta or Moose::Meta::Role::Application::ToRole::meta or Moose::Meta::Role::Application::meta or Moose::Meta::Role::Composite::meta or Moose::Meta::Role::Method::Required::meta or Moose::Meta::Role::meta or Moose::Meta::TypeCoercion::Union::meta or Moose::Meta::TypeCoercion::meta or Moose::Meta::TypeConstraint::Class::meta or Moose::Meta::TypeConstraint::DuckType::meta or Moose::Meta::TypeConstraint::Enum::meta or Moose::Meta::TypeConstraint::Parameterizable::meta or Moose::Meta::TypeConstraint::Parameterized::meta or Moose::Meta::TypeConstraint::Registry::meta or Moose::Meta::TypeConstraint::Role::meta or Moose::Meta::TypeConstraint::Union::meta or Moose::Meta::TypeConstraint::meta or MooseX::Role::Parameterized::Meta::Parameter::meta or MooseX::Role::Parameterized::Meta::Role::Parameterizable::meta or MooseX::Role::Parameterized::Meta::Role::Parameterized::meta or MooseX::Role::Parameterized::Parameters::meta at line 44 of Class/MOP/Method/Meta.pm, avg 65µs/call
# 547 times (18.1ms+5.38ms) by Class::MOP::Class::find_next_method_by_name at line 1208, avg 43µs/call
# 253 times (7.96ms+2.24ms) by Class::MOP::Class::find_all_methods_by_name at line 1191, avg 40µs/call
# 232 times (7.70ms+2.23ms) by Class::MOP::Class::class_precedence_list at line 1068, avg 43µs/call
# 209 times (6.64ms+2.02ms) by Moose::Meta::Attribute::_new or Moose::Meta::Method::_new or Moose::Meta::Role::_new at line 4 of generated method (unknown origin), avg 41µs/call
# 206 times (7.26ms+1.46ms) by Class::MOP::Class::_fix_metaclass_incompatibility at line 298, avg 42µs/call
# 194 times (6.04ms+1.66ms) by Class::MOP::Class::find_attribute_by_name at line 958, avg 40µs/call
# 111 times (7.69ms+627ms) by Moose::Meta::Class::initialize at line 68 of Moose/Meta/Class.pm, avg 5.71ms/call
# 98 times (3.33ms+1.05ms) by Class::MOP::Attribute::set_initial_value at line 259 of Class/MOP/Attribute.pm, avg 45µs/call
# 80 times (2.90ms+830µs) by Moose::Util::MetaRole::_make_new_class at line 157 of Moose/Util/MetaRole.pm, avg 47µs/call
# 49 times (2.36ms+586µs) by namespace::autoclean::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/namespace/autoclean.pm:57] at line 44 of namespace/autoclean.pm, avg 60µs/call
# 33 times (1.39ms+25.4ms) by Class::MOP::Object::meta at line 18 of Class/MOP/Object.pm, avg 812µs/call
# 26 times (834µs+7.58ms) by Class::MOP::Method::_new at line 54 of Class/MOP/Method.pm, avg 324µs/call
# 19 times (996µs+7.73ms) by metaclass::import at line 45 of metaclass.pm, avg 459µs/call
# 18 times (692µs+6.40ms) by Class::MOP::Mixin::meta at line 14 of Class/MOP/Mixin.pm, avg 394µs/call
# 15 times (701µs+12.7ms) by Class::MOP::MiniTrait::apply at line 15 of Class/MOP/MiniTrait.pm, avg 896µs/call
# 14 times (552µs+159µs) by Class::MOP::Attribute::get_raw_value at line 295 of Class/MOP/Attribute.pm, avg 51µs/call
# 11 times (329µs+89µs) by Class::MOP::Class::get_all_methods at line 1170, avg 38µs/call
# 8 times (282µs+87µs) by Class::MOP::Attribute::has_value at line 316 of Class/MOP/Attribute.pm, avg 46µs/call
# 7 times (325µs+2.67ms) by Moose::BEGIN@38 at line 11 of Moose/Meta/Attribute/Native.pm, avg 428µs/call
# 2 times (89µs+873µs) by Class::MOP::Class::create at line 513, avg 481µs/call
# 2 times (57µs+17µs) by Class::MOP::Attribute::set_raw_value at line 272 of Class/MOP/Attribute.pm, avg 37µs/call
# once (32µs+10µs) by Class::MOP::Attribute::_new at line 62 of Class/MOP/Attribute.pm | ||||
| 31 | 33325 | 211ms | my $class = shift; | ||
| 32 | |||||
| 33 | my $package_name; | ||||
| 34 | |||||
| 35 | if ( @_ % 2 ) { | ||||
| 36 | $package_name = shift; | ||||
| 37 | } else { | ||||
| 38 | my %options = @_; | ||||
| 39 | $package_name = $options{package}; | ||||
| 40 | } | ||||
| 41 | |||||
| 42 | ($package_name && !ref($package_name)) | ||||
| 43 | || confess "You must pass a package name and it cannot be blessed"; | ||||
| 44 | |||||
| 45 | 6840 | 770ms | return Class::MOP::get_metaclass_by_name($package_name) # spent 709ms making 175 calls to Class::MOP::Class::_construct_class_instance, avg 4.05ms/call, recursion: max depth 1, sum of overlapping time 715µs
# spent 61.9ms making 6665 calls to Class::MOP::get_metaclass_by_name, avg 9µs/call | ||
| 46 | || $class->_construct_class_instance(package => $package_name, @_); | ||||
| 47 | } | ||||
| 48 | |||||
| 49 | # spent 555ms (8.91+546) within Class::MOP::Class::reinitialize which was called 42 times, avg 13.2ms/call:
# 42 times (8.91ms+546ms) by Moose::Meta::Class::reinitialize at line 157 of Moose/Meta/Class.pm, avg 13.2ms/call | ||||
| 50 | 378 | 10.2ms | my ( $class, @args ) = @_; | ||
| 51 | unshift @args, "package" if @args % 2; | ||||
| 52 | my %options = @args; | ||||
| 53 | 42 | 278µs | my $old_metaclass = blessed($options{package}) # spent 278µs making 42 calls to Scalar::Util::blessed, avg 7µs/call | ||
| 54 | ? $options{package} | ||||
| 55 | : Class::MOP::get_metaclass_by_name($options{package}); | ||||
| 56 | 168 | 1.68ms | $options{weaken} = Class::MOP::metaclass_is_weak($old_metaclass->name) # spent 1.01ms making 42 calls to Class::MOP::metaclass_is_weak, avg 24µs/call
# spent 250µs making 42 calls to UNIVERSAL::isa, avg 6µs/call
# spent 231µs making 42 calls to Scalar::Util::blessed, avg 6µs/call
# spent 189µs making 42 calls to Class::MOP::Package::name, avg 4µs/call | ||
| 57 | if !exists $options{weaken} | ||||
| 58 | && blessed($old_metaclass) | ||||
| 59 | && $old_metaclass->isa('Class::MOP::Class'); | ||||
| 60 | 84 | 2.87ms | $old_metaclass->_remove_generated_metaobjects # spent 2.65ms making 42 calls to Class::MOP::Class::_remove_generated_metaobjects, avg 63µs/call
# spent 220µs making 42 calls to UNIVERSAL::isa, avg 5µs/call | ||
| 61 | if $old_metaclass && $old_metaclass->isa('Class::MOP::Class'); | ||||
| 62 | 42 | 363ms | my $new_metaclass = $class->SUPER::reinitialize(%options); # spent 363ms making 42 calls to Class::MOP::Package::reinitialize, avg 8.65ms/call | ||
| 63 | 84 | 178ms | $new_metaclass->_restore_metaobjects_from($old_metaclass) # spent 177ms making 42 calls to Class::MOP::Class::_restore_metaobjects_from, avg 4.22ms/call
# spent 297µs making 42 calls to UNIVERSAL::isa, avg 7µs/call | ||
| 64 | if $old_metaclass && $old_metaclass->isa('Class::MOP::Class'); | ||||
| 65 | return $new_metaclass; | ||||
| 66 | } | ||||
| 67 | |||||
| 68 | # NOTE: (meta-circularity) | ||||
| 69 | # this is a special form of _construct_instance | ||||
| 70 | # (see below), which is used to construct class | ||||
| 71 | # meta-object instances for any Class::MOP::* | ||||
| 72 | # class. All other classes will use the more | ||||
| 73 | # normal &construct_instance. | ||||
| 74 | # spent 708ms (21.3+687) within Class::MOP::Class::_construct_class_instance which was called 175 times, avg 4.05ms/call:
# 175 times (21.3ms+687ms) by Class::MOP::Class::initialize at line 45, avg 4.05ms/call | ||||
| 75 | 2211 | 19.7ms | my $class = shift; | ||
| 76 | my $options = @_ == 1 ? $_[0] : {@_}; | ||||
| 77 | my $package_name = $options->{package}; | ||||
| 78 | (defined $package_name && $package_name) | ||||
| 79 | || confess "You must pass a package name"; | ||||
| 80 | # NOTE: | ||||
| 81 | # return the metaclass if we have it cached, | ||||
| 82 | # and it is still defined (it has not been | ||||
| 83 | # reaped by DESTROY yet, which can happen | ||||
| 84 | # annoyingly enough during global destruction) | ||||
| 85 | |||||
| 86 | 175 | 1.38ms | if (defined(my $meta = Class::MOP::get_metaclass_by_name($package_name))) { # spent 1.38ms making 175 calls to Class::MOP::get_metaclass_by_name, avg 8µs/call | ||
| 87 | return $meta; | ||||
| 88 | } | ||||
| 89 | |||||
| 90 | $class | ||||
| 91 | 10 | 1.01ms | = ref $class # spent 1.01ms making 10 calls to Class::MOP::Class::_real_ref_name, avg 101µs/call | ||
| 92 | ? $class->_real_ref_name | ||||
| 93 | : $class; | ||||
| 94 | |||||
| 95 | # now create the metaclass | ||||
| 96 | my $meta; | ||||
| 97 | 64 | 4.07ms | if ($class eq 'Class::MOP::Class') { # spent 4.07ms making 64 calls to Class::MOP::Class::_new, avg 64µs/call | ||
| 98 | $meta = $class->_new($options); | ||||
| 99 | } | ||||
| 100 | else { | ||||
| 101 | # NOTE: | ||||
| 102 | # it is safe to use meta here because | ||||
| 103 | # class will always be a subclass of | ||||
| 104 | # Class::MOP::Class, which defines meta | ||||
| 105 | 222 | 406ms | $meta = $class->meta->_construct_instance($options) # spent 396ms making 111 calls to Class::MOP::Class::_construct_instance, avg 3.57ms/call
# spent 6.53ms making 73 calls to Class::MOP::Object::meta, avg 89µs/call
# spent 3.12ms making 38 calls to Class::MOP::Class::__ANON__::SERIAL::2::meta, avg 82µs/call | ||
| 106 | } | ||||
| 107 | |||||
| 108 | # and check the metaclass compatibility | ||||
| 109 | 175 | 270ms | $meta->_check_metaclass_compatibility(); # spent 273ms making 175 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 1.56ms/call, recursion: max depth 1, sum of overlapping time 3.19ms | ||
| 110 | |||||
| 111 | 175 | 2.39ms | Class::MOP::store_metaclass_by_name($package_name, $meta); # spent 2.39ms making 175 calls to Class::MOP::store_metaclass_by_name, avg 14µs/call | ||
| 112 | |||||
| 113 | # NOTE: | ||||
| 114 | # we need to weaken any anon classes | ||||
| 115 | # so that they can call DESTROY properly | ||||
| 116 | 2 | 57µs | Class::MOP::weaken_metaclass($package_name) if $options->{weaken}; # spent 57µs making 2 calls to Class::MOP::weaken_metaclass, avg 29µs/call | ||
| 117 | |||||
| 118 | $meta; | ||||
| 119 | } | ||||
| 120 | |||||
| 121 | # spent 17.1ms (10.8+6.34) within Class::MOP::Class::_real_ref_name which was called 382 times, avg 45µs/call:
# 206 times (5.84ms+3.38ms) by Class::MOP::Class::_class_metaclass_can_be_made_compatible at line 343, avg 45µs/call
# 163 times (4.50ms+2.25ms) by Class::MOP::Class::_class_metaclass_is_compatible at line 253, avg 41µs/call
# 10 times (367µs+645µs) by Class::MOP::Class::_construct_class_instance at line 91, avg 101µs/call
# 3 times (90µs+71µs) by Class::MOP::Class::_immutable_metaclass at line 1385, avg 54µs/call | ||||
| 122 | 764 | 10.2ms | my $self = shift; | ||
| 123 | |||||
| 124 | # NOTE: we need to deal with the possibility of class immutability here, | ||||
| 125 | # and then get the name of the class appropriately | ||||
| 126 | 444 | 6.34ms | return $self->is_immutable # spent 2.74ms making 56 calls to Class::MOP::Class::Immutable::Class::MOP::Class::is_immutable, avg 49µs/call
# spent 2.41ms making 320 calls to Class::MOP::Class::is_immutable, avg 8µs/call
# spent 890µs making 62 calls to Class::MOP::Class::Immutable::Trait::_get_mutable_metaclass_name, avg 14µs/call
# spent 300µs making 6 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::is_immutable, avg 50µs/call | ||
| 127 | ? $self->_get_mutable_metaclass_name() | ||||
| 128 | : ref $self; | ||||
| 129 | } | ||||
| 130 | |||||
| 131 | # spent 4.07ms within Class::MOP::Class::_new which was called 64 times, avg 64µs/call:
# 64 times (4.07ms+0s) by Class::MOP::Class::_construct_class_instance at line 97, avg 64µs/call | ||||
| 132 | 256 | 4.32ms | my $class = shift; | ||
| 133 | |||||
| 134 | return Class::MOP::Class->initialize($class)->new_object(@_) | ||||
| 135 | if $class ne __PACKAGE__; | ||||
| 136 | |||||
| 137 | my $options = @_ == 1 ? $_[0] : {@_}; | ||||
| 138 | |||||
| 139 | return bless { | ||||
| 140 | # inherited from Class::MOP::Package | ||||
| 141 | 'package' => $options->{package}, | ||||
| 142 | |||||
| 143 | # NOTE: | ||||
| 144 | # since the following attributes will | ||||
| 145 | # actually be loaded from the symbol | ||||
| 146 | # table, and actually bypass the instance | ||||
| 147 | # entirely, we can just leave these things | ||||
| 148 | # listed here for reference, because they | ||||
| 149 | # should not actually have a value associated | ||||
| 150 | # with the slot. | ||||
| 151 | 'namespace' => \undef, | ||||
| 152 | 'methods' => {}, | ||||
| 153 | |||||
| 154 | # inherited from Class::MOP::Module | ||||
| 155 | 'version' => \undef, | ||||
| 156 | 'authority' => \undef, | ||||
| 157 | |||||
| 158 | # defined in Class::MOP::Class | ||||
| 159 | 'superclasses' => \undef, | ||||
| 160 | |||||
| 161 | 'attributes' => {}, | ||||
| 162 | 'attribute_metaclass' => | ||||
| 163 | ( $options->{'attribute_metaclass'} || 'Class::MOP::Attribute' ), | ||||
| 164 | 'method_metaclass' => | ||||
| 165 | ( $options->{'method_metaclass'} || 'Class::MOP::Method' ), | ||||
| 166 | 'wrapped_method_metaclass' => ( | ||||
| 167 | $options->{'wrapped_method_metaclass'} | ||||
| 168 | || 'Class::MOP::Method::Wrapped' | ||||
| 169 | ), | ||||
| 170 | 'instance_metaclass' => | ||||
| 171 | ( $options->{'instance_metaclass'} || 'Class::MOP::Instance' ), | ||||
| 172 | 'immutable_trait' => ( | ||||
| 173 | $options->{'immutable_trait'} | ||||
| 174 | || 'Class::MOP::Class::Immutable::Trait' | ||||
| 175 | ), | ||||
| 176 | 'constructor_name' => ( $options->{constructor_name} || 'new' ), | ||||
| 177 | 'constructor_class' => ( | ||||
| 178 | $options->{constructor_class} || 'Class::MOP::Method::Constructor' | ||||
| 179 | ), | ||||
| 180 | 'destructor_class' => $options->{destructor_class}, | ||||
| 181 | }, $class; | ||||
| 182 | } | ||||
| 183 | |||||
| 184 | ## Metaclass compatibility | ||||
| 185 | { | ||||
| 186 | 2 | 22µs | my %base_metaclass = ( | ||
| 187 | attribute_metaclass => 'Class::MOP::Attribute', | ||||
| 188 | method_metaclass => 'Class::MOP::Method', | ||||
| 189 | wrapped_method_metaclass => 'Class::MOP::Method::Wrapped', | ||||
| 190 | instance_metaclass => 'Class::MOP::Instance', | ||||
| 191 | constructor_class => 'Class::MOP::Method::Constructor', | ||||
| 192 | destructor_class => 'Class::MOP::Method::Destructor', | ||||
| 193 | ); | ||||
| 194 | |||||
| 195 | 391 | 9.03ms | # spent 7.24ms within Class::MOP::Class::_base_metaclasses which was called 391 times, avg 19µs/call:
# 314 times (5.93ms+0s) by Moose::Meta::Class::_base_metaclasses at line 538 of Moose/Meta/Class.pm, avg 19µs/call
# 43 times (765µs+0s) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 331, avg 18µs/call
# 34 times (543µs+0s) by Class::MOP::Class::_check_metaclass_compatibility at line 206, avg 16µs/call | ||
| 196 | } | ||||
| 197 | |||||
| 198 | # spent 763ms (66.6+697) within Class::MOP::Class::_check_metaclass_compatibility which was called 286 times, avg 2.67ms/call:
# 175 times (22.3ms+247ms) by Class::MOP::Class::_construct_class_instance at line 109, avg 1.54ms/call
# 111 times (44.3ms+449ms) by Class::MOP::Class::superclasses at line 998, avg 4.45ms/call | ||||
| 199 | 4847 | 64.8ms | my $self = shift; | ||
| 200 | |||||
| 201 | 286 | 42.5ms | my @superclasses = $self->superclasses # spent 52.4ms making 220 calls to Moose::Meta::Class::superclasses, avg 238µs/call, recursion: max depth 1, sum of overlapping time 20.5ms
# spent 11.0ms making 66 calls to Class::MOP::Class::superclasses, avg 166µs/call, recursion: max depth 1, sum of overlapping time 428µs | ||
| 202 | or return; | ||||
| 203 | |||||
| 204 | 185 | 335ms | $self->_fix_metaclass_incompatibility(@superclasses); # spent 337ms making 185 calls to Class::MOP::Class::_fix_metaclass_incompatibility, avg 1.82ms/call, recursion: max depth 1, sum of overlapping time 2.32ms | ||
| 205 | |||||
| 206 | 185 | 33.8ms | my %base_metaclass = $self->_base_metaclasses; # spent 33.2ms making 151 calls to Moose::Meta::Class::_base_metaclasses, avg 220µs/call
# spent 543µs making 34 calls to Class::MOP::Class::_base_metaclasses, avg 16µs/call | ||
| 207 | |||||
| 208 | # this is always okay ... | ||||
| 209 | return | ||||
| 210 | if ref($self) eq 'Class::MOP::Class' | ||||
| 211 | && all { | ||||
| 212 | 408 | 4.21ms | 204 | 1.05ms | my $meta = $self->$_; # spent 189µs making 34 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 6µs/call
# spent 180µs making 34 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call
# spent 177µs making 34 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call
# spent 168µs making 34 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call
# spent 167µs making 34 calls to Class::MOP::Class::constructor_class, avg 5µs/call
# spent 166µs making 34 calls to Class::MOP::Class::destructor_class, avg 5µs/call |
| 213 | 1 | 1.22ms | !defined($meta) || $meta eq $base_metaclass{$_}; | ||
| 214 | } | ||||
| 215 | 34 | 5.09ms | keys %base_metaclass; # spent 5.09ms making 34 calls to List::MoreUtils::all, avg 150µs/call | ||
| 216 | |||||
| 217 | for my $superclass (@superclasses) { | ||||
| 218 | 163 | 27.0ms | $self->_check_class_metaclass_compatibility($superclass); # spent 27.0ms making 163 calls to Class::MOP::Class::_check_class_metaclass_compatibility, avg 165µs/call | ||
| 219 | } | ||||
| 220 | |||||
| 221 | for my $metaclass_type ( keys %base_metaclass ) { | ||||
| 222 | 1057 | 10.2ms | next unless defined $self->$metaclass_type; # spent 2.20ms making 151 calls to Moose::Meta::Class::error_class, avg 15µs/call
# spent 2.12ms making 151 calls to Moose::Meta::Class::constructor_class, avg 14µs/call
# spent 2.10ms making 151 calls to Moose::Meta::Class::destructor_class, avg 14µs/call
# spent 1.02ms making 151 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 7µs/call
# spent 977µs making 151 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 6µs/call
# spent 900µs making 151 calls to Class::MOP::Class::instance_metaclass, avg 6µs/call
# spent 835µs making 151 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 6µs/call | ||
| 223 | for my $superclass (@superclasses) { | ||||
| 224 | 1141 | 223ms | $self->_check_single_metaclass_compatibility( $metaclass_type, # spent 223ms making 1141 calls to Class::MOP::Class::_check_single_metaclass_compatibility, avg 196µs/call | ||
| 225 | $superclass ); | ||||
| 226 | } | ||||
| 227 | } | ||||
| 228 | } | ||||
| 229 | |||||
| 230 | # spent 27.0ms (4.44+22.5) within Class::MOP::Class::_check_class_metaclass_compatibility which was called 163 times, avg 165µs/call:
# 163 times (4.44ms+22.5ms) by Class::MOP::Class::_check_metaclass_compatibility at line 218, avg 165µs/call | ||||
| 231 | 489 | 4.13ms | my $self = shift; | ||
| 232 | my ( $superclass_name ) = @_; | ||||
| 233 | |||||
| 234 | 163 | 22.5ms | if (!$self->_class_metaclass_is_compatible($superclass_name)) { # spent 22.5ms making 163 calls to Class::MOP::Class::_class_metaclass_is_compatible, avg 138µs/call | ||
| 235 | my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name); | ||||
| 236 | |||||
| 237 | my $super_meta_type = $super_meta->_real_ref_name; | ||||
| 238 | |||||
| 239 | confess "The metaclass of " . $self->name . " (" | ||||
| 240 | . (ref($self)) . ")" . " is not compatible with " | ||||
| 241 | . "the metaclass of its superclass, " | ||||
| 242 | . $superclass_name . " (" . ($super_meta_type) . ")"; | ||||
| 243 | } | ||||
| 244 | } | ||||
| 245 | |||||
| 246 | # spent 22.5ms (8.99+13.5) within Class::MOP::Class::_class_metaclass_is_compatible which was called 163 times, avg 138µs/call:
# 163 times (8.99ms+13.5ms) by Class::MOP::Class::_check_class_metaclass_compatibility at line 234, avg 138µs/call | ||||
| 247 | 815 | 7.98ms | my $self = shift; | ||
| 248 | my ( $superclass_name ) = @_; | ||||
| 249 | |||||
| 250 | 163 | 1.65ms | my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name) # spent 1.65ms making 163 calls to Class::MOP::get_metaclass_by_name, avg 10µs/call | ||
| 251 | || return 1; | ||||
| 252 | |||||
| 253 | 163 | 6.75ms | my $super_meta_name = $super_meta->_real_ref_name; # spent 6.75ms making 163 calls to Class::MOP::Class::_real_ref_name, avg 41µs/call | ||
| 254 | |||||
| 255 | 163 | 5.15ms | return $self->_is_compatible_with($super_meta_name); # spent 5.15ms making 163 calls to Class::MOP::Object::_is_compatible_with, avg 32µs/call | ||
| 256 | } | ||||
| 257 | |||||
| 258 | # spent 223ms (30.6+193) within Class::MOP::Class::_check_single_metaclass_compatibility which was called 1141 times, avg 196µs/call:
# 1141 times (30.6ms+193ms) by Class::MOP::Class::_check_metaclass_compatibility at line 224, avg 196µs/call | ||||
| 259 | 3423 | 29.4ms | my $self = shift; | ||
| 260 | my ( $metaclass_type, $superclass_name ) = @_; | ||||
| 261 | |||||
| 262 | 1141 | 193ms | if (!$self->_single_metaclass_is_compatible($metaclass_type, $superclass_name)) { # spent 193ms making 1141 calls to Class::MOP::Class::_single_metaclass_is_compatible, avg 169µs/call | ||
| 263 | my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name); | ||||
| 264 | my $metaclass_type_name = $metaclass_type; | ||||
| 265 | $metaclass_type_name =~ s/_(?:meta)?class$//; | ||||
| 266 | $metaclass_type_name =~ s/_/ /g; | ||||
| 267 | confess "The $metaclass_type_name metaclass for " | ||||
| 268 | . $self->name . " (" . ($self->$metaclass_type) | ||||
| 269 | . ")" . " is not compatible with the " | ||||
| 270 | . "$metaclass_type_name metaclass of its " | ||||
| 271 | . "superclass, $superclass_name (" | ||||
| 272 | . ($super_meta->$metaclass_type) . ")"; | ||||
| 273 | } | ||||
| 274 | } | ||||
| 275 | |||||
| 276 | # spent 193ms (106+86.7) within Class::MOP::Class::_single_metaclass_is_compatible which was called 1141 times, avg 169µs/call:
# 1141 times (106ms+86.7ms) by Class::MOP::Class::_check_single_metaclass_compatibility at line 262, avg 169µs/call | ||||
| 277 | 7842 | 117ms | my $self = shift; | ||
| 278 | my ( $metaclass_type, $superclass_name ) = @_; | ||||
| 279 | |||||
| 280 | 1141 | 9.60ms | my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name) # spent 9.60ms making 1141 calls to Class::MOP::get_metaclass_by_name, avg 8µs/call | ||
| 281 | || return 1; | ||||
| 282 | |||||
| 283 | # for instance, Moose::Meta::Class has a error_class attribute, but | ||||
| 284 | # Class::MOP::Class doesn't - this shouldn't be an error | ||||
| 285 | 1141 | 7.31ms | return 1 unless $super_meta->can($metaclass_type); # spent 7.31ms making 1141 calls to UNIVERSAL::can, avg 6µs/call | ||
| 286 | # for instance, Moose::Meta::Class has a destructor_class, but | ||||
| 287 | # Class::MOP::Class doesn't - this shouldn't be an error | ||||
| 288 | 1112 | 8.80ms | return 1 unless defined $super_meta->$metaclass_type; # spent 1.71ms making 134 calls to Moose::Meta::Class::error_class, avg 13µs/call
# spent 1.62ms making 134 calls to Moose::Meta::Class::destructor_class, avg 12µs/call
# spent 1.61ms making 134 calls to Moose::Meta::Class::constructor_class, avg 12µs/call
# spent 950µs making 163 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 6µs/call
# spent 885µs making 163 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call
# spent 883µs making 163 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call
# spent 849µs making 163 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call
# spent 154µs making 29 calls to Class::MOP::Class::constructor_class, avg 5µs/call
# spent 147µs making 29 calls to Class::MOP::Class::destructor_class, avg 5µs/call | ||
| 289 | # if metaclass is defined in superclass but not here, it's not compatible | ||||
| 290 | # this is a really odd case | ||||
| 291 | 1083 | 8.37ms | return 0 unless defined $self->$metaclass_type; # spent 1.95ms making 163 calls to Moose::Meta::Class::constructor_class, avg 12µs/call
# spent 1.64ms making 134 calls to Moose::Meta::Class::error_class, avg 12µs/call
# spent 1.59ms making 134 calls to Moose::Meta::Class::destructor_class, avg 12µs/call
# spent 817µs making 163 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call
# spent 803µs making 163 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 5µs/call
# spent 802µs making 163 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call
# spent 771µs making 163 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call | ||
| 292 | |||||
| 293 | 3249 | 52.6ms | return $self->$metaclass_type->_is_compatible_with($super_meta->$metaclass_type); # spent 36.9ms making 1083 calls to Class::MOP::Object::_is_compatible_with, avg 34µs/call
# spent 3.44ms making 297 calls to Moose::Meta::Class::constructor_class, avg 12µs/call
# spent 3.15ms making 268 calls to Moose::Meta::Class::error_class, avg 12µs/call
# spent 3.08ms making 268 calls to Moose::Meta::Class::destructor_class, avg 11µs/call
# spent 1.53ms making 326 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call
# spent 1.50ms making 326 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 5µs/call
# spent 1.48ms making 326 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call
# spent 1.43ms making 326 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 4µs/call
# spent 147µs making 29 calls to Class::MOP::Class::constructor_class, avg 5µs/call | ||
| 294 | } | ||||
| 295 | |||||
| 296 | # spent 335ms (12.9+322) within Class::MOP::Class::_fix_metaclass_incompatibility which was called 185 times, avg 1.81ms/call:
# 185 times (12.9ms+322ms) by Class::MOP::Class::_check_metaclass_compatibility at line 204, avg 1.81ms/call | ||||
| 297 | 1337 | 12.0ms | my $self = shift; | ||
| 298 | 206 | 8.73ms | my @supers = map { Class::MOP::Class->initialize($_) } @_; # spent 13.0ms making 206 calls to Class::MOP::Class::initialize, avg 63µs/call, recursion: max depth 1, sum of overlapping time 4.32ms | ||
| 299 | |||||
| 300 | my $necessary = 0; | ||||
| 301 | for my $super (@supers) { | ||||
| 302 | 206 | 311ms | $necessary = 1 # spent 311ms making 206 calls to Class::MOP::Class::_can_fix_metaclass_incompatibility, avg 1.51ms/call | ||
| 303 | if $self->_can_fix_metaclass_incompatibility($super); | ||||
| 304 | } | ||||
| 305 | return unless $necessary; | ||||
| 306 | |||||
| 307 | for my $super (@supers) { | ||||
| 308 | if (!$self->_class_metaclass_is_compatible($super->name)) { | ||||
| 309 | $self->_fix_class_metaclass_incompatibility($super); | ||||
| 310 | } | ||||
| 311 | } | ||||
| 312 | |||||
| 313 | my %base_metaclass = $self->_base_metaclasses; | ||||
| 314 | for my $metaclass_type (keys %base_metaclass) { | ||||
| 315 | for my $super (@supers) { | ||||
| 316 | if (!$self->_single_metaclass_is_compatible($metaclass_type, $super->name)) { | ||||
| 317 | $self->_fix_single_metaclass_incompatibility( | ||||
| 318 | $metaclass_type, $super | ||||
| 319 | ); | ||||
| 320 | } | ||||
| 321 | } | ||||
| 322 | } | ||||
| 323 | } | ||||
| 324 | |||||
| 325 | # spent 311ms (38.0+273) within Class::MOP::Class::_can_fix_metaclass_incompatibility which was called 206 times, avg 1.51ms/call:
# 206 times (38.0ms+273ms) by Class::MOP::Class::_fix_metaclass_incompatibility at line 302, avg 1.51ms/call | ||||
| 326 | 2635 | 34.8ms | my $self = shift; | ||
| 327 | my ($super_meta) = @_; | ||||
| 328 | |||||
| 329 | 206 | 29.3ms | return 1 if $self->_class_metaclass_can_be_made_compatible($super_meta); # spent 29.3ms making 206 calls to Class::MOP::Class::_class_metaclass_can_be_made_compatible, avg 142µs/call | ||
| 330 | |||||
| 331 | 206 | 38.0ms | my %base_metaclass = $self->_base_metaclasses; # spent 37.2ms making 163 calls to Moose::Meta::Class::_base_metaclasses, avg 228µs/call
# spent 765µs making 43 calls to Class::MOP::Class::_base_metaclasses, avg 18µs/call | ||
| 332 | for my $metaclass_type (keys %base_metaclass) { | ||||
| 333 | 1399 | 206ms | return 1 if $self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type); # spent 206ms making 1399 calls to Class::MOP::Class::_single_metaclass_can_be_made_compatible, avg 147µs/call | ||
| 334 | } | ||||
| 335 | |||||
| 336 | return; | ||||
| 337 | } | ||||
| 338 | |||||
| 339 | # spent 29.3ms (7.65+21.6) within Class::MOP::Class::_class_metaclass_can_be_made_compatible which was called 206 times, avg 142µs/call:
# 206 times (7.65ms+21.6ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 329, avg 142µs/call | ||||
| 340 | 618 | 7.48ms | my $self = shift; | ||
| 341 | my ($super_meta) = @_; | ||||
| 342 | |||||
| 343 | 412 | 21.6ms | return $self->_can_be_made_compatible_with($super_meta->_real_ref_name); # spent 12.4ms making 206 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 60µs/call
# spent 9.21ms making 206 calls to Class::MOP::Class::_real_ref_name, avg 45µs/call | ||
| 344 | } | ||||
| 345 | |||||
| 346 | # spent 206ms (101+105) within Class::MOP::Class::_single_metaclass_can_be_made_compatible which was called 1399 times, avg 147µs/call:
# 1399 times (101ms+105ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 333, avg 147µs/call | ||||
| 347 | 10932 | 116ms | my $self = shift; | ||
| 348 | my ($super_meta, $metaclass_type) = @_; | ||||
| 349 | |||||
| 350 | 1399 | 12.6ms | my $specific_meta = $self->$metaclass_type; # spent 2.51ms making 163 calls to Moose::Meta::Class::error_class, avg 15µs/call
# spent 2.48ms making 163 calls to Moose::Meta::Class::constructor_class, avg 15µs/call
# spent 2.23ms making 163 calls to Moose::Meta::Class::destructor_class, avg 14µs/call
# spent 1.40ms making 206 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 7µs/call
# spent 1.26ms making 206 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 6µs/call
# spent 1.26ms making 206 calls to Class::MOP::Class::instance_metaclass, avg 6µs/call
# spent 1.07ms making 206 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call
# spent 217µs making 43 calls to Class::MOP::Class::constructor_class, avg 5µs/call
# spent 206µs making 43 calls to Class::MOP::Class::destructor_class, avg 5µs/call | ||
| 351 | |||||
| 352 | 1399 | 9.29ms | return unless $super_meta->can($metaclass_type); # spent 9.29ms making 1399 calls to UNIVERSAL::can, avg 7µs/call | ||
| 353 | 1370 | 10.2ms | my $super_specific_meta = $super_meta->$metaclass_type; # spent 1.71ms making 134 calls to Moose::Meta::Class::error_class, avg 13µs/call
# spent 1.65ms making 134 calls to Moose::Meta::Class::destructor_class, avg 12µs/call
# spent 1.64ms making 134 calls to Moose::Meta::Class::constructor_class, avg 12µs/call
# spent 1.14ms making 206 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 6µs/call
# spent 1.11ms making 206 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call
# spent 1.09ms making 206 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call
# spent 1.08ms making 206 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call
# spent 377µs making 72 calls to Class::MOP::Class::constructor_class, avg 5µs/call
# spent 372µs making 72 calls to Class::MOP::Class::destructor_class, avg 5µs/call | ||
| 354 | |||||
| 355 | # for instance, Moose::Meta::Class has a destructor_class, but | ||||
| 356 | # Class::MOP::Class doesn't - this shouldn't be an error | ||||
| 357 | return unless defined $super_specific_meta; | ||||
| 358 | |||||
| 359 | # if metaclass is defined in superclass but not here, it's fixable | ||||
| 360 | # this is a really odd case | ||||
| 361 | return 1 unless defined $specific_meta; | ||||
| 362 | |||||
| 363 | 1298 | 72.7ms | return 1 if $specific_meta->_can_be_made_compatible_with($super_specific_meta); # spent 72.7ms making 1298 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 56µs/call | ||
| 364 | } | ||||
| 365 | |||||
| 366 | sub _fix_class_metaclass_incompatibility { | ||||
| 367 | my $self = shift; | ||||
| 368 | my ( $super_meta ) = @_; | ||||
| 369 | |||||
| 370 | if ($self->_class_metaclass_can_be_made_compatible($super_meta)) { | ||||
| 371 | ($self->is_pristine) | ||||
| 372 | || confess "Can't fix metaclass incompatibility for " | ||||
| 373 | . $self->name | ||||
| 374 | . " because it is not pristine."; | ||||
| 375 | |||||
| 376 | my $super_meta_name = $super_meta->_real_ref_name; | ||||
| 377 | |||||
| 378 | $self->_make_compatible_with($super_meta_name); | ||||
| 379 | } | ||||
| 380 | } | ||||
| 381 | |||||
| 382 | sub _fix_single_metaclass_incompatibility { | ||||
| 383 | my $self = shift; | ||||
| 384 | my ( $metaclass_type, $super_meta ) = @_; | ||||
| 385 | |||||
| 386 | if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) { | ||||
| 387 | ($self->is_pristine) | ||||
| 388 | || confess "Can't fix metaclass incompatibility for " | ||||
| 389 | . $self->name | ||||
| 390 | . " because it is not pristine."; | ||||
| 391 | |||||
| 392 | my $new_metaclass = $self->$metaclass_type | ||||
| 393 | ? $self->$metaclass_type->_get_compatible_metaclass($super_meta->$metaclass_type) | ||||
| 394 | : $super_meta->$metaclass_type; | ||||
| 395 | $self->{$metaclass_type} = $new_metaclass; | ||||
| 396 | } | ||||
| 397 | } | ||||
| 398 | |||||
| 399 | # spent 177ms (1.81+175) within Class::MOP::Class::_restore_metaobjects_from which was called 42 times, avg 4.22ms/call:
# 42 times (1.81ms+175ms) by Class::MOP::Class::reinitialize at line 63, avg 4.22ms/call | ||||
| 400 | 168 | 1.74ms | my $self = shift; | ||
| 401 | my ($old_meta) = @_; | ||||
| 402 | |||||
| 403 | 42 | 172ms | $self->_restore_metamethods_from($old_meta); # spent 172ms making 42 calls to Class::MOP::Mixin::HasMethods::_restore_metamethods_from, avg 4.10ms/call | ||
| 404 | 42 | 3.33ms | $self->_restore_metaattributes_from($old_meta); # spent 3.33ms making 42 calls to Class::MOP::Mixin::HasAttributes::_restore_metaattributes_from, avg 79µs/call | ||
| 405 | } | ||||
| 406 | |||||
| 407 | # spent 2.65ms (1.25+1.40) within Class::MOP::Class::_remove_generated_metaobjects which was called 42 times, avg 63µs/call:
# 42 times (1.25ms+1.40ms) by Class::MOP::Class::reinitialize at line 60, avg 63µs/call | ||||
| 408 | 84 | 1.20ms | my $self = shift; | ||
| 409 | |||||
| 410 | 42 | 1.40ms | for my $attr (map { $self->get_attribute($_) } $self->get_attribute_list) { # spent 1.40ms making 42 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 33µs/call | ||
| 411 | $attr->remove_accessors; | ||||
| 412 | } | ||||
| 413 | } | ||||
| 414 | |||||
| 415 | ## ANON classes | ||||
| 416 | |||||
| 417 | { | ||||
| 418 | # NOTE: | ||||
| 419 | # this should be sufficient, if you have a | ||||
| 420 | # use case where it is not, write a test and | ||||
| 421 | # I will change it. | ||||
| 422 | 2 | 6µs | my $ANON_CLASS_SERIAL = 0; | ||
| 423 | |||||
| 424 | # NOTE: | ||||
| 425 | # we need a sufficiently annoying prefix | ||||
| 426 | # this should suffice for now, this is | ||||
| 427 | # used in a couple of places below, so | ||||
| 428 | # need to put it up here for now. | ||||
| 429 | 1 | 3µs | my $ANON_CLASS_PREFIX = 'Class::MOP::Class::__ANON__::SERIAL::'; | ||
| 430 | |||||
| 431 | # spent 1.81ms (1.40+414µs) within Class::MOP::Class::is_anon_class which was called 42 times, avg 43µs/call:
# 42 times (1.40ms+414µs) by Moose::Meta::Class::reinitialize at line 153 of Moose/Meta/Class.pm, avg 43µs/call | ||||
| 432 | 84 | 1.85ms | my $self = shift; | ||
| 433 | 3 | 478µs | 2 | 241µs | # spent 164µs (88+77) within Class::MOP::Class::BEGIN@433 which was called:
# once (88µs+77µs) by Class::MOP::BEGIN@19 at line 433 # spent 164µs making 1 call to Class::MOP::Class::BEGIN@433
# spent 76µs making 1 call to warnings::unimport |
| 434 | 85 | 414µs | $self->name =~ /^$ANON_CLASS_PREFIX/o; # spent 209µs making 42 calls to Class::MOP::Package::name, avg 5µs/call
# spent 170µs making 42 calls to Class::MOP::Class::CORE:match, avg 4µs/call
# spent 34µs making 1 call to Class::MOP::Class::CORE:regcomp | ||
| 435 | } | ||||
| 436 | |||||
| 437 | # spent 995ms (1.01+994) within Class::MOP::Class::create_anon_class which was called 22 times, avg 45.2ms/call:
# 22 times (1.01ms+994ms) by Moose::Meta::Class::create_anon_class at line 111 of Moose/Meta/Class.pm, avg 45.2ms/call | ||||
| 438 | 88 | 969µs | my ($class, %options) = @_; | ||
| 439 | $options{weaken} = 1 unless exists $options{weaken}; | ||||
| 440 | my $package_name = $ANON_CLASS_PREFIX . ++$ANON_CLASS_SERIAL; | ||||
| 441 | 22 | 994ms | return $class->create($package_name, %options); # spent 994ms making 22 calls to Moose::Meta::Class::create, avg 45.2ms/call | ||
| 442 | } | ||||
| 443 | |||||
| 444 | # NOTE: | ||||
| 445 | # this will only get called for | ||||
| 446 | # anon-classes, all other calls | ||||
| 447 | # are assumed to occur during | ||||
| 448 | # global destruction and so don't | ||||
| 449 | # really need to be handled explicitly | ||||
| 450 | # spent 2.75ms (2.03+713µs) within Class::MOP::Class::DESTROY which was called 42 times, avg 65µs/call:
# 42 times (2.03ms+713µs) by Moose::Util::MetaRole::apply_metaroles at line 627 of Moose/Exporter.pm, avg 65µs/call | ||||
| 451 | 168 | 3.51ms | my $self = shift; | ||
| 452 | |||||
| 453 | 42 | 329µs | return if in_global_destruction(); # it'll happen soon anyway and this just makes things more complicated # spent 329µs making 42 calls to Devel::GlobalDestruction::in_global_destruction, avg 8µs/call | ||
| 454 | |||||
| 455 | 3 | 268µs | 2 | 164µs | # spent 103µs (43+60) within Class::MOP::Class::BEGIN@455 which was called:
# once (43µs+60µs) by Class::MOP::BEGIN@19 at line 455 # spent 103µs making 1 call to Class::MOP::Class::BEGIN@455
# spent 60µs making 1 call to warnings::unimport |
| 456 | 42 | 229µs | my $name = $self->name; # spent 229µs making 42 calls to Class::MOP::Package::name, avg 5µs/call | ||
| 457 | 43 | 156µs | return unless $name =~ /^$ANON_CLASS_PREFIX/o; # spent 121µs making 42 calls to Class::MOP::Class::CORE:match, avg 3µs/call
# spent 35µs making 1 call to Class::MOP::Class::CORE:regcomp | ||
| 458 | |||||
| 459 | # Moose does a weird thing where it replaces the metaclass for | ||||
| 460 | # class when fixing metaclass incompatibility. In that case, | ||||
| 461 | # we don't want to clean out the namespace now. We can detect | ||||
| 462 | # that because Moose will explicitly update the singleton | ||||
| 463 | # cache in Class::MOP. | ||||
| 464 | my $current_meta = Class::MOP::get_metaclass_by_name($name); | ||||
| 465 | return if $current_meta ne $self; | ||||
| 466 | |||||
| 467 | my ($serial_id) = ($name =~ /^$ANON_CLASS_PREFIX(\d+)/o); | ||||
| 468 | 3 | 16.5ms | 2 | 183µs | # spent 118µs (52+65) within Class::MOP::Class::BEGIN@468 which was called:
# once (52µs+65µs) by Class::MOP::BEGIN@19 at line 468 # spent 118µs making 1 call to Class::MOP::Class::BEGIN@468
# spent 66µs making 1 call to strict::unimport |
| 469 | @{$name . '::ISA'} = (); | ||||
| 470 | %{$name . '::'} = (); | ||||
| 471 | delete ${$ANON_CLASS_PREFIX}{$serial_id . '::'}; | ||||
| 472 | |||||
| 473 | Class::MOP::remove_metaclass_by_name($name); | ||||
| 474 | } | ||||
| 475 | |||||
| 476 | } | ||||
| 477 | |||||
| 478 | # creating classes with MOP ... | ||||
| 479 | |||||
| 480 | # spent 329ms (4.25+325) within Class::MOP::Class::create which was called 25 times, avg 13.2ms/call:
# 23 times (3.91ms+314ms) by Moose::Meta::Class::create at line 85 of Moose/Meta/Class.pm, avg 13.8ms/call
# 2 times (344µs+10.5ms) by Class::MOP::Class::_immutable_metaclass at line 1387, avg 5.43ms/call | ||||
| 481 | 425 | 4.05ms | my ( $class, @args ) = @_; | ||
| 482 | |||||
| 483 | unshift @args, 'package' if @args % 2 == 1; | ||||
| 484 | |||||
| 485 | my (%options) = @args; | ||||
| 486 | my $package_name = $options{package}; | ||||
| 487 | |||||
| 488 | (ref $options{superclasses} eq 'ARRAY') | ||||
| 489 | || confess "You must pass an ARRAY ref of superclasses" | ||||
| 490 | if exists $options{superclasses}; | ||||
| 491 | |||||
| 492 | (ref $options{attributes} eq 'ARRAY') | ||||
| 493 | || confess "You must pass an ARRAY ref of attributes" | ||||
| 494 | if exists $options{attributes}; | ||||
| 495 | |||||
| 496 | (ref $options{methods} eq 'HASH') | ||||
| 497 | || confess "You must pass a HASH ref of methods" | ||||
| 498 | if exists $options{methods}; | ||||
| 499 | |||||
| 500 | $options{meta_name} = 'meta' | ||||
| 501 | unless exists $options{meta_name}; | ||||
| 502 | |||||
| 503 | my (%initialize_options) = @args; | ||||
| 504 | delete @initialize_options{qw( | ||||
| 505 | package | ||||
| 506 | superclasses | ||||
| 507 | attributes | ||||
| 508 | methods | ||||
| 509 | meta_name | ||||
| 510 | version | ||||
| 511 | authority | ||||
| 512 | )}; | ||||
| 513 | 25 | 93.7ms | my $meta = $class->initialize( $package_name => %initialize_options ); # spent 92.7ms making 23 calls to Moose::Meta::Class::initialize, avg 4.03ms/call
# spent 962µs making 2 calls to Class::MOP::Class::initialize, avg 481µs/call | ||
| 514 | |||||
| 515 | 25 | 3.06ms | $meta->_instantiate_module( $options{version}, $options{authority} ); # spent 3.06ms making 25 calls to Class::MOP::Module::_instantiate_module, avg 122µs/call | ||
| 516 | |||||
| 517 | 25 | 67.6ms | $meta->_add_meta_method($options{meta_name}) # spent 67.6ms making 25 calls to Class::MOP::Mixin::HasMethods::_add_meta_method, avg 2.70ms/call | ||
| 518 | if defined $options{meta_name}; | ||||
| 519 | |||||
| 520 | 25 | 160ms | $meta->superclasses(@{$options{superclasses}}) # spent 156ms making 23 calls to Moose::Meta::Class::superclasses, avg 6.78ms/call
# spent 4.43ms making 2 calls to Class::MOP::Class::superclasses, avg 2.21ms/call | ||
| 521 | if exists $options{superclasses}; | ||||
| 522 | # NOTE: | ||||
| 523 | # process attributes first, so that they can | ||||
| 524 | # install accessors, but locally defined methods | ||||
| 525 | # can then overwrite them. It is maybe a little odd, but | ||||
| 526 | # I think this should be the order of things. | ||||
| 527 | if (exists $options{attributes}) { | ||||
| 528 | foreach my $attr (@{$options{attributes}}) { | ||||
| 529 | $meta->add_attribute($attr); | ||||
| 530 | } | ||||
| 531 | } | ||||
| 532 | if (exists $options{methods}) { | ||||
| 533 | foreach my $method_name (keys %{$options{methods}}) { | ||||
| 534 | $meta->add_method($method_name, $options{methods}->{$method_name}); | ||||
| 535 | } | ||||
| 536 | } | ||||
| 537 | return $meta; | ||||
| 538 | } | ||||
| 539 | |||||
| 540 | # Instance Construction & Cloning | ||||
| 541 | |||||
| 542 | # spent 562ms (13.7+548) within Class::MOP::Class::new_object which was called 279 times, avg 2.01ms/call:
# 150 times (7.19ms+187ms) by Moose::Meta::Method::_new at line 4 of generated method (unknown origin), avg 1.30ms/call
# 101 times (5.08ms+325ms) by Moose::Meta::Class::new_object at line 256 of Moose/Meta/Class.pm, avg 3.27ms/call
# 26 times (1.27ms+31.1ms) by Class::MOP::Method::_new at line 54 of Class/MOP/Method.pm, avg 1.25ms/call
# once (67µs+4.21ms) by Class::MOP::Attribute::_new at line 62 of Class/MOP/Attribute.pm
# once (54µs+1.36ms) by Class::MOP::Object::_new at line 22 of Class/MOP/Object.pm | ||||
| 543 | 837 | 19.7ms | my $class = shift; | ||
| 544 | |||||
| 545 | # NOTE: | ||||
| 546 | # we need to protect the integrity of the | ||||
| 547 | # Class::MOP::Class singletons here, so we | ||||
| 548 | # delegate this to &construct_class_instance | ||||
| 549 | # which will deal with the singletons | ||||
| 550 | 558 | 5.96ms | return $class->_construct_class_instance(@_) # spent 4.32ms making 279 calls to UNIVERSAL::isa, avg 15µs/call
# spent 1.64ms making 279 calls to Class::MOP::Package::name, avg 6µs/call | ||
| 551 | if $class->name->isa('Class::MOP::Class'); | ||||
| 552 | 279 | 543ms | return $class->_construct_instance(@_); # spent 543ms making 279 calls to Class::MOP::Class::_construct_instance, avg 1.94ms/call | ||
| 553 | } | ||||
| 554 | |||||
| 555 | # spent 938ms (113+825) within Class::MOP::Class::_construct_instance which was called 390 times, avg 2.41ms/call:
# 279 times (69.6ms+473ms) by Class::MOP::Class::new_object at line 552, avg 1.94ms/call
# 111 times (43.7ms+352ms) by Class::MOP::Class::_construct_class_instance at line 105, avg 3.57ms/call | ||||
| 556 | 7924 | 109ms | my $class = shift; | ||
| 557 | my $params = @_ == 1 ? $_[0] : {@_}; | ||||
| 558 | 390 | 23.5ms | my $meta_instance = $class->get_meta_instance(); # spent 15.0ms making 254 calls to Class::MOP::Class::get_meta_instance, avg 59µs/call
# spent 5.70ms making 92 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 62µs/call
# spent 2.80ms making 44 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::get_meta_instance, avg 64µs/call | ||
| 559 | # FIXME: | ||||
| 560 | # the code below is almost certainly incorrect | ||||
| 561 | # but this is foreign inheritance, so we might | ||||
| 562 | # have to kludge it in the end. | ||||
| 563 | my $instance; | ||||
| 564 | 390 | 2.83ms | if (my $instance_class = blessed($params->{__INSTANCE__})) { # spent 2.83ms making 390 calls to Scalar::Util::blessed, avg 7µs/call | ||
| 565 | ($instance_class eq $class->name) | ||||
| 566 | || confess "Objects passed as the __INSTANCE__ parameter must " | ||||
| 567 | . "already be blessed into the correct class, but " | ||||
| 568 | . "$params->{__INSTANCE__} is not a " . $class->name; | ||||
| 569 | $instance = $params->{__INSTANCE__}; | ||||
| 570 | } | ||||
| 571 | elsif (exists $params->{__INSTANCE__}) { | ||||
| 572 | confess "The __INSTANCE__ parameter must be a blessed reference, not " | ||||
| 573 | . $params->{__INSTANCE__}; | ||||
| 574 | } | ||||
| 575 | else { | ||||
| 576 | 390 | 22.7ms | $instance = $meta_instance->create_instance(); # spent 22.7ms making 390 calls to Class::MOP::Instance::create_instance, avg 58µs/call | ||
| 577 | } | ||||
| 578 | 390 | 141ms | foreach my $attr ($class->get_all_attributes()) { # spent 130ms making 254 calls to Class::MOP::Class::get_all_attributes, avg 511µs/call
# spent 6.91ms making 92 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 75µs/call
# spent 4.52ms making 44 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::get_all_attributes, avg 103µs/call | ||
| 579 | 4414 | 621ms | $attr->initialize_instance_slot($meta_instance, $instance, $params); # spent 555ms making 4304 calls to Class::MOP::Attribute::initialize_instance_slot, avg 129µs/call
# spent 65.8ms making 110 calls to Moose::Meta::Attribute::initialize_instance_slot, avg 598µs/call | ||
| 580 | } | ||||
| 581 | 822 | 14.1ms | if (Class::MOP::metaclass_is_weak($class->name)) { # spent 9.97ms making 390 calls to Class::MOP::metaclass_is_weak, avg 26µs/call
# spent 2.36ms making 390 calls to Class::MOP::Package::name, avg 6µs/call
# spent 1.81ms making 42 calls to Class::MOP::Instance::_set_mop_slot, avg 43µs/call | ||
| 582 | $meta_instance->_set_mop_slot($instance, $class); | ||||
| 583 | } | ||||
| 584 | return $instance; | ||||
| 585 | } | ||||
| 586 | |||||
| 587 | # spent 491ms (6.52+485) within Class::MOP::Class::_inline_new_object which was called 73 times, avg 6.73ms/call:
# 73 times (6.52ms+485ms) by Class::MOP::Method::Constructor::_generate_constructor_method_inline at line 112 of Class/MOP/Method/Constructor.pm, avg 6.73ms/call | ||||
| 588 | 146 | 5.86ms | my $self = shift; | ||
| 589 | |||||
| 590 | return ( | ||||
| 591 | 438 | 485ms | 'my $class = shift;', # spent 323ms making 73 calls to Class::MOP::Class::_inline_slot_initializers, avg 4.42ms/call
# spent 86.6ms making 42 calls to Moose::Meta::Class::_inline_extra_init, avg 2.06ms/call
# spent 37.9ms making 42 calls to Moose::Meta::Class::_inline_params, avg 902µs/call
# spent 26.5ms making 73 calls to Class::MOP::Class::_inline_generate_instance, avg 363µs/call
# spent 4.98ms making 73 calls to Class::MOP::Class::_inline_preserve_weak_metaclasses, avg 68µs/call
# spent 4.93ms making 73 calls to Class::MOP::Class::_inline_fallback_constructor, avg 68µs/call
# spent 561µs making 31 calls to Class::MOP::Class::_inline_params, avg 18µs/call
# spent 233µs making 31 calls to Class::MOP::Class::_inline_extra_init, avg 8µs/call | ||
| 592 | '$class = Scalar::Util::blessed($class) || $class;', | ||||
| 593 | $self->_inline_fallback_constructor('$class'), | ||||
| 594 | $self->_inline_params('$params', '$class'), | ||||
| 595 | $self->_inline_generate_instance('$instance', '$class'), | ||||
| 596 | $self->_inline_slot_initializers, | ||||
| 597 | $self->_inline_preserve_weak_metaclasses, | ||||
| 598 | $self->_inline_extra_init, | ||||
| 599 | 'return $instance', | ||||
| 600 | ); | ||||
| 601 | } | ||||
| 602 | |||||
| 603 | # spent 4.93ms (3.18+1.75) within Class::MOP::Class::_inline_fallback_constructor which was called 73 times, avg 68µs/call:
# 73 times (3.18ms+1.75ms) by Class::MOP::Class::_inline_new_object at line 591, avg 68µs/call | ||||
| 604 | 219 | 3.43ms | my $self = shift; | ||
| 605 | my ($class) = @_; | ||||
| 606 | return ( | ||||
| 607 | 146 | 1.75ms | 'return ' . $self->_generate_fallback_constructor($class), # spent 807µs making 42 calls to Moose::Meta::Class::_generate_fallback_constructor, avg 19µs/call
# spent 553µs making 31 calls to Class::MOP::Class::_generate_fallback_constructor, avg 18µs/call
# spent 391µs making 73 calls to Class::MOP::Package::name, avg 5µs/call | ||
| 608 | 'if ' . $class . ' ne \'' . $self->name . '\';', | ||||
| 609 | ); | ||||
| 610 | } | ||||
| 611 | |||||
| 612 | # spent 553µs within Class::MOP::Class::_generate_fallback_constructor which was called 31 times, avg 18µs/call:
# 31 times (553µs+0s) by Class::MOP::Class::_inline_fallback_constructor at line 607, avg 18µs/call | ||||
| 613 | 93 | 717µs | my $self = shift; | ||
| 614 | my ($class) = @_; | ||||
| 615 | return 'Class::MOP::Class->initialize(' . $class . ')->new_object(@_)', | ||||
| 616 | } | ||||
| 617 | |||||
| 618 | # spent 561µs within Class::MOP::Class::_inline_params which was called 31 times, avg 18µs/call:
# 31 times (561µs+0s) by Class::MOP::Class::_inline_new_object at line 591, avg 18µs/call | ||||
| 619 | 93 | 650µs | my $self = shift; | ||
| 620 | my ($params, $class) = @_; | ||||
| 621 | return ( | ||||
| 622 | 'my ' . $params . ' = @_ == 1 ? $_[0] : {@_};', | ||||
| 623 | ); | ||||
| 624 | } | ||||
| 625 | |||||
| 626 | # spent 26.5ms (2.29+24.2) within Class::MOP::Class::_inline_generate_instance which was called 73 times, avg 363µs/call:
# 73 times (2.29ms+24.2ms) by Class::MOP::Class::_inline_new_object at line 591, avg 363µs/call | ||||
| 627 | 219 | 2.15ms | my $self = shift; | ||
| 628 | my ($inst, $class) = @_; | ||||
| 629 | return ( | ||||
| 630 | 73 | 24.2ms | 'my ' . $inst . ' = ' . $self->_inline_create_instance($class) . ';', # spent 24.2ms making 73 calls to Class::MOP::Class::_inline_create_instance, avg 331µs/call | ||
| 631 | ); | ||||
| 632 | } | ||||
| 633 | |||||
| 634 | # spent 24.2ms (2.83+21.4) within Class::MOP::Class::_inline_create_instance which was called 73 times, avg 331µs/call:
# 73 times (2.83ms+21.4ms) by Class::MOP::Class::_inline_generate_instance at line 630, avg 331µs/call | ||||
| 635 | 146 | 2.50ms | my $self = shift; | ||
| 636 | |||||
| 637 | 146 | 21.4ms | return $self->get_meta_instance->inline_create_instance(@_); # spent 20.3ms making 73 calls to Class::MOP::Class::get_meta_instance, avg 277µs/call
# spent 1.10ms making 73 calls to Class::MOP::Instance::inline_create_instance, avg 15µs/call | ||
| 638 | } | ||||
| 639 | |||||
| 640 | # spent 323ms (9.45+314) within Class::MOP::Class::_inline_slot_initializers which was called 73 times, avg 4.42ms/call:
# 73 times (9.45ms+314ms) by Class::MOP::Class::_inline_new_object at line 591, avg 4.42ms/call | ||||
| 641 | 1608 | 35.9ms | my $self = shift; | ||
| 642 | |||||
| 643 | my $idx = 0; | ||||
| 644 | |||||
| 645 | 2379 | 268ms | return map { $self->_inline_slot_initializer($_, $idx++) } # spent 142ms making 267 calls to Class::MOP::Class::_inline_slot_initializer, avg 532µs/call
# spent 118ms making 132 calls to Moose::Meta::Class::_inline_slot_initializer, avg 893µs/call
# spent 8.56ms making 1980 calls to Class::MOP::Mixin::AttributeCore::name, avg 4µs/call | ||
| 646 | 146 | 53.7ms | sort { $a->name cmp $b->name } $self->get_all_attributes; # spent 27.3ms making 73 calls to Class::MOP::Class::CORE:sort, avg 374µs/call
# spent 26.3ms making 73 calls to Class::MOP::Class::get_all_attributes, avg 361µs/call | ||
| 647 | } | ||||
| 648 | |||||
| 649 | # spent 239ms (27.5+212) within Class::MOP::Class::_inline_slot_initializer which was called 399 times, avg 599µs/call:
# 267 times (17.5ms+125ms) by Class::MOP::Class::_inline_slot_initializers at line 645, avg 532µs/call
# 132 times (10.1ms+87.0ms) by Moose::Meta::Class::_inline_slot_initializer at line 344 of Moose/Meta/Class.pm, avg 735µs/call | ||||
| 650 | 2310 | 28.9ms | my $self = shift; | ||
| 651 | my ($attr, $idx) = @_; | ||||
| 652 | |||||
| 653 | 428 | 16.7ms | if (defined(my $init_arg = $attr->init_arg)) { # spent 9.65ms making 18 calls to Moose::Meta::Class::_inline_init_attr_from_default, avg 536µs/call
# spent 4.90ms making 11 calls to Class::MOP::Class::_inline_init_attr_from_default, avg 446µs/call
# spent 2.19ms making 399 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 5µs/call | ||
| 654 | 370 | 130ms | my @source = ( # spent 80.1ms making 256 calls to Class::MOP::Class::_inline_init_attr_from_constructor, avg 313µs/call
# spent 49.8ms making 114 calls to Moose::Meta::Class::_inline_init_attr_from_constructor, avg 437µs/call | ||
| 655 | 'if (exists $params->{\'' . $init_arg . '\'}) {', | ||||
| 656 | $self->_inline_init_attr_from_constructor($attr, $idx), | ||||
| 657 | '}', | ||||
| 658 | ); | ||||
| 659 | 370 | 64.9ms | if (my @default = $self->_inline_init_attr_from_default($attr, $idx)) { # spent 38.0ms making 256 calls to Class::MOP::Class::_inline_init_attr_from_default, avg 148µs/call
# spent 26.9ms making 114 calls to Moose::Meta::Class::_inline_init_attr_from_default, avg 236µs/call | ||
| 660 | push @source, ( | ||||
| 661 | 'else {', | ||||
| 662 | @default, | ||||
| 663 | '}', | ||||
| 664 | ); | ||||
| 665 | } | ||||
| 666 | return @source; | ||||
| 667 | } | ||||
| 668 | elsif (my @default = $self->_inline_init_attr_from_default($attr, $idx)) { | ||||
| 669 | return ( | ||||
| 670 | '{', | ||||
| 671 | @default, | ||||
| 672 | '}', | ||||
| 673 | ); | ||||
| 674 | } | ||||
| 675 | else { | ||||
| 676 | return (); | ||||
| 677 | } | ||||
| 678 | } | ||||
| 679 | |||||
| 680 | # spent 80.1ms (14.6+65.5) within Class::MOP::Class::_inline_init_attr_from_constructor which was called 256 times, avg 313µs/call:
# 256 times (14.6ms+65.5ms) by Class::MOP::Class::_inline_slot_initializer at line 654, avg 313µs/call | ||||
| 681 | 1280 | 14.6ms | my $self = shift; | ||
| 682 | my ($attr, $idx) = @_; | ||||
| 683 | |||||
| 684 | 512 | 62.8ms | my @initial_value = $attr->_inline_set_value( # spent 56.1ms making 254 calls to Class::MOP::Attribute::_inline_set_value, avg 221µs/call
# spent 5.55ms making 2 calls to Moose::Meta::Attribute::_inline_set_value, avg 2.78ms/call
# spent 1.17ms making 256 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 5µs/call | ||
| 685 | '$instance', '$params->{\'' . $attr->init_arg . '\'}', | ||||
| 686 | ); | ||||
| 687 | |||||
| 688 | 256 | 2.67ms | push @initial_value, ( # spent 2.67ms making 256 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 10µs/call | ||
| 689 | '$attrs->[' . $idx . ']->set_initial_value(', | ||||
| 690 | '$instance,', | ||||
| 691 | $attr->_inline_instance_get('$instance'), | ||||
| 692 | ');', | ||||
| 693 | ) if $attr->has_initializer; | ||||
| 694 | |||||
| 695 | return @initial_value; | ||||
| 696 | } | ||||
| 697 | |||||
| 698 | # spent 42.9ms (10.2+32.7) within Class::MOP::Class::_inline_init_attr_from_default which was called 267 times, avg 161µs/call:
# 256 times (9.55ms+28.4ms) by Class::MOP::Class::_inline_slot_initializer at line 659, avg 148µs/call
# 11 times (675µs+4.23ms) by Class::MOP::Class::_inline_slot_initializer at line 653, avg 446µs/call | ||||
| 699 | 1335 | 9.34ms | my $self = shift; | ||
| 700 | my ($attr, $idx) = @_; | ||||
| 701 | |||||
| 702 | 267 | 15.7ms | my $default = $self->_inline_default_value($attr, $idx); # spent 15.7ms making 267 calls to Class::MOP::Class::_inline_default_value, avg 59µs/call | ||
| 703 | return unless $default; | ||||
| 704 | |||||
| 705 | 89 | 16.1ms | my @initial_value = $attr->_inline_set_value('$instance', $default); # spent 16.1ms making 89 calls to Class::MOP::Attribute::_inline_set_value, avg 180µs/call | ||
| 706 | |||||
| 707 | 89 | 870µs | push @initial_value, ( # spent 870µs making 89 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 10µs/call | ||
| 708 | '$attrs->[' . $idx . ']->set_initial_value(', | ||||
| 709 | '$instance,', | ||||
| 710 | $attr->_inline_instance_get('$instance'), | ||||
| 711 | ');', | ||||
| 712 | ) if $attr->has_initializer; | ||||
| 713 | |||||
| 714 | return @initial_value; | ||||
| 715 | } | ||||
| 716 | |||||
| 717 | # spent 25.0ms (16.2+8.87) within Class::MOP::Class::_inline_default_value which was called 399 times, avg 63µs/call:
# 267 times (10.1ms+5.64ms) by Class::MOP::Class::_inline_init_attr_from_default at line 702, avg 59µs/call
# 132 times (6.07ms+3.23ms) by Moose::Meta::Class::_inline_init_attr_from_default at line 396 of Moose/Meta/Class.pm, avg 70µs/call | ||||
| 718 | 1502 | 14.6ms | my $self = shift; | ||
| 719 | my ($attr, $index) = @_; | ||||
| 720 | |||||
| 721 | 802 | 8.87ms | if ($attr->has_default) { # spent 3.69ms making 399 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 9µs/call
# spent 2.64ms making 151 calls to Class::MOP::Mixin::AttributeCore::is_default_a_coderef, avg 17µs/call
# spent 2.51ms making 248 calls to Class::MOP::Mixin::AttributeCore::has_builder, avg 10µs/call
# spent 22µs making 4 calls to Class::MOP::Mixin::AttributeCore::builder, avg 6µs/call | ||
| 722 | # NOTE: | ||||
| 723 | # default values can either be CODE refs | ||||
| 724 | # in which case we need to call them. Or | ||||
| 725 | # they can be scalars (strings/numbers) | ||||
| 726 | # in which case we can just deal with them | ||||
| 727 | # in the code we eval. | ||||
| 728 | if ($attr->is_default_a_coderef) { | ||||
| 729 | return '$defaults->[' . $index . ']->($instance)'; | ||||
| 730 | } | ||||
| 731 | else { | ||||
| 732 | return '$defaults->[' . $index . ']'; | ||||
| 733 | } | ||||
| 734 | } | ||||
| 735 | elsif ($attr->has_builder) { | ||||
| 736 | return '$instance->' . $attr->builder; | ||||
| 737 | } | ||||
| 738 | else { | ||||
| 739 | return; | ||||
| 740 | } | ||||
| 741 | } | ||||
| 742 | |||||
| 743 | # spent 4.98ms (2.58+2.40) within Class::MOP::Class::_inline_preserve_weak_metaclasses which was called 73 times, avg 68µs/call:
# 73 times (2.58ms+2.40ms) by Class::MOP::Class::_inline_new_object at line 591, avg 68µs/call | ||||
| 744 | 219 | 3.01ms | my $self = shift; | ||
| 745 | 146 | 2.40ms | if (Class::MOP::metaclass_is_weak($self->name)) { # spent 1.97ms making 73 calls to Class::MOP::metaclass_is_weak, avg 27µs/call
# spent 429µs making 73 calls to Class::MOP::Package::name, avg 6µs/call | ||
| 746 | return ( | ||||
| 747 | $self->_inline_set_mop_slot( | ||||
| 748 | '$instance', 'Class::MOP::class_of($class)' | ||||
| 749 | ) . ';' | ||||
| 750 | ); | ||||
| 751 | } | ||||
| 752 | else { | ||||
| 753 | return (); | ||||
| 754 | } | ||||
| 755 | } | ||||
| 756 | |||||
| 757 | 31 | 301µs | # spent 233µs within Class::MOP::Class::_inline_extra_init which was called 31 times, avg 8µs/call:
# 31 times (233µs+0s) by Class::MOP::Class::_inline_new_object at line 591, avg 8µs/call | ||
| 758 | |||||
| 759 | |||||
| 760 | # spent 148ms (11.9+136) within Class::MOP::Class::get_meta_instance which was called 784 times, avg 188µs/call:
# 254 times (3.58ms+11.4ms) by Class::MOP::Class::_construct_instance at line 558, avg 59µs/call
# 229 times (3.13ms+26.4ms) by Class::MOP::Attribute::_inline_instance_set at line 285 of Class/MOP/Attribute.pm, avg 129µs/call
# 155 times (2.86ms+65.8ms) by Class::MOP::Attribute::_inline_instance_get at line 308 of Class/MOP/Attribute.pm, avg 443µs/call
# 73 times (1.29ms+19.0ms) by Class::MOP::Class::_inline_create_instance at line 637, avg 277µs/call
# 31 times (399µs+0s) by Class::MOP::Attribute::_inline_instance_has at line 329 of Class/MOP/Attribute.pm, avg 13µs/call
# 24 times (450µs+12.5ms) by Class::MOP::Class:::around at line 74 of Class/MOP/Class/Immutable/Trait.pm, avg 540µs/call
# 12 times (158µs+0s) by Class::MOP::Attribute::set_initial_value at line 259 of Class/MOP/Attribute.pm, avg 13µs/call
# 3 times (37µs+0s) by Class::MOP::Attribute::get_raw_value at line 295 of Class/MOP/Attribute.pm, avg 12µs/call
# once (24µs+714µs) by MooseX::Types::Combine::BEGIN@12 at line 684 of Class/MOP.pm
# once (14µs+0s) by Class::MOP::Attribute::has_value at line 316 of Class/MOP/Attribute.pm
# once (12µs+0s) by Moose::Meta::Attribute::_inline_weaken_value at line 676 of Moose/Meta/Attribute.pm | ||||
| 761 | 1568 | 14.3ms | my $self = shift; | ||
| 762 | 138 | 136ms | $self->{'_meta_instance'} ||= $self->_create_meta_instance(); # spent 136ms making 138 calls to Class::MOP::Class::_create_meta_instance, avg 984µs/call | ||
| 763 | } | ||||
| 764 | |||||
| 765 | # spent 136ms (9.75+126) within Class::MOP::Class::_create_meta_instance which was called 138 times, avg 984µs/call:
# 138 times (9.75ms+126ms) by Class::MOP::Class::get_meta_instance at line 762, avg 984µs/call | ||||
| 766 | 552 | 9.79ms | my $self = shift; | ||
| 767 | |||||
| 768 | 414 | 125ms | my $instance = $self->instance_metaclass->new( # spent 67.0ms making 138 calls to Class::MOP::Instance::new, avg 486µs/call
# spent 51.1ms making 126 calls to Class::MOP::Class::get_all_attributes, avg 406µs/call
# spent 5.89ms making 12 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 491µs/call
# spent 780µs making 138 calls to Class::MOP::Class::instance_metaclass, avg 6µs/call | ||
| 769 | associated_metaclass => $self, | ||||
| 770 | attributes => [ $self->get_all_attributes() ], | ||||
| 771 | ); | ||||
| 772 | |||||
| 773 | 138 | 1.15ms | $self->add_meta_instance_dependencies() # spent 1.15ms making 138 calls to Class::MOP::Instance::is_dependent_on_superclasses, avg 8µs/call | ||
| 774 | if $instance->is_dependent_on_superclasses(); | ||||
| 775 | |||||
| 776 | return $instance; | ||||
| 777 | } | ||||
| 778 | |||||
| 779 | sub _inline_rebless_instance { | ||||
| 780 | my $self = shift; | ||||
| 781 | |||||
| 782 | return $self->get_meta_instance->inline_rebless_instance_structure(@_); | ||||
| 783 | } | ||||
| 784 | |||||
| 785 | sub _inline_get_mop_slot { | ||||
| 786 | my $self = shift; | ||||
| 787 | |||||
| 788 | return $self->get_meta_instance->_inline_get_mop_slot(@_); | ||||
| 789 | } | ||||
| 790 | |||||
| 791 | sub _inline_set_mop_slot { | ||||
| 792 | my $self = shift; | ||||
| 793 | |||||
| 794 | return $self->get_meta_instance->_inline_set_mop_slot(@_); | ||||
| 795 | } | ||||
| 796 | |||||
| 797 | sub _inline_clear_mop_slot { | ||||
| 798 | my $self = shift; | ||||
| 799 | |||||
| 800 | return $self->get_meta_instance->_inline_clear_mop_slot(@_); | ||||
| 801 | } | ||||
| 802 | |||||
| 803 | # spent 1.20ms (99µs+1.10) within Class::MOP::Class::clone_object which was called:
# once (99µs+1.10ms) by Class::MOP::Attribute::clone at line 516 of Class/MOP.pm | ||||
| 804 | 5 | 121µs | my $class = shift; | ||
| 805 | my $instance = shift; | ||||
| 806 | 3 | 17µs | (blessed($instance) && $instance->isa($class->name)) # spent 6µs making 1 call to Scalar::Util::blessed
# spent 6µs making 1 call to Class::MOP::Package::name
# spent 5µs making 1 call to UNIVERSAL::isa | ||
| 807 | || confess "You must pass an instance of the metaclass (" . (ref $class ? $class->name : $class) . "), not ($instance)"; | ||||
| 808 | |||||
| 809 | # NOTE: | ||||
| 810 | # we need to protect the integrity of the | ||||
| 811 | # Class::MOP::Class singletons here, they | ||||
| 812 | # should not be cloned. | ||||
| 813 | 1 | 8µs | return $instance if $instance->isa('Class::MOP::Class'); # spent 8µs making 1 call to UNIVERSAL::isa | ||
| 814 | 1 | 1.07ms | $class->_clone_instance($instance, @_); # spent 1.07ms making 1 call to Class::MOP::Class::_clone_instance | ||
| 815 | } | ||||
| 816 | |||||
| 817 | # spent 1.07ms (343µs+731µs) within Class::MOP::Class::_clone_instance which was called:
# once (343µs+731µs) by Class::MOP::Class::clone_object at line 814 | ||||
| 818 | 20 | 403µs | my ($class, $instance, %params) = @_; | ||
| 819 | 1 | 6µs | (blessed($instance)) # spent 6µs making 1 call to Scalar::Util::blessed | ||
| 820 | || confess "You can only clone instances, ($instance) is not a blessed instance"; | ||||
| 821 | 1 | 92µs | my $meta_instance = $class->get_meta_instance(); # spent 92µs making 1 call to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance | ||
| 822 | 1 | 117µs | my $clone = $meta_instance->clone_instance($instance); # spent 117µs making 1 call to Class::MOP::Instance::clone_instance | ||
| 823 | 1 | 59µs | foreach my $attr ($class->get_all_attributes()) { # spent 59µs making 1 call to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes | ||
| 824 | 16 | 457µs | if ( defined( my $init_arg = $attr->init_arg ) ) { # spent 384µs making 2 calls to Class::MOP::Attribute::set_value, avg 192µs/call
# spent 73µs making 14 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 5µs/call | ||
| 825 | if (exists $params{$init_arg}) { | ||||
| 826 | $attr->set_value($clone, $params{$init_arg}); | ||||
| 827 | } | ||||
| 828 | } | ||||
| 829 | } | ||||
| 830 | return $clone; | ||||
| 831 | } | ||||
| 832 | |||||
| 833 | sub _force_rebless_instance { | ||||
| 834 | my ($self, $instance, %params) = @_; | ||||
| 835 | my $old_metaclass = Class::MOP::class_of($instance); | ||||
| 836 | |||||
| 837 | $old_metaclass->rebless_instance_away($instance, $self, %params) | ||||
| 838 | if $old_metaclass; | ||||
| 839 | |||||
| 840 | my $meta_instance = $self->get_meta_instance; | ||||
| 841 | |||||
| 842 | if (Class::MOP::metaclass_is_weak($old_metaclass->name)) { | ||||
| 843 | $meta_instance->_clear_mop_slot($instance); | ||||
| 844 | } | ||||
| 845 | |||||
| 846 | # rebless! | ||||
| 847 | # we use $_[1] here because of t/306_rebless_overload.t regressions on 5.8.8 | ||||
| 848 | $meta_instance->rebless_instance_structure($_[1], $self); | ||||
| 849 | |||||
| 850 | $self->_fixup_attributes_after_rebless($instance, $old_metaclass, %params); | ||||
| 851 | |||||
| 852 | if (Class::MOP::metaclass_is_weak($self->name)) { | ||||
| 853 | $meta_instance->_set_mop_slot($instance, $self); | ||||
| 854 | } | ||||
| 855 | } | ||||
| 856 | |||||
| 857 | sub rebless_instance { | ||||
| 858 | my ($self, $instance, %params) = @_; | ||||
| 859 | my $old_metaclass = Class::MOP::class_of($instance); | ||||
| 860 | |||||
| 861 | my $old_class = $old_metaclass ? $old_metaclass->name : blessed($instance); | ||||
| 862 | $self->name->isa($old_class) | ||||
| 863 | || confess "You may rebless only into a subclass of ($old_class), of which (". $self->name .") isn't."; | ||||
| 864 | |||||
| 865 | $self->_force_rebless_instance($_[1], %params); | ||||
| 866 | |||||
| 867 | return $instance; | ||||
| 868 | } | ||||
| 869 | |||||
| 870 | sub rebless_instance_back { | ||||
| 871 | my ( $self, $instance ) = @_; | ||||
| 872 | my $old_metaclass = Class::MOP::class_of($instance); | ||||
| 873 | |||||
| 874 | my $old_class | ||||
| 875 | = $old_metaclass ? $old_metaclass->name : blessed($instance); | ||||
| 876 | $old_class->isa( $self->name ) | ||||
| 877 | || confess | ||||
| 878 | "You may rebless only into a superclass of ($old_class), of which (" | ||||
| 879 | . $self->name | ||||
| 880 | . ") isn't."; | ||||
| 881 | |||||
| 882 | $self->_force_rebless_instance($_[1]); | ||||
| 883 | |||||
| 884 | return $instance; | ||||
| 885 | } | ||||
| 886 | |||||
| 887 | sub rebless_instance_away { | ||||
| 888 | # this intentionally does nothing, it is just a hook | ||||
| 889 | } | ||||
| 890 | |||||
| 891 | sub _fixup_attributes_after_rebless { | ||||
| 892 | my $self = shift; | ||||
| 893 | my ($instance, $rebless_from, %params) = @_; | ||||
| 894 | my $meta_instance = $self->get_meta_instance; | ||||
| 895 | |||||
| 896 | for my $attr ( $rebless_from->get_all_attributes ) { | ||||
| 897 | next if $self->find_attribute_by_name( $attr->name ); | ||||
| 898 | $meta_instance->deinitialize_slot( $instance, $_ ) for $attr->slots; | ||||
| 899 | } | ||||
| 900 | |||||
| 901 | foreach my $attr ( $self->get_all_attributes ) { | ||||
| 902 | if ( $attr->has_value($instance) ) { | ||||
| 903 | if ( defined( my $init_arg = $attr->init_arg ) ) { | ||||
| 904 | $params{$init_arg} = $attr->get_value($instance) | ||||
| 905 | unless exists $params{$init_arg}; | ||||
| 906 | } | ||||
| 907 | else { | ||||
| 908 | $attr->set_value($instance, $attr->get_value($instance)); | ||||
| 909 | } | ||||
| 910 | } | ||||
| 911 | } | ||||
| 912 | |||||
| 913 | foreach my $attr ($self->get_all_attributes) { | ||||
| 914 | $attr->initialize_instance_slot($meta_instance, $instance, \%params); | ||||
| 915 | } | ||||
| 916 | } | ||||
| 917 | |||||
| 918 | # spent 16.2ms (4.53+11.6) within Class::MOP::Class::_attach_attribute which was called 188 times, avg 86µs/call:
# 188 times (4.53ms+11.6ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 25 of Class/MOP/Mixin/HasAttributes.pm, avg 86µs/call | ||||
| 919 | 376 | 4.62ms | my ($self, $attribute) = @_; | ||
| 920 | 188 | 11.6ms | $attribute->attach_to_class($self); # spent 11.6ms making 188 calls to Class::MOP::Attribute::attach_to_class, avg 62µs/call | ||
| 921 | } | ||||
| 922 | |||||
| 923 | # spent 2.27s (12.4ms+2.26) within Class::MOP::Class::_post_add_attribute which was called 188 times, avg 12.1ms/call:
# 188 times (12.4ms+2.26s) by Class::MOP::Mixin::HasAttributes::add_attribute at line 42 of Class/MOP/Mixin/HasAttributes.pm, avg 12.1ms/call | ||||
| 924 | 564 | 11.4ms | my ( $self, $attribute ) = @_; | ||
| 925 | |||||
| 926 | 188 | 9.87ms | $self->invalidate_meta_instances; # spent 9.87ms making 188 calls to Class::MOP::Class::invalidate_meta_instances, avg 53µs/call | ||
| 927 | |||||
| 928 | # invalidate package flag here | ||||
| 929 | # spent 2.23s (8.41ms+2.22) within Class::MOP::Class::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Class.pm:932] which was called 188 times, avg 11.9ms/call:
# 188 times (8.41ms+2.22s) by Try::Tiny::try at line 76 of Try/Tiny.pm, avg 11.9ms/call | ||||
| 930 | 376 | 8.28ms | local $SIG{__DIE__}; | ||
| 931 | 188 | 2.22s | $attribute->install_accessors; # spent 471ms making 2 calls to Class::MOP::Class::__ANON__::SERIAL::5::install_accessors, avg 235ms/call
# spent 435ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::15::install_accessors
# spent 433ms making 66 calls to Moose::Meta::Attribute::install_accessors, avg 6.56ms/call
# spent 287ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::19::install_accessors
# spent 218ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::11::install_accessors
# spent 216ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::8::install_accessors
# spent 163ms making 116 calls to Class::MOP::Attribute::install_accessors, avg 1.40ms/call | ||
| 932 | } | ||||
| 933 | catch { | ||||
| 934 | $self->remove_attribute( $attribute->name ); | ||||
| 935 | die $_; | ||||
| 936 | 376 | 2.08s | }; # spent 2.25s making 188 calls to Try::Tiny::try, avg 12.0ms/call, recursion: max depth 1, sum of overlapping time 176ms
# spent 3.97ms making 188 calls to Try::Tiny::catch, avg 21µs/call | ||
| 937 | } | ||||
| 938 | |||||
| 939 | sub remove_attribute { | ||||
| 940 | my $self = shift; | ||||
| 941 | |||||
| 942 | my $removed_attribute = $self->SUPER::remove_attribute(@_) | ||||
| 943 | or return; | ||||
| 944 | |||||
| 945 | $self->invalidate_meta_instances; | ||||
| 946 | |||||
| 947 | $removed_attribute->remove_accessors; | ||||
| 948 | $removed_attribute->detach_from_class; | ||||
| 949 | |||||
| 950 | return$removed_attribute; | ||||
| 951 | } | ||||
| 952 | |||||
| 953 | # spent 32.6ms (9.64+23.0) within Class::MOP::Class::find_attribute_by_name which was called 103 times, avg 317µs/call:
# 94 times (7.56ms+17.9ms) by Class::MOP::Class::_immutable_metaclass at line 1364, avg 271µs/call
# 8 times (1.84ms+4.51ms) by Moose::Util::MetaRole::_make_new_metaclass at line 117 of Moose/Util/MetaRole.pm, avg 794µs/call
# once (239µs+561µs) by Moose::Meta::Class::_process_inherited_attribute at line 627 of Moose/Meta/Class.pm | ||||
| 954 | 598 | 8.54ms | my ( $self, $attr_name ) = @_; | ||
| 955 | |||||
| 956 | 103 | 5.89ms | foreach my $class ( $self->linearized_isa ) { # spent 3.83ms making 61 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 63µs/call
# spent 2.06ms making 42 calls to Class::MOP::Class::linearized_isa, avg 49µs/call | ||
| 957 | # fetch the meta-class ... | ||||
| 958 | 194 | 7.70ms | my $meta = Class::MOP::Class->initialize($class); # spent 7.70ms making 194 calls to Class::MOP::Class::initialize, avg 40µs/call | ||
| 959 | 293 | 9.39ms | return $meta->get_attribute($attr_name) # spent 6.33ms making 194 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 33µs/call
# spent 3.06ms making 99 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 31µs/call | ||
| 960 | if $meta->has_attribute($attr_name); | ||||
| 961 | } | ||||
| 962 | |||||
| 963 | return; | ||||
| 964 | } | ||||
| 965 | |||||
| 966 | # spent 314ms (135+179) within Class::MOP::Class::get_all_attributes which was called 730 times, avg 430µs/call:
# 254 times (56.2ms+73.6ms) by Class::MOP::Class::_construct_instance at line 578, avg 511µs/call
# 126 times (22.2ms+28.9ms) by Class::MOP::Class::_create_meta_instance at line 768, avg 406µs/call
# 73 times (11.1ms+15.3ms) by Class::MOP::Method::Constructor::_attributes at line 79 of Class/MOP/Method/Constructor.pm, avg 361µs/call
# 73 times (11.2ms+15.1ms) by Class::MOP::Class::_inline_slot_initializers at line 646, avg 361µs/call
# 57 times (9.83ms+13.0ms) by Moose::Meta::Class::new_object at line 258 of Moose/Meta/Class.pm, avg 400µs/call
# 42 times (6.32ms+8.53ms) by Moose::Meta::Class::_inline_triggers at line 432 of Moose/Meta/Class.pm, avg 354µs/call
# 37 times (4.85ms+6.56ms) by Class::MOP::Class:::around at line 24 of MooseX/StrictConstructor/Role/Meta/Class.pm, avg 308µs/call
# 34 times (4.62ms+6.28ms) by Markdent::Role::Event::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Markdent/Role/Event.pm:88] at line 43 of Markdent/Role/Event.pm, avg 321µs/call
# 18 times (3.60ms+5.69ms) by Class::MOP::Class:::around at line 68 of Class/MOP/Class/Immutable/Trait.pm, avg 516µs/call
# 16 times (5.34ms+6.00ms) by Moose::Meta::Attribute::new at line 69 of Moose/Meta/Attribute.pm, avg 709µs/call | ||||
| 967 | 8464 | 147ms | my $self = shift; | ||
| 968 | 7004 | 165ms | my %attrs = map { %{ Class::MOP::Class->initialize($_)->_attribute_map } } # spent 126ms making 3137 calls to Class::MOP::Class::initialize, avg 40µs/call, recursion: max depth 1, sum of overlapping time 14.4ms
# spent 33.1ms making 712 calls to Class::MOP::Class::linearized_isa, avg 47µs/call
# spent 18.2ms making 3137 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 6µs/call
# spent 1.69ms making 15 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 113µs/call
# spent 376µs making 3 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::linearized_isa, avg 125µs/call | ||
| 969 | reverse $self->linearized_isa; | ||||
| 970 | return values %attrs; | ||||
| 971 | } | ||||
| 972 | |||||
| 973 | # Inheritance | ||||
| 974 | |||||
| 975 | sub superclasses { | ||||
| 976 | 4222 | 46.2ms | my $self = shift; | ||
| 977 | |||||
| 978 | 889 | 76.0ms | my $isa = $self->get_or_add_package_symbol('@ISA'); # spent 76.0ms making 889 calls to Class::MOP::Package::get_or_add_package_symbol, avg 86µs/call | ||
| 979 | |||||
| 980 | if (@_) { | ||||
| 981 | my @supers = @_; | ||||
| 982 | @{$isa} = @supers; | ||||
| 983 | |||||
| 984 | # NOTE: | ||||
| 985 | # on 5.8 and below, we need to call | ||||
| 986 | # a method to get Perl to detect | ||||
| 987 | # a cycle in the class hierarchy | ||||
| 988 | 111 | 730µs | my $class = $self->name; # spent 730µs making 111 calls to Class::MOP::Package::name, avg 7µs/call | ||
| 989 | 111 | 1.04ms | $class->isa($class); # spent 1.04ms making 111 calls to UNIVERSAL::isa, avg 9µs/call | ||
| 990 | |||||
| 991 | # NOTE: | ||||
| 992 | # we need to check the metaclass | ||||
| 993 | # compatibility here so that we can | ||||
| 994 | # be sure that the superclass is | ||||
| 995 | # not potentially creating an issues | ||||
| 996 | # we don't know about | ||||
| 997 | |||||
| 998 | 111 | 494ms | $self->_check_metaclass_compatibility(); # spent 494ms making 111 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 4.45ms/call | ||
| 999 | 111 | 38.8ms | $self->_superclasses_updated(); # spent 38.8ms making 111 calls to Class::MOP::Class::_superclasses_updated, avg 349µs/call | ||
| 1000 | } | ||||
| 1001 | |||||
| 1002 | return @{$isa}; | ||||
| 1003 | } | ||||
| 1004 | |||||
| 1005 | # spent 38.8ms (8.24+30.5) within Class::MOP::Class::_superclasses_updated which was called 111 times, avg 349µs/call:
# 111 times (8.24ms+30.5ms) by Class::MOP::Class::superclasses at line 999, avg 349µs/call | ||||
| 1006 | 456 | 6.77ms | my $self = shift; | ||
| 1007 | 111 | 1.30ms | $self->update_meta_instance_dependencies(); # spent 1.30ms making 111 calls to Class::MOP::Class::update_meta_instance_dependencies, avg 12µs/call | ||
| 1008 | # keep strong references to all our parents, so they don't disappear if | ||||
| 1009 | # they are anon classes and don't have any direct instances | ||||
| 1010 | 123 | 4.25ms | $self->_superclass_metas( # spent 4.25ms making 123 calls to Class::MOP::class_of, avg 35µs/call | ||
| 1011 | 222 | 1.91ms | map { Class::MOP::class_of($_) } $self->superclasses # spent 1.91ms making 111 calls to Class::MOP::Class::_superclass_metas, avg 17µs/call
# spent 196µs making 2 calls to Class::MOP::Class::superclasses, avg 98µs/call, recursion: max depth 1, sum of overlapping time 196µs
# spent 22.8ms making 109 calls to Moose::Meta::Class::superclasses, avg 210µs/call, recursion: max depth 1, sum of overlapping time 22.8ms | ||
| 1012 | ); | ||||
| 1013 | } | ||||
| 1014 | |||||
| 1015 | # spent 1.91ms within Class::MOP::Class::_superclass_metas which was called 111 times, avg 17µs/call:
# 111 times (1.91ms+0s) by Class::MOP::Class::_superclasses_updated at line 1011, avg 17µs/call | ||||
| 1016 | 222 | 2.22ms | my $self = shift; | ||
| 1017 | $self->{_superclass_metas} = [@_]; | ||||
| 1018 | } | ||||
| 1019 | |||||
| 1020 | sub subclasses { | ||||
| 1021 | my $self = shift; | ||||
| 1022 | my $super_class = $self->name; | ||||
| 1023 | |||||
| 1024 | return @{ $super_class->mro::get_isarev() }; | ||||
| 1025 | } | ||||
| 1026 | |||||
| 1027 | sub direct_subclasses { | ||||
| 1028 | my $self = shift; | ||||
| 1029 | my $super_class = $self->name; | ||||
| 1030 | |||||
| 1031 | return grep { | ||||
| 1032 | grep { | ||||
| 1033 | $_ eq $super_class | ||||
| 1034 | } Class::MOP::Class->initialize($_)->superclasses | ||||
| 1035 | } $self->subclasses; | ||||
| 1036 | } | ||||
| 1037 | |||||
| 1038 | # spent 66.5ms (42.8+23.7) within Class::MOP::Class::linearized_isa which was called 1405 times, avg 47µs/call:
# 712 times (21.1ms+12.0ms) by Class::MOP::Class::get_all_attributes at line 968, avg 47µs/call
# 277 times (8.80ms+4.64ms) by Class::MOP::Class::find_method_by_name at line 1158, avg 49µs/call
# 266 times (8.48ms+4.54ms) by Class::MOP::Class::find_next_method_by_name at line 1205, avg 49µs/call
# 81 times (2.29ms+1.28ms) by Class::MOP::Class::find_all_methods_by_name at line 1189, avg 44µs/call
# 42 times (1.29ms+774µs) by Class::MOP::Class::find_attribute_by_name at line 956, avg 49µs/call
# 18 times (564µs+309µs) by Class::MOP::Class:::around at line 50 of Class/MOP/Class/Immutable/Trait.pm, avg 49µs/call
# 9 times (253µs+153µs) by Class::MOP::Class::get_all_methods at line 1169, avg 45µs/call | ||||
| 1039 | 1405 | 70.5ms | 2810 | 23.7ms | return @{ mro::get_linear_isa( (shift)->name ) }; # spent 16.4ms making 1405 calls to mro::get_linear_isa, avg 12µs/call
# spent 7.26ms making 1405 calls to Class::MOP::Package::name, avg 5µs/call |
| 1040 | } | ||||
| 1041 | |||||
| 1042 | # spent 99.5ms (25.1+74.5) within Class::MOP::Class::class_precedence_list which was called 294 times, avg 338µs/call:
# 159 times (11.7ms+-11.7ms) by Class::MOP::Class::class_precedence_list at line 1068, avg 0s/call
# 73 times (7.53ms+66.4ms) by Moose::Meta::Class::excludes_role at line 239 of Moose/Meta/Class.pm, avg 1.01ms/call
# 44 times (4.28ms+21.3ms) by Moose::Meta::Class::does_role at line 219 of Moose/Meta/Class.pm, avg 581µs/call
# 18 times (1.55ms+-1.55ms) by Class::MOP::Class:::around at line 43 of Class/MOP/Class/Immutable/Trait.pm, avg 0s/call | ||||
| 1043 | 1702 | 30.5ms | my $self = shift; | ||
| 1044 | 294 | 1.65ms | my $name = $self->name; # spent 1.65ms making 294 calls to Class::MOP::Package::name, avg 6µs/call | ||
| 1045 | |||||
| 1046 | 294 | 1.53ms | unless (Class::MOP::IS_RUNNING_ON_5_10()) { # spent 1.53ms making 294 calls to Class::MOP::__ANON__, avg 5µs/call | ||
| 1047 | # NOTE: | ||||
| 1048 | # We need to check for circular inheritance here | ||||
| 1049 | # if we are are not on 5.10, cause 5.8 detects it | ||||
| 1050 | # late. This will do nothing if all is well, and | ||||
| 1051 | # blow up otherwise. Yes, it's an ugly hack, better | ||||
| 1052 | # suggestions are welcome. | ||||
| 1053 | # - SL | ||||
| 1054 | ($name || return)->isa('This is a test for circular inheritance') | ||||
| 1055 | } | ||||
| 1056 | |||||
| 1057 | # if our mro is c3, we can | ||||
| 1058 | # just grab the linear_isa | ||||
| 1059 | 294 | 3.65ms | if (mro::get_mro($name) eq 'c3') { # spent 3.65ms making 294 calls to mro::get_mro, avg 12µs/call | ||
| 1060 | return @{ mro::get_linear_isa($name) } | ||||
| 1061 | } | ||||
| 1062 | else { | ||||
| 1063 | # NOTE: | ||||
| 1064 | # we can't grab the linear_isa for dfs | ||||
| 1065 | # since it has all the duplicates | ||||
| 1066 | # already removed. | ||||
| 1067 | return ( | ||||
| 1068 | 464 | 20.0ms | $name, # spent 19.7ms making 73 calls to Class::MOP::Class::Immutable::Class::MOP::Class::class_precedence_list, avg 270µs/call, recursion: max depth 4, sum of overlapping time 9.57ms
# spent 9.93ms making 232 calls to Class::MOP::Class::initialize, avg 43µs/call
# spent 59.6ms making 159 calls to Class::MOP::Class::class_precedence_list, avg 375µs/call, recursion: max depth 2, sum of overlapping time 59.6ms | ||
| 1069 | map { | ||||
| 1070 | 294 | 53.1ms | Class::MOP::Class->initialize($_)->class_precedence_list() # spent 49.2ms making 264 calls to Moose::Meta::Class::superclasses, avg 186µs/call
# spent 2.75ms making 18 calls to Class::MOP::Class::Immutable::Class::MOP::Class::superclasses, avg 153µs/call
# spent 1.11ms making 12 calls to Class::MOP::Class::superclasses, avg 92µs/call | ||
| 1071 | } $self->superclasses() | ||||
| 1072 | ); | ||||
| 1073 | } | ||||
| 1074 | } | ||||
| 1075 | |||||
| 1076 | ## Methods | ||||
| 1077 | |||||
| 1078 | { | ||||
| 1079 | 1 | 4µs | # spent 218ms (14.4+204) within Class::MOP::Class::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Class.pm:1108] which was called 131 times, avg 1.67ms/call:
# 114 times (12.7ms+184ms) by Class::MOP::Class::add_around_method_modifier at line 1134, avg 1.72ms/call
# 11 times (1.22ms+16.5ms) by Class::MOP::Class::add_before_method_modifier at line 1114, avg 1.61ms/call
# 6 times (514µs+3.96ms) by Class::MOP::Class::add_after_method_modifier at line 1124, avg 746µs/call | ||
| 1080 | 1155 | 15.1ms | my ($self, $method_name) = @_; | ||
| 1081 | 131 | 812µs | my $wrapped_metaclass = $self->wrapped_method_metaclass; # spent 812µs making 131 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 6µs/call | ||
| 1082 | # fetch it locally | ||||
| 1083 | 131 | 19.6ms | my $method = $self->get_method($method_name); # spent 19.6ms making 131 calls to Class::MOP::Mixin::HasMethods::get_method, avg 149µs/call | ||
| 1084 | # if we dont have local ... | ||||
| 1085 | unless ($method) { | ||||
| 1086 | # try to find the next method | ||||
| 1087 | 119 | 88.0ms | $method = $self->find_next_method_by_name($method_name); # spent 88.0ms making 119 calls to Class::MOP::Class::find_next_method_by_name, avg 739µs/call | ||
| 1088 | # die if it does not exist | ||||
| 1089 | (defined $method) | ||||
| 1090 | || confess "The method '$method_name' was not found in the inheritance hierarchy for " . $self->name; | ||||
| 1091 | # and now make sure to wrap it | ||||
| 1092 | # even if it is already wrapped | ||||
| 1093 | # because we need a new sub ref | ||||
| 1094 | 238 | 38.4ms | $method = $wrapped_metaclass->wrap($method, # spent 37.7ms making 119 calls to Class::MOP::Method::Wrapped::wrap, avg 316µs/call
# spent 760µs making 119 calls to Class::MOP::Package::name, avg 6µs/call | ||
| 1095 | package_name => $self->name, | ||||
| 1096 | name => $method_name, | ||||
| 1097 | ); | ||||
| 1098 | } | ||||
| 1099 | else { | ||||
| 1100 | # now make sure we wrap it properly | ||||
| 1101 | 26 | 2.26ms | $method = $wrapped_metaclass->wrap($method, # spent 2.10ms making 7 calls to Class::MOP::Method::Wrapped::wrap, avg 300µs/call
# spent 124µs making 12 calls to UNIVERSAL::isa, avg 10µs/call
# spent 35µs making 7 calls to Class::MOP::Package::name, avg 5µs/call | ||
| 1102 | package_name => $self->name, | ||||
| 1103 | name => $method_name, | ||||
| 1104 | ) unless $method->isa($wrapped_metaclass); | ||||
| 1105 | } | ||||
| 1106 | 131 | 55.0ms | $self->add_method($method_name => $method); # spent 55.0ms making 131 calls to Class::MOP::Mixin::HasMethods::add_method, avg 420µs/call | ||
| 1107 | return $method; | ||||
| 1108 | 1 | 15µs | }; | ||
| 1109 | |||||
| 1110 | # spent 19.2ms (587µs+18.6) within Class::MOP::Class::add_before_method_modifier which was called 11 times, avg 1.75ms/call:
# 11 times (587µs+18.6ms) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 221 of Moose/Meta/Role/Application/ToClass.pm, avg 1.75ms/call | ||||
| 1111 | 44 | 706µs | my ($self, $method_name, $method_modifier) = @_; | ||
| 1112 | (defined $method_name && length $method_name) | ||||
| 1113 | || confess "You must pass in a method name"; | ||||
| 1114 | 11 | 17.7ms | my $method = $fetch_and_prepare_method->($self, $method_name); # spent 17.7ms making 11 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:1108], avg 1.61ms/call | ||
| 1115 | 22 | 905µs | $method->add_before_modifier( # spent 758µs making 11 calls to Class::MOP::Method::Wrapped::add_before_modifier, avg 69µs/call
# spent 147µs making 11 calls to Sub::Name::subname, avg 13µs/call | ||
| 1116 | subname(':before' => $method_modifier) | ||||
| 1117 | ); | ||||
| 1118 | } | ||||
| 1119 | |||||
| 1120 | # spent 5.35ms (343µs+5.01) within Class::MOP::Class::add_after_method_modifier which was called 6 times, avg 892µs/call:
# 6 times (343µs+5.01ms) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 221 of Moose/Meta/Role/Application/ToClass.pm, avg 892µs/call | ||||
| 1121 | 24 | 408µs | my ($self, $method_name, $method_modifier) = @_; | ||
| 1122 | (defined $method_name && length $method_name) | ||||
| 1123 | || confess "You must pass in a method name"; | ||||
| 1124 | 6 | 4.48ms | my $method = $fetch_and_prepare_method->($self, $method_name); # spent 4.48ms making 6 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:1108], avg 746µs/call | ||
| 1125 | 12 | 533µs | $method->add_after_modifier( # spent 448µs making 6 calls to Class::MOP::Method::Wrapped::add_after_modifier, avg 75µs/call
# spent 85µs making 6 calls to Sub::Name::subname, avg 14µs/call | ||
| 1126 | subname(':after' => $method_modifier) | ||||
| 1127 | ); | ||||
| 1128 | } | ||||
| 1129 | |||||
| 1130 | # spent 219ms (6.04+213) within Class::MOP::Class::add_around_method_modifier which was called 114 times, avg 1.92ms/call:
# 68 times (3.52ms+127ms) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 1.92ms/call
# 45 times (2.47ms+85.1ms) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 221 of Moose/Meta/Role/Application/ToClass.pm, avg 1.94ms/call
# once (51µs+1.44ms) by Moose::Util::add_method_modifier at line 244 of Moose/Util.pm | ||||
| 1131 | 456 | 7.45ms | my ($self, $method_name, $method_modifier) = @_; | ||
| 1132 | (defined $method_name && length $method_name) | ||||
| 1133 | || confess "You must pass in a method name"; | ||||
| 1134 | 114 | 196ms | my $method = $fetch_and_prepare_method->($self, $method_name); # spent 196ms making 114 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:1108], avg 1.72ms/call | ||
| 1135 | 228 | 17.0ms | $method->add_around_modifier( # spent 15.4ms making 114 calls to Class::MOP::Method::Wrapped::add_around_modifier, avg 135µs/call
# spent 1.61ms making 114 calls to Sub::Name::subname, avg 14µs/call | ||
| 1136 | subname(':around' => $method_modifier) | ||||
| 1137 | ); | ||||
| 1138 | } | ||||
| 1139 | |||||
| 1140 | # NOTE: | ||||
| 1141 | # the methods above used to be named like this: | ||||
| 1142 | # ${pkg}::${method}:(before|after|around) | ||||
| 1143 | # but this proved problematic when using one modifier | ||||
| 1144 | # to wrap multiple methods (something which is likely | ||||
| 1145 | # to happen pretty regularly IMO). So instead of naming | ||||
| 1146 | # it like this, I have chosen to just name them purely | ||||
| 1147 | # with their modifier names, like so: | ||||
| 1148 | # :(before|after|around) | ||||
| 1149 | # The fact is that in a stack trace, it will be fairly | ||||
| 1150 | # evident from the context what method they are attached | ||||
| 1151 | # to, and so don't need the fully qualified name. | ||||
| 1152 | } | ||||
| 1153 | |||||
| 1154 | # spent 202ms (31.6+171) within Class::MOP::Class::find_method_by_name which was called 277 times, avg 730µs/call:
# 92 times (6.22ms+23.7ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 23 of Class/MOP/Mixin/HasMethods.pm, avg 326µs/call
# 80 times (12.3ms+83.3ms) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 1.20ms/call
# 43 times (6.34ms+29.4ms) by Moose::Meta::Method::Destructor::is_needed at line 62 of Moose/Meta/Method/Destructor.pm, avg 832µs/call
# 42 times (5.39ms+26.5ms) by Moose::Meta::Class::_inline_BUILDARGS at line 303 of Moose/Meta/Class.pm, avg 760µs/call
# 13 times (856µs+5.93ms) by Moose::Meta::Role::Application::ToClass::check_required_methods at line 64 of Moose/Meta/Role/Application/ToClass.pm, avg 522µs/call
# 7 times (442µs+1.61ms) by Moose::BEGIN@38 at line 14 of Moose/Meta/Attribute/Native.pm, avg 294µs/call | ||||
| 1155 | 2451 | 28.4ms | my ($self, $method_name) = @_; | ||
| 1156 | (defined $method_name && length $method_name) | ||||
| 1157 | || confess "You must define a method name to find"; | ||||
| 1158 | 277 | 13.4ms | foreach my $class ($self->linearized_isa) { # spent 13.4ms making 277 calls to Class::MOP::Class::linearized_isa, avg 49µs/call | ||
| 1159 | 1504 | 157ms | my $method = Class::MOP::Class->initialize($class)->get_method($method_name); # spent 125ms making 752 calls to Class::MOP::Mixin::HasMethods::get_method, avg 167µs/call
# spent 31.9ms making 752 calls to Class::MOP::Class::initialize, avg 42µs/call | ||
| 1160 | return $method if defined $method; | ||||
| 1161 | } | ||||
| 1162 | return; | ||||
| 1163 | } | ||||
| 1164 | |||||
| 1165 | # spent 17.3ms (1.83+15.4) within Class::MOP::Class::get_all_methods which was called 9 times, avg 1.92ms/call:
# 9 times (1.83ms+15.4ms) by Class::MOP::MiniTrait::apply at line 18 of Class/MOP/MiniTrait.pm, avg 1.92ms/call | ||||
| 1166 | 69 | 2.18ms | my $self = shift; | ||
| 1167 | |||||
| 1168 | my %methods; | ||||
| 1169 | 9 | 407µs | for my $class ( reverse $self->linearized_isa ) { # spent 407µs making 9 calls to Class::MOP::Class::linearized_isa, avg 45µs/call | ||
| 1170 | 11 | 418µs | my $meta = Class::MOP::Class->initialize($class); # spent 418µs making 11 calls to Class::MOP::Class::initialize, avg 38µs/call | ||
| 1171 | |||||
| 1172 | 91 | 14.6ms | $methods{ $_->name } = $_ for $meta->_get_local_methods; # spent 14.2ms making 11 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 1.29ms/call
# spent 394µs making 80 calls to Class::MOP::Method::name, avg 5µs/call | ||
| 1173 | } | ||||
| 1174 | |||||
| 1175 | return values %methods; | ||||
| 1176 | } | ||||
| 1177 | |||||
| 1178 | sub get_all_method_names { | ||||
| 1179 | my $self = shift; | ||||
| 1180 | my %uniq; | ||||
| 1181 | return grep { !$uniq{$_}++ } map { Class::MOP::Class->initialize($_)->get_method_list } $self->linearized_isa; | ||||
| 1182 | } | ||||
| 1183 | |||||
| 1184 | # spent 61.9ms (11.0+50.9) within Class::MOP::Class::find_all_methods_by_name which was called 81 times, avg 765µs/call:
# 42 times (5.99ms+28.7ms) by Moose::Meta::Class::_inline_BUILDALL at line 456 of Moose/Meta/Class.pm, avg 825µs/call
# 39 times (5.05ms+22.2ms) by Moose::Meta::Method::Destructor::_generate_DEMOLISHALL at line 118 of Moose/Meta/Method/Destructor.pm, avg 699µs/call | ||||
| 1185 | 911 | 9.70ms | my ($self, $method_name) = @_; | ||
| 1186 | (defined $method_name && length $method_name) | ||||
| 1187 | || confess "You must define a method name to find"; | ||||
| 1188 | my @methods; | ||||
| 1189 | 81 | 3.58ms | foreach my $class ($self->linearized_isa) { # spent 3.58ms making 81 calls to Class::MOP::Class::linearized_isa, avg 44µs/call | ||
| 1190 | # fetch the meta-class ... | ||||
| 1191 | 253 | 10.2ms | my $meta = Class::MOP::Class->initialize($class); # spent 10.2ms making 253 calls to Class::MOP::Class::initialize, avg 40µs/call | ||
| 1192 | 254 | 37.1ms | push @methods => { # spent 37.0ms making 253 calls to Class::MOP::Mixin::HasMethods::has_method, avg 146µs/call
# spent 79µs making 1 call to Class::MOP::Mixin::HasMethods::get_method | ||
| 1193 | name => $method_name, | ||||
| 1194 | class => $class, | ||||
| 1195 | code => $meta->get_method($method_name) | ||||
| 1196 | } if $meta->has_method($method_name); | ||||
| 1197 | } | ||||
| 1198 | return @methods; | ||||
| 1199 | } | ||||
| 1200 | |||||
| 1201 | # spent 157ms (29.2+128) within Class::MOP::Class::find_next_method_by_name which was called 266 times, avg 590µs/call:
# 119 times (14.9ms+73.1ms) by Class::MOP::Class::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Class.pm:1108] at line 1087, avg 739µs/call
# 111 times (11.3ms+44.8ms) by Class::MOP::Method::Inlined::can_be_inlined at line 38 of Class/MOP/Method/Inlined.pm, avg 505µs/call
# 36 times (3.05ms+9.83ms) by Moose::Meta::Method::Overridden::new at line 23 of Moose/Meta/Method/Overridden.pm, avg 358µs/call | ||||
| 1202 | 2429 | 26.8ms | my ($self, $method_name) = @_; | ||
| 1203 | (defined $method_name && length $method_name) | ||||
| 1204 | || confess "You must define a method name to find"; | ||||
| 1205 | 266 | 13.0ms | my @cpl = $self->linearized_isa; # spent 13.0ms making 266 calls to Class::MOP::Class::linearized_isa, avg 49µs/call | ||
| 1206 | shift @cpl; # discard ourselves | ||||
| 1207 | foreach my $class (@cpl) { | ||||
| 1208 | 1094 | 115ms | my $method = Class::MOP::Class->initialize($class)->get_method($method_name); # spent 91.2ms making 547 calls to Class::MOP::Mixin::HasMethods::get_method, avg 167µs/call
# spent 23.5ms making 547 calls to Class::MOP::Class::initialize, avg 43µs/call | ||
| 1209 | return $method if defined $method; | ||||
| 1210 | } | ||||
| 1211 | return; | ||||
| 1212 | } | ||||
| 1213 | |||||
| 1214 | # spent 1.30ms within Class::MOP::Class::update_meta_instance_dependencies which was called 111 times, avg 12µs/call:
# 111 times (1.30ms+0s) by Class::MOP::Class::_superclasses_updated at line 1007, avg 12µs/call | ||||
| 1215 | 222 | 1.84ms | my $self = shift; | ||
| 1216 | |||||
| 1217 | if ( $self->{meta_instance_dependencies} ) { | ||||
| 1218 | return $self->add_meta_instance_dependencies; | ||||
| 1219 | } | ||||
| 1220 | } | ||||
| 1221 | |||||
| 1222 | sub add_meta_instance_dependencies { | ||||
| 1223 | my $self = shift; | ||||
| 1224 | |||||
| 1225 | $self->remove_meta_instance_dependencies; | ||||
| 1226 | |||||
| 1227 | my @attrs = $self->get_all_attributes(); | ||||
| 1228 | |||||
| 1229 | my %seen; | ||||
| 1230 | my @classes = grep { not $seen{ $_->name }++ } | ||||
| 1231 | map { $_->associated_class } @attrs; | ||||
| 1232 | |||||
| 1233 | foreach my $class (@classes) { | ||||
| 1234 | $class->add_dependent_meta_instance($self); | ||||
| 1235 | } | ||||
| 1236 | |||||
| 1237 | $self->{meta_instance_dependencies} = \@classes; | ||||
| 1238 | } | ||||
| 1239 | |||||
| 1240 | sub remove_meta_instance_dependencies { | ||||
| 1241 | my $self = shift; | ||||
| 1242 | |||||
| 1243 | if ( my $classes = delete $self->{meta_instance_dependencies} ) { | ||||
| 1244 | foreach my $class (@$classes) { | ||||
| 1245 | $class->remove_dependent_meta_instance($self); | ||||
| 1246 | } | ||||
| 1247 | |||||
| 1248 | return $classes; | ||||
| 1249 | } | ||||
| 1250 | |||||
| 1251 | return; | ||||
| 1252 | |||||
| 1253 | } | ||||
| 1254 | |||||
| 1255 | sub add_dependent_meta_instance { | ||||
| 1256 | my ( $self, $metaclass ) = @_; | ||||
| 1257 | push @{ $self->{dependent_meta_instances} }, $metaclass; | ||||
| 1258 | } | ||||
| 1259 | |||||
| 1260 | sub remove_dependent_meta_instance { | ||||
| 1261 | my ( $self, $metaclass ) = @_; | ||||
| 1262 | my $name = $metaclass->name; | ||||
| 1263 | @$_ = grep { $_->name ne $name } @$_ | ||||
| 1264 | for $self->{dependent_meta_instances}; | ||||
| 1265 | } | ||||
| 1266 | |||||
| 1267 | # spent 9.87ms (7.53+2.34) within Class::MOP::Class::invalidate_meta_instances which was called 188 times, avg 53µs/call:
# 188 times (7.53ms+2.34ms) by Class::MOP::Class::_post_add_attribute at line 926, avg 53µs/call | ||||
| 1268 | 564 | 7.36ms | my $self = shift; | ||
| 1269 | $_->invalidate_meta_instance() | ||||
| 1270 | 188 | 2.34ms | for $self, @{ $self->{dependent_meta_instances} }; # spent 2.34ms making 188 calls to Class::MOP::Class::invalidate_meta_instance, avg 12µs/call | ||
| 1271 | } | ||||
| 1272 | |||||
| 1273 | # spent 2.34ms within Class::MOP::Class::invalidate_meta_instance which was called 188 times, avg 12µs/call:
# 188 times (2.34ms+0s) by Class::MOP::Class::invalidate_meta_instances at line 1270, avg 12µs/call | ||||
| 1274 | 376 | 3.07ms | my $self = shift; | ||
| 1275 | undef $self->{_meta_instance}; | ||||
| 1276 | } | ||||
| 1277 | |||||
| 1278 | # check if we can reinitialize | ||||
| 1279 | sub is_pristine { | ||||
| 1280 | my $self = shift; | ||||
| 1281 | |||||
| 1282 | # if any local attr is defined | ||||
| 1283 | return if $self->get_attribute_list; | ||||
| 1284 | |||||
| 1285 | # or any non-declared methods | ||||
| 1286 | for my $method ( map { $self->get_method($_) } $self->get_method_list ) { | ||||
| 1287 | return if $method->isa("Class::MOP::Method::Generated"); | ||||
| 1288 | # FIXME do we need to enforce this too? return unless $method->isa( $self->method_metaclass ); | ||||
| 1289 | } | ||||
| 1290 | |||||
| 1291 | return 1; | ||||
| 1292 | } | ||||
| 1293 | |||||
| 1294 | ## Class closing | ||||
| 1295 | |||||
| 1296 | 125 | 1.45ms | # spent 868µs within Class::MOP::Class::is_mutable which was called 125 times, avg 7µs/call:
# 94 times (676µs+0s) by Class::MOP::Class::make_immutable at line 1320, avg 7µs/call
# 22 times (135µs+0s) by MooseX::Types::BEGIN@2 at line 231 of Moose.pm, avg 6µs/call
# 9 times (57µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 688 of Moose/Util/TypeConstraints.pm, avg 6µs/call | ||
| 1297 | 320 | 3.76ms | # spent 2.41ms within Class::MOP::Class::is_immutable which was called 320 times, avg 8µs/call:
# 320 times (2.41ms+0s) by Class::MOP::Class::_real_ref_name at line 126, avg 8µs/call | ||
| 1298 | |||||
| 1299 | sub immutable_options { %{ $_[0]{__immutable}{options} || {} } } | ||||
| 1300 | |||||
| 1301 | # spent 9.98ms (6.81+3.18) within Class::MOP::Class::_immutable_options which was called 94 times, avg 106µs/call:
# 51 times (3.28ms+968µs) by Class::MOP::Class::make_immutable at line 1321, avg 83µs/call
# 43 times (3.52ms+2.21ms) by Moose::Meta::Class::_immutable_options at line 645 of Moose/Meta/Class.pm, avg 133µs/call | ||||
| 1302 | 188 | 7.81ms | my ( $self, @args ) = @_; | ||
| 1303 | |||||
| 1304 | return ( | ||||
| 1305 | 376 | 3.18ms | inline_accessors => 1, # spent 655µs making 43 calls to Moose::Meta::Class::immutable_trait, avg 15µs/call
# spent 621µs making 43 calls to Moose::Meta::Class::constructor_class, avg 14µs/call
# spent 613µs making 43 calls to Moose::Meta::Class::destructor_class, avg 14µs/call
# spent 570µs making 94 calls to Class::MOP::Class::constructor_name, avg 6µs/call
# spent 273µs making 51 calls to Class::MOP::Class::immutable_trait, avg 5µs/call
# spent 222µs making 51 calls to Class::MOP::Class::destructor_class, avg 4µs/call
# spent 222µs making 51 calls to Class::MOP::Class::constructor_class, avg 4µs/call | ||
| 1306 | inline_constructor => 1, | ||||
| 1307 | inline_destructor => 0, | ||||
| 1308 | debug => 0, | ||||
| 1309 | immutable_trait => $self->immutable_trait, | ||||
| 1310 | constructor_name => $self->constructor_name, | ||||
| 1311 | constructor_class => $self->constructor_class, | ||||
| 1312 | destructor_class => $self->destructor_class, | ||||
| 1313 | @args, | ||||
| 1314 | ); | ||||
| 1315 | } | ||||
| 1316 | |||||
| 1317 | # spent 1.68s (7.96ms+1.67) within Class::MOP::Class::make_immutable which was called 94 times, avg 17.9ms/call:
# 22 times (1.92ms+406ms) by MooseX::Types::BEGIN@2 at line 236 of Moose.pm, avg 18.6ms/call
# 13 times (978µs+85.8ms) by MooseX::Types::Combine::BEGIN@12 at line 699 of Class/MOP.pm, avg 6.68ms/call
# 9 times (751µs+176ms) by Moose::Meta::Attribute::BEGIN@20 at line 693 of Moose/Util/TypeConstraints.pm, avg 19.7ms/call
# 4 times (269µs+2.30ms) by MooseX::Types::Combine::BEGIN@12 at line 724 of Class/MOP.pm, avg 643µs/call
# 3 times (260µs+-260µs) by Class::MOP::Class::_immutable_metaclass at line 1394, avg 0s/call
# once (183µs+112ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@10 at line 15 of Markdent/Event/StartDocument.pm
# once (123µs+105ms) by Markdent::Simple::Document::BEGIN@9 at line 48 of Markdent/Handler/HTMLStream/Document.pm
# once (90µs+47.8ms) by MooseX::Role::Parameterized::Meta::Role::Parameterizable::BEGIN@8 at line 22 of MooseX/Role/Parameterized/Meta/Parameter.pm
# once (82µs+47.2ms) by MooseX::Role::Parameterized::BEGIN@8 at line 130 of MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm
# once (80µs+46.7ms) by MooseX::Types::BEGIN@2 at line 268 of Moose.pm
# once (84µs+45.0ms) by MooseX::Role::Parameterized::Meta::Role::Parameterizable::BEGIN@7 at line 8 of MooseX/Role/Parameterized/Meta/Role/Parameterized.pm
# once (121µs+26.0ms) by Markdent::Simple::Document::BEGIN@10 at line 198 of Markdent/Parser.pm
# once (84µs+25.6ms) by Markdent::Parser::BEGIN@11 at line 895 of Markdent/Dialect/Standard/SpanParser.pm
# once (97µs+25.5ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@21 at line 47 of Markdent/Event/Image.pm
# once (87µs+23.6ms) by Markdent::Parser::BEGIN@10 at line 748 of Markdent/Dialect/Standard/BlockParser.pm
# once (94µs+22.7ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@24 at line 29 of Markdent/Event/StartHTMLTag.pm
# once (81µs+20.0ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@25 at line 43 of Markdent/Event/StartLink.pm
# once (98µs+18.7ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@14 at line 23 of Markdent/Event/StartHeader.pm
# once (82µs+18.5ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@27 at line 35 of Markdent/Event/Text.pm
# once (80µs+17.0ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@20 at line 29 of Markdent/Event/HTMLTag.pm
# once (81µs+17.0ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@19 at line 23 of Markdent/Event/HTMLEntity.pm
# once (79µs+16.7ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@26 at line 29 of Markdent/Event/StartStrong.pm
# once (81µs+15.2ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@15 at line 23 of Markdent/Event/EndHTMLTag.pm
# once (82µs+14.8ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@18 at line 23 of Markdent/Event/HTMLComment.pm
# once (82µs+14.8ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@26 at line 23 of Markdent/Event/HTMLCommentBlock.pm
# once (85µs+14.8ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@25 at line 23 of Markdent/Event/HTMLBlock.pm
# once (81µs+14.7ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@23 at line 29 of Markdent/Event/StartEmphasis.pm
# once (82µs+14.7ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@13 at line 29 of Markdent/Event/EndCode.pm
# once (90µs+14.7ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@14 at line 29 of Markdent/Event/EndEmphasis.pm
# once (81µs+14.7ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@15 at line 23 of Markdent/Event/EndHeader.pm
# once (85µs+14.7ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@22 at line 29 of Markdent/Event/StartCode.pm
# once (83µs+14.7ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@12 at line 23 of Markdent/Event/AutoLink.pm
# once (79µs+14.7ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@17 at line 29 of Markdent/Event/EndStrong.pm
# once (97µs+14.6ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@11 at line 15 of Markdent/Event/EndDocument.pm
# once (82µs+14.6ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@27 at line 23 of Markdent/Event/Preformatted.pm
# once (82µs+14.2ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@17 at line 15 of Markdent/Event/EndListItem.pm
# once (93µs+13.8ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@22 at line 15 of Markdent/Event/StartUnorderedList.pm
# once (81µs+13.6ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@21 at line 15 of Markdent/Event/EndParagraph.pm
# once (81µs+13.5ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@19 at line 15 of Markdent/Event/EndOrderedList.pm
# once (81µs+13.5ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@20 at line 15 of Markdent/Event/StartParagraph.pm
# once (82µs+13.5ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@23 at line 15 of Markdent/Event/EndUnorderedList.pm
# once (80µs+13.5ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@16 at line 17 of Markdent/Event/EndLink.pm
# once (81µs+13.5ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@16 at line 15 of Markdent/Event/StartListItem.pm
# once (80µs+13.4ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@18 at line 15 of Markdent/Event/StartOrderedList.pm
# once (82µs+13.4ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@24 at line 15 of Markdent/Event/HorizontalRule.pm
# once (84µs+13.4ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@13 at line 15 of Markdent/Event/EndBlockquote.pm
# once (79µs+13.4ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@12 at line 15 of Markdent/Event/StartBlockquote.pm
# once (80µs+11.0ms) by MooseX::Role::Parameterized::Meta::Trait::Parameterized::BEGIN@6 at line 6 of MooseX/Role/Parameterized/Parameters.pm | ||||
| 1318 | 470 | 7.55ms | my ( $self, @args ) = @_; | ||
| 1319 | |||||
| 1320 | 94 | 676µs | if ( $self->is_mutable ) { # spent 676µs making 94 calls to Class::MOP::Class::is_mutable, avg 7µs/call | ||
| 1321 | 188 | 1.36s | $self->_initialize_immutable( $self->_immutable_options(@args) ); # spent 1.35s making 94 calls to Class::MOP::Class::_initialize_immutable, avg 14.4ms/call
# spent 7.61ms making 43 calls to Moose::Meta::Class::_immutable_options, avg 177µs/call
# spent 4.25ms making 51 calls to Class::MOP::Class::_immutable_options, avg 83µs/call | ||
| 1322 | 94 | 311ms | $self->_rebless_as_immutable(@args); # spent 313ms making 94 calls to Class::MOP::Class::_rebless_as_immutable, avg 3.33ms/call, recursion: max depth 1, sum of overlapping time 1.77ms | ||
| 1323 | return $self; | ||||
| 1324 | } | ||||
| 1325 | else { | ||||
| 1326 | return; | ||||
| 1327 | } | ||||
| 1328 | } | ||||
| 1329 | |||||
| 1330 | sub make_mutable { | ||||
| 1331 | my $self = shift; | ||||
| 1332 | |||||
| 1333 | if ( $self->is_immutable ) { | ||||
| 1334 | my @args = $self->immutable_options; | ||||
| 1335 | $self->_rebless_as_mutable(); | ||||
| 1336 | $self->_remove_inlined_code(@args); | ||||
| 1337 | delete $self->{__immutable}; | ||||
| 1338 | return $self; | ||||
| 1339 | } | ||||
| 1340 | else { | ||||
| 1341 | return; | ||||
| 1342 | } | ||||
| 1343 | } | ||||
| 1344 | |||||
| 1345 | # spent 311ms (4.41+306) within Class::MOP::Class::_rebless_as_immutable which was called 94 times, avg 3.31ms/call:
# 94 times (4.41ms+306ms) by Class::MOP::Class::make_immutable at line 1322, avg 3.31ms/call | ||||
| 1346 | 282 | 4.30ms | my ( $self, @args ) = @_; | ||
| 1347 | |||||
| 1348 | $self->{__immutable}{original_class} = ref $self; | ||||
| 1349 | |||||
| 1350 | 94 | 307ms | bless $self => $self->_immutable_metaclass(@args); # spent 308ms making 94 calls to Class::MOP::Class::_immutable_metaclass, avg 3.28ms/call, recursion: max depth 1, sum of overlapping time 1.57ms | ||
| 1351 | } | ||||
| 1352 | |||||
| 1353 | # spent 307ms (10.1+297) within Class::MOP::Class::_immutable_metaclass which was called 94 times, avg 3.26ms/call:
# 94 times (10.1ms+297ms) by Class::MOP::Class::_rebless_as_immutable at line 1350, avg 3.26ms/call | ||||
| 1354 | 767 | 11.5ms | my ( $self, %args ) = @_; | ||
| 1355 | |||||
| 1356 | if ( my $class = $args{immutable_metaclass} ) { | ||||
| 1357 | return $class; | ||||
| 1358 | } | ||||
| 1359 | |||||
| 1360 | 94 | 953µs | my $trait = $args{immutable_trait} = $self->immutable_trait # spent 669µs making 43 calls to Moose::Meta::Class::immutable_trait, avg 16µs/call
# spent 284µs making 51 calls to Class::MOP::Class::immutable_trait, avg 6µs/call | ||
| 1361 | || confess "no immutable trait specified for $self"; | ||||
| 1362 | |||||
| 1363 | 94 | 7.94ms | my $meta = $self->meta; # spent 4.70ms making 57 calls to Class::MOP::Object::meta, avg 83µs/call
# spent 3.24ms making 37 calls to Class::MOP::Class::__ANON__::SERIAL::2::meta, avg 88µs/call | ||
| 1364 | 94 | 25.5ms | my $meta_attr = $meta->find_attribute_by_name("immutable_trait"); # spent 25.5ms making 94 calls to Class::MOP::Class::find_attribute_by_name, avg 271µs/call | ||
| 1365 | |||||
| 1366 | my $class_name; | ||||
| 1367 | |||||
| 1368 | 94 | 1.62ms | if ( $meta_attr and $trait eq $meta_attr->default ) { # spent 1.62ms making 94 calls to Class::MOP::Mixin::AttributeCore::default, avg 17µs/call | ||
| 1369 | # if the trait is the same as the default we try and pick a | ||||
| 1370 | # predictable name for the immutable metaclass | ||||
| 1371 | $class_name = 'Class::MOP::Class::Immutable::' . ref($self); | ||||
| 1372 | } | ||||
| 1373 | else { | ||||
| 1374 | $class_name = join '::', 'Class::MOP::Class::Immutable::CustomTrait', | ||||
| 1375 | $trait, 'ForMetaClass', ref($self); | ||||
| 1376 | } | ||||
| 1377 | |||||
| 1378 | 94 | 1.68ms | return $class_name # spent 1.68ms making 94 calls to Class::MOP::is_class_loaded, avg 18µs/call | ||
| 1379 | if Class::MOP::is_class_loaded($class_name); | ||||
| 1380 | |||||
| 1381 | # If the metaclass is a subclass of CMOP::Class which has had | ||||
| 1382 | # metaclass roles applied (via Moose), then we want to make sure | ||||
| 1383 | # that we preserve that anonymous class (see Fey::ORM for an | ||||
| 1384 | # example of where this matters). | ||||
| 1385 | 3 | 161µs | my $meta_name = $meta->_real_ref_name; # spent 161µs making 3 calls to Class::MOP::Class::_real_ref_name, avg 54µs/call | ||
| 1386 | |||||
| 1387 | 3 | 22.9ms | my $immutable_meta = $meta_name->create( # spent 12.0ms making 1 call to Moose::Meta::Class::create
# spent 10.9ms making 2 calls to Class::MOP::Class::create, avg 5.43ms/call | ||
| 1388 | $class_name, | ||||
| 1389 | superclasses => [ ref $self ], | ||||
| 1390 | ); | ||||
| 1391 | |||||
| 1392 | 3 | 232ms | Class::MOP::MiniTrait::apply( $immutable_meta, $trait ); # spent 232ms making 3 calls to Class::MOP::MiniTrait::apply, avg 77.2ms/call | ||
| 1393 | |||||
| 1394 | 3 | 0s | $immutable_meta->make_immutable( # spent 5.76ms making 3 calls to Class::MOP::Class::make_immutable, avg 1.92ms/call, recursion: max depth 1, sum of overlapping time 5.76ms | ||
| 1395 | inline_constructor => 0, | ||||
| 1396 | inline_accessors => 0, | ||||
| 1397 | ); | ||||
| 1398 | |||||
| 1399 | return $class_name; | ||||
| 1400 | } | ||||
| 1401 | |||||
| 1402 | sub _remove_inlined_code { | ||||
| 1403 | my $self = shift; | ||||
| 1404 | |||||
| 1405 | $self->remove_method( $_->name ) for $self->_inlined_methods; | ||||
| 1406 | |||||
| 1407 | delete $self->{__immutable}{inlined_methods}; | ||||
| 1408 | } | ||||
| 1409 | |||||
| 1410 | sub _inlined_methods { @{ $_[0]{__immutable}{inlined_methods} || [] } } | ||||
| 1411 | |||||
| 1412 | sub _add_inlined_method { | ||||
| 1413 | 224 | 2.47ms | my ( $self, $method ) = @_; | ||
| 1414 | |||||
| 1415 | push @{ $self->{__immutable}{inlined_methods} ||= [] }, $method; | ||||
| 1416 | } | ||||
| 1417 | |||||
| 1418 | # spent 1.35s (5.37ms+1.35) within Class::MOP::Class::_initialize_immutable which was called 94 times, avg 14.4ms/call:
# 94 times (5.37ms+1.35s) by Class::MOP::Class::make_immutable at line 1321, avg 14.4ms/call | ||||
| 1419 | 282 | 5.28ms | my ( $self, %args ) = @_; | ||
| 1420 | |||||
| 1421 | $self->{__immutable}{options} = \%args; | ||||
| 1422 | 94 | 1.35s | $self->_install_inlined_code(%args); # spent 1.35s making 94 calls to Class::MOP::Class::_install_inlined_code, avg 14.3ms/call | ||
| 1423 | } | ||||
| 1424 | |||||
| 1425 | # spent 1.35s (6.15ms+1.34) within Class::MOP::Class::_install_inlined_code which was called 94 times, avg 14.3ms/call:
# 94 times (6.15ms+1.34s) by Class::MOP::Class::_initialize_immutable at line 1422, avg 14.3ms/call | ||||
| 1426 | 376 | 6.06ms | my ( $self, %args ) = @_; | ||
| 1427 | |||||
| 1428 | # FIXME | ||||
| 1429 | 32 | 243ms | $self->_inline_accessors(%args) if $args{inline_accessors}; # spent 243ms making 32 calls to Class::MOP::Class::_inline_accessors, avg 7.60ms/call | ||
| 1430 | 73 | 907ms | $self->_inline_constructor(%args) if $args{inline_constructor}; # spent 907ms making 73 calls to Class::MOP::Class::_inline_constructor, avg 12.4ms/call | ||
| 1431 | 43 | 190ms | $self->_inline_destructor(%args) if $args{inline_destructor}; # spent 190ms making 43 calls to Class::MOP::Class::_inline_destructor, avg 4.41ms/call | ||
| 1432 | } | ||||
| 1433 | |||||
| 1434 | sub _rebless_as_mutable { | ||||
| 1435 | my $self = shift; | ||||
| 1436 | |||||
| 1437 | bless $self, $self->_get_mutable_metaclass_name; | ||||
| 1438 | |||||
| 1439 | return $self; | ||||
| 1440 | } | ||||
| 1441 | |||||
| 1442 | # spent 243ms (3.06+240) within Class::MOP::Class::_inline_accessors which was called 32 times, avg 7.60ms/call:
# 32 times (3.06ms+240ms) by Class::MOP::Class::_install_inlined_code at line 1429, avg 7.60ms/call | ||||
| 1443 | 133 | 2.72ms | my $self = shift; | ||
| 1444 | |||||
| 1445 | 32 | 1.05ms | foreach my $attr_name ( $self->get_attribute_list ) { # spent 1.05ms making 32 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 33µs/call | ||
| 1446 | 138 | 239ms | $self->get_attribute($attr_name)->install_accessors(1); # spent 230ms making 68 calls to Class::MOP::Attribute::install_accessors, avg 3.39ms/call
# spent 6.30ms making 1 call to Moose::Meta::Attribute::install_accessors
# spent 2.38ms making 69 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 35µs/call | ||
| 1447 | } | ||||
| 1448 | } | ||||
| 1449 | |||||
| 1450 | # spent 907ms (10.7+896) within Class::MOP::Class::_inline_constructor which was called 73 times, avg 12.4ms/call:
# 73 times (10.7ms+896ms) by Class::MOP::Class::_install_inlined_code at line 1430, avg 12.4ms/call | ||||
| 1451 | 730 | 10.2ms | my ( $self, %args ) = @_; | ||
| 1452 | |||||
| 1453 | my $name = $args{constructor_name}; | ||||
| 1454 | # A class may not even have a constructor, and that's okay. | ||||
| 1455 | return unless defined $name; | ||||
| 1456 | |||||
| 1457 | 73 | 18.8ms | if ( $self->has_method($name) && !$args{replace_constructor} ) { # spent 18.8ms making 73 calls to Class::MOP::Mixin::HasMethods::has_method, avg 258µs/call | ||
| 1458 | my $class = $self->name; | ||||
| 1459 | warn "Not inlining a constructor for $class since it defines" | ||||
| 1460 | . " its own constructor.\n" | ||||
| 1461 | . "If you are certain you don't need to inline your" | ||||
| 1462 | . " constructor, specify inline_constructor => 0 in your" | ||||
| 1463 | . " call to $class->meta->make_immutable\n"; | ||||
| 1464 | return; | ||||
| 1465 | } | ||||
| 1466 | |||||
| 1467 | my $constructor_class = $args{constructor_class}; | ||||
| 1468 | |||||
| 1469 | 73 | 9.66ms | Class::MOP::load_class($constructor_class); # spent 18.5ms making 73 calls to Class::MOP::load_class, avg 254µs/call, recursion: max depth 2, sum of overlapping time 8.87ms | ||
| 1470 | |||||
| 1471 | 146 | 774ms | my $constructor = $constructor_class->new( # spent 461ms making 42 calls to Moose::Meta::Method::Constructor::new, avg 11.0ms/call
# spent 312ms making 31 calls to Class::MOP::Method::Constructor::new, avg 10.1ms/call
# spent 453µs making 73 calls to Class::MOP::Package::name, avg 6µs/call | ||
| 1472 | options => \%args, | ||||
| 1473 | metaclass => $self, | ||||
| 1474 | is_inline => 1, | ||||
| 1475 | package_name => $self->name, | ||||
| 1476 | name => $name, | ||||
| 1477 | ); | ||||
| 1478 | |||||
| 1479 | 72 | 52.6ms | if ( $args{replace_constructor} or $constructor->can_be_inlined ) { # spent 52.6ms making 72 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 730µs/call | ||
| 1480 | 73 | 30.9ms | $self->add_method( $name => $constructor ); # spent 30.9ms making 73 calls to Class::MOP::Mixin::HasMethods::add_method, avg 423µs/call | ||
| 1481 | 73 | 1.52ms | $self->_add_inlined_method($constructor); # spent 1.52ms making 73 calls to Class::MOP::Class::_add_inlined_method, avg 21µs/call | ||
| 1482 | } | ||||
| 1483 | } | ||||
| 1484 | |||||
| 1485 | # spent 190ms (7.08+183) within Class::MOP::Class::_inline_destructor which was called 43 times, avg 4.41ms/call:
# 43 times (7.08ms+183ms) by Class::MOP::Class::_install_inlined_code at line 1431, avg 4.41ms/call | ||||
| 1486 | 414 | 6.81ms | my ( $self, %args ) = @_; | ||
| 1487 | |||||
| 1488 | ( exists $args{destructor_class} && defined $args{destructor_class} ) | ||||
| 1489 | || confess "The 'inline_destructor' option is present, but " | ||||
| 1490 | . "no destructor class was specified"; | ||||
| 1491 | |||||
| 1492 | 43 | 6.53ms | if ( $self->has_method('DESTROY') && ! $args{replace_destructor} ) { # spent 6.53ms making 43 calls to Class::MOP::Mixin::HasMethods::has_method, avg 152µs/call | ||
| 1493 | my $class = $self->name; | ||||
| 1494 | warn "Not inlining a destructor for $class since it defines" | ||||
| 1495 | . " its own destructor.\n"; | ||||
| 1496 | return; | ||||
| 1497 | } | ||||
| 1498 | |||||
| 1499 | my $destructor_class = $args{destructor_class}; | ||||
| 1500 | |||||
| 1501 | 43 | 9.88ms | Class::MOP::load_class($destructor_class); # spent 10.8ms making 43 calls to Class::MOP::load_class, avg 252µs/call, recursion: max depth 2, sum of overlapping time 970µs | ||
| 1502 | |||||
| 1503 | 43 | 38.7ms | return unless $destructor_class->is_needed($self); # spent 38.7ms making 43 calls to Moose::Meta::Method::Destructor::is_needed, avg 900µs/call | ||
| 1504 | |||||
| 1505 | 78 | 83.8ms | my $destructor = $destructor_class->new( # spent 83.5ms making 39 calls to Moose::Meta::Method::Destructor::new, avg 2.14ms/call
# spent 240µs making 39 calls to Class::MOP::Package::name, avg 6µs/call | ||
| 1506 | options => \%args, | ||||
| 1507 | metaclass => $self, | ||||
| 1508 | package_name => $self->name, | ||||
| 1509 | name => 'DESTROY' | ||||
| 1510 | ); | ||||
| 1511 | |||||
| 1512 | 39 | 25.6ms | if ( $args{replace_destructor} or $destructor->can_be_inlined ) { # spent 25.6ms making 39 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 657µs/call | ||
| 1513 | 39 | 16.3ms | $self->add_method( 'DESTROY' => $destructor ); # spent 16.3ms making 39 calls to Class::MOP::Mixin::HasMethods::add_method, avg 419µs/call | ||
| 1514 | 39 | 708µs | $self->_add_inlined_method($destructor); # spent 708µs making 39 calls to Class::MOP::Class::_add_inlined_method, avg 18µs/call | ||
| 1515 | } | ||||
| 1516 | } | ||||
| 1517 | |||||
| 1518 | 1 | 25µs | 1; | ||
| 1519 | |||||
| 1520 | __END__ | ||||
sub Class::MOP::Class::CORE:match; # opcode | |||||
sub Class::MOP::Class::CORE:regcomp; # opcode | |||||
# spent 27.3ms (18.8+8.56) within Class::MOP::Class::CORE:sort which was called 73 times, avg 374µs/call:
# 73 times (18.8ms+8.56ms) by Class::MOP::Class::_inline_slot_initializers at line 646, avg 374µs/call |