| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP/Class.pm |
| Statements | Executed 52847 statements in 636ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 3144 | 24 | 13 | 105ms | 367ms | Class::MOP::Class::initialize (recurses: max depth 1, inclusive time 5.19ms) |
| 361 | 6 | 5 | 63.2ms | 147ms | Class::MOP::Class::get_all_attributes |
| 172 | 2 | 1 | 42.8ms | 310ms | Class::MOP::Class::_construct_instance |
| 531 | 1 | 1 | 37.6ms | 77.1ms | Class::MOP::Class::_single_metaclass_can_be_made_compatible |
| 273 | 1 | 1 | 27.2ms | 50.5ms | Class::MOP::Class::_single_metaclass_is_compatible |
| 797 | 7 | 2 | 23.6ms | 37.4ms | Class::MOP::Class::linearized_isa |
| 211 | 6 | 6 | 19.9ms | 185ms | Class::MOP::Class::find_method_by_name |
| 134 | 2 | 1 | 19.7ms | 267ms | Class::MOP::Class::_check_metaclass_compatibility (recurses: max depth 1, inclusive time 3.72ms) |
| 164 | 4 | 3 | 15.4ms | 107ms | Class::MOP::Class::find_next_method_by_name |
| 238 | 1 | 1 | 15.3ms | 1.47s | Class::MOP::Class::_post_add_attribute |
| 82 | 1 | 1 | 14.1ms | 113ms | Class::MOP::Class::_can_fix_metaclass_incompatibility |
| 173 | 1 | 1 | 12.8ms | 156ms | Class::MOP::Class::_create_meta_instance |
| 815 | 12 | 5 | 12.4ms | 168ms | Class::MOP::Class::get_meta_instance |
| 98 | 1 | 1 | 11.1ms | 236ms | Class::MOP::Class::_construct_class_instance (recurses: max depth 1, inclusive time 1.10ms) |
| 238 | 1 | 1 | 10.5ms | 1.42s | Class::MOP::Class::__ANON__[:790] |
| 238 | 1 | 1 | 9.82ms | 12.8ms | Class::MOP::Class::invalidate_meta_instances |
| 77 | 3 | 1 | 9.47ms | 147ms | Class::MOP::Class::__ANON__[:967] |
| 55 | 1 | 1 | 8.18ms | 535ms | Class::MOP::Class::_inline_constructor |
| 75 | 1 | 1 | 7.88ms | 242ms | Class::MOP::Class::_immutable_metaclass (recurses: max depth 1, inclusive time 1.05ms) |
| 273 | 1 | 1 | 7.23ms | 57.7ms | Class::MOP::Class::_check_single_metaclass_compatibility |
| 138 | 6 | 6 | 6.68ms | 202ms | Class::MOP::Class::new_object |
| 75 | 30 | 28 | 6.33ms | 1.10s | Class::MOP::Class::make_immutable (recurses: max depth 1, inclusive time 1.75ms) |
| 75 | 2 | 2 | 5.86ms | 9.03ms | Class::MOP::Class::_immutable_options |
| 238 | 1 | 1 | 5.67ms | 20.5ms | Class::MOP::Class::_attach_attribute |
| 1 | 1 | 1 | 5.25ms | 5.98ms | Class::MOP::Class::BEGIN@7 |
| 77 | 2 | 2 | 5.21ms | 18.8ms | Class::MOP::Class::find_attribute_by_name |
| 48 | 2 | 2 | 5.14ms | 38.3ms | Class::MOP::Class::find_all_methods_by_name |
| 1 | 1 | 1 | 5.08ms | 9.58ms | Class::MOP::Class::BEGIN@10 |
| 68 | 1 | 1 | 4.91ms | 123ms | Class::MOP::Class::_fix_metaclass_incompatibility (recurses: max depth 1, inclusive time 2.48ms) |
| 51 | 3 | 3 | 4.64ms | 22.2ms | Class::MOP::Class::class_precedence_list (recurses: max depth 4, inclusive time 17.8ms) |
| 1 | 1 | 1 | 4.50ms | 8.94ms | Class::MOP::Class::BEGIN@9 |
| 75 | 1 | 1 | 4.50ms | 838ms | Class::MOP::Class::_install_inlined_code |
| 1 | 1 | 1 | 4.20ms | 5.04ms | Class::MOP::Class::BEGIN@8 |
| 24 | 1 | 1 | 4.17ms | 108ms | Class::MOP::Class::_inline_destructor |
| 75 | 1 | 1 | 4.12ms | 842ms | Class::MOP::Class::_initialize_immutable |
| 64 | 1 | 1 | 3.91ms | 3.91ms | Class::MOP::Class::_new |
| 70 | 2 | 2 | 3.77ms | 151ms | Class::MOP::Class::add_around_method_modifier |
| 131 | 4 | 1 | 3.74ms | 7.02ms | Class::MOP::Class::_real_ref_name |
| 75 | 1 | 1 | 3.32ms | 245ms | Class::MOP::Class::_rebless_as_immutable (recurses: max depth 1, inclusive time 1.17ms) |
| 32 | 1 | 1 | 3.07ms | 191ms | Class::MOP::Class::_inline_accessors |
| 238 | 1 | 1 | 2.98ms | 2.98ms | Class::MOP::Class::invalidate_meta_instance |
| 82 | 1 | 1 | 2.91ms | 12.0ms | Class::MOP::Class::_class_metaclass_can_be_made_compatible |
| 150 | 3 | 2 | 2.71ms | 2.71ms | Class::MOP::Class::_base_metaclasses |
| 36 | 1 | 1 | 2.69ms | 15.0ms | Class::MOP::Class::_superclasses_updated |
| 39 | 1 | 1 | 2.21ms | 5.76ms | Class::MOP::Class::_class_metaclass_is_compatible |
| 55 | 2 | 2 | 2.11ms | 11.9ms | Class::MOP::Class::inline_create_instance |
| 79 | 2 | 1 | 1.86ms | 1.86ms | Class::MOP::Class::_add_inlined_method |
| 1 | 1 | 1 | 1.80ms | 2.11ms | Class::MOP::Class::BEGIN@11 |
| 10 | 2 | 2 | 1.79ms | 135ms | Class::MOP::Class::create |
| 8 | 1 | 1 | 1.54ms | 27.5ms | Class::MOP::Class::get_all_methods |
| 1 | 1 | 1 | 1.22ms | 15.6ms | Class::MOP::Class::BEGIN@16 |
| 39 | 1 | 1 | 1.08ms | 6.84ms | Class::MOP::Class::_check_class_metaclass_compatibility |
| 106 | 3 | 3 | 715µs | 715µs | Class::MOP::Class::is_mutable |
| 91 | 1 | 1 | 651µs | 651µs | Class::MOP::Class::is_immutable |
| 36 | 1 | 1 | 594µs | 594µs | Class::MOP::Class::_superclass_metas |
| 36 | 1 | 1 | 419µs | 419µs | Class::MOP::Class::update_meta_instance_dependencies |
| 8 | 1 | 1 | 386µs | 447ms | Class::MOP::Class::create_anon_class |
| 5 | 2 | 2 | 286µs | 9.97ms | Class::MOP::Class::add_before_method_modifier |
| 21 | 1 | 1 | 259µs | 259µs | Class::MOP::Class::reset_package_cache_flag |
| 2 | 1 | 1 | 117µs | 1.77ms | Class::MOP::Class::add_after_method_modifier |
| 1 | 1 | 1 | 82µs | 105µs | Class::MOP::Class::BEGIN@4 |
| 1 | 1 | 1 | 62µs | 353µs | Class::MOP::Class::BEGIN@14 |
| 1 | 1 | 1 | 62µs | 294µs | Class::MOP::Class::BEGIN@13 |
| 1 | 1 | 1 | 58µs | 255µs | Class::MOP::Class::BEGIN@15 |
| 1 | 1 | 1 | 54µs | 128µs | Class::MOP::Class::BEGIN@445 |
| 1 | 1 | 1 | 51µs | 125µs | Class::MOP::Class::BEGIN@467 |
| 1 | 1 | 1 | 45µs | 248µs | Class::MOP::Class::BEGIN@17 |
| 1 | 1 | 1 | 44µs | 110µs | Class::MOP::Class::BEGIN@480 |
| 1 | 1 | 1 | 42µs | 14.2ms | Class::MOP::Class::BEGIN@24 |
| 1 | 1 | 1 | 40µs | 111µs | Class::MOP::Class::BEGIN@5 |
| 1 | 1 | 1 | 37µs | 177µs | Class::MOP::Class::BEGIN@18 |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::DESTROY |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::__ANON__[:226] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::__ANON__[:794] |
| 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_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::inline_rebless_instance |
| 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 |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::update_package_cache_flag |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | package Class::MOP::Class; | ||||
| 3 | |||||
| 4 | 3 | 110µs | 2 | 128µs | # spent 105µs (82+23) within Class::MOP::Class::BEGIN@4 which was called:
# once (82µs+23µs) by Class::MOP::BEGIN@19 at line 4 # spent 105µs making 1 call to Class::MOP::Class::BEGIN@4
# spent 23µs making 1 call to strict::import |
| 5 | 3 | 114µs | 2 | 183µs | # spent 111µs (40+72) within Class::MOP::Class::BEGIN@5 which was called:
# once (40µs+72µs) by Class::MOP::BEGIN@19 at line 5 # spent 111µs making 1 call to Class::MOP::Class::BEGIN@5
# spent 72µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 3 | 498µs | 1 | 5.98ms | # spent 5.98ms (5.25+733µs) within Class::MOP::Class::BEGIN@7 which was called:
# once (5.25ms+733µs) by Class::MOP::BEGIN@19 at line 7 # spent 5.98ms making 1 call to Class::MOP::Class::BEGIN@7 |
| 8 | 3 | 494µs | 1 | 5.04ms | # spent 5.04ms (4.20+841µs) within Class::MOP::Class::BEGIN@8 which was called:
# once (4.20ms+841µs) by Class::MOP::BEGIN@19 at line 8 # spent 5.04ms making 1 call to Class::MOP::Class::BEGIN@8 |
| 9 | 3 | 485µs | 1 | 8.94ms | # spent 8.94ms (4.50+4.44) within Class::MOP::Class::BEGIN@9 which was called:
# once (4.50ms+4.44ms) by Class::MOP::BEGIN@19 at line 9 # spent 8.94ms making 1 call to Class::MOP::Class::BEGIN@9 |
| 10 | 3 | 571µs | 1 | 9.58ms | # spent 9.58ms (5.08+4.50) within Class::MOP::Class::BEGIN@10 which was called:
# once (5.08ms+4.50ms) by Class::MOP::BEGIN@19 at line 10 # spent 9.58ms making 1 call to Class::MOP::Class::BEGIN@10 |
| 11 | 3 | 698µs | 1 | 2.11ms | # spent 2.11ms (1.80+318µs) within Class::MOP::Class::BEGIN@11 which was called:
# once (1.80ms+318µs) by Class::MOP::BEGIN@19 at line 11 # spent 2.11ms making 1 call to Class::MOP::Class::BEGIN@11 |
| 12 | |||||
| 13 | 3 | 195µs | 2 | 526µs | # spent 294µs (62+232) within Class::MOP::Class::BEGIN@13 which was called:
# once (62µs+232µs) by Class::MOP::BEGIN@19 at line 13 # spent 294µs making 1 call to Class::MOP::Class::BEGIN@13
# spent 232µs making 1 call to Exporter::import |
| 14 | 3 | 176µs | 2 | 644µs | # spent 353µs (62+291) within Class::MOP::Class::BEGIN@14 which was called:
# once (62µs+291µs) by Class::MOP::BEGIN@19 at line 14 # spent 353µs making 1 call to Class::MOP::Class::BEGIN@14
# spent 291µs making 1 call to Exporter::import |
| 15 | 3 | 176µs | 2 | 451µs | # spent 255µs (58+196) within Class::MOP::Class::BEGIN@15 which was called:
# once (58µs+196µs) by Class::MOP::BEGIN@19 at line 15 # spent 255µs making 1 call to Class::MOP::Class::BEGIN@15
# spent 196µs making 1 call to Exporter::import |
| 16 | 3 | 674µs | 2 | 16.4ms | # spent 15.6ms (1.22+14.4) within Class::MOP::Class::BEGIN@16 which was called:
# once (1.22ms+14.4ms) by Class::MOP::BEGIN@19 at line 16 # spent 15.6ms making 1 call to Class::MOP::Class::BEGIN@16
# spent 815µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756] |
| 17 | 3 | 111µs | 2 | 451µs | # spent 248µs (45+203) within Class::MOP::Class::BEGIN@17 which was called:
# once (45µs+203µs) by Class::MOP::BEGIN@19 at line 17 # spent 248µs making 1 call to Class::MOP::Class::BEGIN@17
# spent 203µs making 1 call to Exporter::import |
| 18 | 3 | 228µs | 2 | 316µs | # spent 177µs (37+140) within Class::MOP::Class::BEGIN@18 which was called:
# once (37µs+140µs) by Class::MOP::BEGIN@19 at line 18 # spent 177µs making 1 call to Class::MOP::Class::BEGIN@18
# spent 140µs making 1 call to Exporter::import |
| 19 | |||||
| 20 | 1 | 5µs | our $VERSION = '1.11'; | ||
| 21 | 1 | 87µs | $VERSION = eval $VERSION; # spent 13µs executing statements in string eval | ||
| 22 | 1 | 3µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 23 | |||||
| 24 | 1 | 14.2ms | # spent 14.2ms (42µs+14.2) within Class::MOP::Class::BEGIN@24 which was called:
# once (42µs+14.2ms) by Class::MOP::BEGIN@19 at line 26 # spent 14.2ms making 1 call to base::import | ||
| 25 | 'Class::MOP::Mixin::HasAttributes', | ||||
| 26 | 3 | 6.01ms | 1 | 14.2ms | 'Class::MOP::Mixin::HasMethods'; # spent 14.2ms making 1 call to Class::MOP::Class::BEGIN@24 |
| 27 | |||||
| 28 | # Creation | ||||
| 29 | |||||
| 30 | # spent 367ms (105+262) within Class::MOP::Class::initialize which was called 3144 times, avg 117µs/call:
# 1294 times (40.7ms+11.0ms) by Class::MOP::Class::get_all_attributes at line 826, avg 40µs/call
# 483 times (17.6ms+22.9ms) 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 84µs/call
# 432 times (14.5ms+4.05ms) by Class::MOP::Class::find_method_by_name at line 1018, avg 43µs/call
# 256 times (8.45ms+2.52ms) by Class::MOP::Class::find_next_method_by_name at line 1067, avg 43µs/call
# 107 times (3.41ms+1.01ms) by Moose::Meta::Attribute::_new or Moose::Meta::Method::_new at line 4 of (eval 74)[Class/MOP/Method/Generated.pm:53], avg 41µs/call
# 98 times (3.35ms+963µs) by Class::MOP::Class::find_all_methods_by_name at line 1050, avg 44µs/call
# 82 times (2.72ms+2.34ms) by Class::MOP::Class::_fix_metaclass_incompatibility at line 310, avg 62µs/call
# 79 times (2.40ms+667µs) by Class::MOP::Class::find_attribute_by_name at line 816, avg 39µs/call
# 58 times (1.67ms+529µs) by Class::MOP::Attribute::has_value at line 282 of Class/MOP/Attribute.pm, avg 38µs/call
# 49 times (1.56ms+507µs) by Class::MOP::Class::class_precedence_list at line 927, avg 42µs/call
# 34 times (1.76ms+142ms) by Moose::Meta::Class::initialize at line 68 of Moose/Meta/Class.pm, avg 4.23ms/call
# 33 times (1.33ms+26.7ms) by Class::MOP::Object::meta at line 18 of Class/MOP/Object.pm, avg 849µs/call
# 29 times (818µs+258µs) by Class::MOP::Attribute::get_raw_value at line 274 of Class/MOP/Attribute.pm, avg 37µs/call
# 26 times (814µs+8.51ms) by Class::MOP::Method::_new at line 54 of Class/MOP/Method.pm, avg 358µs/call
# 19 times (983µs+11.0ms) by metaclass::import at line 45 of metaclass.pm, avg 630µs/call
# 18 times (679µs+7.28ms) by Class::MOP::Mixin::meta at line 14 of Class/MOP/Mixin.pm, avg 442µs/call
# 14 times (621µs+14.7ms) by Class::MOP::MiniTrait::apply at line 15 of Class/MOP/MiniTrait.pm, avg 1.09ms/call
# 11 times (342µs+102µs) by Class::MOP::Attribute::set_initial_value at line 253 of Class/MOP/Attribute.pm, avg 40µs/call
# 9 times (278µs+75µs) by Class::MOP::Class::get_all_methods at line 1029, avg 39µs/call
# 7 times (324µs+3.75ms) by Moose::BEGIN@38 at line 11 of Moose/Meta/Attribute/Native.pm, avg 583µs/call
# 2 times (87µs+1.17ms) by Class::MOP::Class::create at line 525, avg 629µs/call
# 2 times (56µs+17µs) by Moose::Meta::Attribute::_weaken_value at line 568 of Moose/Meta/Attribute.pm, avg 37µs/call
# once (40µs+12µs) by Moose::Object::new at line 26 of Moose/Object.pm
# once (32µs+9µs) by Class::MOP::Attribute::_new at line 62 of Class/MOP/Attribute.pm | ||||
| 31 | 15720 | 101ms | my $class = shift; | ||
| 32 | |||||
| 33 | my $package_name; | ||||
| 34 | |||||
| 35 | if ( @_ % 2 ) { | ||||
| 36 | $package_name = shift; | ||||
| 37 | } else { | ||||
| 38 | my %options = @_; | ||||
| 39 | $package_name = $options{package}; | ||||
| 40 | } | ||||
| 41 | |||||
| 42 | ($package_name && !ref($package_name)) | ||||
| 43 | || confess "You must pass a package name and it cannot be blessed"; | ||||
| 44 | |||||
| 45 | 3242 | 266ms | return Class::MOP::get_metaclass_by_name($package_name) # spent 237ms making 98 calls to Class::MOP::Class::_construct_class_instance, avg 2.42ms/call, recursion: max depth 1, sum of overlapping time 1.10ms
# spent 30.4ms making 3144 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 236ms (11.1+225) within Class::MOP::Class::_construct_class_instance which was called 98 times, avg 2.40ms/call:
# 98 times (11.1ms+225ms) by Class::MOP::Class::initialize at line 45, avg 2.40ms/call | ||||
| 75 | 1210 | 10.1ms | my $class = shift; | ||
| 76 | my $options = @_ == 1 ? $_[0] : {@_}; | ||||
| 77 | my $package_name = $options->{package}; | ||||
| 78 | (defined $package_name && $package_name) | ||||
| 79 | || confess "You must pass a package name"; | ||||
| 80 | # NOTE: | ||||
| 81 | # return the metaclass if we have it cached, | ||||
| 82 | # and it is still defined (it has not been | ||||
| 83 | # reaped by DESTROY yet, which can happen | ||||
| 84 | # annoyingly enough during global destruction) | ||||
| 85 | |||||
| 86 | 98 | 800µs | if (defined(my $meta = Class::MOP::get_metaclass_by_name($package_name))) { # spent 800µs making 98 calls to Class::MOP::get_metaclass_by_name, avg 8µs/call | ||
| 87 | return $meta; | ||||
| 88 | } | ||||
| 89 | |||||
| 90 | $class | ||||
| 91 | 8 | 837µs | = ref $class # spent 837µ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 | my $meta; | ||||
| 97 | 64 | 3.91ms | if ($class eq 'Class::MOP::Class') { # spent 3.91ms making 64 calls to Class::MOP::Class::_new, avg 61µ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 | 68 | 120ms | $meta = $class->meta->_construct_instance($options) # spent 118ms making 34 calls to Class::MOP::Class::_construct_instance, avg 3.46ms/call
# spent 2.83ms making 34 calls to Class::MOP::Object::meta, avg 83µs/call | ||
| 106 | } | ||||
| 107 | |||||
| 108 | # and check the metaclass compatibility | ||||
| 109 | 98 | 94.8ms | $meta->_check_metaclass_compatibility(); # spent 98.5ms making 98 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 1.00ms/call, recursion: max depth 1, sum of overlapping time 3.72ms | ||
| 110 | |||||
| 111 | 98 | 1.28ms | Class::MOP::store_metaclass_by_name($package_name, $meta); # spent 1.28ms making 98 calls to Class::MOP::store_metaclass_by_name, avg 13µs/call | ||
| 112 | |||||
| 113 | # NOTE: | ||||
| 114 | # we need to weaken any anon classes | ||||
| 115 | # so that they can call DESTROY properly | ||||
| 116 | Class::MOP::weaken_metaclass($package_name) if $options->{weaken}; | ||||
| 117 | |||||
| 118 | $meta; | ||||
| 119 | } | ||||
| 120 | |||||
| 121 | # spent 7.02ms (3.74+3.28) 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 355, avg 51µs/call
# 39 times (1.08ms+811µs) by Class::MOP::Class::_class_metaclass_is_compatible at line 265, avg 48µs/call
# 8 times (271µs+566µs) by Class::MOP::Class::_construct_class_instance at line 91, avg 105µs/call
# 2 times (61µs+63µs) by Class::MOP::Class::_immutable_metaclass at line 1244, avg 62µs/call | ||||
| 122 | 262 | 3.54ms | 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 | 171 | 3.28ms | return $self->is_immutable # spent 1.96ms making 38 calls to Class::MOP::Class::Immutable::Class::MOP::Class::is_immutable, avg 52µs/call
# spent 651µs making 91 calls to Class::MOP::Class::is_immutable, avg 7µs/call
# spent 558µs making 40 calls to Class::MOP::Class::Immutable::Trait::_get_mutable_metaclass_name, avg 14µs/call
# spent 106µs making 2 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::is_immutable, avg 53µs/call | ||
| 127 | ? $self->_get_mutable_metaclass_name() | ||||
| 128 | : ref $self; | ||||
| 129 | } | ||||
| 130 | |||||
| 131 | # spent 3.91ms within Class::MOP::Class::_new which was called 64 times, avg 61µs/call:
# 64 times (3.91ms+0s) by Class::MOP::Class::_construct_class_instance at line 97, avg 61µs/call | ||||
| 132 | 256 | 4.13ms | my $class = shift; | ||
| 133 | |||||
| 134 | return Class::MOP::Class->initialize($class)->new_object(@_) | ||||
| 135 | if $class ne __PACKAGE__; | ||||
| 136 | |||||
| 137 | my $options = @_ == 1 ? $_[0] : {@_}; | ||||
| 138 | |||||
| 139 | return bless { | ||||
| 140 | # inherited from Class::MOP::Package | ||||
| 141 | 'package' => $options->{package}, | ||||
| 142 | |||||
| 143 | # NOTE: | ||||
| 144 | # since the following attributes will | ||||
| 145 | # actually be loaded from the symbol | ||||
| 146 | # table, and actually bypass the instance | ||||
| 147 | # entirely, we can just leave these things | ||||
| 148 | # listed here for reference, because they | ||||
| 149 | # should not actually have a value associated | ||||
| 150 | # with the slot. | ||||
| 151 | 'namespace' => \undef, | ||||
| 152 | 'methods' => {}, | ||||
| 153 | |||||
| 154 | # inherited from Class::MOP::Module | ||||
| 155 | 'version' => \undef, | ||||
| 156 | 'authority' => \undef, | ||||
| 157 | |||||
| 158 | # defined in Class::MOP::Class | ||||
| 159 | 'superclasses' => \undef, | ||||
| 160 | |||||
| 161 | 'attributes' => {}, | ||||
| 162 | 'attribute_metaclass' => | ||||
| 163 | ( $options->{'attribute_metaclass'} || 'Class::MOP::Attribute' ), | ||||
| 164 | 'method_metaclass' => | ||||
| 165 | ( $options->{'method_metaclass'} || 'Class::MOP::Method' ), | ||||
| 166 | 'wrapped_method_metaclass' => ( | ||||
| 167 | $options->{'wrapped_method_metaclass'} | ||||
| 168 | || 'Class::MOP::Method::Wrapped' | ||||
| 169 | ), | ||||
| 170 | 'instance_metaclass' => | ||||
| 171 | ( $options->{'instance_metaclass'} || 'Class::MOP::Instance' ), | ||||
| 172 | 'immutable_trait' => ( | ||||
| 173 | $options->{'immutable_trait'} | ||||
| 174 | || 'Class::MOP::Class::Immutable::Trait' | ||||
| 175 | ), | ||||
| 176 | 'constructor_name' => ( $options->{constructor_name} || 'new' ), | ||||
| 177 | 'constructor_class' => ( | ||||
| 178 | $options->{constructor_class} || 'Class::MOP::Method::Constructor' | ||||
| 179 | ), | ||||
| 180 | 'destructor_class' => $options->{destructor_class}, | ||||
| 181 | }, $class; | ||||
| 182 | } | ||||
| 183 | |||||
| 184 | 21 | 332µs | # spent 259µs within Class::MOP::Class::reset_package_cache_flag which was called 21 times, avg 12µs/call:
# 21 times (259µs+0s) by Moose::Meta::Role::Application::ToClass::apply_methods at line 190 of Moose/Meta/Role/Application/ToClass.pm, avg 12µs/call | ||
| 185 | sub update_package_cache_flag { | ||||
| 186 | my $self = shift; | ||||
| 187 | # NOTE: | ||||
| 188 | # we can manually update the cache number | ||||
| 189 | # since we are actually adding the method | ||||
| 190 | # to our cache as well. This avoids us | ||||
| 191 | # having to regenerate the method_map. | ||||
| 192 | # - SL | ||||
| 193 | $self->{'_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name); | ||||
| 194 | } | ||||
| 195 | |||||
| 196 | ## Metaclass compatibility | ||||
| 197 | { | ||||
| 198 | 2 | 21µs | my %base_metaclass = ( | ||
| 199 | attribute_metaclass => 'Class::MOP::Attribute', | ||||
| 200 | method_metaclass => 'Class::MOP::Method', | ||||
| 201 | wrapped_method_metaclass => 'Class::MOP::Method::Wrapped', | ||||
| 202 | instance_metaclass => 'Class::MOP::Instance', | ||||
| 203 | constructor_class => 'Class::MOP::Method::Constructor', | ||||
| 204 | destructor_class => 'Class::MOP::Method::Destructor', | ||||
| 205 | ); | ||||
| 206 | |||||
| 207 | 150 | 3.39ms | # spent 2.71ms within Class::MOP::Class::_base_metaclasses which was called 150 times, avg 18µs/call:
# 73 times (1.36ms+0s) by Moose::Meta::Class::_base_metaclasses at line 354 of Moose/Meta/Class.pm, avg 19µs/call
# 43 times (796µs+0s) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 343, avg 19µs/call
# 34 times (546µs+0s) by Class::MOP::Class::_check_metaclass_compatibility at line 218, avg 16µs/call | ||
| 208 | } | ||||
| 209 | |||||
| 210 | # spent 267ms (19.7+247) within Class::MOP::Class::_check_metaclass_compatibility which was called 134 times, avg 1.99ms/call:
# 98 times (4.89ms+89.9ms) by Class::MOP::Class::_construct_class_instance at line 109, avg 967µs/call
# 36 times (14.8ms+157ms) by Class::MOP::Class::superclasses at line 857, avg 4.78ms/call | ||||
| 211 | 1328 | 17.3ms | my $self = shift; | ||
| 212 | |||||
| 213 | 134 | 34.3ms | my @superclasses = $self->superclasses # spent 19.7ms making 66 calls to Class::MOP::Class::superclasses, avg 299µs/call, recursion: max depth 1, sum of overlapping time 539µs
# spent 23.6ms making 68 calls to Moose::Meta::Class::superclasses, avg 347µs/call, recursion: max depth 1, sum of overlapping time 8.45ms | ||
| 214 | or return; | ||||
| 215 | |||||
| 216 | 68 | 123ms | $self->_fix_metaclass_incompatibility(@superclasses); # spent 125ms making 68 calls to Class::MOP::Class::_fix_metaclass_incompatibility, avg 1.84ms/call, recursion: max depth 1, sum of overlapping time 2.48ms | ||
| 217 | |||||
| 218 | 68 | 7.95ms | my %base_metaclass = $self->_base_metaclasses; # spent 7.41ms making 34 calls to Moose::Meta::Class::_base_metaclasses, avg 218µs/call
# spent 546µs making 34 calls to Class::MOP::Class::_base_metaclasses, avg 16µs/call | ||
| 219 | |||||
| 220 | # this is always okay ... | ||||
| 221 | return | ||||
| 222 | if ref($self) eq 'Class::MOP::Class' | ||||
| 223 | && all { | ||||
| 224 | 408 | 3.06ms | 204 | 1.98ms | my $meta = $self->$_; # spent 345µs making 34 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 10µs/call
# spent 339µs making 34 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 10µs/call
# spent 338µs making 34 calls to Class::MOP::Class::destructor_class, avg 10µs/call
# spent 322µs making 34 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 9µs/call
# spent 322µs making 34 calls to Class::MOP::Class::instance_metaclass, avg 9µs/call
# spent 311µs making 34 calls to Class::MOP::Class::constructor_class, avg 9µs/call |
| 225 | 1 | 1.17ms | !defined($meta) || $meta eq $base_metaclass{$_}; | ||
| 226 | } | ||||
| 227 | 34 | 6.51ms | keys %base_metaclass; # spent 6.51ms making 34 calls to List::MoreUtils::all, avg 191µs/call | ||
| 228 | |||||
| 229 | for my $superclass (@superclasses) { | ||||
| 230 | 39 | 6.84ms | $self->_check_class_metaclass_compatibility($superclass); # spent 6.84ms making 39 calls to Class::MOP::Class::_check_class_metaclass_compatibility, avg 175µs/call | ||
| 231 | } | ||||
| 232 | |||||
| 233 | for my $metaclass_type ( keys %base_metaclass ) { | ||||
| 234 | 238 | 3.07ms | next unless defined $self->$metaclass_type; # spent 506µs making 34 calls to Moose::Meta::Class::constructor_class, avg 15µs/call
# spent 475µs making 34 calls to Moose::Meta::Class::error_class, avg 14µs/call
# spent 466µs making 34 calls to Moose::Meta::Class::destructor_class, avg 14µs/call
# spent 424µs making 34 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 12µs/call
# spent 407µs making 34 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 12µs/call
# spent 397µs making 34 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 12µs/call
# spent 391µs making 34 calls to Class::MOP::Class::instance_metaclass, avg 11µs/call | ||
| 235 | for my $superclass (@superclasses) { | ||||
| 236 | 273 | 57.7ms | $self->_check_single_metaclass_compatibility( $metaclass_type, # spent 57.7ms making 273 calls to Class::MOP::Class::_check_single_metaclass_compatibility, avg 211µs/call | ||
| 237 | $superclass ); | ||||
| 238 | } | ||||
| 239 | } | ||||
| 240 | } | ||||
| 241 | |||||
| 242 | # spent 6.84ms (1.08+5.76) within Class::MOP::Class::_check_class_metaclass_compatibility which was called 39 times, avg 175µs/call:
# 39 times (1.08ms+5.76ms) by Class::MOP::Class::_check_metaclass_compatibility at line 230, avg 175µs/call | ||||
| 243 | 117 | 1.04ms | my $self = shift; | ||
| 244 | my ( $superclass_name ) = @_; | ||||
| 245 | |||||
| 246 | 39 | 5.76ms | if (!$self->_class_metaclass_is_compatible($superclass_name)) { # spent 5.76ms making 39 calls to Class::MOP::Class::_class_metaclass_is_compatible, avg 148µs/call | ||
| 247 | my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name); | ||||
| 248 | |||||
| 249 | my $super_meta_type = $super_meta->_real_ref_name; | ||||
| 250 | |||||
| 251 | confess "The metaclass of " . $self->name . " (" | ||||
| 252 | . (ref($self)) . ")" . " is not compatible with " | ||||
| 253 | . "the metaclass of its superclass, " | ||||
| 254 | . $superclass_name . " (" . ($super_meta_type) . ")"; | ||||
| 255 | } | ||||
| 256 | } | ||||
| 257 | |||||
| 258 | # spent 5.76ms (2.21+3.54) within Class::MOP::Class::_class_metaclass_is_compatible which was called 39 times, avg 148µs/call:
# 39 times (2.21ms+3.54ms) by Class::MOP::Class::_check_class_metaclass_compatibility at line 246, avg 148µs/call | ||||
| 259 | 195 | 1.95ms | my $self = shift; | ||
| 260 | my ( $superclass_name ) = @_; | ||||
| 261 | |||||
| 262 | 39 | 406µs | my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name) # spent 406µs making 39 calls to Class::MOP::get_metaclass_by_name, avg 10µs/call | ||
| 263 | || return 1; | ||||
| 264 | |||||
| 265 | 39 | 1.89ms | my $super_meta_name = $super_meta->_real_ref_name; # spent 1.89ms making 39 calls to Class::MOP::Class::_real_ref_name, avg 48µs/call | ||
| 266 | |||||
| 267 | 39 | 1.25ms | return $self->_is_compatible_with($super_meta_name); # spent 1.25ms making 39 calls to Class::MOP::Object::_is_compatible_with, avg 32µs/call | ||
| 268 | } | ||||
| 269 | |||||
| 270 | # spent 57.7ms (7.23+50.5) within Class::MOP::Class::_check_single_metaclass_compatibility which was called 273 times, avg 211µs/call:
# 273 times (7.23ms+50.5ms) by Class::MOP::Class::_check_metaclass_compatibility at line 236, avg 211µs/call | ||||
| 271 | 819 | 6.90ms | my $self = shift; | ||
| 272 | my ( $metaclass_type, $superclass_name ) = @_; | ||||
| 273 | |||||
| 274 | 273 | 50.5ms | if (!$self->_single_metaclass_is_compatible($metaclass_type, $superclass_name)) { # spent 50.5ms making 273 calls to Class::MOP::Class::_single_metaclass_is_compatible, avg 185µs/call | ||
| 275 | my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name); | ||||
| 276 | my $metaclass_type_name = $metaclass_type; | ||||
| 277 | $metaclass_type_name =~ s/_(?:meta)?class$//; | ||||
| 278 | $metaclass_type_name =~ s/_/ /g; | ||||
| 279 | confess "The $metaclass_type_name metaclass for " | ||||
| 280 | . $self->name . " (" . ($self->$metaclass_type) | ||||
| 281 | . ")" . " is not compatible with the " | ||||
| 282 | . "$metaclass_type_name metaclass of its " | ||||
| 283 | . "superclass, $superclass_name (" | ||||
| 284 | . ($super_meta->$metaclass_type) . ")"; | ||||
| 285 | } | ||||
| 286 | } | ||||
| 287 | |||||
| 288 | # spent 50.5ms (27.2+23.2) within Class::MOP::Class::_single_metaclass_is_compatible which was called 273 times, avg 185µs/call:
# 273 times (27.2ms+23.2ms) by Class::MOP::Class::_check_single_metaclass_compatibility at line 274, avg 185µs/call | ||||
| 289 | 1846 | 24.5ms | my $self = shift; | ||
| 290 | my ( $metaclass_type, $superclass_name ) = @_; | ||||
| 291 | |||||
| 292 | 273 | 2.33ms | my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name) # spent 2.33ms making 273 calls to Class::MOP::get_metaclass_by_name, avg 9µs/call | ||
| 293 | || return 1; | ||||
| 294 | |||||
| 295 | # for instance, Moose::Meta::Class has a error_class attribute, but | ||||
| 296 | # Class::MOP::Class doesn't - this shouldn't be an error | ||||
| 297 | 273 | 1.72ms | return 1 unless $super_meta->can($metaclass_type); # spent 1.72ms making 273 calls to UNIVERSAL::can, avg 6µs/call | ||
| 298 | # for instance, Moose::Meta::Class has a destructor_class, but | ||||
| 299 | # Class::MOP::Class doesn't - this shouldn't be an error | ||||
| 300 | 260 | 2.82ms | return 1 unless defined $super_meta->$metaclass_type; # spent 413µs making 39 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 11µs/call
# spent 398µs making 39 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 10µs/call
# spent 386µs making 39 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 10µs/call
# spent 386µs making 39 calls to Class::MOP::Class::instance_metaclass, avg 10µs/call
# spent 366µs making 26 calls to Moose::Meta::Class::constructor_class, avg 14µs/call
# spent 311µs making 26 calls to Moose::Meta::Class::destructor_class, avg 12µs/call
# spent 308µs making 26 calls to Moose::Meta::Class::error_class, avg 12µs/call
# spent 128µs making 13 calls to Class::MOP::Class::constructor_class, avg 10µs/call
# spent 121µs making 13 calls to Class::MOP::Class::destructor_class, avg 9µs/call | ||
| 301 | # if metaclass is defined in superclass but not here, it's not compatible | ||||
| 302 | # this is a really odd case | ||||
| 303 | 247 | 2.61ms | return 0 unless defined $self->$metaclass_type; # spent 469µs making 39 calls to Moose::Meta::Class::constructor_class, avg 12µs/call
# spent 442µs making 39 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 11µs/call
# spent 384µs making 39 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 10µs/call
# spent 364µs making 39 calls to Class::MOP::Class::instance_metaclass, avg 9µs/call
# spent 360µs making 39 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 9µs/call
# spent 296µs making 26 calls to Moose::Meta::Class::error_class, avg 11µs/call
# spent 296µs making 26 calls to Moose::Meta::Class::destructor_class, avg 11µs/call | ||
| 304 | |||||
| 305 | 741 | 13.8ms | return $self->$metaclass_type->_is_compatible_with($super_meta->$metaclass_type); # spent 8.72ms making 247 calls to Class::MOP::Object::_is_compatible_with, avg 35µs/call
# spent 770µs making 78 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 10µs/call
# spent 759µs making 65 calls to Moose::Meta::Class::constructor_class, avg 12µs/call
# spent 737µs making 78 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 9µs/call
# spent 724µs making 78 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 9µs/call
# spent 700µs making 78 calls to Class::MOP::Class::instance_metaclass, avg 9µs/call
# spent 598µs making 52 calls to Moose::Meta::Class::error_class, avg 11µs/call
# spent 590µs making 52 calls to Moose::Meta::Class::destructor_class, avg 11µs/call
# spent 158µs making 13 calls to Class::MOP::Class::constructor_class, avg 12µs/call | ||
| 306 | } | ||||
| 307 | |||||
| 308 | # spent 123ms (4.91+118) within Class::MOP::Class::_fix_metaclass_incompatibility which was called 68 times, avg 1.81ms/call:
# 68 times (4.91ms+118ms) by Class::MOP::Class::_check_metaclass_compatibility at line 216, avg 1.81ms/call | ||||
| 309 | 504 | 4.54ms | my $self = shift; | ||
| 310 | 82 | 5.06ms | my @supers = map { Class::MOP::Class->initialize($_) } @_; # spent 7.84ms making 82 calls to Class::MOP::Class::initialize, avg 96µs/call, recursion: max depth 1, sum of overlapping time 2.78ms | ||
| 311 | |||||
| 312 | my $necessary = 0; | ||||
| 313 | for my $super (@supers) { | ||||
| 314 | 82 | 113ms | $necessary = 1 # spent 113ms making 82 calls to Class::MOP::Class::_can_fix_metaclass_incompatibility, avg 1.37ms/call | ||
| 315 | if $self->_can_fix_metaclass_incompatibility($super); | ||||
| 316 | } | ||||
| 317 | return unless $necessary; | ||||
| 318 | |||||
| 319 | for my $super (@supers) { | ||||
| 320 | if (!$self->_class_metaclass_is_compatible($super->name)) { | ||||
| 321 | $self->_fix_class_metaclass_incompatibility($super); | ||||
| 322 | } | ||||
| 323 | } | ||||
| 324 | |||||
| 325 | my %base_metaclass = $self->_base_metaclasses; | ||||
| 326 | for my $metaclass_type (keys %base_metaclass) { | ||||
| 327 | for my $super (@supers) { | ||||
| 328 | if (!$self->_single_metaclass_is_compatible($metaclass_type, $super->name)) { | ||||
| 329 | $self->_fix_single_metaclass_incompatibility( | ||||
| 330 | $metaclass_type, $super | ||||
| 331 | ); | ||||
| 332 | } | ||||
| 333 | } | ||||
| 334 | } | ||||
| 335 | } | ||||
| 336 | |||||
| 337 | # spent 113ms (14.1+98.6) within Class::MOP::Class::_can_fix_metaclass_incompatibility which was called 82 times, avg 1.37ms/call:
# 82 times (14.1ms+98.6ms) by Class::MOP::Class::_fix_metaclass_incompatibility at line 314, avg 1.37ms/call | ||||
| 338 | 1023 | 12.7ms | my $self = shift; | ||
| 339 | my ($super_meta) = @_; | ||||
| 340 | |||||
| 341 | 82 | 12.0ms | return 1 if $self->_class_metaclass_can_be_made_compatible($super_meta); # spent 12.0ms making 82 calls to Class::MOP::Class::_class_metaclass_can_be_made_compatible, avg 147µs/call | ||
| 342 | |||||
| 343 | 82 | 9.41ms | my %base_metaclass = $self->_base_metaclasses; # spent 8.62ms making 39 calls to Moose::Meta::Class::_base_metaclasses, avg 221µs/call
# spent 796µs making 43 calls to Class::MOP::Class::_base_metaclasses, avg 19µs/call | ||
| 344 | for my $metaclass_type (keys %base_metaclass) { | ||||
| 345 | 531 | 77.1ms | return 1 if $self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type); # spent 77.1ms making 531 calls to Class::MOP::Class::_single_metaclass_can_be_made_compatible, avg 145µs/call | ||
| 346 | } | ||||
| 347 | |||||
| 348 | return; | ||||
| 349 | } | ||||
| 350 | |||||
| 351 | # spent 12.0ms (2.91+9.12) within Class::MOP::Class::_class_metaclass_can_be_made_compatible which was called 82 times, avg 147µs/call:
# 82 times (2.91ms+9.12ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 341, avg 147µs/call | ||||
| 352 | 246 | 2.78ms | my $self = shift; | ||
| 353 | my ($super_meta) = @_; | ||||
| 354 | |||||
| 355 | 164 | 9.12ms | return $self->_can_be_made_compatible_with($super_meta->_real_ref_name); # spent 4.95ms making 82 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 60µs/call
# spent 4.17ms making 82 calls to Class::MOP::Class::_real_ref_name, avg 51µs/call | ||
| 356 | } | ||||
| 357 | |||||
| 358 | # spent 77.1ms (37.6+39.5) within Class::MOP::Class::_single_metaclass_can_be_made_compatible which was called 531 times, avg 145µs/call:
# 531 times (37.6ms+39.5ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 345, avg 145µs/call | ||||
| 359 | 4084 | 37.4ms | my $self = shift; | ||
| 360 | my ($super_meta, $metaclass_type) = @_; | ||||
| 361 | |||||
| 362 | 531 | 5.79ms | my $specific_meta = $self->$metaclass_type; # spent 925µs making 82 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 11µs/call
# spent 917µs making 82 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 11µs/call
# spent 870µs making 82 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 11µs/call
# spent 784µs making 82 calls to Class::MOP::Class::instance_metaclass, avg 10µs/call
# spent 537µs making 39 calls to Moose::Meta::Class::error_class, avg 14µs/call
# spent 515µs making 39 calls to Moose::Meta::Class::destructor_class, avg 13µs/call
# spent 510µs making 39 calls to Moose::Meta::Class::constructor_class, avg 13µs/call
# spent 384µs making 43 calls to Class::MOP::Class::constructor_class, avg 9µs/call
# spent 343µs making 43 calls to Class::MOP::Class::destructor_class, avg 8µs/call | ||
| 363 | |||||
| 364 | 531 | 3.55ms | return unless $super_meta->can($metaclass_type); # spent 3.55ms making 531 calls to UNIVERSAL::can, avg 7µs/call | ||
| 365 | 518 | 5.12ms | my $super_specific_meta = $super_meta->$metaclass_type; # spent 827µs making 82 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 10µs/call
# spent 800µs making 82 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 10µs/call
# spent 786µs making 82 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 10µs/call
# spent 770µs making 82 calls to Class::MOP::Class::instance_metaclass, avg 9µs/call
# spent 518µs making 56 calls to Class::MOP::Class::constructor_class, avg 9µs/call
# spent 458µs making 56 calls to Class::MOP::Class::destructor_class, avg 8µs/call
# spent 337µs making 26 calls to Moose::Meta::Class::error_class, avg 13µs/call
# spent 314µs making 26 calls to Moose::Meta::Class::destructor_class, avg 12µs/call
# spent 314µs making 26 calls to Moose::Meta::Class::constructor_class, avg 12µs/call | ||
| 366 | |||||
| 367 | # for instance, Moose::Meta::Class has a destructor_class, but | ||||
| 368 | # Class::MOP::Class doesn't - this shouldn't be an error | ||||
| 369 | return unless defined $super_specific_meta; | ||||
| 370 | |||||
| 371 | # if metaclass is defined in superclass but not here, it's fixable | ||||
| 372 | # this is a really odd case | ||||
| 373 | return 1 unless defined $specific_meta; | ||||
| 374 | |||||
| 375 | 462 | 25.0ms | return 1 if $specific_meta->_can_be_made_compatible_with($super_specific_meta); # spent 25.0ms making 462 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 54µs/call | ||
| 376 | } | ||||
| 377 | |||||
| 378 | sub _fix_class_metaclass_incompatibility { | ||||
| 379 | my $self = shift; | ||||
| 380 | my ( $super_meta ) = @_; | ||||
| 381 | |||||
| 382 | if ($self->_class_metaclass_can_be_made_compatible($super_meta)) { | ||||
| 383 | ($self->is_pristine) | ||||
| 384 | || confess "Can't fix metaclass incompatibility for " | ||||
| 385 | . $self->name | ||||
| 386 | . " because it is not pristine."; | ||||
| 387 | |||||
| 388 | my $super_meta_name = $super_meta->_real_ref_name; | ||||
| 389 | |||||
| 390 | $self->_make_compatible_with($super_meta_name); | ||||
| 391 | } | ||||
| 392 | } | ||||
| 393 | |||||
| 394 | sub _fix_single_metaclass_incompatibility { | ||||
| 395 | my $self = shift; | ||||
| 396 | my ( $metaclass_type, $super_meta ) = @_; | ||||
| 397 | |||||
| 398 | if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) { | ||||
| 399 | ($self->is_pristine) | ||||
| 400 | || confess "Can't fix metaclass incompatibility for " | ||||
| 401 | . $self->name | ||||
| 402 | . " because it is not pristine."; | ||||
| 403 | |||||
| 404 | my $new_metaclass = $self->$metaclass_type | ||||
| 405 | ? $self->$metaclass_type->_get_compatible_metaclass($super_meta->$metaclass_type) | ||||
| 406 | : $super_meta->$metaclass_type; | ||||
| 407 | $self->{$metaclass_type} = $new_metaclass; | ||||
| 408 | } | ||||
| 409 | } | ||||
| 410 | |||||
| 411 | sub _restore_metaobjects_from { | ||||
| 412 | my $self = shift; | ||||
| 413 | my ($old_meta) = @_; | ||||
| 414 | |||||
| 415 | $self->_restore_metamethods_from($old_meta); | ||||
| 416 | $self->_restore_metaattributes_from($old_meta); | ||||
| 417 | } | ||||
| 418 | |||||
| 419 | sub _remove_generated_metaobjects { | ||||
| 420 | my $self = shift; | ||||
| 421 | |||||
| 422 | for my $attr (map { $self->get_attribute($_) } $self->get_attribute_list) { | ||||
| 423 | $attr->remove_accessors; | ||||
| 424 | } | ||||
| 425 | } | ||||
| 426 | |||||
| 427 | ## ANON classes | ||||
| 428 | |||||
| 429 | { | ||||
| 430 | # NOTE: | ||||
| 431 | # this should be sufficient, if you have a | ||||
| 432 | # use case where it is not, write a test and | ||||
| 433 | # I will change it. | ||||
| 434 | 2 | 6µs | my $ANON_CLASS_SERIAL = 0; | ||
| 435 | |||||
| 436 | # NOTE: | ||||
| 437 | # we need a sufficiently annoying prefix | ||||
| 438 | # this should suffice for now, this is | ||||
| 439 | # used in a couple of places below, so | ||||
| 440 | # need to put it up here for now. | ||||
| 441 | 1 | 3µs | my $ANON_CLASS_PREFIX = 'Class::MOP::Class::__ANON__::SERIAL::'; | ||
| 442 | |||||
| 443 | sub is_anon_class { | ||||
| 444 | my $self = shift; | ||||
| 445 | 3 | 425µs | 2 | 203µs | # spent 128µs (54+74) within Class::MOP::Class::BEGIN@445 which was called:
# once (54µs+74µs) by Class::MOP::BEGIN@19 at line 445 # spent 128µs making 1 call to Class::MOP::Class::BEGIN@445
# spent 74µs making 1 call to warnings::unimport |
| 446 | $self->name =~ /^$ANON_CLASS_PREFIX/o; | ||||
| 447 | } | ||||
| 448 | |||||
| 449 | # spent 447ms (386µs+446) within Class::MOP::Class::create_anon_class which was called 8 times, avg 55.8ms/call:
# 8 times (386µs+446ms) by Moose::Meta::Class::create_anon_class at line 111 of Moose/Meta/Class.pm, avg 55.8ms/call | ||||
| 450 | 32 | 359µs | my ($class, %options) = @_; | ||
| 451 | $options{weaken} = 1 unless exists $options{weaken}; | ||||
| 452 | my $package_name = $ANON_CLASS_PREFIX . ++$ANON_CLASS_SERIAL; | ||||
| 453 | 8 | 446ms | return $class->create($package_name, %options); # spent 446ms making 8 calls to Moose::Meta::Class::create, avg 55.8ms/call | ||
| 454 | } | ||||
| 455 | |||||
| 456 | # NOTE: | ||||
| 457 | # this will only get called for | ||||
| 458 | # anon-classes, all other calls | ||||
| 459 | # are assumed to occur during | ||||
| 460 | # global destruction and so don't | ||||
| 461 | # really need to be handled explicitly | ||||
| 462 | sub DESTROY { | ||||
| 463 | my $self = shift; | ||||
| 464 | |||||
| 465 | return if in_global_destruction(); # it'll happen soon anyway and this just makes things more complicated | ||||
| 466 | |||||
| 467 | 3 | 298µs | 2 | 199µs | # spent 125µs (51+74) within Class::MOP::Class::BEGIN@467 which was called:
# once (51µs+74µs) by Class::MOP::BEGIN@19 at line 467 # spent 125µs making 1 call to Class::MOP::Class::BEGIN@467
# spent 74µs making 1 call to warnings::unimport |
| 468 | my $name = $self->name; | ||||
| 469 | return unless $name =~ /^$ANON_CLASS_PREFIX/o; | ||||
| 470 | |||||
| 471 | # Moose does a weird thing where it replaces the metaclass for | ||||
| 472 | # class when fixing metaclass incompatibility. In that case, | ||||
| 473 | # we don't want to clean out the namespace now. We can detect | ||||
| 474 | # that because Moose will explicitly update the singleton | ||||
| 475 | # cache in Class::MOP. | ||||
| 476 | my $current_meta = Class::MOP::get_metaclass_by_name($name); | ||||
| 477 | return if $current_meta ne $self; | ||||
| 478 | |||||
| 479 | my ($serial_id) = ($name =~ /^$ANON_CLASS_PREFIX(\d+)/o); | ||||
| 480 | 3 | 14.2ms | 2 | 175µs | # spent 110µs (44+66) within Class::MOP::Class::BEGIN@480 which was called:
# once (44µs+66µs) by Class::MOP::BEGIN@19 at line 480 # spent 110µs making 1 call to Class::MOP::Class::BEGIN@480
# spent 66µs making 1 call to strict::unimport |
| 481 | @{$name . '::ISA'} = (); | ||||
| 482 | %{$name . '::'} = (); | ||||
| 483 | delete ${$ANON_CLASS_PREFIX}{$serial_id . '::'}; | ||||
| 484 | |||||
| 485 | Class::MOP::remove_metaclass_by_name($name); | ||||
| 486 | } | ||||
| 487 | |||||
| 488 | } | ||||
| 489 | |||||
| 490 | # creating classes with MOP ... | ||||
| 491 | |||||
| 492 | # spent 135ms (1.79+134) within Class::MOP::Class::create which was called 10 times, avg 13.5ms/call:
# 8 times (1.44ms+122ms) by Moose::Meta::Class::create at line 85 of Moose/Meta/Class.pm, avg 15.4ms/call
# 2 times (355µs+11.6ms) by Class::MOP::Class::_immutable_metaclass at line 1246, avg 5.99ms/call | ||||
| 493 | 170 | 1.70ms | my ( $class, @args ) = @_; | ||
| 494 | |||||
| 495 | unshift @args, 'package' if @args % 2 == 1; | ||||
| 496 | |||||
| 497 | my (%options) = @args; | ||||
| 498 | my $package_name = $options{package}; | ||||
| 499 | |||||
| 500 | (ref $options{superclasses} eq 'ARRAY') | ||||
| 501 | || confess "You must pass an ARRAY ref of superclasses" | ||||
| 502 | if exists $options{superclasses}; | ||||
| 503 | |||||
| 504 | (ref $options{attributes} eq 'ARRAY') | ||||
| 505 | || confess "You must pass an ARRAY ref of attributes" | ||||
| 506 | if exists $options{attributes}; | ||||
| 507 | |||||
| 508 | (ref $options{methods} eq 'HASH') | ||||
| 509 | || confess "You must pass a HASH ref of methods" | ||||
| 510 | if exists $options{methods}; | ||||
| 511 | |||||
| 512 | $options{meta_name} = 'meta' | ||||
| 513 | unless exists $options{meta_name}; | ||||
| 514 | |||||
| 515 | my (%initialize_options) = @args; | ||||
| 516 | delete @initialize_options{qw( | ||||
| 517 | package | ||||
| 518 | superclasses | ||||
| 519 | attributes | ||||
| 520 | methods | ||||
| 521 | meta_name | ||||
| 522 | version | ||||
| 523 | authority | ||||
| 524 | )}; | ||||
| 525 | 10 | 35.5ms | my $meta = $class->initialize( $package_name => %initialize_options ); # spent 34.2ms making 8 calls to Moose::Meta::Class::initialize, avg 4.28ms/call
# spent 1.26ms making 2 calls to Class::MOP::Class::initialize, avg 629µs/call | ||
| 526 | |||||
| 527 | 10 | 1.24ms | $meta->_instantiate_module( $options{version}, $options{authority} ); # spent 1.24ms making 10 calls to Class::MOP::Module::_instantiate_module, avg 124µs/call | ||
| 528 | |||||
| 529 | 10 | 27.5ms | $meta->_add_meta_method($options{meta_name}) # spent 27.5ms making 10 calls to Class::MOP::Mixin::HasMethods::_add_meta_method, avg 2.75ms/call | ||
| 530 | if defined $options{meta_name}; | ||||
| 531 | |||||
| 532 | 10 | 69.3ms | $meta->superclasses(@{$options{superclasses}}) # spent 64.3ms making 8 calls to Moose::Meta::Class::superclasses, avg 8.04ms/call
# spent 5.01ms making 2 calls to Class::MOP::Class::superclasses, avg 2.50ms/call | ||
| 533 | if exists $options{superclasses}; | ||||
| 534 | # NOTE: | ||||
| 535 | # process attributes first, so that they can | ||||
| 536 | # install accessors, but locally defined methods | ||||
| 537 | # can then overwrite them. It is maybe a little odd, but | ||||
| 538 | # I think this should be the order of things. | ||||
| 539 | if (exists $options{attributes}) { | ||||
| 540 | foreach my $attr (@{$options{attributes}}) { | ||||
| 541 | $meta->add_attribute($attr); | ||||
| 542 | } | ||||
| 543 | } | ||||
| 544 | if (exists $options{methods}) { | ||||
| 545 | foreach my $method_name (keys %{$options{methods}}) { | ||||
| 546 | $meta->add_method($method_name, $options{methods}->{$method_name}); | ||||
| 547 | } | ||||
| 548 | } | ||||
| 549 | return $meta; | ||||
| 550 | } | ||||
| 551 | |||||
| 552 | ## Attribute readers | ||||
| 553 | |||||
| 554 | # NOTE: | ||||
| 555 | # all these attribute readers will be bootstrapped | ||||
| 556 | # away in the Class::MOP bootstrap section | ||||
| 557 | |||||
| 558 | 851 | 12.0ms | sub instance_metaclass { $_[0]->{'instance_metaclass'} } | ||
| 559 | 102 | 1.41ms | sub immutable_trait { $_[0]->{'immutable_trait'} } | ||
| 560 | 210 | 2.80ms | sub constructor_class { $_[0]->{'constructor_class'} } | ||
| 561 | 75 | 978µs | sub constructor_name { $_[0]->{'constructor_name'} } | ||
| 562 | 197 | 2.34ms | sub destructor_class { $_[0]->{'destructor_class'} } | ||
| 563 | |||||
| 564 | # Instance Construction & Cloning | ||||
| 565 | |||||
| 566 | # spent 202ms (6.68+195) within Class::MOP::Class::new_object which was called 138 times, avg 1.46ms/call:
# 102 times (4.81ms+132ms) by Moose::Meta::Method::_new at line 4 of (eval 74)[Class/MOP/Method/Generated.pm:53], avg 1.34ms/call
# 26 times (1.34ms+30.9ms) by Class::MOP::Method::_new at line 54 of Class/MOP/Method.pm, avg 1.24ms/call
# 6 times (289µs+24.0ms) by Moose::Meta::Class::new_object at line 256 of Moose/Meta/Class.pm, avg 4.05ms/call
# 2 times (123µs+2.78ms) by Moose::Meta::TypeCoercion::new at line 34 of Moose/Meta/TypeCoercion.pm, avg 1.45ms/call
# once (67µs+4.20ms) by Class::MOP::Attribute::_new at line 62 of Class/MOP/Attribute.pm
# once (54µs+1.37ms) by Class::MOP::Object::_new at line 22 of Class/MOP/Object.pm | ||||
| 567 | 414 | 9.57ms | my $class = shift; | ||
| 568 | |||||
| 569 | # NOTE: | ||||
| 570 | # we need to protect the integrity of the | ||||
| 571 | # Class::MOP::Class singletons here, so we | ||||
| 572 | # delegate this to &construct_class_instance | ||||
| 573 | # which will deal with the singletons | ||||
| 574 | 276 | 2.80ms | return $class->_construct_class_instance(@_) # spent 2.00ms making 138 calls to UNIVERSAL::isa, avg 14µs/call
# spent 798µs making 138 calls to Class::MOP::Package::name, avg 6µs/call | ||
| 575 | if $class->name->isa('Class::MOP::Class'); | ||||
| 576 | 138 | 192ms | return $class->_construct_instance(@_); # spent 192ms making 138 calls to Class::MOP::Class::_construct_instance, avg 1.39ms/call | ||
| 577 | } | ||||
| 578 | |||||
| 579 | # spent 310ms (42.8+267) within Class::MOP::Class::_construct_instance which was called 172 times, avg 1.80ms/call:
# 138 times (29.3ms+163ms) by Class::MOP::Class::new_object at line 576, avg 1.39ms/call
# 34 times (13.5ms+104ms) by Class::MOP::Class::_construct_class_instance at line 105, avg 3.46ms/call | ||||
| 580 | 2996 | 41.6ms | my $class = shift; | ||
| 581 | my $params = @_ == 1 ? $_[0] : {@_}; | ||||
| 582 | 172 | 14.2ms | my $meta_instance = $class->get_meta_instance(); # spent 10.7ms making 117 calls to Class::MOP::Class::get_meta_instance, avg 91µs/call
# spent 3.46ms making 55 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 63µs/call | ||
| 583 | # FIXME: | ||||
| 584 | # the code below is almost certainly incorrect | ||||
| 585 | # but this is foreign inheritance, so we might | ||||
| 586 | # have to kludge it in the end. | ||||
| 587 | my $instance; | ||||
| 588 | 172 | 1.30ms | if (my $instance_class = blessed($params->{__INSTANCE__})) { # spent 1.30ms making 172 calls to Scalar::Util::blessed, avg 8µs/call | ||
| 589 | ($instance_class eq $class->name) | ||||
| 590 | || confess "Objects passed as the __INSTANCE__ parameter must " | ||||
| 591 | . "already be blessed into the correct class, but " | ||||
| 592 | . "$params->{__INSTANCE__} is not a " . $class->name; | ||||
| 593 | $instance = $params->{__INSTANCE__}; | ||||
| 594 | } | ||||
| 595 | elsif (exists $params->{__INSTANCE__}) { | ||||
| 596 | confess "The __INSTANCE__ parameter must be a blessed reference, not " | ||||
| 597 | . $params->{__INSTANCE__}; | ||||
| 598 | } | ||||
| 599 | else { | ||||
| 600 | 172 | 12.7ms | $instance = $meta_instance->create_instance(); # spent 12.7ms making 172 calls to Class::MOP::Instance::create_instance, avg 74µs/call | ||
| 601 | } | ||||
| 602 | 172 | 64.3ms | foreach my $attr ($class->get_all_attributes()) { # spent 59.4ms making 117 calls to Class::MOP::Class::get_all_attributes, avg 508µs/call
# spent 4.89ms making 55 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 89µs/call | ||
| 603 | 1448 | 169ms | $attr->initialize_instance_slot($meta_instance, $instance, $params); # spent 161ms making 1434 calls to Class::MOP::Attribute::initialize_instance_slot, avg 112µs/call
# spent 7.88ms making 14 calls to Moose::Meta::Attribute::initialize_instance_slot, avg 563µs/call | ||
| 604 | } | ||||
| 605 | 344 | 5.43ms | if (Class::MOP::metaclass_is_weak($class->name)) { # spent 4.36ms making 172 calls to Class::MOP::metaclass_is_weak, avg 25µs/call
# spent 1.07ms making 172 calls to Class::MOP::Package::name, avg 6µs/call | ||
| 606 | $meta_instance->_set_mop_slot($instance, $class); | ||||
| 607 | } | ||||
| 608 | return $instance; | ||||
| 609 | } | ||||
| 610 | |||||
| 611 | |||||
| 612 | # spent 168ms (12.4+156) within Class::MOP::Class::get_meta_instance which was called 815 times, avg 206µs/call:
# 196 times (2.74ms+24.4ms) by Moose::Meta::Attribute::inline_set at line 697 of Moose/Meta/Attribute.pm, avg 139µs/call
# 195 times (3.76ms+83.9ms) by Class::MOP::Attribute::inline_get at line 411 of Class/MOP/Attribute.pm, avg 450µs/call
# 126 times (1.62ms+8.55ms) by Class::MOP::Attribute::inline_set at line 419 of Class/MOP/Attribute.pm, avg 81µs/call
# 117 times (1.65ms+9.04ms) by Class::MOP::Class::_construct_instance at line 582, avg 91µs/call
# 62 times (811µs+0s) by Class::MOP::Attribute::inline_has at line 428 of Class/MOP/Attribute.pm, avg 13µs/call
# 55 times (771µs+8.14ms) by Class::MOP::Class::inline_create_instance at line 634, avg 162µs/call
# 29 times (399µs+609µs) by Class::MOP::Attribute::inline_clear at line 437 of Class/MOP/Attribute.pm, avg 35µs/call
# 21 times (450µs+20.1ms) by Class::MOP::Class:::around at line 74 of Class/MOP/Class/Immutable/Trait.pm, avg 979µs/call
# 9 times (113µs+0s) by Class::MOP::Attribute::set_initial_value at line 253 of Class/MOP/Attribute.pm, avg 13µs/call
# 3 times (36µs+0s) by Class::MOP::Attribute::get_raw_value at line 274 of Class/MOP/Attribute.pm, avg 12µs/call
# once (28µs+792µs) by Moose::Exporter::BEGIN@11 at line 684 of Class/MOP.pm
# once (13µs+0s) by Class::MOP::Attribute::has_value at line 282 of Class/MOP/Attribute.pm | ||||
| 613 | 1630 | 14.3ms | my $self = shift; | ||
| 614 | 173 | 156ms | $self->{'_meta_instance'} ||= $self->_create_meta_instance(); # spent 156ms making 173 calls to Class::MOP::Class::_create_meta_instance, avg 899µs/call | ||
| 615 | } | ||||
| 616 | |||||
| 617 | # spent 156ms (12.8+143) within Class::MOP::Class::_create_meta_instance which was called 173 times, avg 899µs/call:
# 173 times (12.8ms+143ms) by Class::MOP::Class::get_meta_instance at line 614, avg 899µs/call | ||||
| 618 | 692 | 11.6ms | my $self = shift; | ||
| 619 | |||||
| 620 | 519 | 141ms | my $instance = $self->instance_metaclass->new( # spent 80.7ms making 173 calls to Class::MOP::Instance::new, avg 466µs/call
# spent 52.0ms making 161 calls to Class::MOP::Class::get_all_attributes, avg 323µs/call
# spent 6.77ms making 12 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 564µs/call
# spent 1.62ms making 173 calls to Class::MOP::Class::instance_metaclass, avg 9µs/call | ||
| 621 | associated_metaclass => $self, | ||||
| 622 | attributes => [ $self->get_all_attributes() ], | ||||
| 623 | ); | ||||
| 624 | |||||
| 625 | 173 | 1.62ms | $self->add_meta_instance_dependencies() # spent 1.62ms making 173 calls to Class::MOP::Instance::is_dependent_on_superclasses, avg 9µs/call | ||
| 626 | if $instance->is_dependent_on_superclasses(); | ||||
| 627 | |||||
| 628 | return $instance; | ||||
| 629 | } | ||||
| 630 | |||||
| 631 | # spent 11.9ms (2.11+9.76) within Class::MOP::Class::inline_create_instance which was called 55 times, avg 216µs/call:
# 31 times (1.15ms+8.53ms) by Class::MOP::Method::Constructor::_generate_constructor_method_inline at line 112 of Class/MOP/Method/Constructor.pm, avg 312µs/call
# 24 times (960µs+1.23ms) by Moose::Meta::Method::Constructor::_generate_instance at line 132 of Moose/Meta/Method/Constructor.pm, avg 91µs/call | ||||
| 632 | 110 | 1.84ms | my $self = shift; | ||
| 633 | |||||
| 634 | 110 | 9.76ms | return $self->get_meta_instance->inline_create_instance(@_); # spent 8.91ms making 55 calls to Class::MOP::Class::get_meta_instance, avg 162µs/call
# spent 847µs making 55 calls to Class::MOP::Instance::inline_create_instance, avg 15µs/call | ||
| 635 | } | ||||
| 636 | |||||
| 637 | sub inline_rebless_instance { | ||||
| 638 | my $self = shift; | ||||
| 639 | |||||
| 640 | return $self->get_meta_instance->inline_rebless_instance_structure(@_); | ||||
| 641 | } | ||||
| 642 | |||||
| 643 | sub _inline_get_mop_slot { | ||||
| 644 | my $self = shift; | ||||
| 645 | |||||
| 646 | return $self->get_meta_instance->_inline_get_mop_slot(@_); | ||||
| 647 | } | ||||
| 648 | |||||
| 649 | sub _inline_set_mop_slot { | ||||
| 650 | my $self = shift; | ||||
| 651 | |||||
| 652 | return $self->get_meta_instance->_inline_set_mop_slot(@_); | ||||
| 653 | } | ||||
| 654 | |||||
| 655 | sub _inline_clear_mop_slot { | ||||
| 656 | my $self = shift; | ||||
| 657 | |||||
| 658 | return $self->get_meta_instance->_inline_clear_mop_slot(@_); | ||||
| 659 | } | ||||
| 660 | |||||
| 661 | sub clone_object { | ||||
| 662 | my $class = shift; | ||||
| 663 | my $instance = shift; | ||||
| 664 | (blessed($instance) && $instance->isa($class->name)) | ||||
| 665 | || confess "You must pass an instance of the metaclass (" . (ref $class ? $class->name : $class) . "), not ($instance)"; | ||||
| 666 | |||||
| 667 | # NOTE: | ||||
| 668 | # we need to protect the integrity of the | ||||
| 669 | # Class::MOP::Class singletons here, they | ||||
| 670 | # should not be cloned. | ||||
| 671 | return $instance if $instance->isa('Class::MOP::Class'); | ||||
| 672 | $class->_clone_instance($instance, @_); | ||||
| 673 | } | ||||
| 674 | |||||
| 675 | sub _clone_instance { | ||||
| 676 | my ($class, $instance, %params) = @_; | ||||
| 677 | (blessed($instance)) | ||||
| 678 | || confess "You can only clone instances, ($instance) is not a blessed instance"; | ||||
| 679 | my $meta_instance = $class->get_meta_instance(); | ||||
| 680 | my $clone = $meta_instance->clone_instance($instance); | ||||
| 681 | foreach my $attr ($class->get_all_attributes()) { | ||||
| 682 | if ( defined( my $init_arg = $attr->init_arg ) ) { | ||||
| 683 | if (exists $params{$init_arg}) { | ||||
| 684 | $attr->set_value($clone, $params{$init_arg}); | ||||
| 685 | } | ||||
| 686 | } | ||||
| 687 | } | ||||
| 688 | return $clone; | ||||
| 689 | } | ||||
| 690 | |||||
| 691 | sub _force_rebless_instance { | ||||
| 692 | my ($self, $instance, %params) = @_; | ||||
| 693 | my $old_metaclass = Class::MOP::class_of($instance); | ||||
| 694 | |||||
| 695 | $old_metaclass->rebless_instance_away($instance, $self, %params) | ||||
| 696 | if $old_metaclass; | ||||
| 697 | |||||
| 698 | my $meta_instance = $self->get_meta_instance; | ||||
| 699 | |||||
| 700 | if (Class::MOP::metaclass_is_weak($old_metaclass->name)) { | ||||
| 701 | $meta_instance->_clear_mop_slot($instance); | ||||
| 702 | } | ||||
| 703 | |||||
| 704 | # rebless! | ||||
| 705 | # we use $_[1] here because of t/306_rebless_overload.t regressions on 5.8.8 | ||||
| 706 | $meta_instance->rebless_instance_structure($_[1], $self); | ||||
| 707 | |||||
| 708 | $self->_fixup_attributes_after_rebless($instance, $old_metaclass, %params); | ||||
| 709 | |||||
| 710 | if (Class::MOP::metaclass_is_weak($self->name)) { | ||||
| 711 | $meta_instance->_set_mop_slot($instance, $self); | ||||
| 712 | } | ||||
| 713 | } | ||||
| 714 | |||||
| 715 | sub rebless_instance { | ||||
| 716 | my ($self, $instance, %params) = @_; | ||||
| 717 | my $old_metaclass = Class::MOP::class_of($instance); | ||||
| 718 | |||||
| 719 | my $old_class = $old_metaclass ? $old_metaclass->name : blessed($instance); | ||||
| 720 | $self->name->isa($old_class) | ||||
| 721 | || confess "You may rebless only into a subclass of ($old_class), of which (". $self->name .") isn't."; | ||||
| 722 | |||||
| 723 | $self->_force_rebless_instance($_[1], %params); | ||||
| 724 | |||||
| 725 | return $instance; | ||||
| 726 | } | ||||
| 727 | |||||
| 728 | sub rebless_instance_back { | ||||
| 729 | my ( $self, $instance ) = @_; | ||||
| 730 | my $old_metaclass = Class::MOP::class_of($instance); | ||||
| 731 | |||||
| 732 | my $old_class | ||||
| 733 | = $old_metaclass ? $old_metaclass->name : blessed($instance); | ||||
| 734 | $old_class->isa( $self->name ) | ||||
| 735 | || confess | ||||
| 736 | "You may rebless only into a superclass of ($old_class), of which (" | ||||
| 737 | . $self->name | ||||
| 738 | . ") isn't."; | ||||
| 739 | |||||
| 740 | $self->_force_rebless_instance($_[1]); | ||||
| 741 | |||||
| 742 | return $instance; | ||||
| 743 | } | ||||
| 744 | |||||
| 745 | sub rebless_instance_away { | ||||
| 746 | # this intentionally does nothing, it is just a hook | ||||
| 747 | } | ||||
| 748 | |||||
| 749 | sub _fixup_attributes_after_rebless { | ||||
| 750 | my $self = shift; | ||||
| 751 | my ($instance, $rebless_from, %params) = @_; | ||||
| 752 | my $meta_instance = $self->get_meta_instance; | ||||
| 753 | |||||
| 754 | for my $attr ( $rebless_from->get_all_attributes ) { | ||||
| 755 | next if $self->find_attribute_by_name( $attr->name ); | ||||
| 756 | $meta_instance->deinitialize_slot( $instance, $_ ) for $attr->slots; | ||||
| 757 | } | ||||
| 758 | |||||
| 759 | foreach my $attr ( $self->get_all_attributes ) { | ||||
| 760 | if ( $attr->has_value($instance) ) { | ||||
| 761 | if ( defined( my $init_arg = $attr->init_arg ) ) { | ||||
| 762 | $params{$init_arg} = $attr->get_value($instance) | ||||
| 763 | unless exists $params{$init_arg}; | ||||
| 764 | } | ||||
| 765 | else { | ||||
| 766 | $attr->set_value($instance, $attr->get_value($instance)); | ||||
| 767 | } | ||||
| 768 | } | ||||
| 769 | } | ||||
| 770 | |||||
| 771 | foreach my $attr ($self->get_all_attributes) { | ||||
| 772 | $attr->initialize_instance_slot($meta_instance, $instance, \%params); | ||||
| 773 | } | ||||
| 774 | } | ||||
| 775 | |||||
| 776 | # spent 20.5ms (5.67+14.8) within Class::MOP::Class::_attach_attribute which was called 238 times, avg 86µs/call:
# 238 times (5.67ms+14.8ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 28 of Class/MOP/Mixin/HasAttributes.pm, avg 86µs/call | ||||
| 777 | 476 | 5.85ms | my ($self, $attribute) = @_; | ||
| 778 | 238 | 14.8ms | $attribute->attach_to_class($self); # spent 14.8ms making 238 calls to Class::MOP::Attribute::attach_to_class, avg 62µs/call | ||
| 779 | } | ||||
| 780 | |||||
| 781 | # spent 1.47s (15.3ms+1.46) within Class::MOP::Class::_post_add_attribute which was called 238 times, avg 6.19ms/call:
# 238 times (15.3ms+1.46s) by Class::MOP::Mixin::HasAttributes::add_attribute at line 45 of Class/MOP/Mixin/HasAttributes.pm, avg 6.19ms/call | ||||
| 782 | 714 | 13.9ms | my ( $self, $attribute ) = @_; | ||
| 783 | |||||
| 784 | 238 | 12.8ms | $self->invalidate_meta_instances; # spent 12.8ms making 238 calls to Class::MOP::Class::invalidate_meta_instances, avg 54µs/call | ||
| 785 | |||||
| 786 | # invalidate package flag here | ||||
| 787 | # spent 1.42s (10.5ms+1.41) within Class::MOP::Class::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP/Class.pm:790] which was called 238 times, avg 5.96ms/call:
# 238 times (10.5ms+1.41s) by Try::Tiny::try at line 76 of Try/Tiny.pm, avg 5.96ms/call | ||||
| 788 | 476 | 10.5ms | local $SIG{__DIE__}; | ||
| 789 | 238 | 1.41s | $attribute->install_accessors; # spent 879ms making 122 calls to Moose::Meta::Attribute::install_accessors, avg 7.21ms/call
# spent 240ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::5::install_accessors
# spent 163ms making 114 calls to Class::MOP::Attribute::install_accessors, avg 1.43ms/call
# spent 125ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::2::install_accessors | ||
| 790 | } | ||||
| 791 | catch { | ||||
| 792 | $self->remove_attribute( $attribute->name ); | ||||
| 793 | die $_; | ||||
| 794 | 476 | 1.40s | }; # spent 1.44s making 238 calls to Try::Tiny::try, avg 6.05ms/call, recursion: max depth 1, sum of overlapping time 46.3ms
# spent 5.10ms making 238 calls to Try::Tiny::catch, avg 21µs/call | ||
| 795 | } | ||||
| 796 | |||||
| 797 | sub remove_attribute { | ||||
| 798 | my $self = shift; | ||||
| 799 | |||||
| 800 | my $removed_attribute = $self->SUPER::remove_attribute(@_) | ||||
| 801 | or return; | ||||
| 802 | |||||
| 803 | $self->invalidate_meta_instances; | ||||
| 804 | |||||
| 805 | $removed_attribute->remove_accessors; | ||||
| 806 | $removed_attribute->detach_from_class; | ||||
| 807 | |||||
| 808 | return$removed_attribute; | ||||
| 809 | } | ||||
| 810 | |||||
| 811 | # spent 18.8ms (5.21+13.6) within Class::MOP::Class::find_attribute_by_name which was called 77 times, avg 244µs/call:
# 75 times (4.96ms+13.0ms) by Class::MOP::Class::_immutable_metaclass at line 1223, avg 240µs/call
# 2 times (254µs+514µs) by Moose::Meta::Class::_process_inherited_attribute at line 443 of Moose/Meta/Class.pm, avg 384µs/call | ||||
| 812 | 312 | 4.59ms | my ( $self, $attr_name ) = @_; | ||
| 813 | |||||
| 814 | 77 | 4.65ms | foreach my $class ( $self->linearized_isa ) { # spent 4.39ms making 71 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 62µs/call
# spent 261µs making 6 calls to Class::MOP::Class::linearized_isa, avg 44µs/call | ||
| 815 | # fetch the meta-class ... | ||||
| 816 | 79 | 3.07ms | my $meta = Class::MOP::Class->initialize($class); # spent 3.07ms making 79 calls to Class::MOP::Class::initialize, avg 39µs/call | ||
| 817 | 156 | 5.84ms | return $meta->get_attribute($attr_name) # spent 3.19ms making 79 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 40µs/call
# spent 2.65ms making 77 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 34µs/call | ||
| 818 | if $meta->has_attribute($attr_name); | ||||
| 819 | } | ||||
| 820 | |||||
| 821 | return; | ||||
| 822 | } | ||||
| 823 | |||||
| 824 | # spent 147ms (63.2+83.8) within Class::MOP::Class::get_all_attributes which was called 361 times, avg 407µs/call:
# 161 times (22.9ms+29.1ms) by Class::MOP::Class::_create_meta_instance at line 620, avg 323µs/call
# 117 times (25.1ms+34.4ms) by Class::MOP::Class::_construct_instance at line 602, avg 508µs/call
# 55 times (8.43ms+10.9ms) by Class::MOP::Method::Constructor::_attributes at line 77 of Class/MOP/Method/Constructor.pm, avg 351µs/call
# 16 times (2.91ms+5.06ms) by Class::MOP::Class:::around at line 68 of Class/MOP/Class/Immutable/Trait.pm, avg 498µs/call
# 6 times (2.07ms+2.29ms) by Moose::Meta::Attribute::new at line 64 of Moose/Meta/Attribute.pm, avg 728µs/call
# 6 times (1.77ms+2.09ms) by Moose::Meta::Class::new_object at line 258 of Moose/Meta/Class.pm, avg 643µs/call | ||||
| 825 | 3671 | 56.5ms | my $self = shift; | ||
| 826 | 2949 | 82.8ms | my %attrs = map { %{ Class::MOP::Class->initialize($_)->_attribute_map } } # spent 52.7ms making 1294 calls to Class::MOP::Class::initialize, avg 41µs/call, recursion: max depth 1, sum of overlapping time 968µs
# spent 16.0ms making 345 calls to Class::MOP::Class::linearized_isa, avg 46µs/call
# spent 13.0ms making 1294 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 10µs/call
# spent 1.97ms making 16 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 123µs/call | ||
| 827 | reverse $self->linearized_isa; | ||||
| 828 | return values %attrs; | ||||
| 829 | } | ||||
| 830 | |||||
| 831 | # Inheritance | ||||
| 832 | |||||
| 833 | sub superclasses { | ||||
| 834 | 1344 | 17.6ms | my $self = shift; | ||
| 835 | |||||
| 836 | 282 | 50.4ms | my $isa = $self->get_or_add_package_symbol( # spent 50.4ms making 282 calls to Class::MOP::Package::get_or_add_package_symbol, avg 179µs/call | ||
| 837 | { sigil => '@', type => 'ARRAY', name => 'ISA' } ); | ||||
| 838 | |||||
| 839 | if (@_) { | ||||
| 840 | my @supers = @_; | ||||
| 841 | @{$isa} = @supers; | ||||
| 842 | |||||
| 843 | # NOTE: | ||||
| 844 | # on 5.8 and below, we need to call | ||||
| 845 | # a method to get Perl to detect | ||||
| 846 | # a cycle in the class hierarchy | ||||
| 847 | 36 | 231µs | my $class = $self->name; # spent 231µs making 36 calls to Class::MOP::Package::name, avg 6µs/call | ||
| 848 | 36 | 286µs | $class->isa($class); # spent 286µs making 36 calls to UNIVERSAL::isa, avg 8µs/call | ||
| 849 | |||||
| 850 | # NOTE: | ||||
| 851 | # we need to check the metaclass | ||||
| 852 | # compatibility here so that we can | ||||
| 853 | # be sure that the superclass is | ||||
| 854 | # not potentially creating an issues | ||||
| 855 | # we don't know about | ||||
| 856 | |||||
| 857 | 36 | 172ms | $self->_check_metaclass_compatibility(); # spent 172ms making 36 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 4.78ms/call | ||
| 858 | 36 | 15.0ms | $self->_superclasses_updated(); # spent 15.0ms making 36 calls to Class::MOP::Class::_superclasses_updated, avg 416µs/call | ||
| 859 | } | ||||
| 860 | |||||
| 861 | return @{$isa}; | ||||
| 862 | } | ||||
| 863 | |||||
| 864 | # spent 15.0ms (2.69+12.3) within Class::MOP::Class::_superclasses_updated which was called 36 times, avg 416µs/call:
# 36 times (2.69ms+12.3ms) by Class::MOP::Class::superclasses at line 858, avg 416µs/call | ||||
| 865 | 149 | 2.19ms | my $self = shift; | ||
| 866 | 36 | 419µs | $self->update_meta_instance_dependencies(); # spent 419µs making 36 calls to Class::MOP::Class::update_meta_instance_dependencies, avg 12µs/call | ||
| 867 | # keep strong references to all our parents, so they don't disappear if | ||||
| 868 | # they are anon classes and don't have any direct instances | ||||
| 869 | 41 | 1.40ms | $self->_superclass_metas( # spent 1.40ms making 41 calls to Class::MOP::class_of, avg 34µs/call | ||
| 870 | 72 | 594µs | map { Class::MOP::class_of($_) } $self->superclasses # spent 594µs making 36 calls to Class::MOP::Class::_superclass_metas, avg 17µs/call
# spent 339µs making 2 calls to Class::MOP::Class::superclasses, avg 170µs/call, recursion: max depth 1, sum of overlapping time 339µs
# spent 9.54ms making 34 calls to Moose::Meta::Class::superclasses, avg 281µs/call, recursion: max depth 1, sum of overlapping time 9.54ms | ||
| 871 | ); | ||||
| 872 | } | ||||
| 873 | |||||
| 874 | # spent 594µs within Class::MOP::Class::_superclass_metas which was called 36 times, avg 17µs/call:
# 36 times (594µs+0s) by Class::MOP::Class::_superclasses_updated at line 870, avg 17µs/call | ||||
| 875 | 72 | 667µs | my $self = shift; | ||
| 876 | $self->{_superclass_metas} = [@_]; | ||||
| 877 | } | ||||
| 878 | |||||
| 879 | sub subclasses { | ||||
| 880 | my $self = shift; | ||||
| 881 | my $super_class = $self->name; | ||||
| 882 | |||||
| 883 | return @{ $super_class->mro::get_isarev() }; | ||||
| 884 | } | ||||
| 885 | |||||
| 886 | sub direct_subclasses { | ||||
| 887 | my $self = shift; | ||||
| 888 | my $super_class = $self->name; | ||||
| 889 | |||||
| 890 | return grep { | ||||
| 891 | grep { | ||||
| 892 | $_ eq $super_class | ||||
| 893 | } Class::MOP::Class->initialize($_)->superclasses | ||||
| 894 | } $self->subclasses; | ||||
| 895 | } | ||||
| 896 | |||||
| 897 | # spent 37.4ms (23.6+13.7) within Class::MOP::Class::linearized_isa which was called 797 times, avg 47µs/call:
# 345 times (10.3ms+5.76ms) by Class::MOP::Class::get_all_attributes at line 826, avg 46µs/call
# 211 times (6.14ms+3.60ms) by Class::MOP::Class::find_method_by_name at line 1017, avg 46µs/call
# 162 times (4.86ms+2.97ms) by Class::MOP::Class::find_next_method_by_name at line 1064, avg 48µs/call
# 48 times (1.38ms+826µs) by Class::MOP::Class::find_all_methods_by_name at line 1048, avg 46µs/call
# 17 times (563µs+318µs) by Class::MOP::Class:::around at line 50 of Class/MOP/Class/Immutable/Trait.pm, avg 52µs/call
# 8 times (247µs+148µs) by Class::MOP::Class::get_all_methods at line 1028, avg 49µs/call
# 6 times (170µs+91µs) by Class::MOP::Class::find_attribute_by_name at line 814, avg 44µs/call | ||||
| 898 | 797 | 39.9ms | 1594 | 13.7ms | return @{ mro::get_linear_isa( (shift)->name ) }; # spent 9.48ms making 797 calls to mro::get_linear_isa, avg 12µs/call
# spent 4.24ms making 797 calls to Class::MOP::Package::name, avg 5µs/call |
| 899 | } | ||||
| 900 | |||||
| 901 | # spent 22.2ms (4.64+17.6) within Class::MOP::Class::class_precedence_list which was called 51 times, avg 435µs/call:
# 21 times (2.26ms+20.0ms) by Moose::Meta::Class::excludes_role at line 239 of Moose/Meta/Class.pm, avg 1.06ms/call
# 18 times (1.31ms+-1.31ms) by Class::MOP::Class::class_precedence_list at line 927, avg 0s/call
# 12 times (1.07ms+-1.07ms) by Class::MOP::Class:::around at line 43 of Class/MOP/Class/Immutable/Trait.pm, avg 0s/call | ||||
| 902 | 304 | 5.50ms | my $self = shift; | ||
| 903 | 51 | 271µs | my $name = $self->name; # spent 271µs making 51 calls to Class::MOP::Package::name, avg 5µs/call | ||
| 904 | |||||
| 905 | 51 | 261µs | unless (Class::MOP::IS_RUNNING_ON_5_10()) { # spent 261µs making 51 calls to Class::MOP::__ANON__, avg 5µs/call | ||
| 906 | # NOTE: | ||||
| 907 | # We need to check for circular inheritance here | ||||
| 908 | # if we are are not on 5.10, cause 5.8 detects it | ||||
| 909 | # late. This will do nothing if all is well, and | ||||
| 910 | # blow up otherwise. Yes, it's an ugly hack, better | ||||
| 911 | # suggestions are welcome. | ||||
| 912 | # - SL | ||||
| 913 | ($name || return)->isa('This is a test for circular inheritance') | ||||
| 914 | } | ||||
| 915 | |||||
| 916 | # if our mro is c3, we can | ||||
| 917 | # just grab the linear_isa | ||||
| 918 | 51 | 597µs | if (mro::get_mro($name) eq 'c3') { # spent 597µs making 51 calls to mro::get_mro, avg 12µs/call | ||
| 919 | return @{ mro::get_linear_isa($name) } | ||||
| 920 | } | ||||
| 921 | else { | ||||
| 922 | # NOTE: | ||||
| 923 | # we can't grab the linear_isa for dfs | ||||
| 924 | # since it has all the duplicates | ||||
| 925 | # already removed. | ||||
| 926 | return ( | ||||
| 927 | 98 | 8.98ms | $name, # spent 12.5ms making 30 calls to Class::MOP::Class::Immutable::Class::MOP::Class::class_precedence_list, avg 418µs/call, recursion: max depth 3, sum of overlapping time 6.58ms
# spent 2.06ms making 49 calls to Class::MOP::Class::initialize, avg 42µs/call
# spent 952µs making 1 call to Class::MOP::Class::Immutable::Moose::Meta::Class::class_precedence_list
# spent 6.34ms making 18 calls to Class::MOP::Class::class_precedence_list, avg 352µs/call, recursion: max depth 2, sum of overlapping time 6.34ms | ||
| 928 | map { | ||||
| 929 | 51 | 12.3ms | Class::MOP::Class->initialize($_)->class_precedence_list() # spent 8.85ms making 34 calls to Moose::Meta::Class::superclasses, avg 260µs/call
# spent 2.30ms making 11 calls to Class::MOP::Class::Immutable::Class::MOP::Class::superclasses, avg 209µs/call
# spent 752µs making 5 calls to Class::MOP::Class::superclasses, avg 150µs/call
# spent 391µs making 1 call to Class::MOP::Class::Immutable::Moose::Meta::Class::superclasses | ||
| 930 | } $self->superclasses() | ||||
| 931 | ); | ||||
| 932 | } | ||||
| 933 | } | ||||
| 934 | |||||
| 935 | ## Methods | ||||
| 936 | |||||
| 937 | { | ||||
| 938 | 1 | 4µs | # spent 147ms (9.47+138) within Class::MOP::Class::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP/Class.pm:967] which was called 77 times, avg 1.91ms/call:
# 70 times (8.68ms+128ms) by Class::MOP::Class::add_around_method_modifier at line 993, avg 1.95ms/call
# 5 times (611µs+8.66ms) by Class::MOP::Class::add_before_method_modifier at line 973, avg 1.85ms/call
# 2 times (177µs+1.31ms) by Class::MOP::Class::add_after_method_modifier at line 983, avg 744µs/call | ||
| 939 | 671 | 9.06ms | my ($self, $method_name) = @_; | ||
| 940 | 77 | 998µs | my $wrapped_metaclass = $self->wrapped_method_metaclass; # spent 998µs making 77 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 13µs/call | ||
| 941 | # fetch it locally | ||||
| 942 | 77 | 17.7ms | my $method = $self->get_method($method_name); # spent 17.7ms making 77 calls to Class::MOP::Mixin::HasMethods::get_method, avg 230µs/call | ||
| 943 | # if we dont have local ... | ||||
| 944 | unless ($method) { | ||||
| 945 | # try to find the next method | ||||
| 946 | 66 | 57.6ms | $method = $self->find_next_method_by_name($method_name); # spent 57.6ms making 66 calls to Class::MOP::Class::find_next_method_by_name, avg 873µs/call | ||
| 947 | # die if it does not exist | ||||
| 948 | (defined $method) | ||||
| 949 | || confess "The method '$method_name' was not found in the inheritance hierarchy for " . $self->name; | ||||
| 950 | # and now make sure to wrap it | ||||
| 951 | # even if it is already wrapped | ||||
| 952 | # because we need a new sub ref | ||||
| 953 | 132 | 22.7ms | $method = $wrapped_metaclass->wrap($method, # spent 22.3ms making 66 calls to Class::MOP::Method::Wrapped::wrap, avg 338µs/call
# spent 373µs making 66 calls to Class::MOP::Package::name, avg 6µs/call | ||
| 954 | package_name => $self->name, | ||||
| 955 | name => $method_name, | ||||
| 956 | ); | ||||
| 957 | } | ||||
| 958 | else { | ||||
| 959 | # now make sure we wrap it properly | ||||
| 960 | 29 | 2.97ms | $method = $wrapped_metaclass->wrap($method, # spent 2.79ms making 9 calls to Class::MOP::Method::Wrapped::wrap, avg 310µs/call
# spent 134µs making 11 calls to UNIVERSAL::isa, avg 12µs/call
# spent 47µs making 9 calls to Class::MOP::Package::name, avg 5µs/call | ||
| 961 | package_name => $self->name, | ||||
| 962 | name => $method_name, | ||||
| 963 | ) unless $method->isa($wrapped_metaclass); | ||||
| 964 | } | ||||
| 965 | 77 | 36.0ms | $self->add_method($method_name => $method); # spent 36.0ms making 77 calls to Class::MOP::Mixin::HasMethods::add_method, avg 467µs/call | ||
| 966 | return $method; | ||||
| 967 | 1 | 14µs | }; | ||
| 968 | |||||
| 969 | # spent 9.97ms (286µs+9.68) within Class::MOP::Class::add_before_method_modifier which was called 5 times, avg 1.99ms/call:
# 4 times (233µs+8.45ms) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 221 of Moose/Meta/Role/Application/ToClass.pm, avg 2.17ms/call
# once (54µs+1.23ms) by Moose::Util::add_method_modifier at line 244 of Moose/Util.pm | ||||
| 970 | 20 | 329µs | my ($self, $method_name, $method_modifier) = @_; | ||
| 971 | (defined $method_name && length $method_name) | ||||
| 972 | || confess "You must pass in a method name"; | ||||
| 973 | 5 | 9.27ms | my $method = $fetch_and_prepare_method->($self, $method_name); # spent 9.27ms making 5 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:967], avg 1.85ms/call | ||
| 974 | 10 | 413µs | $method->add_before_modifier( # spent 352µs making 5 calls to Class::MOP::Method::Wrapped::add_before_modifier, avg 70µs/call
# spent 61µs making 5 calls to Sub::Name::subname, avg 12µs/call | ||
| 975 | subname(':before' => $method_modifier) | ||||
| 976 | ); | ||||
| 977 | } | ||||
| 978 | |||||
| 979 | # spent 1.77ms (117µs+1.66) within Class::MOP::Class::add_after_method_modifier which was called 2 times, avg 887µs/call:
# 2 times (117µs+1.66ms) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 221 of Moose/Meta/Role/Application/ToClass.pm, avg 887µs/call | ||||
| 980 | 8 | 132µs | my ($self, $method_name, $method_modifier) = @_; | ||
| 981 | (defined $method_name && length $method_name) | ||||
| 982 | || confess "You must pass in a method name"; | ||||
| 983 | 2 | 1.49ms | my $method = $fetch_and_prepare_method->($self, $method_name); # spent 1.49ms making 2 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:967], avg 744µs/call | ||
| 984 | 4 | 168µs | $method->add_after_modifier( # spent 143µs making 2 calls to Class::MOP::Method::Wrapped::add_after_modifier, avg 72µs/call
# spent 24µs making 2 calls to Sub::Name::subname, avg 12µs/call | ||
| 985 | subname(':after' => $method_modifier) | ||||
| 986 | ); | ||||
| 987 | } | ||||
| 988 | |||||
| 989 | # spent 151ms (3.77+147) within Class::MOP::Class::add_around_method_modifier which was called 70 times, avg 2.16ms/call:
# 46 times (2.46ms+99.7ms) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 2.22ms/call
# 24 times (1.31ms+47.6ms) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 221 of Moose/Meta/Role/Application/ToClass.pm, avg 2.04ms/call | ||||
| 990 | 280 | 4.47ms | my ($self, $method_name, $method_modifier) = @_; | ||
| 991 | (defined $method_name && length $method_name) | ||||
| 992 | || confess "You must pass in a method name"; | ||||
| 993 | 70 | 137ms | my $method = $fetch_and_prepare_method->($self, $method_name); # spent 137ms making 70 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:967], avg 1.95ms/call | ||
| 994 | 140 | 10.6ms | $method->add_around_modifier( # spent 9.64ms making 70 calls to Class::MOP::Method::Wrapped::add_around_modifier, avg 138µs/call
# spent 927µs making 70 calls to Sub::Name::subname, avg 13µs/call | ||
| 995 | subname(':around' => $method_modifier) | ||||
| 996 | ); | ||||
| 997 | } | ||||
| 998 | |||||
| 999 | # NOTE: | ||||
| 1000 | # the methods above used to be named like this: | ||||
| 1001 | # ${pkg}::${method}:(before|after|around) | ||||
| 1002 | # but this proved problematic when using one modifier | ||||
| 1003 | # to wrap multiple methods (something which is likely | ||||
| 1004 | # to happen pretty regularly IMO). So instead of naming | ||||
| 1005 | # it like this, I have chosen to just name them purely | ||||
| 1006 | # with their modifier names, like so: | ||||
| 1007 | # :(before|after|around) | ||||
| 1008 | # The fact is that in a stack trace, it will be fairly | ||||
| 1009 | # evident from the context what method they are attached | ||||
| 1010 | # to, and so don't need the fully qualified name. | ||||
| 1011 | } | ||||
| 1012 | |||||
| 1013 | # spent 185ms (19.9+165) within Class::MOP::Class::find_method_by_name which was called 211 times, avg 877µs/call:
# 57 times (3.93ms+20.9ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 25 of Class/MOP/Mixin/HasMethods.pm, avg 436µs/call
# 56 times (8.34ms+81.1ms) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 1.60ms/call
# 43 times (2.50ms+26.0ms) by Moose::Meta::Role::Application::ToClass::check_required_methods at line 64 of Moose/Meta/Role/Application/ToClass.pm, avg 664µs/call
# 24 times (2.34ms+17.5ms) by Moose::Meta::Method::Constructor::_generate_BUILDARGS at line 146 of Moose/Meta/Method/Constructor.pm, avg 825µs/call
# 24 times (2.32ms+17.0ms) by Moose::Meta::Method::Destructor::is_needed at line 62 of Moose/Meta/Method/Destructor.pm, avg 804µs/call
# 7 times (481µs+2.63ms) by Moose::BEGIN@38 at line 14 of Moose/Meta/Attribute/Native.pm, avg 444µs/call | ||||
| 1014 | 1569 | 18.2ms | my ($self, $method_name) = @_; | ||
| 1015 | (defined $method_name && length $method_name) | ||||
| 1016 | || confess "You must define a method name to find"; | ||||
| 1017 | 211 | 9.74ms | foreach my $class ($self->linearized_isa) { # spent 9.74ms making 211 calls to Class::MOP::Class::linearized_isa, avg 46µs/call | ||
| 1018 | 864 | 155ms | my $method = Class::MOP::Class->initialize($class)->get_method($method_name); # spent 137ms making 432 calls to Class::MOP::Mixin::HasMethods::get_method, avg 317µs/call
# spent 18.6ms making 432 calls to Class::MOP::Class::initialize, avg 43µs/call | ||
| 1019 | return $method if defined $method; | ||||
| 1020 | } | ||||
| 1021 | return; | ||||
| 1022 | } | ||||
| 1023 | |||||
| 1024 | # spent 27.5ms (1.54+25.9) within Class::MOP::Class::get_all_methods which was called 8 times, avg 3.43ms/call:
# 8 times (1.54ms+25.9ms) by Class::MOP::MiniTrait::apply at line 18 of Class/MOP/MiniTrait.pm, avg 3.43ms/call | ||||
| 1025 | 59 | 1.72ms | my $self = shift; | ||
| 1026 | |||||
| 1027 | my %methods; | ||||
| 1028 | 8 | 395µs | for my $class ( reverse $self->linearized_isa ) { # spent 395µs making 8 calls to Class::MOP::Class::linearized_isa, avg 49µs/call | ||
| 1029 | 9 | 353µs | my $meta = Class::MOP::Class->initialize($class); # spent 353µs making 9 calls to Class::MOP::Class::initialize, avg 39µs/call | ||
| 1030 | |||||
| 1031 | 65 | 25.2ms | $methods{ $_->name } = $_ for $meta->_get_local_methods; # spent 24.9ms making 9 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 2.77ms/call
# spent 251µs making 56 calls to Class::MOP::Method::name, avg 4µs/call | ||
| 1032 | } | ||||
| 1033 | |||||
| 1034 | return values %methods; | ||||
| 1035 | } | ||||
| 1036 | |||||
| 1037 | sub get_all_method_names { | ||||
| 1038 | my $self = shift; | ||||
| 1039 | my %uniq; | ||||
| 1040 | return grep { !$uniq{$_}++ } map { Class::MOP::Class->initialize($_)->get_method_list } $self->linearized_isa; | ||||
| 1041 | } | ||||
| 1042 | |||||
| 1043 | # spent 38.3ms (5.14+33.1) within Class::MOP::Class::find_all_methods_by_name which was called 48 times, avg 797µs/call:
# 24 times (2.62ms+17.1ms) by Moose::Meta::Method::Constructor::_generate_BUILDALL at line 184 of Moose/Meta/Method/Constructor.pm, avg 820µs/call
# 24 times (2.52ms+16.1ms) by Moose::Meta::Method::Destructor::_initialize_body at line 81 of Moose/Meta/Method/Destructor.pm, avg 774µs/call | ||||
| 1044 | 436 | 4.62ms | my ($self, $method_name) = @_; | ||
| 1045 | (defined $method_name && length $method_name) | ||||
| 1046 | || confess "You must define a method name to find"; | ||||
| 1047 | my @methods; | ||||
| 1048 | 48 | 2.21ms | foreach my $class ($self->linearized_isa) { # spent 2.21ms making 48 calls to Class::MOP::Class::linearized_isa, avg 46µs/call | ||
| 1049 | # fetch the meta-class ... | ||||
| 1050 | 98 | 4.31ms | my $meta = Class::MOP::Class->initialize($class); # spent 4.31ms making 98 calls to Class::MOP::Class::initialize, avg 44µs/call | ||
| 1051 | 102 | 26.6ms | push @methods => { # spent 24.4ms making 98 calls to Class::MOP::Mixin::HasMethods::has_method, avg 249µs/call
# spent 2.20ms making 4 calls to Class::MOP::Mixin::HasMethods::get_method, avg 551µs/call | ||
| 1052 | name => $method_name, | ||||
| 1053 | class => $class, | ||||
| 1054 | code => $meta->get_method($method_name) | ||||
| 1055 | } if $meta->has_method($method_name); | ||||
| 1056 | } | ||||
| 1057 | return @methods; | ||||
| 1058 | } | ||||
| 1059 | |||||
| 1060 | # spent 107ms (15.4+92.0) within Class::MOP::Class::find_next_method_by_name which was called 164 times, avg 655µs/call:
# 79 times (6.02ms+32.9ms) by Class::MOP::Method::Inlined::can_be_inlined at line 40 of Class/MOP/Method/Inlined.pm, avg 493µs/call
# 66 times (7.81ms+49.8ms) by Class::MOP::Class::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP/Class.pm:967] at line 946, avg 873µs/call
# 17 times (1.44ms+8.49ms) by Moose::Meta::Method::Overridden::new at line 23 of Moose/Meta/Method/Overridden.pm, avg 584µs/call
# 2 times (141µs+727µs) by Class::MOP::Method::Inlined::_uninlined_body at line 20 of Class/MOP/Method/Inlined.pm, avg 434µs/call | ||||
| 1061 | 1335 | 14.2ms | my ($self, $method_name) = @_; | ||
| 1062 | (defined $method_name && length $method_name) | ||||
| 1063 | || confess "You must define a method name to find"; | ||||
| 1064 | 164 | 8.00ms | my @cpl = $self->linearized_isa; # spent 7.83ms making 162 calls to Class::MOP::Class::linearized_isa, avg 48µs/call
# spent 166µs making 2 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::linearized_isa, avg 83µs/call | ||
| 1065 | shift @cpl; # discard ourselves | ||||
| 1066 | foreach my $class (@cpl) { | ||||
| 1067 | 512 | 84.0ms | my $method = Class::MOP::Class->initialize($class)->get_method($method_name); # spent 73.0ms making 256 calls to Class::MOP::Mixin::HasMethods::get_method, avg 285µs/call
# spent 11.0ms making 256 calls to Class::MOP::Class::initialize, avg 43µs/call | ||
| 1068 | return $method if defined $method; | ||||
| 1069 | } | ||||
| 1070 | return; | ||||
| 1071 | } | ||||
| 1072 | |||||
| 1073 | # spent 419µs within Class::MOP::Class::update_meta_instance_dependencies which was called 36 times, avg 12µs/call:
# 36 times (419µs+0s) by Class::MOP::Class::_superclasses_updated at line 866, avg 12µs/call | ||||
| 1074 | 72 | 580µs | my $self = shift; | ||
| 1075 | |||||
| 1076 | if ( $self->{meta_instance_dependencies} ) { | ||||
| 1077 | return $self->add_meta_instance_dependencies; | ||||
| 1078 | } | ||||
| 1079 | } | ||||
| 1080 | |||||
| 1081 | sub add_meta_instance_dependencies { | ||||
| 1082 | my $self = shift; | ||||
| 1083 | |||||
| 1084 | $self->remove_meta_instance_dependencies; | ||||
| 1085 | |||||
| 1086 | my @attrs = $self->get_all_attributes(); | ||||
| 1087 | |||||
| 1088 | my %seen; | ||||
| 1089 | my @classes = grep { not $seen{ $_->name }++ } | ||||
| 1090 | map { $_->associated_class } @attrs; | ||||
| 1091 | |||||
| 1092 | foreach my $class (@classes) { | ||||
| 1093 | $class->add_dependent_meta_instance($self); | ||||
| 1094 | } | ||||
| 1095 | |||||
| 1096 | $self->{meta_instance_dependencies} = \@classes; | ||||
| 1097 | } | ||||
| 1098 | |||||
| 1099 | sub remove_meta_instance_dependencies { | ||||
| 1100 | my $self = shift; | ||||
| 1101 | |||||
| 1102 | if ( my $classes = delete $self->{meta_instance_dependencies} ) { | ||||
| 1103 | foreach my $class (@$classes) { | ||||
| 1104 | $class->remove_dependent_meta_instance($self); | ||||
| 1105 | } | ||||
| 1106 | |||||
| 1107 | return $classes; | ||||
| 1108 | } | ||||
| 1109 | |||||
| 1110 | return; | ||||
| 1111 | |||||
| 1112 | } | ||||
| 1113 | |||||
| 1114 | sub add_dependent_meta_instance { | ||||
| 1115 | my ( $self, $metaclass ) = @_; | ||||
| 1116 | push @{ $self->{dependent_meta_instances} }, $metaclass; | ||||
| 1117 | } | ||||
| 1118 | |||||
| 1119 | sub remove_dependent_meta_instance { | ||||
| 1120 | my ( $self, $metaclass ) = @_; | ||||
| 1121 | my $name = $metaclass->name; | ||||
| 1122 | @$_ = grep { $_->name ne $name } @$_ | ||||
| 1123 | for $self->{dependent_meta_instances}; | ||||
| 1124 | } | ||||
| 1125 | |||||
| 1126 | # spent 12.8ms (9.82+2.98) within Class::MOP::Class::invalidate_meta_instances which was called 238 times, avg 54µs/call:
# 238 times (9.82ms+2.98ms) by Class::MOP::Class::_post_add_attribute at line 784, avg 54µs/call | ||||
| 1127 | 714 | 9.64ms | my $self = shift; | ||
| 1128 | $_->invalidate_meta_instance() | ||||
| 1129 | 238 | 2.98ms | for $self, @{ $self->{dependent_meta_instances} }; # spent 2.98ms making 238 calls to Class::MOP::Class::invalidate_meta_instance, avg 13µs/call | ||
| 1130 | } | ||||
| 1131 | |||||
| 1132 | # spent 2.98ms within Class::MOP::Class::invalidate_meta_instance which was called 238 times, avg 13µs/call:
# 238 times (2.98ms+0s) by Class::MOP::Class::invalidate_meta_instances at line 1129, avg 13µs/call | ||||
| 1133 | 476 | 3.86ms | my $self = shift; | ||
| 1134 | undef $self->{_meta_instance}; | ||||
| 1135 | } | ||||
| 1136 | |||||
| 1137 | # check if we can reinitialize | ||||
| 1138 | sub is_pristine { | ||||
| 1139 | my $self = shift; | ||||
| 1140 | |||||
| 1141 | # if any local attr is defined | ||||
| 1142 | return if $self->get_attribute_list; | ||||
| 1143 | |||||
| 1144 | # or any non-declared methods | ||||
| 1145 | for my $method ( map { $self->get_method($_) } $self->get_method_list ) { | ||||
| 1146 | return if $method->isa("Class::MOP::Method::Generated"); | ||||
| 1147 | # FIXME do we need to enforce this too? return unless $method->isa( $self->method_metaclass ); | ||||
| 1148 | } | ||||
| 1149 | |||||
| 1150 | return 1; | ||||
| 1151 | } | ||||
| 1152 | |||||
| 1153 | ## Class closing | ||||
| 1154 | |||||
| 1155 | 106 | 1.27ms | # spent 715µs within Class::MOP::Class::is_mutable which was called 106 times, avg 7µs/call:
# 75 times (519µs+0s) by Class::MOP::Class::make_immutable at line 1179, avg 7µs/call
# 22 times (139µs+0s) by KiokuDB::BEGIN@4 at line 231 of Moose.pm, avg 6µs/call
# 9 times (57µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 688 of Moose/Util/TypeConstraints.pm, avg 6µs/call | ||
| 1156 | 91 | 1.03ms | # spent 651µs within Class::MOP::Class::is_immutable which was called 91 times, avg 7µs/call:
# 91 times (651µs+0s) by Class::MOP::Class::_real_ref_name at line 126, avg 7µs/call | ||
| 1157 | |||||
| 1158 | sub immutable_options { %{ $_[0]{__immutable}{options} || {} } } | ||||
| 1159 | |||||
| 1160 | # spent 9.03ms (5.86+3.17) within Class::MOP::Class::_immutable_options which was called 75 times, avg 120µs/call:
# 51 times (3.81ms+1.91ms) by Class::MOP::Class::make_immutable at line 1180, avg 112µs/call
# 24 times (2.05ms+1.27ms) by Moose::Meta::Class::_immutable_options at line 461 of Moose/Meta/Class.pm, avg 138µs/call | ||||
| 1161 | 150 | 4.92ms | my ( $self, @args ) = @_; | ||
| 1162 | |||||
| 1163 | return ( | ||||
| 1164 | 300 | 3.17ms | inline_accessors => 1, # spent 758µs making 75 calls to Class::MOP::Class::constructor_name, avg 10µs/call
# spent 493µs making 51 calls to Class::MOP::Class::immutable_trait, avg 10µs/call
# spent 481µs making 51 calls to Class::MOP::Class::constructor_class, avg 9µs/call
# spent 440µs making 51 calls to Class::MOP::Class::destructor_class, avg 9µs/call
# spent 353µs making 24 calls to Moose::Meta::Class::immutable_trait, avg 15µs/call
# spent 335µs making 24 calls to Moose::Meta::Class::destructor_class, avg 14µs/call
# spent 312µs making 24 calls to Moose::Meta::Class::constructor_class, avg 13µs/call | ||
| 1165 | inline_constructor => 1, | ||||
| 1166 | inline_destructor => 0, | ||||
| 1167 | debug => 0, | ||||
| 1168 | immutable_trait => $self->immutable_trait, | ||||
| 1169 | constructor_name => $self->constructor_name, | ||||
| 1170 | constructor_class => $self->constructor_class, | ||||
| 1171 | destructor_class => $self->destructor_class, | ||||
| 1172 | @args, | ||||
| 1173 | ); | ||||
| 1174 | } | ||||
| 1175 | |||||
| 1176 | # spent 1.10s (6.33ms+1.10) within Class::MOP::Class::make_immutable which was called 75 times, avg 14.7ms/call:
# 22 times (1.99ms+307ms) by KiokuDB::BEGIN@4 at line 236 of Moose.pm, avg 14.0ms/call
# 13 times (931µs+110ms) by Moose::Exporter::BEGIN@11 at line 699 of Class/MOP.pm, avg 8.50ms/call
# 9 times (760µs+126ms) by Moose::Meta::Attribute::BEGIN@20 at line 693 of Moose/Util/TypeConstraints.pm, avg 14.1ms/call
# 4 times (324µs+2.50ms) by Moose::Exporter::BEGIN@11 at line 724 of Class/MOP.pm, avg 705µs/call
# 2 times (176µs+-176µs) by Class::MOP::Class::_immutable_metaclass at line 1253, avg 0s/call
# once (129µs+132ms) by KiokuDB::Collapser::BEGIN@12 at line 304 of KiokuDB/Entry.pm
# once (81µs+36.1ms) by KiokuDB::BEGIN@4 at line 268 of Moose.pm
# once (85µs+26.4ms) by KiokuDB::Collapser::BEGIN@15 at line 231 of KiokuDB/Collapser/Buffer.pm
# once (83µs+25.9ms) by main::BEGIN@0 at line 655 of KiokuDB.pm
# once (98µs+24.7ms) by KiokuDB::BEGIN@13 at line 531 of KiokuDB/LiveObjects.pm
# once (83µs+22.6ms) by KiokuDB::BEGIN@11 at line 396 of KiokuDB/Collapser.pm
# once (96µs+18.9ms) by KiokuDB::TypeMap::Resolver::BEGIN@9 at line 484 of KiokuDB/TypeMap/Entry/MOP.pm
# once (81µs+18.8ms) by KiokuDB::BEGIN@12 at line 381 of KiokuDB/Linker.pm
# once (81µs+17.9ms) by KiokuDB::TypeMap::Entry::Std::BEGIN@6 at line 26 of KiokuDB/TypeMap/Entry/Compiled.pm
# once (95µs+17.6ms) by KiokuDB::LiveObjects::BEGIN@14 at line 55 of KiokuDB/LiveObjects/TXNScope.pm
# once (83µs+16.8ms) by KiokuDB::BEGIN@14 at line 171 of KiokuDB/TypeMap.pm
# once (82µs+16.7ms) by KiokuDB::BEGIN@17 at line 79 of KiokuDB/Stream/Objects.pm
# once (93µs+15.9ms) by KiokuDB::Collapser::BEGIN@14 at line 39 of KiokuDB/Reference.pm
# once (82µs+15.8ms) by KiokuDB::LiveObjects::BEGIN@13 at line 60 of KiokuDB/LiveObjects/Scope.pm
# once (83µs+15.3ms) by KiokuDB::Collapser::BEGIN@13 at line 27 of KiokuDB/Entry/Skip.pm
# once (82µs+14.8ms) by KiokuDB::BEGIN@16 at line 117 of KiokuDB/TypeMap/Resolver.pm
# once (82µs+14.6ms) by KiokuDB::TypeMap::Entry::MOP::BEGIN@9 at line 51 of KiokuDB/Thunk.pm
# once (87µs+14.0ms) by KiokuDB::Linker::BEGIN@18 at line 37 of KiokuDB/Error/MissingObjects.pm
# once (84µs+13.9ms) by KiokuDB::Collapser::BEGIN@16 at line 25 of KiokuDB/Error/UnknownObjects.pm
# once (82µs+13.1ms) by KiokuDB::Collapser::BEGIN@18 at line 443 of Data/Visitor.pm
# once (80µs+13.1ms) by Class::MOP::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP.pm:118] at line 38 of Data/Stream/Bulk/Filter.pm
# once (81µs+11.8ms) by KiokuDB::BEGIN@15 at line 28 of KiokuDB/TypeMap/Shadow.pm
# once (81µs+11.7ms) by KiokuDB::TypeMap::BEGIN@10 at line 14 of KiokuDB/TypeMap/Entry/Alias.pm
# once (84µs+11.7ms) by Class::MOP::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP.pm:118] at line 51 of Data/Stream/Bulk/Cat.pm
# once (79µs+11.3ms) by Class::MOP::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP.pm:118] at line 35 of Data/Stream/Bulk/Nil.pm | ||||
| 1177 | 375 | 5.75ms | my ( $self, @args ) = @_; | ||
| 1178 | |||||
| 1179 | 75 | 519µs | if ( $self->is_mutable ) { # spent 519µs making 75 calls to Class::MOP::Class::is_mutable, avg 7µs/call | ||
| 1180 | 150 | 852ms | $self->_initialize_immutable( $self->_immutable_options(@args) ); # spent 842ms making 75 calls to Class::MOP::Class::_initialize_immutable, avg 11.2ms/call
# spent 5.71ms making 51 calls to Class::MOP::Class::_immutable_options, avg 112µs/call
# spent 4.34ms making 24 calls to Moose::Meta::Class::_immutable_options, avg 181µs/call | ||
| 1181 | 75 | 245ms | $self->_rebless_as_immutable(@args); # spent 246ms making 75 calls to Class::MOP::Class::_rebless_as_immutable, avg 3.28ms/call, recursion: max depth 1, sum of overlapping time 1.17ms | ||
| 1182 | return $self; | ||||
| 1183 | } | ||||
| 1184 | else { | ||||
| 1185 | return; | ||||
| 1186 | } | ||||
| 1187 | } | ||||
| 1188 | |||||
| 1189 | sub make_mutable { | ||||
| 1190 | my $self = shift; | ||||
| 1191 | |||||
| 1192 | if ( $self->is_immutable ) { | ||||
| 1193 | my @args = $self->immutable_options; | ||||
| 1194 | $self->_rebless_as_mutable(); | ||||
| 1195 | $self->_remove_inlined_code(@args); | ||||
| 1196 | delete $self->{__immutable}; | ||||
| 1197 | return $self; | ||||
| 1198 | } | ||||
| 1199 | else { | ||||
| 1200 | return; | ||||
| 1201 | } | ||||
| 1202 | } | ||||
| 1203 | |||||
| 1204 | # spent 245ms (3.32+241) within Class::MOP::Class::_rebless_as_immutable which was called 75 times, avg 3.26ms/call:
# 75 times (3.32ms+241ms) by Class::MOP::Class::make_immutable at line 1181, avg 3.26ms/call | ||||
| 1205 | 225 | 3.22ms | my ( $self, @args ) = @_; | ||
| 1206 | |||||
| 1207 | $self->{__immutable}{original_class} = ref $self; | ||||
| 1208 | |||||
| 1209 | 75 | 242ms | bless $self => $self->_immutable_metaclass(@args); # spent 243ms making 75 calls to Class::MOP::Class::_immutable_metaclass, avg 3.23ms/call, recursion: max depth 1, sum of overlapping time 1.05ms | ||
| 1210 | } | ||||
| 1211 | |||||
| 1212 | # spent 242ms (7.88+234) within Class::MOP::Class::_immutable_metaclass which was called 75 times, avg 3.22ms/call:
# 75 times (7.88ms+234ms) by Class::MOP::Class::_rebless_as_immutable at line 1209, avg 3.22ms/call | ||||
| 1213 | 610 | 8.67ms | my ( $self, %args ) = @_; | ||
| 1214 | |||||
| 1215 | if ( my $class = $args{immutable_metaclass} ) { | ||||
| 1216 | return $class; | ||||
| 1217 | } | ||||
| 1218 | |||||
| 1219 | 75 | 829µs | my $trait = $args{immutable_trait} = $self->immutable_trait # spent 497µs making 51 calls to Class::MOP::Class::immutable_trait, avg 10µs/call
# spent 332µs making 24 calls to Moose::Meta::Class::immutable_trait, avg 14µs/call | ||
| 1220 | || confess "no immutable trait specified for $self"; | ||||
| 1221 | |||||
| 1222 | 75 | 6.31ms | my $meta = $self->meta; # spent 6.31ms making 75 calls to Class::MOP::Object::meta, avg 84µs/call | ||
| 1223 | 75 | 18.0ms | my $meta_attr = $meta->find_attribute_by_name("immutable_trait"); # spent 18.0ms making 75 calls to Class::MOP::Class::find_attribute_by_name, avg 240µs/call | ||
| 1224 | |||||
| 1225 | my $class_name; | ||||
| 1226 | |||||
| 1227 | 75 | 1.28ms | if ( $meta_attr and $trait eq $meta_attr->default ) { # spent 1.28ms making 75 calls to Class::MOP::Mixin::AttributeCore::default, avg 17µs/call | ||
| 1228 | # if the trait is the same as the default we try and pick a | ||||
| 1229 | # predictable name for the immutable metaclass | ||||
| 1230 | $class_name = 'Class::MOP::Class::Immutable::' . ref($self); | ||||
| 1231 | } | ||||
| 1232 | else { | ||||
| 1233 | $class_name = join '::', 'Class::MOP::Class::Immutable::CustomTrait', | ||||
| 1234 | $trait, 'ForMetaClass', ref($self); | ||||
| 1235 | } | ||||
| 1236 | |||||
| 1237 | 75 | 1.39ms | return $class_name # spent 1.39ms making 75 calls to Class::MOP::is_class_loaded, avg 18µs/call | ||
| 1238 | if Class::MOP::is_class_loaded($class_name); | ||||
| 1239 | |||||
| 1240 | # If the metaclass is a subclass of CMOP::Class which has had | ||||
| 1241 | # metaclass roles applied (via Moose), then we want to make sure | ||||
| 1242 | # that we preserve that anonymous class (see Fey::ORM for an | ||||
| 1243 | # example of where this matters). | ||||
| 1244 | 2 | 125µs | my $meta_name = $meta->_real_ref_name; # spent 125µs making 2 calls to Class::MOP::Class::_real_ref_name, avg 62µs/call | ||
| 1245 | |||||
| 1246 | 2 | 12.0ms | my $immutable_meta = $meta_name->create( # spent 12.0ms making 2 calls to Class::MOP::Class::create, avg 5.99ms/call | ||
| 1247 | $class_name, | ||||
| 1248 | superclasses => [ ref $self ], | ||||
| 1249 | ); | ||||
| 1250 | |||||
| 1251 | 2 | 193ms | Class::MOP::MiniTrait::apply( $immutable_meta, $trait ); # spent 193ms making 2 calls to Class::MOP::MiniTrait::apply, avg 96.5ms/call | ||
| 1252 | |||||
| 1253 | 2 | 0s | $immutable_meta->make_immutable( # spent 1.75ms making 2 calls to Class::MOP::Class::make_immutable, avg 877µs/call, recursion: max depth 1, sum of overlapping time 1.75ms | ||
| 1254 | inline_constructor => 0, | ||||
| 1255 | inline_accessors => 0, | ||||
| 1256 | ); | ||||
| 1257 | |||||
| 1258 | return $class_name; | ||||
| 1259 | } | ||||
| 1260 | |||||
| 1261 | sub _remove_inlined_code { | ||||
| 1262 | my $self = shift; | ||||
| 1263 | |||||
| 1264 | $self->remove_method( $_->name ) for $self->_inlined_methods; | ||||
| 1265 | |||||
| 1266 | delete $self->{__immutable}{inlined_methods}; | ||||
| 1267 | } | ||||
| 1268 | |||||
| 1269 | sub _inlined_methods { @{ $_[0]{__immutable}{inlined_methods} || [] } } | ||||
| 1270 | |||||
| 1271 | sub _add_inlined_method { | ||||
| 1272 | 158 | 1.98ms | my ( $self, $method ) = @_; | ||
| 1273 | |||||
| 1274 | push @{ $self->{__immutable}{inlined_methods} ||= [] }, $method; | ||||
| 1275 | } | ||||
| 1276 | |||||
| 1277 | # spent 842ms (4.12+838) within Class::MOP::Class::_initialize_immutable which was called 75 times, avg 11.2ms/call:
# 75 times (4.12ms+838ms) by Class::MOP::Class::make_immutable at line 1180, avg 11.2ms/call | ||||
| 1278 | 225 | 4.04ms | my ( $self, %args ) = @_; | ||
| 1279 | |||||
| 1280 | $self->{__immutable}{options} = \%args; | ||||
| 1281 | 75 | 838ms | $self->_install_inlined_code(%args); # spent 838ms making 75 calls to Class::MOP::Class::_install_inlined_code, avg 11.2ms/call | ||
| 1282 | } | ||||
| 1283 | |||||
| 1284 | # spent 838ms (4.50+833) within Class::MOP::Class::_install_inlined_code which was called 75 times, avg 11.2ms/call:
# 75 times (4.50ms+833ms) by Class::MOP::Class::_initialize_immutable at line 1281, avg 11.2ms/call | ||||
| 1285 | 300 | 4.54ms | my ( $self, %args ) = @_; | ||
| 1286 | |||||
| 1287 | # FIXME | ||||
| 1288 | 32 | 191ms | $self->_inline_accessors(%args) if $args{inline_accessors}; # spent 191ms making 32 calls to Class::MOP::Class::_inline_accessors, avg 5.97ms/call | ||
| 1289 | 55 | 535ms | $self->_inline_constructor(%args) if $args{inline_constructor}; # spent 535ms making 55 calls to Class::MOP::Class::_inline_constructor, avg 9.72ms/call | ||
| 1290 | 24 | 108ms | $self->_inline_destructor(%args) if $args{inline_destructor}; # spent 108ms making 24 calls to Class::MOP::Class::_inline_destructor, avg 4.49ms/call | ||
| 1291 | } | ||||
| 1292 | |||||
| 1293 | sub _rebless_as_mutable { | ||||
| 1294 | my $self = shift; | ||||
| 1295 | |||||
| 1296 | bless $self, $self->_get_mutable_metaclass_name; | ||||
| 1297 | |||||
| 1298 | return $self; | ||||
| 1299 | } | ||||
| 1300 | |||||
| 1301 | # spent 191ms (3.07+188) within Class::MOP::Class::_inline_accessors which was called 32 times, avg 5.97ms/call:
# 32 times (3.07ms+188ms) by Class::MOP::Class::_install_inlined_code at line 1288, avg 5.97ms/call | ||||
| 1302 | 132 | 2.74ms | my $self = shift; | ||
| 1303 | |||||
| 1304 | 32 | 1.16ms | foreach my $attr_name ( $self->get_attribute_list ) { # spent 1.16ms making 32 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 36µs/call | ||
| 1305 | 136 | 187ms | $self->get_attribute($attr_name)->install_accessors(1); # spent 178ms making 67 calls to Class::MOP::Attribute::install_accessors, avg 2.65ms/call
# spent 6.65ms making 1 call to Moose::Meta::Attribute::install_accessors
# spent 2.77ms making 68 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 41µs/call | ||
| 1306 | } | ||||
| 1307 | } | ||||
| 1308 | |||||
| 1309 | # spent 535ms (8.18+526) within Class::MOP::Class::_inline_constructor which was called 55 times, avg 9.72ms/call:
# 55 times (8.18ms+526ms) by Class::MOP::Class::_install_inlined_code at line 1289, avg 9.72ms/call | ||||
| 1310 | 550 | 8.05ms | my ( $self, %args ) = @_; | ||
| 1311 | |||||
| 1312 | my $name = $args{constructor_name}; | ||||
| 1313 | # A class may not even have a constructor, and that's okay. | ||||
| 1314 | return unless defined $name; | ||||
| 1315 | |||||
| 1316 | 55 | 17.1ms | if ( $self->has_method($name) && !$args{replace_constructor} ) { # spent 17.1ms making 55 calls to Class::MOP::Mixin::HasMethods::has_method, avg 311µs/call | ||
| 1317 | my $class = $self->name; | ||||
| 1318 | warn "Not inlining a constructor for $class since it defines" | ||||
| 1319 | . " its own constructor.\n" | ||||
| 1320 | . "If you are certain you don't need to inline your" | ||||
| 1321 | . " constructor, specify inline_constructor => 0 in your" | ||||
| 1322 | . " call to $class->meta->make_immutable\n"; | ||||
| 1323 | return; | ||||
| 1324 | } | ||||
| 1325 | |||||
| 1326 | my $constructor_class = $args{constructor_class}; | ||||
| 1327 | |||||
| 1328 | 55 | 12.2ms | Class::MOP::load_class($constructor_class); # spent 13.2ms making 55 calls to Class::MOP::load_class, avg 241µs/call, recursion: max depth 1, sum of overlapping time 1.01ms | ||
| 1329 | |||||
| 1330 | 110 | 427ms | my $constructor = $constructor_class->new( # spent 232ms making 24 calls to Moose::Meta::Method::Constructor::new, avg 9.67ms/call
# spent 195ms making 31 calls to Class::MOP::Method::Constructor::new, avg 6.29ms/call
# spent 368µs making 55 calls to Class::MOP::Package::name, avg 7µs/call | ||
| 1331 | options => \%args, | ||||
| 1332 | metaclass => $self, | ||||
| 1333 | is_inline => 1, | ||||
| 1334 | package_name => $self->name, | ||||
| 1335 | name => $name, | ||||
| 1336 | ); | ||||
| 1337 | |||||
| 1338 | 55 | 41.0ms | if ( $args{replace_constructor} or $constructor->can_be_inlined ) { # spent 41.0ms making 55 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 746µs/call | ||
| 1339 | 55 | 26.1ms | $self->add_method( $name => $constructor ); # spent 26.1ms making 55 calls to Class::MOP::Mixin::HasMethods::add_method, avg 475µs/call | ||
| 1340 | 55 | 1.41ms | $self->_add_inlined_method($constructor); # spent 1.41ms making 55 calls to Class::MOP::Class::_add_inlined_method, avg 26µs/call | ||
| 1341 | } | ||||
| 1342 | } | ||||
| 1343 | |||||
| 1344 | # spent 108ms (4.17+104) within Class::MOP::Class::_inline_destructor which was called 24 times, avg 4.49ms/call:
# 24 times (4.17ms+104ms) by Class::MOP::Class::_install_inlined_code at line 1290, avg 4.49ms/call | ||||
| 1345 | 240 | 3.94ms | my ( $self, %args ) = @_; | ||
| 1346 | |||||
| 1347 | ( exists $args{destructor_class} && defined $args{destructor_class} ) | ||||
| 1348 | || confess "The 'inline_destructor' option is present, but " | ||||
| 1349 | . "no destructor class was specified"; | ||||
| 1350 | |||||
| 1351 | 24 | 7.50ms | if ( $self->has_method('DESTROY') && ! $args{replace_destructor} ) { # spent 7.50ms making 24 calls to Class::MOP::Mixin::HasMethods::has_method, avg 312µs/call | ||
| 1352 | my $class = $self->name; | ||||
| 1353 | warn "Not inlining a destructor for $class since it defines" | ||||
| 1354 | . " its own destructor.\n"; | ||||
| 1355 | return; | ||||
| 1356 | } | ||||
| 1357 | |||||
| 1358 | my $destructor_class = $args{destructor_class}; | ||||
| 1359 | |||||
| 1360 | 24 | 5.04ms | Class::MOP::load_class($destructor_class); # spent 6.03ms making 24 calls to Class::MOP::load_class, avg 251µs/call, recursion: max depth 1, sum of overlapping time 986µs | ||
| 1361 | |||||
| 1362 | 24 | 20.9ms | return unless $destructor_class->is_needed($self); # spent 20.9ms making 24 calls to Moose::Meta::Method::Destructor::is_needed, avg 872µs/call | ||
| 1363 | |||||
| 1364 | 48 | 41.2ms | my $destructor = $destructor_class->new( # spent 41.1ms making 24 calls to Moose::Meta::Method::Destructor::new, avg 1.71ms/call
# spent 142µs making 24 calls to Class::MOP::Package::name, avg 6µs/call | ||
| 1365 | options => \%args, | ||||
| 1366 | metaclass => $self, | ||||
| 1367 | package_name => $self->name, | ||||
| 1368 | name => 'DESTROY' | ||||
| 1369 | ); | ||||
| 1370 | |||||
| 1371 | 24 | 14.4ms | if ( $args{replace_destructor} or $destructor->can_be_inlined ) { # spent 14.4ms making 24 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 600µs/call | ||
| 1372 | 24 | 13.1ms | $self->add_method( 'DESTROY' => $destructor ); # spent 13.1ms making 24 calls to Class::MOP::Mixin::HasMethods::add_method, avg 545µs/call | ||
| 1373 | 24 | 444µs | $self->_add_inlined_method($destructor); # spent 444µs making 24 calls to Class::MOP::Class::_add_inlined_method, avg 18µs/call | ||
| 1374 | } | ||||
| 1375 | } | ||||
| 1376 | |||||
| 1377 | 1 | 23µs | 1; | ||
| 1378 | |||||
| 1379 | __END__ |