| Filename | /home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Class.pm |
| Statements | Executed 59300 statements in 739ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 3125 | 24 | 13 | 105ms | 349ms | Class::MOP::Class::initialize (recurses: max depth 1, inclusive time 4.98ms) |
| 406 | 8 | 5 | 62.9ms | 146ms | Class::MOP::Class::get_all_attributes |
| 531 | 1 | 1 | 36.6ms | 72.8ms | Class::MOP::Class::_single_metaclass_can_be_made_compatible |
| 138 | 2 | 1 | 35.3ms | 262ms | Class::MOP::Class::_construct_instance |
| 378 | 2 | 2 | 25.7ms | 249ms | Class::MOP::Class::_inline_slot_initializer |
| 837 | 7 | 2 | 25.0ms | 38.9ms | Class::MOP::Class::linearized_isa |
| 273 | 1 | 1 | 24.9ms | 45.1ms | Class::MOP::Class::_single_metaclass_is_compatible |
| 213 | 6 | 6 | 19.5ms | 136ms | Class::MOP::Class::find_method_by_name |
| 134 | 2 | 1 | 19.0ms | 240ms | Class::MOP::Class::_check_metaclass_compatibility (recurses: max depth 1, inclusive time 3.70ms) |
| 239 | 1 | 1 | 17.7ms | 1.94s | Class::MOP::Class::_post_add_attribute |
| 55 | 1 | 1 | 15.8ms | 23.0ms | Class::MOP::Class::CORE:sort (opcode) |
| 157 | 4 | 3 | 15.3ms | 76.9ms | Class::MOP::Class::find_next_method_by_name |
| 378 | 2 | 2 | 15.1ms | 23.6ms | Class::MOP::Class::_inline_default_value |
| 256 | 1 | 1 | 14.4ms | 76.9ms | Class::MOP::Class::_inline_init_attr_from_constructor |
| 82 | 1 | 1 | 14.3ms | 109ms | Class::MOP::Class::_can_fix_metaclass_incompatibility |
| 810 | 12 | 5 | 12.7ms | 160ms | Class::MOP::Class::get_meta_instance |
| 173 | 1 | 1 | 12.3ms | 148ms | Class::MOP::Class::_create_meta_instance |
| 98 | 1 | 1 | 10.9ms | 218ms | Class::MOP::Class::_construct_class_instance (recurses: max depth 1, inclusive time 726µs) |
| 239 | 1 | 1 | 10.8ms | 1.89s | Class::MOP::Class::__ANON__[:932] |
| 267 | 2 | 1 | 10.1ms | 43.1ms | Class::MOP::Class::_inline_init_attr_from_default |
| 239 | 1 | 1 | 10.0ms | 13.0ms | Class::MOP::Class::invalidate_meta_instances |
| 55 | 1 | 1 | 8.51ms | 317ms | Class::MOP::Class::_inline_slot_initializers |
| 75 | 1 | 1 | 8.01ms | 195ms | Class::MOP::Class::_immutable_metaclass (recurses: max depth 1, inclusive time 939µs) |
| 55 | 1 | 1 | 7.93ms | 710ms | Class::MOP::Class::_inline_constructor |
| 68 | 3 | 1 | 7.56ms | 112ms | Class::MOP::Class::__ANON__[:1108] |
| 273 | 1 | 1 | 7.30ms | 52.4ms | Class::MOP::Class::_check_single_metaclass_compatibility |
| 75 | 30 | 28 | 6.24ms | 1.27s | Class::MOP::Class::make_immutable (recurses: max depth 1, inclusive time 1.56ms) |
| 239 | 1 | 1 | 5.67ms | 20.9ms | Class::MOP::Class::_attach_attribute |
| 77 | 2 | 2 | 5.46ms | 18.6ms | Class::MOP::Class::find_attribute_by_name |
| 75 | 2 | 2 | 5.36ms | 7.56ms | Class::MOP::Class::_immutable_options |
| 104 | 6 | 6 | 5.22ms | 152ms | Class::MOP::Class::new_object |
| 1 | 1 | 1 | 5.11ms | 5.79ms | Class::MOP::Class::BEGIN@7 |
| 48 | 2 | 2 | 5.02ms | 27.4ms | Class::MOP::Class::find_all_methods_by_name |
| 55 | 1 | 1 | 4.81ms | 396ms | Class::MOP::Class::_inline_new_object |
| 68 | 1 | 1 | 4.81ms | 119ms | Class::MOP::Class::_fix_metaclass_incompatibility (recurses: max depth 1, inclusive time 2.92ms) |
| 1 | 1 | 1 | 4.78ms | 36.5ms | Class::MOP::Class::BEGIN@9 |
| 75 | 1 | 1 | 4.63ms | 1.06s | Class::MOP::Class::_install_inlined_code |
| 51 | 3 | 3 | 4.57ms | 18.5ms | Class::MOP::Class::class_precedence_list (recurses: max depth 4, inclusive time 14.7ms) |
| 1 | 1 | 1 | 4.24ms | 5.08ms | Class::MOP::Class::BEGIN@8 |
| 75 | 1 | 1 | 4.07ms | 1.06s | Class::MOP::Class::_initialize_immutable |
| 64 | 1 | 1 | 4.05ms | 4.05ms | Class::MOP::Class::_new |
| 24 | 1 | 1 | 3.88ms | 98.2ms | Class::MOP::Class::_inline_destructor |
| 131 | 4 | 1 | 3.79ms | 7.06ms | Class::MOP::Class::_real_ref_name |
| 75 | 1 | 1 | 3.36ms | 198ms | Class::MOP::Class::_rebless_as_immutable (recurses: max depth 1, inclusive time 1.06ms) |
| 32 | 1 | 1 | 3.12ms | 244ms | Class::MOP::Class::_inline_accessors |
| 61 | 2 | 2 | 3.04ms | 112ms | Class::MOP::Class::add_around_method_modifier |
| 82 | 1 | 1 | 3.02ms | 12.3ms | Class::MOP::Class::_class_metaclass_can_be_made_compatible |
| 239 | 1 | 1 | 2.96ms | 2.96ms | Class::MOP::Class::invalidate_meta_instance |
| 1 | 1 | 1 | 2.89ms | 7.27ms | Class::MOP::Class::BEGIN@10 |
| 150 | 3 | 2 | 2.73ms | 2.73ms | Class::MOP::Class::_base_metaclasses |
| 36 | 1 | 1 | 2.66ms | 12.4ms | Class::MOP::Class::_superclasses_updated |
| 55 | 1 | 1 | 2.37ms | 3.59ms | Class::MOP::Class::_inline_fallback_constructor |
| 39 | 1 | 1 | 2.27ms | 5.89ms | Class::MOP::Class::_class_metaclass_is_compatible |
| 55 | 1 | 1 | 2.10ms | 12.3ms | Class::MOP::Class::_inline_create_instance |
| 55 | 1 | 1 | 1.91ms | 3.80ms | Class::MOP::Class::_inline_preserve_weak_metaclasses |
| 55 | 1 | 1 | 1.81ms | 14.1ms | Class::MOP::Class::_inline_generate_instance |
| 10 | 2 | 2 | 1.69ms | 125ms | Class::MOP::Class::create |
| 79 | 2 | 1 | 1.67ms | 1.67ms | Class::MOP::Class::_add_inlined_method |
| 8 | 1 | 1 | 1.42ms | 16.3ms | Class::MOP::Class::get_all_methods |
| 1 | 1 | 1 | 1.16ms | 4.84ms | Class::MOP::Class::BEGIN@16 |
| 1 | 1 | 1 | 1.10ms | 1.30ms | Class::MOP::Class::BEGIN@11 |
| 39 | 1 | 1 | 1.10ms | 6.98ms | Class::MOP::Class::_check_class_metaclass_compatibility |
| 106 | 3 | 3 | 750µs | 750µs | Class::MOP::Class::is_mutable |
| 91 | 1 | 1 | 708µs | 708µs | Class::MOP::Class::is_immutable |
| 36 | 1 | 1 | 604µs | 604µs | Class::MOP::Class::_superclass_metas |
| 31 | 1 | 1 | 577µs | 577µs | Class::MOP::Class::_inline_params |
| 31 | 1 | 1 | 505µs | 505µs | Class::MOP::Class::_generate_fallback_constructor |
| 36 | 1 | 1 | 442µs | 442µs | Class::MOP::Class::update_meta_instance_dependencies |
| 8 | 1 | 1 | 387µs | 381ms | Class::MOP::Class::create_anon_class |
| 5 | 2 | 2 | 303µs | 10.7ms | Class::MOP::Class::add_before_method_modifier |
| 31 | 1 | 1 | 220µs | 220µs | Class::MOP::Class::_inline_extra_init |
| 2 | 1 | 1 | 217µs | 1.63ms | Class::MOP::Class::add_after_method_modifier |
| 1 | 1 | 1 | 151µs | 174µs | Class::MOP::Class::BEGIN@4 |
| 1 | 1 | 1 | 56µs | 132µs | Class::MOP::Class::BEGIN@433 |
| 1 | 1 | 1 | 42µs | 106µs | Class::MOP::Class::BEGIN@468 |
| 1 | 1 | 1 | 42µs | 248µs | Class::MOP::Class::BEGIN@17 |
| 1 | 1 | 1 | 42µs | 102µs | Class::MOP::Class::BEGIN@455 |
| 1 | 1 | 1 | 40µs | 21.9ms | Class::MOP::Class::BEGIN@24 |
| 1 | 1 | 1 | 40µs | 110µs | Class::MOP::Class::BEGIN@5 |
| 1 | 1 | 1 | 39µs | 216µs | Class::MOP::Class::BEGIN@14 |
| 1 | 1 | 1 | 38µs | 198µs | Class::MOP::Class::BEGIN@13 |
| 1 | 1 | 1 | 38µs | 166µs | Class::MOP::Class::BEGIN@18 |
| 1 | 1 | 1 | 36µs | 164µs | Class::MOP::Class::BEGIN@15 |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::DESTROY |
| 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::_clone_instance |
| 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_generated_metaobjects |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_remove_inlined_code |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_restore_metaobjects_from |
| 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::clone_object |
| 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_anon_class |
| 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::reinitialize |
| 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 | 182µs | 2 | 196µs | # spent 174µs (151+23) within Class::MOP::Class::BEGIN@4 which was called:
# once (151µs+23µs) by Class::MOP::BEGIN@19 at line 4 # spent 174µs making 1 call to Class::MOP::Class::BEGIN@4
# spent 23µs making 1 call to strict::import |
| 5 | 3 | 97µs | 2 | 180µs | # spent 110µs (40+70) within Class::MOP::Class::BEGIN@5 which was called:
# once (40µs+70µs) by Class::MOP::BEGIN@19 at line 5 # spent 110µs making 1 call to Class::MOP::Class::BEGIN@5
# spent 70µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 3 | 428µs | 1 | 5.79ms | # spent 5.79ms (5.11+678µs) within Class::MOP::Class::BEGIN@7 which was called:
# once (5.11ms+678µs) by Class::MOP::BEGIN@19 at line 7 # spent 5.79ms making 1 call to Class::MOP::Class::BEGIN@7 |
| 8 | 3 | 478µs | 1 | 5.08ms | # spent 5.08ms (4.24+845µs) within Class::MOP::Class::BEGIN@8 which was called:
# once (4.24ms+845µs) by Class::MOP::BEGIN@19 at line 8 # spent 5.08ms making 1 call to Class::MOP::Class::BEGIN@8 |
| 9 | 3 | 442µs | 1 | 36.5ms | # spent 36.5ms (4.78+31.8) within Class::MOP::Class::BEGIN@9 which was called:
# once (4.78ms+31.8ms) by Class::MOP::BEGIN@19 at line 9 # spent 36.5ms making 1 call to Class::MOP::Class::BEGIN@9 |
| 10 | 3 | 471µs | 1 | 7.27ms | # spent 7.27ms (2.89+4.38) within Class::MOP::Class::BEGIN@10 which was called:
# once (2.89ms+4.38ms) by Class::MOP::BEGIN@19 at line 10 # spent 7.27ms making 1 call to Class::MOP::Class::BEGIN@10 |
| 11 | 3 | 500µs | 1 | 1.30ms | # spent 1.30ms (1.10+199µs) within Class::MOP::Class::BEGIN@11 which was called:
# once (1.10ms+199µs) by Class::MOP::BEGIN@19 at line 11 # spent 1.30ms making 1 call to Class::MOP::Class::BEGIN@11 |
| 12 | |||||
| 13 | 3 | 116µs | 2 | 357µs | # spent 198µs (38+159) within Class::MOP::Class::BEGIN@13 which was called:
# once (38µs+159µs) by Class::MOP::BEGIN@19 at line 13 # spent 198µs making 1 call to Class::MOP::Class::BEGIN@13
# spent 159µs making 1 call to Exporter::import |
| 14 | 3 | 100µs | 2 | 394µs | # spent 216µs (39+178) within Class::MOP::Class::BEGIN@14 which was called:
# once (39µs+178µs) by Class::MOP::BEGIN@19 at line 14 # spent 216µs making 1 call to Class::MOP::Class::BEGIN@14
# spent 178µs making 1 call to Exporter::import |
| 15 | 3 | 101µs | 2 | 293µs | # spent 164µs (36+128) within Class::MOP::Class::BEGIN@15 which was called:
# once (36µs+128µs) by Class::MOP::BEGIN@19 at line 15 # spent 164µs making 1 call to Class::MOP::Class::BEGIN@15
# spent 128µs making 1 call to Exporter::import |
| 16 | 3 | 607µs | 2 | 5.64ms | # spent 4.84ms (1.16+3.68) within Class::MOP::Class::BEGIN@16 which was called:
# once (1.16ms+3.68ms) by Class::MOP::BEGIN@19 at line 16 # spent 4.84ms making 1 call to Class::MOP::Class::BEGIN@16
# spent 801µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756] |
| 17 | 3 | 114µs | 2 | 453µs | # spent 248µs (42+205) within Class::MOP::Class::BEGIN@17 which was called:
# once (42µ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 | 232µs | 2 | 295µs | # spent 166µs (38+129) within Class::MOP::Class::BEGIN@18 which was called:
# once (38µs+129µs) by Class::MOP::BEGIN@19 at line 18 # spent 166µs making 1 call to Class::MOP::Class::BEGIN@18
# spent 129µs making 1 call to Exporter::import |
| 19 | |||||
| 20 | 1 | 5µs | our $VERSION = '1.11'; | ||
| 21 | 1 | 87µs | $VERSION = eval $VERSION; # spent 12µs executing statements in string eval | ||
| 22 | 1 | 4µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 23 | |||||
| 24 | 1 | 25µs | 1 | 21.9ms | # spent 21.9ms (40µs+21.9) within Class::MOP::Class::BEGIN@24 which was called:
# once (40µs+21.9ms) by Class::MOP::BEGIN@19 at line 26 # spent 21.9ms making 1 call to base::import |
| 25 | 'Class::MOP::Mixin::HasAttributes', | ||||
| 26 | 2 | 5.66ms | 1 | 21.9ms | 'Class::MOP::Mixin::HasMethods'; # spent 21.9ms making 1 call to Class::MOP::Class::BEGIN@24 |
| 27 | |||||
| 28 | # Creation | ||||
| 29 | |||||
| 30 | # spent 349ms (105+244) within Class::MOP::Class::initialize which was called 3125 times, avg 112µs/call:
# 1334 times (43.2ms+11.2ms) by Class::MOP::Class::get_all_attributes at line 968, avg 41µs/call
# 449 times (16.5ms+20.4ms) by 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::Mixin::meta or Class::MOP::Object::meta or Data::Stream::Bulk::Cat::meta or Data::Stream::Bulk::Filter::meta or Data::Stream::Bulk::Nil::meta or Data::Visitor::meta or KiokuDB::Collapser::Buffer::meta or KiokuDB::Collapser::meta or KiokuDB::Entry::Skip::meta or KiokuDB::Entry::meta or KiokuDB::Error::MissingObjects::meta or KiokuDB::Error::UnknownObjects::meta or KiokuDB::Linker::meta or KiokuDB::LiveObjects::Scope::meta or KiokuDB::LiveObjects::TXNScope::meta or KiokuDB::LiveObjects::meta or KiokuDB::Reference::meta or KiokuDB::Stream::Objects::meta or KiokuDB::Thunk::meta or KiokuDB::TypeMap::Entry::Alias::meta or KiokuDB::TypeMap::Entry::Compiled::meta or KiokuDB::TypeMap::Entry::MOP::meta or KiokuDB::TypeMap::Resolver::meta or KiokuDB::TypeMap::Shadow::meta or KiokuDB::TypeMap::meta or KiokuDB::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 at line 44 of Class/MOP/Method/Meta.pm, avg 82µs/call
# 436 times (14.4ms+4.17ms) by Class::MOP::Class::find_method_by_name at line 1159, avg 43µs/call
# 249 times (8.26ms+2.57ms) by Class::MOP::Class::find_next_method_by_name at line 1208, avg 43µs/call
# 98 times (3.16ms+869µs) by Class::MOP::Class::find_all_methods_by_name at line 1191, avg 41µs/call
# 82 times (2.83ms+2.73ms) by Class::MOP::Class::_fix_metaclass_incompatibility at line 298, avg 68µs/call
# 79 times (2.55ms+687µs) by Class::MOP::Class::find_attribute_by_name at line 958, avg 41µs/call
# 73 times (2.26ms+664µs) by Moose::Meta::Attribute::_new or Moose::Meta::Method::_new at line 4 of generated method (unknown origin), avg 40µs/call
# 64 times (1.78ms+553µs) by Class::MOP::Attribute::has_value at line 316 of Class/MOP/Attribute.pm, avg 36µs/call
# 49 times (1.64ms+470µs) by Class::MOP::Class::class_precedence_list at line 1068, avg 43µs/call
# 35 times (1.01ms+311µs) by Class::MOP::Attribute::get_raw_value at line 295 of Class/MOP/Attribute.pm, avg 38µs/call
# 34 times (1.84ms+136ms) by Moose::Meta::Class::initialize at line 68 of Moose/Meta/Class.pm, avg 4.06ms/call
# 33 times (1.30ms+23.1ms) by Class::MOP::Object::meta at line 18 of Class/MOP/Object.pm, avg 738µs/call
# 26 times (841µs+7.68ms) by Class::MOP::Method::_new at line 54 of Class/MOP/Method.pm, avg 328µs/call
# 19 times (1.05ms+7.93ms) by metaclass::import at line 45 of metaclass.pm, avg 472µs/call
# 18 times (741µs+7.20ms) by Class::MOP::Mixin::meta at line 14 of Class/MOP/Mixin.pm, avg 441µs/call
# 14 times (673µs+13.7ms) by Class::MOP::MiniTrait::apply at line 15 of Class/MOP/MiniTrait.pm, avg 1.03ms/call
# 11 times (342µs+105µs) by Class::MOP::Attribute::set_initial_value at line 259 of Class/MOP/Attribute.pm, avg 41µs/call
# 9 times (276µs+75µs) by Class::MOP::Class::get_all_methods at line 1170, avg 39µs/call
# 7 times (319µs+2.64ms) by Moose::BEGIN@38 at line 11 of Moose/Meta/Attribute/Native.pm, avg 423µs/call
# 2 times (87µs+865µs) by Class::MOP::Class::create at line 513, avg 476µs/call
# 2 times (58µs+17µs) by Moose::Meta::Attribute::_weaken_value at line 695 of Moose/Meta/Attribute.pm, avg 38µs/call
# once (41µs+13µs) by Moose::Object::new at line 26 of Moose/Object.pm
# once (30µs+9µs) by Class::MOP::Attribute::_new at line 62 of Class/MOP/Attribute.pm | ||||
| 31 | 3125 | 11.6ms | my $class = shift; | ||
| 32 | |||||
| 33 | 3125 | 5.56ms | my $package_name; | ||
| 34 | |||||
| 35 | 3125 | 14.9ms | if ( @_ % 2 ) { | ||
| 36 | $package_name = shift; | ||||
| 37 | } else { | ||||
| 38 | my %options = @_; | ||||
| 39 | $package_name = $options{package}; | ||||
| 40 | } | ||||
| 41 | |||||
| 42 | 3125 | 7.97ms | ($package_name && !ref($package_name)) | ||
| 43 | || confess "You must pass a package name and it cannot be blessed"; | ||||
| 44 | |||||
| 45 | 3125 | 61.0ms | 3223 | 248ms | return Class::MOP::get_metaclass_by_name($package_name) # spent 219ms making 98 calls to Class::MOP::Class::_construct_class_instance, avg 2.23ms/call, recursion: max depth 1, sum of overlapping time 726µs
# spent 30.3ms making 3125 calls to Class::MOP::get_metaclass_by_name, avg 10µs/call |
| 46 | || $class->_construct_class_instance(package => $package_name, @_); | ||||
| 47 | } | ||||
| 48 | |||||
| 49 | sub reinitialize { | ||||
| 50 | my ( $class, @args ) = @_; | ||||
| 51 | unshift @args, "package" if @args % 2; | ||||
| 52 | my %options = @args; | ||||
| 53 | my $old_metaclass = blessed($options{package}) | ||||
| 54 | ? $options{package} | ||||
| 55 | : Class::MOP::get_metaclass_by_name($options{package}); | ||||
| 56 | $options{weaken} = Class::MOP::metaclass_is_weak($old_metaclass->name) | ||||
| 57 | if !exists $options{weaken} | ||||
| 58 | && blessed($old_metaclass) | ||||
| 59 | && $old_metaclass->isa('Class::MOP::Class'); | ||||
| 60 | $old_metaclass->_remove_generated_metaobjects | ||||
| 61 | if $old_metaclass && $old_metaclass->isa('Class::MOP::Class'); | ||||
| 62 | my $new_metaclass = $class->SUPER::reinitialize(%options); | ||||
| 63 | $new_metaclass->_restore_metaobjects_from($old_metaclass) | ||||
| 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 218ms (10.9+207) within Class::MOP::Class::_construct_class_instance which was called 98 times, avg 2.23ms/call:
# 98 times (10.9ms+207ms) by Class::MOP::Class::initialize at line 45, avg 2.23ms/call | ||||
| 75 | 98 | 361µs | my $class = shift; | ||
| 76 | 98 | 1.00ms | my $options = @_ == 1 ? $_[0] : {@_}; | ||
| 77 | 98 | 335µs | my $package_name = $options->{package}; | ||
| 78 | 98 | 222µs | (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 | 98 | 985µs | 98 | 793µs | if (defined(my $meta = Class::MOP::get_metaclass_by_name($package_name))) { # spent 793µs making 98 calls to Class::MOP::get_metaclass_by_name, avg 8µs/call |
| 87 | return $meta; | ||||
| 88 | } | ||||
| 89 | |||||
| 90 | $class | ||||
| 91 | 98 | 290µs | 8 | 840µs | = ref $class # spent 840µs making 8 calls to Class::MOP::Class::_real_ref_name, avg 105µs/call |
| 92 | ? $class->_real_ref_name | ||||
| 93 | : $class; | ||||
| 94 | |||||
| 95 | # now create the metaclass | ||||
| 96 | 98 | 188µs | my $meta; | ||
| 97 | 98 | 1.18ms | 64 | 4.05ms | if ($class eq 'Class::MOP::Class') { # spent 4.05ms making 64 calls to Class::MOP::Class::_new, avg 63µ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 | 34 | 832µs | 68 | 120ms | $meta = $class->meta->_construct_instance($options) # spent 117ms making 34 calls to Class::MOP::Class::_construct_instance, avg 3.44ms/call
# spent 2.81ms making 34 calls to Class::MOP::Object::meta, avg 83µs/call |
| 106 | } | ||||
| 107 | |||||
| 108 | # and check the metaclass compatibility | ||||
| 109 | 98 | 1.57ms | 98 | 77.6ms | $meta->_check_metaclass_compatibility(); # spent 81.3ms making 98 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 829µs/call, recursion: max depth 1, sum of overlapping time 3.70ms |
| 110 | |||||
| 111 | 98 | 1.15ms | 98 | 1.33ms | Class::MOP::store_metaclass_by_name($package_name, $meta); # spent 1.33ms making 98 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 | 98 | 341µs | Class::MOP::weaken_metaclass($package_name) if $options->{weaken}; | ||
| 117 | |||||
| 118 | 98 | 1.45ms | $meta; | ||
| 119 | } | ||||
| 120 | |||||
| 121 | # spent 7.06ms (3.79+3.27) within Class::MOP::Class::_real_ref_name which was called 131 times, avg 54µs/call:
# 82 times (2.33ms+1.84ms) by Class::MOP::Class::_class_metaclass_can_be_made_compatible at line 343, avg 51µs/call
# 39 times (1.13ms+803µs) by Class::MOP::Class::_class_metaclass_is_compatible at line 253, avg 50µs/call
# 8 times (270µs+570µs) by Class::MOP::Class::_construct_class_instance at line 91, avg 105µs/call
# 2 times (61µs+64µs) by Class::MOP::Class::_immutable_metaclass at line 1385, avg 62µs/call | ||||
| 122 | 131 | 362µs | 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 | 131 | 3.23ms | 171 | 3.27ms | return $self->is_immutable # spent 1.91ms making 38 calls to Class::MOP::Class::Immutable::Class::MOP::Class::is_immutable, avg 50µs/call
# spent 708µs making 91 calls to Class::MOP::Class::is_immutable, avg 8µs/call
# spent 546µs making 40 calls to Class::MOP::Class::Immutable::Trait::_get_mutable_metaclass_name, avg 14µs/call
# spent 104µs making 2 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::is_immutable, avg 52µs/call |
| 127 | ? $self->_get_mutable_metaclass_name() | ||||
| 128 | : ref $self; | ||||
| 129 | } | ||||
| 130 | |||||
| 131 | # spent 4.05ms within Class::MOP::Class::_new which was called 64 times, avg 63µs/call:
# 64 times (4.05ms+0s) by Class::MOP::Class::_construct_class_instance at line 97, avg 63µs/call | ||||
| 132 | 64 | 259µs | my $class = shift; | ||
| 133 | |||||
| 134 | 64 | 165µs | return Class::MOP::Class->initialize($class)->new_object(@_) | ||
| 135 | if $class ne __PACKAGE__; | ||||
| 136 | |||||
| 137 | 64 | 226µs | my $options = @_ == 1 ? $_[0] : {@_}; | ||
| 138 | |||||
| 139 | 64 | 3.64ms | 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 | 150 | 3.37ms | # spent 2.73ms within Class::MOP::Class::_base_metaclasses which was called 150 times, avg 18µs/call:
# 73 times (1.38ms+0s) by Moose::Meta::Class::_base_metaclasses at line 538 of Moose/Meta/Class.pm, avg 19µs/call
# 43 times (827µs+0s) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 331, avg 19µs/call
# 34 times (527µs+0s) by Class::MOP::Class::_check_metaclass_compatibility at line 206, avg 15µs/call | ||
| 196 | } | ||||
| 197 | |||||
| 198 | # spent 240ms (19.0+221) within Class::MOP::Class::_check_metaclass_compatibility which was called 134 times, avg 1.79ms/call:
# 98 times (4.95ms+72.6ms) by Class::MOP::Class::_construct_class_instance at line 109, avg 791µs/call
# 36 times (14.1ms+148ms) by Class::MOP::Class::superclasses at line 998, avg 4.51ms/call | ||||
| 199 | 134 | 457µs | my $self = shift; | ||
| 200 | |||||
| 201 | 134 | 2.44ms | 134 | 21.1ms | my @superclasses = $self->superclasses # spent 11.2ms making 66 calls to Class::MOP::Class::superclasses, avg 169µs/call, recursion: max depth 1, sum of overlapping time 314µs
# spent 16.4ms making 68 calls to Moose::Meta::Class::superclasses, avg 241µs/call, recursion: max depth 1, sum of overlapping time 6.16ms |
| 202 | or return; | ||||
| 203 | |||||
| 204 | 68 | 863µs | 68 | 119ms | $self->_fix_metaclass_incompatibility(@superclasses); # spent 122ms making 68 calls to Class::MOP::Class::_fix_metaclass_incompatibility, avg 1.79ms/call, recursion: max depth 1, sum of overlapping time 2.92ms |
| 205 | |||||
| 206 | 68 | 1.61ms | 68 | 8.13ms | my %base_metaclass = $self->_base_metaclasses; # spent 7.60ms making 34 calls to Moose::Meta::Class::_base_metaclasses, avg 224µs/call
# spent 527µs making 34 calls to Class::MOP::Class::_base_metaclasses, avg 15µs/call |
| 207 | |||||
| 208 | # this is always okay ... | ||||
| 209 | return | ||||
| 210 | if ref($self) eq 'Class::MOP::Class' | ||||
| 211 | && all { | ||||
| 212 | 204 | 3.52ms | 204 | 1.07ms | my $meta = $self->$_; # spent 196µs making 34 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 6µs/call
# spent 178µs making 34 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call
# spent 177µs making 34 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call
# spent 175µs making 34 calls to Class::MOP::Class::destructor_class, avg 5µs/call
# spent 174µs making 34 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call
# spent 167µs making 34 calls to Class::MOP::Class::constructor_class, avg 5µs/call |
| 213 | 204 | 1.89ms | !defined($meta) || $meta eq $base_metaclass{$_}; | ||
| 214 | } | ||||
| 215 | 68 | 1.08ms | 34 | 5.09ms | keys %base_metaclass; # spent 5.09ms making 34 calls to List::MoreUtils::all, avg 150µs/call |
| 216 | |||||
| 217 | 34 | 207µs | for my $superclass (@superclasses) { | ||
| 218 | 39 | 647µs | 39 | 6.98ms | $self->_check_class_metaclass_compatibility($superclass); # spent 6.98ms making 39 calls to Class::MOP::Class::_check_class_metaclass_compatibility, avg 179µs/call |
| 219 | } | ||||
| 220 | |||||
| 221 | 34 | 907µs | for my $metaclass_type ( keys %base_metaclass ) { | ||
| 222 | 238 | 3.96ms | 238 | 2.38ms | next unless defined $self->$metaclass_type; # spent 512µs making 34 calls to Moose::Meta::Class::error_class, avg 15µs/call
# spent 502µs making 34 calls to Moose::Meta::Class::constructor_class, avg 15µs/call
# spent 489µs making 34 calls to Moose::Meta::Class::destructor_class, avg 14µs/call
# spent 245µs making 34 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 7µs/call
# spent 217µs making 34 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 6µs/call
# spent 211µs making 34 calls to Class::MOP::Class::instance_metaclass, avg 6µs/call
# spent 207µs making 34 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 6µs/call |
| 223 | 238 | 1.80ms | for my $superclass (@superclasses) { | ||
| 224 | 273 | 4.16ms | 273 | 52.4ms | $self->_check_single_metaclass_compatibility( $metaclass_type, # spent 52.4ms making 273 calls to Class::MOP::Class::_check_single_metaclass_compatibility, avg 192µs/call |
| 225 | $superclass ); | ||||
| 226 | } | ||||
| 227 | } | ||||
| 228 | } | ||||
| 229 | |||||
| 230 | # spent 6.98ms (1.10+5.89) within Class::MOP::Class::_check_class_metaclass_compatibility which was called 39 times, avg 179µs/call:
# 39 times (1.10ms+5.89ms) by Class::MOP::Class::_check_metaclass_compatibility at line 218, avg 179µs/call | ||||
| 231 | 39 | 126µs | my $self = shift; | ||
| 232 | 39 | 150µs | my ( $superclass_name ) = @_; | ||
| 233 | |||||
| 234 | 39 | 751µs | 39 | 5.89ms | if (!$self->_class_metaclass_is_compatible($superclass_name)) { # spent 5.89ms making 39 calls to Class::MOP::Class::_class_metaclass_is_compatible, avg 151µ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 5.89ms (2.27+3.62) within Class::MOP::Class::_class_metaclass_is_compatible which was called 39 times, avg 151µs/call:
# 39 times (2.27ms+3.62ms) by Class::MOP::Class::_check_class_metaclass_compatibility at line 234, avg 151µs/call | ||||
| 247 | 39 | 106µs | my $self = shift; | ||
| 248 | 39 | 120µs | my ( $superclass_name ) = @_; | ||
| 249 | |||||
| 250 | 39 | 442µs | 39 | 415µs | my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name) # spent 415µs making 39 calls to Class::MOP::get_metaclass_by_name, avg 11µs/call |
| 251 | || return 1; | ||||
| 252 | |||||
| 253 | 39 | 505µs | 39 | 1.93ms | my $super_meta_name = $super_meta->_real_ref_name; # spent 1.93ms making 39 calls to Class::MOP::Class::_real_ref_name, avg 50µs/call |
| 254 | |||||
| 255 | 39 | 797µs | 39 | 1.28ms | return $self->_is_compatible_with($super_meta_name); # spent 1.28ms making 39 calls to Class::MOP::Object::_is_compatible_with, avg 33µs/call |
| 256 | } | ||||
| 257 | |||||
| 258 | # spent 52.4ms (7.30+45.1) within Class::MOP::Class::_check_single_metaclass_compatibility which was called 273 times, avg 192µs/call:
# 273 times (7.30ms+45.1ms) by Class::MOP::Class::_check_metaclass_compatibility at line 224, avg 192µs/call | ||||
| 259 | 273 | 792µs | my $self = shift; | ||
| 260 | 273 | 1.06ms | my ( $metaclass_type, $superclass_name ) = @_; | ||
| 261 | |||||
| 262 | 273 | 4.96ms | 273 | 45.1ms | if (!$self->_single_metaclass_is_compatible($metaclass_type, $superclass_name)) { # spent 45.1ms making 273 calls to Class::MOP::Class::_single_metaclass_is_compatible, avg 165µ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 45.1ms (24.9+20.1) within Class::MOP::Class::_single_metaclass_is_compatible which was called 273 times, avg 165µs/call:
# 273 times (24.9ms+20.1ms) by Class::MOP::Class::_check_single_metaclass_compatibility at line 262, avg 165µs/call | ||||
| 277 | 273 | 684µs | my $self = shift; | ||
| 278 | 273 | 891µs | my ( $metaclass_type, $superclass_name ) = @_; | ||
| 279 | |||||
| 280 | 273 | 2.60ms | 273 | 2.31ms | my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name) # spent 2.31ms making 273 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 | 273 | 4.85ms | 273 | 1.68ms | return 1 unless $super_meta->can($metaclass_type); # spent 1.68ms making 273 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 | 260 | 3.98ms | 260 | 1.95ms | return 1 unless defined $super_meta->$metaclass_type; # spent 332µs making 26 calls to Moose::Meta::Class::error_class, avg 13µs/call
# spent 325µs making 26 calls to Moose::Meta::Class::constructor_class, avg 12µs/call
# spent 319µs making 26 calls to Moose::Meta::Class::destructor_class, avg 12µs/call
# spent 217µs making 39 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 6µs/call
# spent 208µs making 39 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call
# spent 208µs making 39 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call
# spent 206µs making 39 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call
# spent 69µs making 13 calls to Class::MOP::Class::destructor_class, avg 5µs/call
# spent 69µs making 13 calls to Class::MOP::Class::constructor_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 | 247 | 3.57ms | 247 | 1.85ms | return 0 unless defined $self->$metaclass_type; # spent 454µs making 39 calls to Moose::Meta::Class::constructor_class, avg 12µs/call
# spent 314µs making 26 calls to Moose::Meta::Class::error_class, avg 12µs/call
# spent 306µs making 26 calls to Moose::Meta::Class::destructor_class, avg 12µs/call
# spent 198µs making 39 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 5µs/call
# spent 197µs making 39 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call
# spent 193µs making 39 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call
# spent 193µs making 39 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call |
| 292 | |||||
| 293 | 247 | 11.4ms | 741 | 12.3ms | return $self->$metaclass_type->_is_compatible_with($super_meta->$metaclass_type); # spent 8.68ms making 247 calls to Class::MOP::Object::_is_compatible_with, avg 35µs/call
# spent 826µs making 65 calls to Moose::Meta::Class::constructor_class, avg 13µs/call
# spent 633µs making 52 calls to Moose::Meta::Class::error_class, avg 12µs/call
# spent 614µs making 52 calls to Moose::Meta::Class::destructor_class, avg 12µs/call
# spent 424µs making 78 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call
# spent 370µs making 78 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 5µs/call
# spent 364µs making 78 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call
# spent 358µs making 78 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call
# spent 67µs making 13 calls to Class::MOP::Class::constructor_class, avg 5µs/call |
| 294 | } | ||||
| 295 | |||||
| 296 | # spent 119ms (4.81+114) within Class::MOP::Class::_fix_metaclass_incompatibility which was called 68 times, avg 1.75ms/call:
# 68 times (4.81ms+114ms) by Class::MOP::Class::_check_metaclass_compatibility at line 204, avg 1.75ms/call | ||||
| 297 | 68 | 208µs | my $self = shift; | ||
| 298 | 150 | 1.53ms | 82 | 5.55ms | my @supers = map { Class::MOP::Class->initialize($_) } @_; # spent 7.93ms making 82 calls to Class::MOP::Class::initialize, avg 97µs/call, recursion: max depth 1, sum of overlapping time 2.38ms |
| 299 | |||||
| 300 | 68 | 158µs | my $necessary = 0; | ||
| 301 | 68 | 391µs | for my $super (@supers) { | ||
| 302 | 82 | 1.35ms | 82 | 109ms | $necessary = 1 # spent 109ms making 82 calls to Class::MOP::Class::_can_fix_metaclass_incompatibility, avg 1.33ms/call |
| 303 | if $self->_can_fix_metaclass_incompatibility($super); | ||||
| 304 | } | ||||
| 305 | 68 | 790µs | 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 109ms (14.3+95.0) within Class::MOP::Class::_can_fix_metaclass_incompatibility which was called 82 times, avg 1.33ms/call:
# 82 times (14.3ms+95.0ms) by Class::MOP::Class::_fix_metaclass_incompatibility at line 302, avg 1.33ms/call | ||||
| 326 | 82 | 256µs | my $self = shift; | ||
| 327 | 82 | 217µs | my ($super_meta) = @_; | ||
| 328 | |||||
| 329 | 82 | 901µs | 82 | 12.3ms | return 1 if $self->_class_metaclass_can_be_made_compatible($super_meta); # spent 12.3ms making 82 calls to Class::MOP::Class::_class_metaclass_can_be_made_compatible, avg 150µs/call |
| 330 | |||||
| 331 | 82 | 1.92ms | 82 | 9.82ms | my %base_metaclass = $self->_base_metaclasses; # spent 9.00ms making 39 calls to Moose::Meta::Class::_base_metaclasses, avg 231µs/call
# spent 827µs making 43 calls to Class::MOP::Class::_base_metaclasses, avg 19µs/call |
| 332 | 82 | 862µs | for my $metaclass_type (keys %base_metaclass) { | ||
| 333 | 531 | 7.34ms | 531 | 72.8ms | return 1 if $self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type); # spent 72.8ms making 531 calls to Class::MOP::Class::_single_metaclass_can_be_made_compatible, avg 137µs/call |
| 334 | } | ||||
| 335 | |||||
| 336 | 82 | 1.27ms | return; | ||
| 337 | } | ||||
| 338 | |||||
| 339 | # spent 12.3ms (3.02+9.28) within Class::MOP::Class::_class_metaclass_can_be_made_compatible which was called 82 times, avg 150µs/call:
# 82 times (3.02ms+9.28ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 329, avg 150µs/call | ||||
| 340 | 82 | 202µs | my $self = shift; | ||
| 341 | 82 | 199µs | my ($super_meta) = @_; | ||
| 342 | |||||
| 343 | 82 | 2.47ms | 164 | 9.28ms | return $self->_can_be_made_compatible_with($super_meta->_real_ref_name); # spent 5.12ms making 82 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 62µs/call
# spent 4.16ms making 82 calls to Class::MOP::Class::_real_ref_name, avg 51µs/call |
| 344 | } | ||||
| 345 | |||||
| 346 | # spent 72.8ms (36.6+36.2) within Class::MOP::Class::_single_metaclass_can_be_made_compatible which was called 531 times, avg 137µs/call:
# 531 times (36.6ms+36.2ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 333, avg 137µs/call | ||||
| 347 | 531 | 1.43ms | my $self = shift; | ||
| 348 | 531 | 1.80ms | my ($super_meta, $metaclass_type) = @_; | ||
| 349 | |||||
| 350 | 531 | 10.1ms | 531 | 4.17ms | my $specific_meta = $self->$metaclass_type; # spent 589µs making 39 calls to Moose::Meta::Class::error_class, avg 15µs/call
# spent 560µs making 39 calls to Moose::Meta::Class::constructor_class, avg 14µs/call
# spent 555µs making 39 calls to Moose::Meta::Class::destructor_class, avg 14µs/call
# spent 536µs making 82 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 7µs/call
# spent 534µs making 82 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 7µs/call
# spent 504µs making 82 calls to Class::MOP::Class::instance_metaclass, avg 6µs/call
# spent 471µs making 82 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 6µs/call
# spent 215µs making 43 calls to Class::MOP::Class::constructor_class, avg 5µs/call
# spent 203µs making 43 calls to Class::MOP::Class::destructor_class, avg 5µs/call |
| 351 | |||||
| 352 | 531 | 9.77ms | 531 | 3.43ms | return unless $super_meta->can($metaclass_type); # spent 3.43ms making 531 calls to UNIVERSAL::can, avg 6µs/call |
| 353 | 518 | 8.64ms | 518 | 3.26ms | my $super_specific_meta = $super_meta->$metaclass_type; # spent 474µs making 82 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 6µs/call
# spent 439µs making 82 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call
# spent 421µs making 82 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call
# spent 410µs making 82 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call
# spent 323µs making 26 calls to Moose::Meta::Class::destructor_class, avg 12µs/call
# spent 322µs making 26 calls to Moose::Meta::Class::error_class, avg 12µs/call
# spent 309µs making 26 calls to Moose::Meta::Class::constructor_class, avg 12µs/call
# spent 280µs making 56 calls to Class::MOP::Class::constructor_class, avg 5µs/call
# spent 278µs making 56 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 | 518 | 1.54ms | 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 | 462 | 777µs | return 1 unless defined $specific_meta; | ||
| 362 | |||||
| 363 | 462 | 10.1ms | 462 | 25.4ms | return 1 if $specific_meta->_can_be_made_compatible_with($super_specific_meta); # spent 25.4ms making 462 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 55µ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 | sub _restore_metaobjects_from { | ||||
| 400 | my $self = shift; | ||||
| 401 | my ($old_meta) = @_; | ||||
| 402 | |||||
| 403 | $self->_restore_metamethods_from($old_meta); | ||||
| 404 | $self->_restore_metaattributes_from($old_meta); | ||||
| 405 | } | ||||
| 406 | |||||
| 407 | sub _remove_generated_metaobjects { | ||||
| 408 | my $self = shift; | ||||
| 409 | |||||
| 410 | for my $attr (map { $self->get_attribute($_) } $self->get_attribute_list) { | ||||
| 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 | sub is_anon_class { | ||||
| 432 | my $self = shift; | ||||
| 433 | 3 | 460µs | 2 | 207µs | # spent 132µs (56+75) within Class::MOP::Class::BEGIN@433 which was called:
# once (56µs+75µs) by Class::MOP::BEGIN@19 at line 433 # spent 132µs making 1 call to Class::MOP::Class::BEGIN@433
# spent 75µs making 1 call to warnings::unimport |
| 434 | $self->name =~ /^$ANON_CLASS_PREFIX/o; | ||||
| 435 | } | ||||
| 436 | |||||
| 437 | # spent 381ms (387µs+381) within Class::MOP::Class::create_anon_class which was called 8 times, avg 47.7ms/call:
# 8 times (387µs+381ms) by Moose::Meta::Class::create_anon_class at line 111 of Moose/Meta/Class.pm, avg 47.7ms/call | ||||
| 438 | 8 | 78µs | my ($class, %options) = @_; | ||
| 439 | 8 | 22µs | $options{weaken} = 1 unless exists $options{weaken}; | ||
| 440 | 8 | 47µs | my $package_name = $ANON_CLASS_PREFIX . ++$ANON_CLASS_SERIAL; | ||
| 441 | 8 | 222µs | 8 | 381ms | return $class->create($package_name, %options); # spent 381ms making 8 calls to Moose::Meta::Class::create, avg 47.6ms/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 | sub DESTROY { | ||||
| 451 | my $self = shift; | ||||
| 452 | |||||
| 453 | return if in_global_destruction(); # it'll happen soon anyway and this just makes things more complicated | ||||
| 454 | |||||
| 455 | 3 | 264µs | 2 | 163µs | # spent 102µs (42+61) within Class::MOP::Class::BEGIN@455 which was called:
# once (42µs+61µs) by Class::MOP::BEGIN@19 at line 455 # spent 102µs making 1 call to Class::MOP::Class::BEGIN@455
# spent 61µs making 1 call to warnings::unimport |
| 456 | my $name = $self->name; | ||||
| 457 | return unless $name =~ /^$ANON_CLASS_PREFIX/o; | ||||
| 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.4ms | 2 | 170µs | # spent 106µs (42+64) within Class::MOP::Class::BEGIN@468 which was called:
# once (42µs+64µs) by Class::MOP::BEGIN@19 at line 468 # spent 106µs making 1 call to Class::MOP::Class::BEGIN@468
# spent 64µ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 125ms (1.69+123) within Class::MOP::Class::create which was called 10 times, avg 12.5ms/call:
# 8 times (1.35ms+113ms) by Moose::Meta::Class::create at line 85 of Moose/Meta/Class.pm, avg 14.3ms/call
# 2 times (339µs+10.3ms) by Class::MOP::Class::_immutable_metaclass at line 1387, avg 5.33ms/call | ||||
| 481 | 10 | 80µs | my ( $class, @args ) = @_; | ||
| 482 | |||||
| 483 | 10 | 76µs | unshift @args, 'package' if @args % 2 == 1; | ||
| 484 | |||||
| 485 | 10 | 93µs | my (%options) = @args; | ||
| 486 | 10 | 33µs | my $package_name = $options{package}; | ||
| 487 | |||||
| 488 | 10 | 48µs | (ref $options{superclasses} eq 'ARRAY') | ||
| 489 | || confess "You must pass an ARRAY ref of superclasses" | ||||
| 490 | if exists $options{superclasses}; | ||||
| 491 | |||||
| 492 | 10 | 24µs | (ref $options{attributes} eq 'ARRAY') | ||
| 493 | || confess "You must pass an ARRAY ref of attributes" | ||||
| 494 | if exists $options{attributes}; | ||||
| 495 | |||||
| 496 | 10 | 25µs | (ref $options{methods} eq 'HASH') | ||
| 497 | || confess "You must pass a HASH ref of methods" | ||||
| 498 | if exists $options{methods}; | ||||
| 499 | |||||
| 500 | 10 | 49µs | $options{meta_name} = 'meta' | ||
| 501 | unless exists $options{meta_name}; | ||||
| 502 | |||||
| 503 | 10 | 60µs | my (%initialize_options) = @args; | ||
| 504 | 10 | 59µs | delete @initialize_options{qw( | ||
| 505 | package | ||||
| 506 | superclasses | ||||
| 507 | attributes | ||||
| 508 | methods | ||||
| 509 | meta_name | ||||
| 510 | version | ||||
| 511 | authority | ||||
| 512 | )}; | ||||
| 513 | 10 | 157µs | 10 | 32.4ms | my $meta = $class->initialize( $package_name => %initialize_options ); # spent 31.4ms making 8 calls to Moose::Meta::Class::initialize, avg 3.93ms/call
# spent 953µs making 2 calls to Class::MOP::Class::initialize, avg 476µs/call |
| 514 | |||||
| 515 | 10 | 224µs | 10 | 1.19ms | $meta->_instantiate_module( $options{version}, $options{authority} ); # spent 1.19ms making 10 calls to Class::MOP::Module::_instantiate_module, avg 119µs/call |
| 516 | |||||
| 517 | 10 | 192µs | 10 | 26.9ms | $meta->_add_meta_method($options{meta_name}) # spent 26.9ms making 10 calls to Class::MOP::Mixin::HasMethods::_add_meta_method, avg 2.69ms/call |
| 518 | if defined $options{meta_name}; | ||||
| 519 | |||||
| 520 | 10 | 192µs | 10 | 62.7ms | $meta->superclasses(@{$options{superclasses}}) # spent 58.4ms making 8 calls to Moose::Meta::Class::superclasses, avg 7.30ms/call
# spent 4.32ms making 2 calls to Class::MOP::Class::superclasses, avg 2.16ms/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 | 10 | 37µs | if (exists $options{attributes}) { | ||
| 528 | foreach my $attr (@{$options{attributes}}) { | ||||
| 529 | $meta->add_attribute($attr); | ||||
| 530 | } | ||||
| 531 | } | ||||
| 532 | 10 | 24µs | 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 | 10 | 217µs | return $meta; | ||
| 538 | } | ||||
| 539 | |||||
| 540 | # Instance Construction & Cloning | ||||
| 541 | |||||
| 542 | # spent 152ms (5.22+147) within Class::MOP::Class::new_object which was called 104 times, avg 1.46ms/call:
# 68 times (3.36ms+84.5ms) by Moose::Meta::Method::_new at line 4 of generated method (unknown origin), avg 1.29ms/call
# 26 times (1.32ms+30.9ms) by Class::MOP::Method::_new at line 54 of Class/MOP/Method.pm, avg 1.24ms/call
# 6 times (309µs+23.5ms) by Moose::Meta::Class::new_object at line 256 of Moose/Meta/Class.pm, avg 3.96ms/call
# 2 times (112µs+2.75ms) by Moose::Meta::TypeCoercion::new at line 34 of Moose/Meta/TypeCoercion.pm, avg 1.43ms/call
# once (65µs+4.05ms) by Class::MOP::Attribute::_new at line 62 of Class/MOP/Attribute.pm
# once (61µs+1.38ms) by Class::MOP::Object::_new at line 22 of Class/MOP/Object.pm | ||||
| 543 | 104 | 391µs | 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 | 104 | 4.81ms | 208 | 2.18ms | return $class->_construct_class_instance(@_) # spent 1.58ms making 104 calls to UNIVERSAL::isa, avg 15µs/call
# spent 605µs making 104 calls to Class::MOP::Package::name, avg 6µs/call |
| 551 | if $class->name->isa('Class::MOP::Class'); | ||||
| 552 | 104 | 2.26ms | 104 | 145ms | return $class->_construct_instance(@_); # spent 145ms making 104 calls to Class::MOP::Class::_construct_instance, avg 1.39ms/call |
| 553 | } | ||||
| 554 | |||||
| 555 | # spent 262ms (35.3+226) within Class::MOP::Class::_construct_instance which was called 138 times, avg 1.90ms/call:
# 104 times (22.0ms+123ms) by Class::MOP::Class::new_object at line 552, avg 1.39ms/call
# 34 times (13.3ms+104ms) by Class::MOP::Class::_construct_class_instance at line 105, avg 3.44ms/call | ||||
| 556 | 138 | 422µs | my $class = shift; | ||
| 557 | 138 | 490µs | my $params = @_ == 1 ? $_[0] : {@_}; | ||
| 558 | 138 | 1.56ms | 138 | 14.0ms | my $meta_instance = $class->get_meta_instance(); # spent 10.7ms making 83 calls to Class::MOP::Class::get_meta_instance, avg 128µs/call
# spent 3.35ms making 55 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 61µ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 | 138 | 248µs | my $instance; | ||
| 564 | 138 | 4.26ms | 138 | 992µs | if (my $instance_class = blessed($params->{__INSTANCE__})) { # spent 992µs making 138 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 | 138 | 1.80ms | 138 | 11.0ms | $instance = $meta_instance->create_instance(); # spent 11.0ms making 138 calls to Class::MOP::Instance::create_instance, avg 80µs/call |
| 577 | } | ||||
| 578 | 138 | 2.44ms | 138 | 44.1ms | foreach my $attr ($class->get_all_attributes()) { # spent 39.4ms making 83 calls to Class::MOP::Class::get_all_attributes, avg 474µs/call
# spent 4.73ms making 55 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 86µs/call |
| 579 | 1278 | 17.4ms | 1278 | 152ms | $attr->initialize_instance_slot($meta_instance, $instance, $params); # spent 144ms making 1264 calls to Class::MOP::Attribute::initialize_instance_slot, avg 114µs/call
# spent 7.71ms making 14 calls to Moose::Meta::Attribute::initialize_instance_slot, avg 551µs/call |
| 580 | } | ||||
| 581 | 138 | 3.83ms | 276 | 4.40ms | if (Class::MOP::metaclass_is_weak($class->name)) { # spent 3.52ms making 138 calls to Class::MOP::metaclass_is_weak, avg 26µs/call
# spent 877µs making 138 calls to Class::MOP::Package::name, avg 6µs/call |
| 582 | $meta_instance->_set_mop_slot($instance, $class); | ||||
| 583 | } | ||||
| 584 | 138 | 1.73ms | return $instance; | ||
| 585 | } | ||||
| 586 | |||||
| 587 | # spent 396ms (4.81+391) within Class::MOP::Class::_inline_new_object which was called 55 times, avg 7.20ms/call:
# 55 times (4.81ms+391ms) by Class::MOP::Method::Constructor::_generate_constructor_method_inline at line 112 of Class/MOP/Method/Constructor.pm, avg 7.20ms/call | ||||
| 588 | 55 | 149µs | my $self = shift; | ||
| 589 | |||||
| 590 | return ( | ||||
| 591 | 55 | 4.21ms | 330 | 391ms | 'my $class = shift;', # spent 317ms making 55 calls to Class::MOP::Class::_inline_slot_initializers, avg 5.77ms/call
# spent 36.0ms making 24 calls to Moose::Meta::Class::_inline_extra_init, avg 1.50ms/call
# spent 15.5ms making 24 calls to Moose::Meta::Class::_inline_params, avg 645µs/call
# spent 14.1ms making 55 calls to Class::MOP::Class::_inline_generate_instance, avg 256µs/call
# spent 3.80ms making 55 calls to Class::MOP::Class::_inline_preserve_weak_metaclasses, avg 69µs/call
# spent 3.59ms making 55 calls to Class::MOP::Class::_inline_fallback_constructor, avg 65µs/call
# spent 577µs making 31 calls to Class::MOP::Class::_inline_params, avg 19µs/call
# spent 220µs making 31 calls to Class::MOP::Class::_inline_extra_init, avg 7µ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 3.59ms (2.37+1.22) within Class::MOP::Class::_inline_fallback_constructor which was called 55 times, avg 65µs/call:
# 55 times (2.37ms+1.22ms) by Class::MOP::Class::_inline_new_object at line 591, avg 65µs/call | ||||
| 604 | 55 | 143µs | my $self = shift; | ||
| 605 | 55 | 206µs | my ($class) = @_; | ||
| 606 | return ( | ||||
| 607 | 55 | 2.17ms | 110 | 1.22ms | 'return ' . $self->_generate_fallback_constructor($class), # spent 505µs making 31 calls to Class::MOP::Class::_generate_fallback_constructor, avg 16µs/call
# spent 418µs making 24 calls to Moose::Meta::Class::_generate_fallback_constructor, avg 17µs/call
# spent 297µs making 55 calls to Class::MOP::Package::name, avg 5µs/call |
| 608 | 'if ' . $class . ' ne \'' . $self->name . '\';', | ||||
| 609 | ); | ||||
| 610 | } | ||||
| 611 | |||||
| 612 | # spent 505µs within Class::MOP::Class::_generate_fallback_constructor which was called 31 times, avg 16µs/call:
# 31 times (505µs+0s) by Class::MOP::Class::_inline_fallback_constructor at line 607, avg 16µs/call | ||||
| 613 | 31 | 80µs | my $self = shift; | ||
| 614 | 31 | 94µs | my ($class) = @_; | ||
| 615 | 31 | 480µs | return 'Class::MOP::Class->initialize(' . $class . ')->new_object(@_)', | ||
| 616 | } | ||||
| 617 | |||||
| 618 | # spent 577µs within Class::MOP::Class::_inline_params which was called 31 times, avg 19µs/call:
# 31 times (577µs+0s) by Class::MOP::Class::_inline_new_object at line 591, avg 19µs/call | ||||
| 619 | 31 | 98µs | my $self = shift; | ||
| 620 | 31 | 117µs | my ($params, $class) = @_; | ||
| 621 | return ( | ||||
| 622 | 31 | 449µs | 'my ' . $params . ' = @_ == 1 ? $_[0] : {@_};', | ||
| 623 | ); | ||||
| 624 | } | ||||
| 625 | |||||
| 626 | # spent 14.1ms (1.81+12.3) within Class::MOP::Class::_inline_generate_instance which was called 55 times, avg 256µs/call:
# 55 times (1.81ms+12.3ms) by Class::MOP::Class::_inline_new_object at line 591, avg 256µs/call | ||||
| 627 | 55 | 172µs | my $self = shift; | ||
| 628 | 55 | 202µs | my ($inst, $class) = @_; | ||
| 629 | return ( | ||||
| 630 | 55 | 1.22ms | 55 | 12.3ms | 'my ' . $inst . ' = ' . $self->_inline_create_instance($class) . ';', # spent 12.3ms making 55 calls to Class::MOP::Class::_inline_create_instance, avg 223µs/call |
| 631 | ); | ||||
| 632 | } | ||||
| 633 | |||||
| 634 | # spent 12.3ms (2.10+10.2) within Class::MOP::Class::_inline_create_instance which was called 55 times, avg 223µs/call:
# 55 times (2.10ms+10.2ms) by Class::MOP::Class::_inline_generate_instance at line 630, avg 223µs/call | ||||
| 635 | 55 | 148µs | my $self = shift; | ||
| 636 | |||||
| 637 | 55 | 1.87ms | 110 | 10.2ms | return $self->get_meta_instance->inline_create_instance(@_); # spent 9.36ms making 55 calls to Class::MOP::Class::get_meta_instance, avg 170µs/call
# spent 829µs making 55 calls to Class::MOP::Instance::inline_create_instance, avg 15µs/call |
| 638 | } | ||||
| 639 | |||||
| 640 | # spent 317ms (8.51+309) within Class::MOP::Class::_inline_slot_initializers which was called 55 times, avg 5.77ms/call:
# 55 times (8.51ms+309ms) by Class::MOP::Class::_inline_new_object at line 591, avg 5.77ms/call | ||||
| 641 | 55 | 155µs | my $self = shift; | ||
| 642 | |||||
| 643 | 55 | 127µs | my $idx = 0; | ||
| 644 | |||||
| 645 | 1235 | 27.3ms | 2092 | 275ms | return map { $self->_inline_slot_initializer($_, $idx++) } # spent 138ms making 267 calls to Class::MOP::Class::_inline_slot_initializer, avg 517µs/call
# spent 130ms making 111 calls to Moose::Meta::Class::_inline_slot_initializer, avg 1.17ms/call
# spent 7.19ms making 1714 calls to Class::MOP::Mixin::AttributeCore::name, avg 4µs/call |
| 646 | 55 | 2.86ms | 110 | 40.9ms | sort { $a->name cmp $b->name } $self->get_all_attributes; # spent 23.0ms making 55 calls to Class::MOP::Class::CORE:sort, avg 418µs/call
# spent 17.9ms making 55 calls to Class::MOP::Class::get_all_attributes, avg 325µs/call |
| 647 | } | ||||
| 648 | |||||
| 649 | # spent 249ms (25.7+224) within Class::MOP::Class::_inline_slot_initializer which was called 378 times, avg 660µs/call:
# 267 times (16.7ms+121ms) by Class::MOP::Class::_inline_slot_initializers at line 645, avg 517µs/call
# 111 times (8.95ms+102ms) by Moose::Meta::Class::_inline_slot_initializer at line 344 of Moose/Meta/Class.pm, avg 1.00ms/call | ||||
| 650 | 378 | 1.05ms | my $self = shift; | ||
| 651 | 378 | 1.07ms | my ($attr, $idx) = @_; | ||
| 652 | |||||
| 653 | 378 | 7.28ms | 395 | 10.8ms | if (defined(my $init_arg = $attr->init_arg)) { # spent 4.91ms making 11 calls to Class::MOP::Class::_inline_init_attr_from_default, avg 447µs/call
# spent 3.88ms making 6 calls to Moose::Meta::Class::_inline_init_attr_from_default, avg 647µs/call
# spent 1.97ms making 378 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 5µs/call |
| 654 | 361 | 5.90ms | 361 | 140ms | my @source = ( # spent 76.9ms making 256 calls to Class::MOP::Class::_inline_init_attr_from_constructor, avg 300µs/call
# spent 62.8ms making 105 calls to Moose::Meta::Class::_inline_init_attr_from_constructor, avg 598µs/call |
| 655 | 'if (exists $params->{\'' . $init_arg . '\'}) {', | ||||
| 656 | $self->_inline_init_attr_from_constructor($attr, $idx), | ||||
| 657 | '}', | ||||
| 658 | ); | ||||
| 659 | 361 | 5.03ms | 361 | 73.3ms | if (my @default = $self->_inline_init_attr_from_default($attr, $idx)) { # spent 38.2ms making 256 calls to Class::MOP::Class::_inline_init_attr_from_default, avg 149µs/call
# spent 35.1ms making 105 calls to Moose::Meta::Class::_inline_init_attr_from_default, avg 335µs/call |
| 660 | push @source, ( | ||||
| 661 | 'else {', | ||||
| 662 | @default, | ||||
| 663 | '}', | ||||
| 664 | ); | ||||
| 665 | } | ||||
| 666 | 361 | 6.49ms | 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 | 1 | 11µs | return (); | ||
| 677 | } | ||||
| 678 | } | ||||
| 679 | |||||
| 680 | # spent 76.9ms (14.4+62.5) within Class::MOP::Class::_inline_init_attr_from_constructor which was called 256 times, avg 300µs/call:
# 256 times (14.4ms+62.5ms) by Class::MOP::Class::_inline_slot_initializer at line 654, avg 300µs/call | ||||
| 681 | 256 | 658µs | my $self = shift; | ||
| 682 | 256 | 669µs | my ($attr, $idx) = @_; | ||
| 683 | |||||
| 684 | 256 | 7.19ms | 512 | 59.8ms | my @initial_value = $attr->_inline_set_value( # spent 54.4ms making 254 calls to Class::MOP::Attribute::_inline_set_value, avg 214µs/call
# spent 4.30ms making 2 calls to Moose::Meta::Attribute::_inline_set_value, avg 2.15ms/call
# spent 1.16ms 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.70ms | 256 | 2.66ms | push @initial_value, ( # spent 2.66ms 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 | 256 | 3.37ms | return @initial_value; | ||
| 696 | } | ||||
| 697 | |||||
| 698 | # spent 43.1ms (10.1+33.0) within Class::MOP::Class::_inline_init_attr_from_default which was called 267 times, avg 161µs/call:
# 256 times (9.45ms+28.7ms) by Class::MOP::Class::_inline_slot_initializer at line 659, avg 149µs/call
# 11 times (646µs+4.27ms) by Class::MOP::Class::_inline_slot_initializer at line 653, avg 447µs/call | ||||
| 699 | 267 | 733µs | my $self = shift; | ||
| 700 | 267 | 755µs | my ($attr, $idx) = @_; | ||
| 701 | |||||
| 702 | 267 | 2.63ms | 267 | 16.0ms | my $default = $self->_inline_default_value($attr, $idx); # spent 16.0ms making 267 calls to Class::MOP::Class::_inline_default_value, avg 60µs/call |
| 703 | 267 | 1.90ms | return unless $default; | ||
| 704 | |||||
| 705 | 89 | 1.24ms | 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 181µs/call |
| 706 | |||||
| 707 | 89 | 923µs | 89 | 885µs | push @initial_value, ( # spent 885µ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 | 89 | 1.15ms | return @initial_value; | ||
| 715 | } | ||||
| 716 | |||||
| 717 | # spent 23.6ms (15.1+8.52) within Class::MOP::Class::_inline_default_value which was called 378 times, avg 62µs/call:
# 267 times (10.2ms+5.79ms) by Class::MOP::Class::_inline_init_attr_from_default at line 702, avg 60µs/call
# 111 times (4.91ms+2.73ms) by Moose::Meta::Class::_inline_init_attr_from_default at line 396 of Moose/Meta/Class.pm, avg 69µs/call | ||||
| 718 | 378 | 975µs | my $self = shift; | ||
| 719 | 378 | 992µs | my ($attr, $index) = @_; | ||
| 720 | |||||
| 721 | 378 | 8.73ms | 773 | 8.52ms | if ($attr->has_default) { # spent 3.63ms making 378 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 10µs/call
# spent 2.51ms making 255 calls to Class::MOP::Mixin::AttributeCore::has_builder, avg 10µs/call
# spent 2.28ms making 123 calls to Class::MOP::Mixin::AttributeCore::is_default_a_coderef, avg 19µs/call
# spent 99µs making 17 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 | 41 | 573µs | return '$defaults->[' . $index . ']'; | ||
| 733 | } | ||||
| 734 | } | ||||
| 735 | elsif ($attr->has_builder) { | ||||
| 736 | return '$instance->' . $attr->builder; | ||||
| 737 | } | ||||
| 738 | else { | ||||
| 739 | 238 | 2.51ms | return; | ||
| 740 | } | ||||
| 741 | } | ||||
| 742 | |||||
| 743 | # spent 3.80ms (1.91+1.89) within Class::MOP::Class::_inline_preserve_weak_metaclasses which was called 55 times, avg 69µs/call:
# 55 times (1.91ms+1.89ms) by Class::MOP::Class::_inline_new_object at line 591, avg 69µs/call | ||||
| 744 | 55 | 174µs | my $self = shift; | ||
| 745 | 55 | 1.58ms | 110 | 1.89ms | if (Class::MOP::metaclass_is_weak($self->name)) { # spent 1.46ms making 55 calls to Class::MOP::metaclass_is_weak, avg 26µs/call
# spent 432µs making 55 calls to Class::MOP::Package::name, avg 8µs/call |
| 746 | return ( | ||||
| 747 | $self->_inline_set_mop_slot( | ||||
| 748 | '$instance', 'Class::MOP::class_of($class)' | ||||
| 749 | ) . ';' | ||||
| 750 | ); | ||||
| 751 | } | ||||
| 752 | else { | ||||
| 753 | 55 | 603µs | return (); | ||
| 754 | } | ||||
| 755 | } | ||||
| 756 | |||||
| 757 | 31 | 292µs | # spent 220µs within Class::MOP::Class::_inline_extra_init which was called 31 times, avg 7µs/call:
# 31 times (220µs+0s) by Class::MOP::Class::_inline_new_object at line 591, avg 7µs/call | ||
| 758 | |||||
| 759 | |||||
| 760 | # spent 160ms (12.7+148) within Class::MOP::Class::get_meta_instance which was called 810 times, avg 198µs/call:
# 341 times (4.75ms+30.2ms) by Class::MOP::Attribute::_inline_instance_set at line 285 of Class/MOP/Attribute.pm, avg 103µs/call
# 196 times (3.91ms+86.0ms) by Class::MOP::Attribute::_inline_instance_get at line 308 of Class/MOP/Attribute.pm, avg 459µs/call
# 83 times (1.17ms+9.49ms) by Class::MOP::Class::_construct_instance at line 558, avg 128µs/call
# 62 times (840µs+0s) by Class::MOP::Attribute::_inline_instance_has at line 329 of Class/MOP/Attribute.pm, avg 14µs/call
# 55 times (880µs+8.48ms) by Class::MOP::Class::_inline_create_instance at line 637, avg 170µs/call
# 29 times (422µs+578µs) by Class::MOP::Attribute::_inline_instance_clear at line 350 of Class/MOP/Attribute.pm, avg 34µs/call
# 21 times (403µs+12.1ms) by Class::MOP::Class:::around at line 74 of Class/MOP/Class/Immutable/Trait.pm, avg 595µs/call
# 9 times (116µs+0s) by Class::MOP::Attribute::set_initial_value at line 259 of Class/MOP/Attribute.pm, avg 13µs/call
# 9 times (107µs+0s) by Moose::Meta::Attribute::_inline_weaken_value at line 676 of Moose/Meta/Attribute.pm, avg 12µ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 (25µs+755µs) by Moose::Exporter::BEGIN@11 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 | ||||
| 761 | 810 | 2.66ms | my $self = shift; | ||
| 762 | 810 | 12.3ms | 173 | 148ms | $self->{'_meta_instance'} ||= $self->_create_meta_instance(); # spent 148ms making 173 calls to Class::MOP::Class::_create_meta_instance, avg 853µs/call |
| 763 | } | ||||
| 764 | |||||
| 765 | # spent 148ms (12.3+135) within Class::MOP::Class::_create_meta_instance which was called 173 times, avg 853µs/call:
# 173 times (12.3ms+135ms) by Class::MOP::Class::get_meta_instance at line 762, avg 853µs/call | ||||
| 766 | 173 | 444µs | my $self = shift; | ||
| 767 | |||||
| 768 | 173 | 7.77ms | 519 | 134ms | my $instance = $self->instance_metaclass->new( # spent 77.1ms making 173 calls to Class::MOP::Instance::new, avg 446µs/call
# spent 50.1ms making 161 calls to Class::MOP::Class::get_all_attributes, avg 311µs/call
# spent 5.74ms making 12 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 478µs/call
# spent 916µs making 173 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call |
| 769 | associated_metaclass => $self, | ||||
| 770 | attributes => [ $self->get_all_attributes() ], | ||||
| 771 | ); | ||||
| 772 | |||||
| 773 | 173 | 2.10ms | 173 | 1.47ms | $self->add_meta_instance_dependencies() # spent 1.47ms making 173 calls to Class::MOP::Instance::is_dependent_on_superclasses, avg 9µs/call |
| 774 | if $instance->is_dependent_on_superclasses(); | ||||
| 775 | |||||
| 776 | 173 | 2.08ms | 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 | sub clone_object { | ||||
| 804 | my $class = shift; | ||||
| 805 | my $instance = shift; | ||||
| 806 | (blessed($instance) && $instance->isa($class->name)) | ||||
| 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 | return $instance if $instance->isa('Class::MOP::Class'); | ||||
| 814 | $class->_clone_instance($instance, @_); | ||||
| 815 | } | ||||
| 816 | |||||
| 817 | sub _clone_instance { | ||||
| 818 | my ($class, $instance, %params) = @_; | ||||
| 819 | (blessed($instance)) | ||||
| 820 | || confess "You can only clone instances, ($instance) is not a blessed instance"; | ||||
| 821 | my $meta_instance = $class->get_meta_instance(); | ||||
| 822 | my $clone = $meta_instance->clone_instance($instance); | ||||
| 823 | foreach my $attr ($class->get_all_attributes()) { | ||||
| 824 | if ( defined( my $init_arg = $attr->init_arg ) ) { | ||||
| 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 20.9ms (5.67+15.2) within Class::MOP::Class::_attach_attribute which was called 239 times, avg 87µs/call:
# 239 times (5.67ms+15.2ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 25 of Class/MOP/Mixin/HasAttributes.pm, avg 87µs/call | ||||
| 919 | 239 | 889µs | my ($self, $attribute) = @_; | ||
| 920 | 239 | 4.91ms | 239 | 15.2ms | $attribute->attach_to_class($self); # spent 15.2ms making 239 calls to Class::MOP::Attribute::attach_to_class, avg 64µs/call |
| 921 | } | ||||
| 922 | |||||
| 923 | # spent 1.94s (17.7ms+1.93) within Class::MOP::Class::_post_add_attribute which was called 239 times, avg 8.14ms/call:
# 239 times (17.7ms+1.93s) by Class::MOP::Mixin::HasAttributes::add_attribute at line 42 of Class/MOP/Mixin/HasAttributes.pm, avg 8.14ms/call | ||||
| 924 | 239 | 947µs | my ( $self, $attribute ) = @_; | ||
| 925 | |||||
| 926 | 239 | 2.59ms | 239 | 13.0ms | $self->invalidate_meta_instances; # spent 13.0ms making 239 calls to Class::MOP::Class::invalidate_meta_instances, avg 54µs/call |
| 927 | |||||
| 928 | # invalidate package flag here | ||||
| 929 | # spent 1.89s (10.8ms+1.87) within Class::MOP::Class::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Class.pm:932] which was called 239 times, avg 7.89ms/call:
# 239 times (10.8ms+1.87s) by Try::Tiny::try at line 76 of Try/Tiny.pm, avg 7.89ms/call | ||||
| 930 | 239 | 4.29ms | local $SIG{__DIE__}; | ||
| 931 | 239 | 6.55ms | 239 | 1.87s | $attribute->install_accessors; # spent 992ms making 122 calls to Moose::Meta::Attribute::install_accessors, avg 8.13ms/call
# spent 483ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::5::install_accessors
# spent 236ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::2::install_accessors
# spent 163ms making 115 calls to Class::MOP::Attribute::install_accessors, avg 1.42ms/call |
| 932 | } | ||||
| 933 | catch { | ||||
| 934 | $self->remove_attribute( $attribute->name ); | ||||
| 935 | die $_; | ||||
| 936 | 239 | 10.6ms | 478 | 1.87s | }; # spent 1.91s making 239 calls to Try::Tiny::try, avg 7.98ms/call, recursion: max depth 1, sum of overlapping time 48.7ms
# spent 5.33ms making 239 calls to Try::Tiny::catch, avg 22µ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 18.6ms (5.46+13.1) within Class::MOP::Class::find_attribute_by_name which was called 77 times, avg 242µs/call:
# 75 times (5.22ms+12.7ms) by Class::MOP::Class::_immutable_metaclass at line 1364, avg 238µs/call
# 2 times (244µs+476µs) by Moose::Meta::Class::_process_inherited_attribute at line 627 of Moose/Meta/Class.pm, avg 360µs/call | ||||
| 954 | 77 | 302µs | my ( $self, $attr_name ) = @_; | ||
| 955 | |||||
| 956 | 77 | 1.00ms | 77 | 4.83ms | foreach my $class ( $self->linearized_isa ) { # spent 4.57ms making 71 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 64µs/call
# spent 265µs making 6 calls to Class::MOP::Class::linearized_isa, avg 44µs/call |
| 957 | # fetch the meta-class ... | ||||
| 958 | 79 | 1.05ms | 79 | 3.24ms | my $meta = Class::MOP::Class->initialize($class); # spent 3.24ms making 79 calls to Class::MOP::Class::initialize, avg 41µs/call |
| 959 | 79 | 2.63ms | 156 | 5.06ms | return $meta->get_attribute($attr_name) # spent 2.77ms making 79 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 35µs/call
# spent 2.29ms making 77 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 30µs/call |
| 960 | if $meta->has_attribute($attr_name); | ||||
| 961 | } | ||||
| 962 | |||||
| 963 | return; | ||||
| 964 | } | ||||
| 965 | |||||
| 966 | # spent 146ms (62.9+83.5) within Class::MOP::Class::get_all_attributes which was called 406 times, avg 361µs/call:
# 161 times (21.5ms+28.6ms) by Class::MOP::Class::_create_meta_instance at line 768, avg 311µs/call
# 83 times (16.9ms+22.4ms) by Class::MOP::Class::_construct_instance at line 578, avg 474µs/call
# 55 times (7.88ms+10.0ms) by Class::MOP::Class::_inline_slot_initializers at line 646, avg 325µs/call
# 55 times (7.68ms+10.2ms) by Class::MOP::Method::Constructor::_attributes at line 79 of Class/MOP/Method/Constructor.pm, avg 325µs/call
# 24 times (2.86ms+3.69ms) by Moose::Meta::Class::_inline_triggers at line 432 of Moose/Meta/Class.pm, avg 273µs/call
# 16 times (2.53ms+4.43ms) by Class::MOP::Class:::around at line 68 of Class/MOP/Class/Immutable/Trait.pm, avg 435µs/call
# 6 times (1.92ms+2.12ms) by Moose::Meta::Attribute::new at line 69 of Moose/Meta/Attribute.pm, avg 672µs/call
# 6 times (1.60ms+1.98ms) by Moose::Meta::Class::new_object at line 258 of Moose/Meta/Class.pm, avg 597µs/call | ||||
| 967 | 406 | 1.13ms | my $self = shift; | ||
| 968 | 3074 | 59.7ms | 3074 | 82.3ms | my %attrs = map { %{ Class::MOP::Class->initialize($_)->_attribute_map } } # spent 55.6ms making 1334 calls to Class::MOP::Class::initialize, avg 42µs/call, recursion: max depth 1, sum of overlapping time 1.21ms
# spent 18.3ms making 390 calls to Class::MOP::Class::linearized_isa, avg 47µs/call
# spent 7.78ms making 1334 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 6µs/call
# spent 1.81ms making 16 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 113µs/call |
| 969 | reverse $self->linearized_isa; | ||||
| 970 | 406 | 7.57ms | return values %attrs; | ||
| 971 | } | ||||
| 972 | |||||
| 973 | # Inheritance | ||||
| 974 | |||||
| 975 | sub superclasses { | ||||
| 976 | 282 | 851µs | my $self = shift; | ||
| 977 | |||||
| 978 | 282 | 3.56ms | 282 | 27.3ms | my $isa = $self->get_or_add_package_symbol('@ISA'); # spent 27.3ms making 282 calls to Class::MOP::Package::get_or_add_package_symbol, avg 97µs/call |
| 979 | |||||
| 980 | 282 | 844µs | if (@_) { | ||
| 981 | 36 | 196µs | my @supers = @_; | ||
| 982 | 36 | 1.90ms | @{$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 | 36 | 788µs | 36 | 236µs | my $class = $self->name; # spent 236µs making 36 calls to Class::MOP::Package::name, avg 7µs/call |
| 989 | 36 | 1.65ms | 36 | 284µs | $class->isa($class); # spent 284µs making 36 calls to UNIVERSAL::isa, avg 8µ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 | 36 | 516µs | 36 | 162ms | $self->_check_metaclass_compatibility(); # spent 162ms making 36 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 4.51ms/call |
| 999 | 36 | 558µs | 36 | 12.4ms | $self->_superclasses_updated(); # spent 12.4ms making 36 calls to Class::MOP::Class::_superclasses_updated, avg 343µs/call |
| 1000 | } | ||||
| 1001 | |||||
| 1002 | 282 | 3.73ms | return @{$isa}; | ||
| 1003 | } | ||||
| 1004 | |||||
| 1005 | # spent 12.4ms (2.66+9.70) within Class::MOP::Class::_superclasses_updated which was called 36 times, avg 343µs/call:
# 36 times (2.66ms+9.70ms) by Class::MOP::Class::superclasses at line 999, avg 343µs/call | ||||
| 1006 | 36 | 108µs | my $self = shift; | ||
| 1007 | 36 | 366µs | 36 | 442µs | $self->update_meta_instance_dependencies(); # spent 442µs making 36 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 | 41 | 518µs | 41 | 1.44ms | $self->_superclass_metas( # spent 1.44ms making 41 calls to Class::MOP::class_of, avg 35µs/call |
| 1011 | 36 | 1.21ms | 72 | 604µs | map { Class::MOP::class_of($_) } $self->superclasses # spent 604µs making 36 calls to Class::MOP::Class::_superclass_metas, avg 17µs/call
# spent 193µs making 2 calls to Class::MOP::Class::superclasses, avg 96µs/call, recursion: max depth 1, sum of overlapping time 193µs
# spent 7.01ms making 34 calls to Moose::Meta::Class::superclasses, avg 206µs/call, recursion: max depth 1, sum of overlapping time 7.01ms |
| 1012 | ); | ||||
| 1013 | } | ||||
| 1014 | |||||
| 1015 | # spent 604µs within Class::MOP::Class::_superclass_metas which was called 36 times, avg 17µs/call:
# 36 times (604µs+0s) by Class::MOP::Class::_superclasses_updated at line 1011, avg 17µs/call | ||||
| 1016 | 36 | 107µs | my $self = shift; | ||
| 1017 | 36 | 589µs | $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 38.9ms (25.0+13.9) within Class::MOP::Class::linearized_isa which was called 837 times, avg 46µs/call:
# 390 times (11.7ms+6.64ms) by Class::MOP::Class::get_all_attributes at line 968, avg 47µs/call
# 213 times (6.23ms+3.39ms) by Class::MOP::Class::find_method_by_name at line 1158, avg 45µs/call
# 155 times (4.80ms+2.72ms) by Class::MOP::Class::find_next_method_by_name at line 1205, avg 49µs/call
# 48 times (1.30ms+697µs) by Class::MOP::Class::find_all_methods_by_name at line 1189, avg 42µs/call
# 17 times (567µs+269µs) by Class::MOP::Class:::around at line 50 of Class/MOP/Class/Immutable/Trait.pm, avg 49µs/call
# 8 times (229µs+143µs) by Class::MOP::Class::get_all_methods at line 1169, avg 46µs/call
# 6 times (178µs+87µs) by Class::MOP::Class::find_attribute_by_name at line 956, avg 44µs/call | ||||
| 1039 | 837 | 41.4ms | 1674 | 13.9ms | return @{ mro::get_linear_isa( (shift)->name ) }; # spent 9.57ms making 837 calls to mro::get_linear_isa, avg 11µs/call
# spent 4.37ms making 837 calls to Class::MOP::Package::name, avg 5µs/call |
| 1040 | } | ||||
| 1041 | |||||
| 1042 | # spent 18.5ms (4.57+13.9) within Class::MOP::Class::class_precedence_list which was called 51 times, avg 363µs/call:
# 21 times (2.22ms+16.3ms) by Moose::Meta::Class::excludes_role at line 239 of Moose/Meta/Class.pm, avg 882µs/call
# 18 times (1.31ms+-1.31ms) by Class::MOP::Class::class_precedence_list at line 1068, avg 0s/call
# 12 times (1.04ms+-1.04ms) by Class::MOP::Class:::around at line 43 of Class/MOP/Class/Immutable/Trait.pm, avg 0s/call | ||||
| 1043 | 51 | 141µs | my $self = shift; | ||
| 1044 | 51 | 1.03ms | 51 | 279µs | my $name = $self->name; # spent 279µs making 51 calls to Class::MOP::Package::name, avg 5µs/call |
| 1045 | |||||
| 1046 | 51 | 745µs | 51 | 242µs | unless (Class::MOP::IS_RUNNING_ON_5_10()) { # spent 242µs making 51 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 | 51 | 1.10ms | 51 | 558µs | if (mro::get_mro($name) eq 'c3') { # spent 558µs making 51 calls to mro::get_mro, avg 11µ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 | 49 | 1.05ms | 98 | 8.11ms | $name, # spent 10.7ms making 30 calls to Class::MOP::Class::Immutable::Class::MOP::Class::class_precedence_list, avg 357µs/call, recursion: max depth 3, sum of overlapping time 5.51ms
# spent 2.11ms making 49 calls to Class::MOP::Class::initialize, avg 43µs/call
# spent 818µs making 1 call to Class::MOP::Class::Immutable::Moose::Meta::Class::class_precedence_list
# spent 5.22ms making 18 calls to Class::MOP::Class::class_precedence_list, avg 290µs/call, recursion: max depth 2, sum of overlapping time 5.22ms |
| 1069 | map { | ||||
| 1070 | 51 | 1.25ms | 51 | 8.76ms | Class::MOP::Class->initialize($_)->class_precedence_list() # spent 6.34ms making 34 calls to Moose::Meta::Class::superclasses, avg 186µs/call
# spent 1.65ms making 11 calls to Class::MOP::Class::Immutable::Class::MOP::Class::superclasses, avg 150µs/call
# spent 448µs making 5 calls to Class::MOP::Class::superclasses, avg 90µs/call
# spent 322µs making 1 call to Class::MOP::Class::Immutable::Moose::Meta::Class::superclasses |
| 1071 | } $self->superclasses() | ||||
| 1072 | ); | ||||
| 1073 | } | ||||
| 1074 | } | ||||
| 1075 | |||||
| 1076 | ## Methods | ||||
| 1077 | |||||
| 1078 | { | ||||
| 1079 | 1 | 4µs | # spent 112ms (7.56+104) within Class::MOP::Class::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Class.pm:1108] which was called 68 times, avg 1.64ms/call:
# 61 times (6.73ms+93.7ms) by Class::MOP::Class::add_around_method_modifier at line 1134, avg 1.65ms/call
# 5 times (637µs+9.22ms) by Class::MOP::Class::add_before_method_modifier at line 1114, avg 1.97ms/call
# 2 times (195µs+1.05ms) by Class::MOP::Class::add_after_method_modifier at line 1124, avg 621µs/call | ||
| 1080 | 68 | 285µs | my ($self, $method_name) = @_; | ||
| 1081 | 68 | 1.50ms | 68 | 424µs | my $wrapped_metaclass = $self->wrapped_method_metaclass; # spent 424µs making 68 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 6µs/call |
| 1082 | # fetch it locally | ||||
| 1083 | 68 | 743µs | 68 | 10.2ms | my $method = $self->get_method($method_name); # spent 10.2ms making 68 calls to Class::MOP::Mixin::HasMethods::get_method, avg 151µs/call |
| 1084 | # if we dont have local ... | ||||
| 1085 | 68 | 385µs | unless ($method) { | ||
| 1086 | # try to find the next method | ||||
| 1087 | 61 | 841µs | 61 | 43.3ms | $method = $self->find_next_method_by_name($method_name); # spent 43.3ms making 61 calls to Class::MOP::Class::find_next_method_by_name, avg 710µs/call |
| 1088 | # die if it does not exist | ||||
| 1089 | 61 | 126µs | (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 | 61 | 1.86ms | 122 | 20.6ms | $method = $wrapped_metaclass->wrap($method, # spent 20.2ms making 61 calls to Class::MOP::Method::Wrapped::wrap, avg 332µs/call
# spent 360µs making 61 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 | 7 | 356µs | 17 | 1.56ms | $method = $wrapped_metaclass->wrap($method, # spent 1.46ms making 5 calls to Class::MOP::Method::Wrapped::wrap, avg 291µs/call
# spent 79µs making 7 calls to UNIVERSAL::isa, avg 11µs/call
# spent 24µs making 5 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 | 68 | 873µs | 68 | 27.9ms | $self->add_method($method_name => $method); # spent 27.9ms making 68 calls to Class::MOP::Mixin::HasMethods::add_method, avg 410µs/call |
| 1107 | 68 | 951µs | return $method; | ||
| 1108 | 1 | 14µs | }; | ||
| 1109 | |||||
| 1110 | # spent 10.7ms (303µs+10.4) within Class::MOP::Class::add_before_method_modifier which was called 5 times, avg 2.13ms/call:
# 4 times (249µs+8.97ms) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 221 of Moose/Meta/Role/Application/ToClass.pm, avg 2.30ms/call
# once (54µs+1.40ms) by Moose::Util::add_method_modifier at line 244 of Moose/Util.pm | ||||
| 1111 | 5 | 26µs | my ($self, $method_name, $method_modifier) = @_; | ||
| 1112 | 5 | 17µs | (defined $method_name && length $method_name) | ||
| 1113 | || confess "You must pass in a method name"; | ||||
| 1114 | 5 | 64µs | 5 | 9.86ms | my $method = $fetch_and_prepare_method->($self, $method_name); # spent 9.86ms making 5 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:1108], avg 1.97ms/call |
| 1115 | 5 | 246µs | 10 | 502µs | $method->add_before_modifier( # spent 438µs making 5 calls to Class::MOP::Method::Wrapped::add_before_modifier, avg 88µs/call
# spent 64µs making 5 calls to Sub::Name::subname, avg 13µs/call |
| 1116 | subname(':before' => $method_modifier) | ||||
| 1117 | ); | ||||
| 1118 | } | ||||
| 1119 | |||||
| 1120 | # spent 1.63ms (217µs+1.42) within Class::MOP::Class::add_after_method_modifier which was called 2 times, avg 816µs/call:
# 2 times (217µs+1.42ms) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 221 of Moose/Meta/Role/Application/ToClass.pm, avg 816µs/call | ||||
| 1121 | 2 | 10µs | my ($self, $method_name, $method_modifier) = @_; | ||
| 1122 | 2 | 7µs | (defined $method_name && length $method_name) | ||
| 1123 | || confess "You must pass in a method name"; | ||||
| 1124 | 2 | 99µs | 2 | 1.24ms | my $method = $fetch_and_prepare_method->($self, $method_name); # spent 1.24ms making 2 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:1108], avg 621µs/call |
| 1125 | 2 | 122µs | 4 | 174µs | $method->add_after_modifier( # spent 146µs making 2 calls to Class::MOP::Method::Wrapped::add_after_modifier, avg 73µs/call
# spent 29µs making 2 calls to Sub::Name::subname, avg 14µs/call |
| 1126 | subname(':after' => $method_modifier) | ||||
| 1127 | ); | ||||
| 1128 | } | ||||
| 1129 | |||||
| 1130 | # spent 112ms (3.04+109) within Class::MOP::Class::add_around_method_modifier which was called 61 times, avg 1.84ms/call:
# 46 times (2.25ms+81.6ms) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 1.82ms/call
# 15 times (792µs+27.9ms) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 221 of Moose/Meta/Role/Application/ToClass.pm, avg 1.91ms/call | ||||
| 1131 | 61 | 269µs | my ($self, $method_name, $method_modifier) = @_; | ||
| 1132 | 61 | 166µs | (defined $method_name && length $method_name) | ||
| 1133 | || confess "You must pass in a method name"; | ||||
| 1134 | 61 | 674µs | 61 | 100ms | my $method = $fetch_and_prepare_method->($self, $method_name); # spent 100ms making 61 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:1108], avg 1.65ms/call |
| 1135 | 61 | 2.74ms | 122 | 9.00ms | $method->add_around_modifier( # spent 8.24ms making 61 calls to Class::MOP::Method::Wrapped::add_around_modifier, avg 135µs/call
# spent 753µs making 61 calls to Sub::Name::subname, avg 12µ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 136ms (19.5+117) within Class::MOP::Class::find_method_by_name which was called 213 times, avg 639µs/call:
# 57 times (3.93ms+15.1ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 23 of Class/MOP/Mixin/HasMethods.pm, avg 334µs/call
# 56 times (8.10ms+56.4ms) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 1.15ms/call
# 45 times (2.56ms+23.7ms) by Moose::Meta::Role::Application::ToClass::check_required_methods at line 64 of Moose/Meta/Role/Application/ToClass.pm, avg 584µs/call
# 24 times (2.24ms+10.0ms) by Moose::Meta::Class::_inline_BUILDARGS at line 303 of Moose/Meta/Class.pm, avg 510µs/call
# 24 times (2.20ms+9.86ms) by Moose::Meta::Method::Destructor::is_needed at line 62 of Moose/Meta/Method/Destructor.pm, avg 503µs/call
# 7 times (448µs+1.62ms) by Moose::BEGIN@38 at line 14 of Moose/Meta/Attribute/Native.pm, avg 295µs/call | ||||
| 1155 | 213 | 830µs | my ($self, $method_name) = @_; | ||
| 1156 | 213 | 682µs | (defined $method_name && length $method_name) | ||
| 1157 | || confess "You must define a method name to find"; | ||||
| 1158 | 213 | 2.76ms | 213 | 9.62ms | foreach my $class ($self->linearized_isa) { # spent 9.62ms making 213 calls to Class::MOP::Class::linearized_isa, avg 45µs/call |
| 1159 | 436 | 9.31ms | 872 | 107ms | my $method = Class::MOP::Class->initialize($class)->get_method($method_name); # spent 88.5ms making 436 calls to Class::MOP::Mixin::HasMethods::get_method, avg 203µs/call
# spent 18.6ms making 436 calls to Class::MOP::Class::initialize, avg 43µs/call |
| 1160 | 436 | 3.65ms | return $method if defined $method; | ||
| 1161 | } | ||||
| 1162 | 72 | 889µs | return; | ||
| 1163 | } | ||||
| 1164 | |||||
| 1165 | # spent 16.3ms (1.42+14.9) within Class::MOP::Class::get_all_methods which was called 8 times, avg 2.04ms/call:
# 8 times (1.42ms+14.9ms) by Class::MOP::MiniTrait::apply at line 18 of Class/MOP/MiniTrait.pm, avg 2.04ms/call | ||||
| 1166 | 8 | 26µs | my $self = shift; | ||
| 1167 | |||||
| 1168 | 8 | 15µs | my %methods; | ||
| 1169 | 8 | 114µs | 8 | 372µs | for my $class ( reverse $self->linearized_isa ) { # spent 372µs making 8 calls to Class::MOP::Class::linearized_isa, avg 46µs/call |
| 1170 | 9 | 100µs | 9 | 350µs | my $meta = Class::MOP::Class->initialize($class); # spent 350µs making 9 calls to Class::MOP::Class::initialize, avg 39µs/call |
| 1171 | |||||
| 1172 | 18 | 1.23ms | 65 | 14.2ms | $methods{ $_->name } = $_ for $meta->_get_local_methods; # spent 13.9ms making 9 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 1.55ms/call
# spent 266µs making 56 calls to Class::MOP::Method::name, avg 5µs/call |
| 1173 | } | ||||
| 1174 | |||||
| 1175 | 8 | 153µs | 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 27.4ms (5.02+22.4) within Class::MOP::Class::find_all_methods_by_name which was called 48 times, avg 571µs/call:
# 24 times (2.54ms+11.6ms) by Moose::Meta::Class::_inline_BUILDALL at line 456 of Moose/Meta/Class.pm, avg 590µs/call
# 24 times (2.48ms+10.8ms) by Moose::Meta::Method::Destructor::_generate_DEMOLISHALL at line 118 of Moose/Meta/Method/Destructor.pm, avg 552µs/call | ||||
| 1185 | 48 | 188µs | my ($self, $method_name) = @_; | ||
| 1186 | 48 | 157µs | (defined $method_name && length $method_name) | ||
| 1187 | || confess "You must define a method name to find"; | ||||
| 1188 | 48 | 105µs | my @methods; | ||
| 1189 | 48 | 694µs | 48 | 2.00ms | foreach my $class ($self->linearized_isa) { # spent 2.00ms making 48 calls to Class::MOP::Class::linearized_isa, avg 42µs/call |
| 1190 | # fetch the meta-class ... | ||||
| 1191 | 98 | 1.17ms | 98 | 4.03ms | my $meta = Class::MOP::Class->initialize($class); # spent 4.03ms making 98 calls to Class::MOP::Class::initialize, avg 41µs/call |
| 1192 | 98 | 1.61ms | 102 | 16.4ms | push @methods => { # spent 14.6ms making 98 calls to Class::MOP::Mixin::HasMethods::has_method, avg 149µs/call
# spent 1.74ms making 4 calls to Class::MOP::Mixin::HasMethods::get_method, avg 435µs/call |
| 1193 | name => $method_name, | ||||
| 1194 | class => $class, | ||||
| 1195 | code => $meta->get_method($method_name) | ||||
| 1196 | } if $meta->has_method($method_name); | ||||
| 1197 | } | ||||
| 1198 | 48 | 574µs | return @methods; | ||
| 1199 | } | ||||
| 1200 | |||||
| 1201 | # spent 76.9ms (15.3+61.6) within Class::MOP::Class::find_next_method_by_name which was called 157 times, avg 490µs/call:
# 79 times (6.09ms+20.9ms) by Class::MOP::Method::Inlined::can_be_inlined at line 38 of Class/MOP/Method/Inlined.pm, avg 342µs/call
# 61 times (7.77ms+35.5ms) by Class::MOP::Class::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Class.pm:1108] at line 1087, avg 710µs/call
# 15 times (1.28ms+4.78ms) by Moose::Meta::Method::Overridden::new at line 23 of Moose/Meta/Method/Overridden.pm, avg 404µs/call
# 2 times (128µs+399µs) by Class::MOP::Method::Inlined::_uninlined_body at line 18 of Class/MOP/Method/Inlined.pm, avg 264µs/call | ||||
| 1202 | 157 | 796µs | my ($self, $method_name) = @_; | ||
| 1203 | 157 | 504µs | (defined $method_name && length $method_name) | ||
| 1204 | || confess "You must define a method name to find"; | ||||
| 1205 | 157 | 2.99ms | 157 | 7.69ms | my @cpl = $self->linearized_isa; # spent 7.52ms making 155 calls to Class::MOP::Class::linearized_isa, avg 49µs/call
# spent 169µs making 2 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::linearized_isa, avg 85µs/call |
| 1206 | 157 | 454µs | shift @cpl; # discard ourselves | ||
| 1207 | 157 | 648µs | foreach my $class (@cpl) { | ||
| 1208 | 249 | 5.53ms | 498 | 53.9ms | my $method = Class::MOP::Class->initialize($class)->get_method($method_name); # spent 43.1ms making 249 calls to Class::MOP::Mixin::HasMethods::get_method, avg 173µs/call
# spent 10.8ms making 249 calls to Class::MOP::Class::initialize, avg 43µs/call |
| 1209 | 249 | 2.89ms | return $method if defined $method; | ||
| 1210 | } | ||||
| 1211 | 3 | 35µs | return; | ||
| 1212 | } | ||||
| 1213 | |||||
| 1214 | # spent 442µs within Class::MOP::Class::update_meta_instance_dependencies which was called 36 times, avg 12µs/call:
# 36 times (442µs+0s) by Class::MOP::Class::_superclasses_updated at line 1007, avg 12µs/call | ||||
| 1215 | 36 | 100µs | my $self = shift; | ||
| 1216 | |||||
| 1217 | 36 | 524µs | 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 13.0ms (10.0+2.96) within Class::MOP::Class::invalidate_meta_instances which was called 239 times, avg 54µs/call:
# 239 times (10.0ms+2.96ms) by Class::MOP::Class::_post_add_attribute at line 926, avg 54µs/call | ||||
| 1268 | 239 | 696µs | my $self = shift; | ||
| 1269 | $_->invalidate_meta_instance() | ||||
| 1270 | 478 | 8.87ms | 239 | 2.96ms | for $self, @{ $self->{dependent_meta_instances} }; # spent 2.96ms making 239 calls to Class::MOP::Class::invalidate_meta_instance, avg 12µs/call |
| 1271 | } | ||||
| 1272 | |||||
| 1273 | # spent 2.96ms within Class::MOP::Class::invalidate_meta_instance which was called 239 times, avg 12µs/call:
# 239 times (2.96ms+0s) by Class::MOP::Class::invalidate_meta_instances at line 1270, avg 12µs/call | ||||
| 1274 | 239 | 678µs | my $self = shift; | ||
| 1275 | 239 | 3.33ms | 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 | 106 | 1.22ms | # spent 750µs within Class::MOP::Class::is_mutable which was called 106 times, avg 7µs/call:
# 75 times (548µs+0s) by Class::MOP::Class::make_immutable at line 1320, avg 7µs/call
# 22 times (141µs+0s) by KiokuDB::BEGIN@4 at line 231 of Moose.pm, avg 6µs/call
# 9 times (61µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 688 of Moose/Util/TypeConstraints.pm, avg 7µs/call | ||
| 1297 | 91 | 1.05ms | # spent 708µs within Class::MOP::Class::is_immutable which was called 91 times, avg 8µs/call:
# 91 times (708µs+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 7.56ms (5.36+2.20) within Class::MOP::Class::_immutable_options which was called 75 times, avg 101µs/call:
# 51 times (3.33ms+987µs) by Class::MOP::Class::make_immutable at line 1321, avg 85µs/call
# 24 times (2.02ms+1.21ms) by Moose::Meta::Class::_immutable_options at line 645 of Moose/Meta/Class.pm, avg 135µs/call | ||||
| 1302 | 75 | 517µs | my ( $self, @args ) = @_; | ||
| 1303 | |||||
| 1304 | return ( | ||||
| 1305 | 75 | 5.83ms | 300 | 2.20ms | inline_accessors => 1, # spent 417µs making 75 calls to Class::MOP::Class::constructor_name, avg 6µs/call
# spent 368µs making 24 calls to Moose::Meta::Class::immutable_trait, avg 15µs/call
# spent 345µs making 24 calls to Moose::Meta::Class::constructor_class, avg 14µs/call
# spent 336µs making 24 calls to Moose::Meta::Class::destructor_class, avg 14µs/call
# spent 288µs making 51 calls to Class::MOP::Class::immutable_trait, avg 6µs/call
# spent 224µs making 51 calls to Class::MOP::Class::constructor_class, avg 4µs/call
# spent 224µs making 51 calls to Class::MOP::Class::destructor_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.27s (6.24ms+1.27) within Class::MOP::Class::make_immutable which was called 75 times, avg 17.0ms/call:
# 22 times (1.98ms+403ms) by KiokuDB::BEGIN@4 at line 236 of Moose.pm, avg 18.4ms/call
# 13 times (953µs+85.3ms) by Moose::Exporter::BEGIN@11 at line 699 of Class/MOP.pm, avg 6.63ms/call
# 9 times (754µs+171ms) by Moose::Meta::Attribute::BEGIN@20 at line 693 of Moose/Util/TypeConstraints.pm, avg 19.1ms/call
# 4 times (267µs+2.33ms) by Moose::Exporter::BEGIN@11 at line 724 of Class/MOP.pm, avg 650µs/call
# 2 times (163µs+-163µs) by Class::MOP::Class::_immutable_metaclass at line 1394, avg 0s/call
# once (121µs+119ms) by KiokuDB::Collapser::BEGIN@12 at line 304 of KiokuDB/Entry.pm
# once (79µs+46.7ms) by KiokuDB::BEGIN@4 at line 268 of Moose.pm
# once (85µs+44.2ms) by main::BEGIN@0 at line 655 of KiokuDB.pm
# once (86µs+31.8ms) by KiokuDB::Collapser::BEGIN@15 at line 231 of KiokuDB/Collapser/Buffer.pm
# once (85µs+27.8ms) by KiokuDB::BEGIN@13 at line 531 of KiokuDB/LiveObjects.pm
# once (84µs+25.8ms) by KiokuDB::BEGIN@11 at line 396 of KiokuDB/Collapser.pm
# once (86µs+22.7ms) by KiokuDB::BEGIN@14 at line 171 of KiokuDB/TypeMap.pm
# once (84µs+21.8ms) by KiokuDB::BEGIN@12 at line 381 of KiokuDB/Linker.pm
# once (86µs+20.6ms) by KiokuDB::TypeMap::Resolver::BEGIN@9 at line 484 of KiokuDB/TypeMap/Entry/MOP.pm
# once (81µs+20.6ms) by KiokuDB::BEGIN@17 at line 79 of KiokuDB/Stream/Objects.pm
# once (85µs+20.5ms) by KiokuDB::TypeMap::Entry::Std::BEGIN@6 at line 26 of KiokuDB/TypeMap/Entry/Compiled.pm
# once (82µs+17.2ms) by KiokuDB::LiveObjects::BEGIN@14 at line 55 of KiokuDB/LiveObjects/TXNScope.pm
# once (83µs+16.9ms) by KiokuDB::TypeMap::Entry::MOP::BEGIN@9 at line 51 of KiokuDB/Thunk.pm
# once (85µs+16.6ms) by KiokuDB::LiveObjects::BEGIN@13 at line 60 of KiokuDB/LiveObjects/Scope.pm
# once (85µs+16.4ms) by KiokuDB::BEGIN@16 at line 117 of KiokuDB/TypeMap/Resolver.pm
# once (83µs+16.1ms) by KiokuDB::Collapser::BEGIN@14 at line 39 of KiokuDB/Reference.pm
# once (82µs+14.8ms) by KiokuDB::Collapser::BEGIN@13 at line 27 of KiokuDB/Entry/Skip.pm
# once (84µs+14.6ms) by KiokuDB::Collapser::BEGIN@16 at line 25 of KiokuDB/Error/UnknownObjects.pm
# once (81µs+14.4ms) by KiokuDB::Linker::BEGIN@18 at line 37 of KiokuDB/Error/MissingObjects.pm
# once (100µs+14.2ms) by KiokuDB::Collapser::BEGIN@18 at line 443 of Data/Visitor.pm
# once (80µs+13.9ms) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 38 of Data/Stream/Bulk/Filter.pm
# once (80µs+13.3ms) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 35 of Data/Stream/Bulk/Nil.pm
# once (83µs+12.3ms) by KiokuDB::BEGIN@15 at line 28 of KiokuDB/TypeMap/Shadow.pm
# once (84µs+12.2ms) by KiokuDB::TypeMap::BEGIN@10 at line 14 of KiokuDB/TypeMap/Entry/Alias.pm
# once (80µs+12.1ms) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 51 of Data/Stream/Bulk/Cat.pm | ||||
| 1318 | 75 | 496µs | my ( $self, @args ) = @_; | ||
| 1319 | |||||
| 1320 | 75 | 837µs | 75 | 548µs | if ( $self->is_mutable ) { # spent 548µs making 75 calls to Class::MOP::Class::is_mutable, avg 7µs/call |
| 1321 | 75 | 2.25ms | 150 | 1.07s | $self->_initialize_immutable( $self->_immutable_options(@args) ); # spent 1.06s making 75 calls to Class::MOP::Class::_initialize_immutable, avg 14.1ms/call
# spent 4.32ms making 51 calls to Class::MOP::Class::_immutable_options, avg 85µs/call
# spent 4.24ms making 24 calls to Moose::Meta::Class::_immutable_options, avg 177µs/call |
| 1322 | 75 | 1.05ms | 75 | 198ms | $self->_rebless_as_immutable(@args); # spent 199ms making 75 calls to Class::MOP::Class::_rebless_as_immutable, avg 2.66ms/call, recursion: max depth 1, sum of overlapping time 1.06ms |
| 1323 | 75 | 1.28ms | 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 198ms (3.36+195) within Class::MOP::Class::_rebless_as_immutable which was called 75 times, avg 2.64ms/call:
# 75 times (3.36ms+195ms) by Class::MOP::Class::make_immutable at line 1322, avg 2.64ms/call | ||||
| 1346 | 75 | 505µs | my ( $self, @args ) = @_; | ||
| 1347 | |||||
| 1348 | 75 | 500µs | $self->{__immutable}{original_class} = ref $self; | ||
| 1349 | |||||
| 1350 | 75 | 2.23ms | 75 | 195ms | bless $self => $self->_immutable_metaclass(@args); # spent 196ms making 75 calls to Class::MOP::Class::_immutable_metaclass, avg 2.61ms/call, recursion: max depth 1, sum of overlapping time 939µs |
| 1351 | } | ||||
| 1352 | |||||
| 1353 | # spent 195ms (8.01+187) within Class::MOP::Class::_immutable_metaclass which was called 75 times, avg 2.60ms/call:
# 75 times (8.01ms+187ms) by Class::MOP::Class::_rebless_as_immutable at line 1350, avg 2.60ms/call | ||||
| 1354 | 75 | 473µs | my ( $self, %args ) = @_; | ||
| 1355 | |||||
| 1356 | 75 | 232µs | if ( my $class = $args{immutable_metaclass} ) { | ||
| 1357 | return $class; | ||||
| 1358 | } | ||||
| 1359 | |||||
| 1360 | 75 | 1.52ms | 75 | 659µs | my $trait = $args{immutable_trait} = $self->immutable_trait # spent 373µs making 24 calls to Moose::Meta::Class::immutable_trait, avg 16µs/call
# spent 287µs making 51 calls to Class::MOP::Class::immutable_trait, avg 6µs/call |
| 1361 | || confess "no immutable trait specified for $self"; | ||||
| 1362 | |||||
| 1363 | 75 | 919µs | 75 | 6.29ms | my $meta = $self->meta; # spent 6.29ms making 75 calls to Class::MOP::Object::meta, avg 84µs/call |
| 1364 | 75 | 1.22ms | 75 | 17.9ms | my $meta_attr = $meta->find_attribute_by_name("immutable_trait"); # spent 17.9ms making 75 calls to Class::MOP::Class::find_attribute_by_name, avg 238µs/call |
| 1365 | |||||
| 1366 | 75 | 134µs | my $class_name; | ||
| 1367 | |||||
| 1368 | 75 | 1.35ms | 75 | 1.29ms | if ( $meta_attr and $trait eq $meta_attr->default ) { # spent 1.29ms making 75 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 | 75 | 3.14ms | 75 | 1.29ms | return $class_name # spent 1.29ms making 75 calls to Class::MOP::is_class_loaded, avg 17µ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 | 2 | 24µs | 2 | 124µs | my $meta_name = $meta->_real_ref_name; # spent 124µs making 2 calls to Class::MOP::Class::_real_ref_name, avg 62µs/call |
| 1386 | |||||
| 1387 | 2 | 36µs | 2 | 10.7ms | my $immutable_meta = $meta_name->create( # spent 10.7ms making 2 calls to Class::MOP::Class::create, avg 5.33ms/call |
| 1388 | $class_name, | ||||
| 1389 | superclasses => [ ref $self ], | ||||
| 1390 | ); | ||||
| 1391 | |||||
| 1392 | 2 | 33µs | 2 | 148ms | Class::MOP::MiniTrait::apply( $immutable_meta, $trait ); # spent 148ms making 2 calls to Class::MOP::MiniTrait::apply, avg 74.0ms/call |
| 1393 | |||||
| 1394 | 2 | 30µs | 2 | 0s | $immutable_meta->make_immutable( # spent 1.56ms making 2 calls to Class::MOP::Class::make_immutable, avg 779µs/call, recursion: max depth 1, sum of overlapping time 1.56ms |
| 1395 | inline_constructor => 0, | ||||
| 1396 | inline_accessors => 0, | ||||
| 1397 | ); | ||||
| 1398 | |||||
| 1399 | 2 | 34µs | 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 | 79 | 289µs | my ( $self, $method ) = @_; | ||
| 1414 | |||||
| 1415 | 79 | 1.52ms | push @{ $self->{__immutable}{inlined_methods} ||= [] }, $method; | ||
| 1416 | } | ||||
| 1417 | |||||
| 1418 | # spent 1.06s (4.07ms+1.06) within Class::MOP::Class::_initialize_immutable which was called 75 times, avg 14.1ms/call:
# 75 times (4.07ms+1.06s) by Class::MOP::Class::make_immutable at line 1321, avg 14.1ms/call | ||||
| 1419 | 75 | 1.29ms | my ( $self, %args ) = @_; | ||
| 1420 | |||||
| 1421 | 75 | 634µs | $self->{__immutable}{options} = \%args; | ||
| 1422 | 75 | 2.15ms | 75 | 1.06s | $self->_install_inlined_code(%args); # spent 1.06s making 75 calls to Class::MOP::Class::_install_inlined_code, avg 14.1ms/call |
| 1423 | } | ||||
| 1424 | |||||
| 1425 | # spent 1.06s (4.63ms+1.05) within Class::MOP::Class::_install_inlined_code which was called 75 times, avg 14.1ms/call:
# 75 times (4.63ms+1.05s) by Class::MOP::Class::_initialize_immutable at line 1422, avg 14.1ms/call | ||||
| 1426 | 75 | 878µs | my ( $self, %args ) = @_; | ||
| 1427 | |||||
| 1428 | # FIXME | ||||
| 1429 | 75 | 772µs | 32 | 244ms | $self->_inline_accessors(%args) if $args{inline_accessors}; # spent 244ms making 32 calls to Class::MOP::Class::_inline_accessors, avg 7.63ms/call |
| 1430 | 75 | 1.20ms | 55 | 710ms | $self->_inline_constructor(%args) if $args{inline_constructor}; # spent 710ms making 55 calls to Class::MOP::Class::_inline_constructor, avg 12.9ms/call |
| 1431 | 75 | 1.74ms | 24 | 98.2ms | $self->_inline_destructor(%args) if $args{inline_destructor}; # spent 98.2ms making 24 calls to Class::MOP::Class::_inline_destructor, avg 4.09ms/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 244ms (3.12+241) within Class::MOP::Class::_inline_accessors which was called 32 times, avg 7.63ms/call:
# 32 times (3.12ms+241ms) by Class::MOP::Class::_install_inlined_code at line 1429, avg 7.63ms/call | ||||
| 1443 | 32 | 102µs | my $self = shift; | ||
| 1444 | |||||
| 1445 | 32 | 836µs | 32 | 1.02ms | foreach my $attr_name ( $self->get_attribute_list ) { # spent 1.02ms making 32 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 32µs/call |
| 1446 | 69 | 1.81ms | 138 | 240ms | $self->get_attribute($attr_name)->install_accessors(1); # spent 231ms making 68 calls to Class::MOP::Attribute::install_accessors, avg 3.40ms/call
# spent 6.36ms making 1 call to Moose::Meta::Attribute::install_accessors
# spent 2.42ms making 69 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 35µs/call |
| 1447 | } | ||||
| 1448 | } | ||||
| 1449 | |||||
| 1450 | # spent 710ms (7.93+702) within Class::MOP::Class::_inline_constructor which was called 55 times, avg 12.9ms/call:
# 55 times (7.93ms+702ms) by Class::MOP::Class::_install_inlined_code at line 1430, avg 12.9ms/call | ||||
| 1451 | 55 | 708µs | my ( $self, %args ) = @_; | ||
| 1452 | |||||
| 1453 | 55 | 189µs | my $name = $args{constructor_name}; | ||
| 1454 | # A class may not even have a constructor, and that's okay. | ||||
| 1455 | 55 | 131µs | return unless defined $name; | ||
| 1456 | |||||
| 1457 | 55 | 664µs | 55 | 10.4ms | if ( $self->has_method($name) && !$args{replace_constructor} ) { # spent 10.4ms making 55 calls to Class::MOP::Mixin::HasMethods::has_method, avg 188µ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 | 55 | 240µs | my $constructor_class = $args{constructor_class}; | ||
| 1468 | |||||
| 1469 | 55 | 643µs | 55 | 12.4ms | Class::MOP::load_class($constructor_class); # spent 13.4ms making 55 calls to Class::MOP::load_class, avg 243µs/call, recursion: max depth 1, sum of overlapping time 961µs |
| 1470 | |||||
| 1471 | 55 | 1.86ms | 110 | 621ms | my $constructor = $constructor_class->new( # spent 317ms making 24 calls to Moose::Meta::Method::Constructor::new, avg 13.2ms/call
# spent 304ms making 31 calls to Class::MOP::Method::Constructor::new, avg 9.81ms/call
# spent 338µs making 55 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 | 55 | 1.71ms | 55 | 32.4ms | if ( $args{replace_constructor} or $constructor->can_be_inlined ) { # spent 32.4ms making 55 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 589µs/call |
| 1480 | 55 | 685µs | 55 | 23.6ms | $self->add_method( $name => $constructor ); # spent 23.6ms making 55 calls to Class::MOP::Mixin::HasMethods::add_method, avg 430µs/call |
| 1481 | 55 | 827µs | 55 | 1.24ms | $self->_add_inlined_method($constructor); # spent 1.24ms making 55 calls to Class::MOP::Class::_add_inlined_method, avg 23µs/call |
| 1482 | } | ||||
| 1483 | } | ||||
| 1484 | |||||
| 1485 | # spent 98.2ms (3.88+94.3) within Class::MOP::Class::_inline_destructor which was called 24 times, avg 4.09ms/call:
# 24 times (3.88ms+94.3ms) by Class::MOP::Class::_install_inlined_code at line 1431, avg 4.09ms/call | ||||
| 1486 | 24 | 383µs | my ( $self, %args ) = @_; | ||
| 1487 | |||||
| 1488 | 24 | 105µs | ( 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 | 24 | 293µs | 24 | 3.63ms | if ( $self->has_method('DESTROY') && ! $args{replace_destructor} ) { # spent 3.63ms making 24 calls to Class::MOP::Mixin::HasMethods::has_method, avg 151µ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 | 24 | 103µs | my $destructor_class = $args{destructor_class}; | ||
| 1500 | |||||
| 1501 | 24 | 265µs | 24 | 4.89ms | Class::MOP::load_class($destructor_class); # spent 5.94ms making 24 calls to Class::MOP::load_class, avg 248µs/call, recursion: max depth 1, sum of overlapping time 1.05ms |
| 1502 | |||||
| 1503 | 24 | 370µs | 24 | 13.7ms | return unless $destructor_class->is_needed($self); # spent 13.7ms making 24 calls to Moose::Meta::Method::Destructor::is_needed, avg 570µs/call |
| 1504 | |||||
| 1505 | 24 | 784µs | 48 | 50.3ms | my $destructor = $destructor_class->new( # spent 50.2ms making 24 calls to Moose::Meta::Method::Destructor::new, avg 2.09ms/call
# spent 141µs making 24 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 | 24 | 718µs | 24 | 10.5ms | if ( $args{replace_destructor} or $destructor->can_be_inlined ) { # spent 10.5ms making 24 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 436µs/call |
| 1513 | 24 | 280µs | 24 | 9.83ms | $self->add_method( 'DESTROY' => $destructor ); # spent 9.83ms making 24 calls to Class::MOP::Mixin::HasMethods::add_method, avg 409µs/call |
| 1514 | 24 | 326µs | 24 | 429µs | $self->_add_inlined_method($destructor); # spent 429µs making 24 calls to Class::MOP::Class::_add_inlined_method, avg 18µs/call |
| 1515 | } | ||||
| 1516 | } | ||||
| 1517 | |||||
| 1518 | 1 | 23µs | 1; | ||
| 1519 | |||||
| 1520 | __END__ | ||||
# spent 23.0ms (15.8+7.19) within Class::MOP::Class::CORE:sort which was called 55 times, avg 418µs/call:
# 55 times (15.8ms+7.19ms) by Class::MOP::Class::_inline_slot_initializers at line 646, avg 418µs/call |