| Filename | /Users/ap13/perl5/lib/perl5/darwin-2level/Class/MOP/Class.pm |
| Statements | Executed 58695 statements in 128ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 2896 | 21 | 12 | 13.9ms | 50.0ms | Class::MOP::Class::initialize (recurses: max depth 2, inclusive time 990µs) |
| 395 | 8 | 4 | 11.2ms | 21.8ms | Class::MOP::Class::get_all_attributes |
| 271 | 2 | 1 | 11.0ms | 59.8ms | Class::MOP::Class::_construct_instance |
| 92 | 2 | 1 | 6.93ms | 8.83ms | Class::MOP::Class::CORE:sort (opcode) |
| 469 | 2 | 2 | 6.00ms | 73.9ms | Class::MOP::Class::_inline_slot_initializer |
| 390 | 1 | 1 | 5.64ms | 10.7ms | Class::MOP::Class::_single_metaclass_can_be_made_compatible |
| 320 | 1 | 1 | 4.15ms | 343ms | Class::MOP::Class::_post_add_attribute |
| 679 | 4 | 2 | 3.45ms | 5.34ms | Class::MOP::Class::linearized_isa |
| 136 | 5 | 5 | 3.41ms | 20.5ms | Class::MOP::Class::find_method_by_name |
| 237 | 1 | 1 | 3.05ms | 35.3ms | Class::MOP::Class::_create_meta_instance |
| 271 | 1 | 1 | 2.66ms | 13.3ms | Class::MOP::Class::_inline_init_attr_from_constructor |
| 322 | 2 | 1 | 2.65ms | 3.23ms | Class::MOP::Class::invalidate_meta_instances |
| 405 | 2 | 2 | 2.59ms | 3.94ms | Class::MOP::Class::_inline_default_value |
| 253 | 5 | 5 | 2.25ms | 51.5ms | Class::MOP::Class::new_object |
| 104 | 2 | 1 | 2.16ms | 30.1ms | Class::MOP::Class::_check_metaclass_compatibility (recurses: max depth 1, inclusive time 331µs) |
| 65 | 1 | 1 | 2.10ms | 15.8ms | Class::MOP::Class::_can_fix_metaclass_incompatibility |
| 84 | 1 | 1 | 2.07ms | 32.8ms | Class::MOP::Class::_construct_class_instance (recurses: max depth 1, inclusive time 421µs) |
| 105 | 2 | 2 | 2.04ms | 9.51ms | Class::MOP::Class::find_next_method_by_name |
| 988 | 11 | 5 | 2.03ms | 37.4ms | Class::MOP::Class::get_meta_instance |
| 1 | 1 | 1 | 2.00ms | 9.26ms | Class::MOP::Class::BEGIN@9 |
| 282 | 2 | 1 | 1.84ms | 7.51ms | Class::MOP::Class::_inline_init_attr_from_default |
| 46 | 1 | 1 | 1.76ms | 188ms | Class::MOP::Class::_inline_constructor |
| 108 | 1 | 1 | 1.75ms | 2.85ms | Class::MOP::Class::_single_metaclass_is_compatible |
| 46 | 1 | 1 | 1.71ms | 87.2ms | Class::MOP::Class::_inline_slot_initializers |
| 70 | 1 | 1 | 1.71ms | 39.8ms | Class::MOP::Class::_immutable_metaclass (recurses: max depth 1, inclusive time 227µs) |
| 70 | 22 | 20 | 1.70ms | 301ms | Class::MOP::Class::make_immutable (recurses: max depth 1, inclusive time 464µs) |
| 46 | 2 | 2 | 1.69ms | 9.81ms | Class::MOP::Class::_eval_environment |
| 1 | 1 | 1 | 1.67ms | 1.86ms | Class::MOP::Class::BEGIN@8 |
| 320 | 1 | 1 | 1.49ms | 5.02ms | Class::MOP::Class::_attach_attribute |
| 1 | 1 | 1 | 1.40ms | 1.53ms | Class::MOP::Class::BEGIN@7 |
| 70 | 2 | 2 | 1.22ms | 1.58ms | Class::MOP::Class::_immutable_options |
| 70 | 1 | 1 | 1.13ms | 3.43ms | Class::MOP::Class::find_attribute_by_name |
| 70 | 1 | 1 | 1.07ms | 257ms | Class::MOP::Class::_initialize_immutable |
| 280 | 4 | 1 | 1.05ms | 3.19ms | Class::MOP::Class::_method_lookup_order |
| 1 | 1 | 1 | 1.04ms | 2.24ms | Class::MOP::Class::BEGIN@10 |
| 70 | 1 | 1 | 1.01ms | 256ms | Class::MOP::Class::_install_inlined_code |
| 66 | 1 | 1 | 992µs | 992µs | Class::MOP::Class::_new |
| 44 | 2 | 1 | 949µs | 13.7ms | Class::MOP::Class::__ANON__[:1082] |
| 70 | 1 | 1 | 914µs | 40.7ms | Class::MOP::Class::_rebless_as_immutable (recurses: max depth 1, inclusive time 284µs) |
| 54 | 1 | 1 | 895µs | 17.4ms | Class::MOP::Class::_fix_metaclass_incompatibility (recurses: max depth 1, inclusive time 198µs) |
| 32 | 2 | 2 | 835µs | 4.23ms | Class::MOP::Class::find_all_methods_by_name |
| 46 | 1 | 1 | 834µs | 100ms | Class::MOP::Class::_inline_new_object |
| 16 | 1 | 1 | 790µs | 13.7ms | Class::MOP::Class::_inline_destructor |
| 33 | 1 | 1 | 605µs | 52.7ms | Class::MOP::Class::_inline_accessors |
| 322 | 1 | 1 | 582µs | 582µs | Class::MOP::Class::invalidate_meta_instance |
| 94 | 4 | 1 | 533µs | 897µs | Class::MOP::Class::_real_ref_name |
| 65 | 1 | 1 | 516µs | 2.05ms | Class::MOP::Class::_class_metaclass_can_be_made_compatible |
| 119 | 3 | 2 | 479µs | 479µs | Class::MOP::Class::_base_metaclasses |
| 7 | 1 | 1 | 448µs | 4.96ms | Class::MOP::Class::get_all_methods |
| 108 | 1 | 1 | 439µs | 3.29ms | Class::MOP::Class::_check_single_metaclass_compatibility |
| 1 | 1 | 1 | 422µs | 525µs | Class::MOP::Class::BEGIN@11 |
| 46 | 1 | 1 | 405µs | 571µs | Class::MOP::Class::_inline_fallback_constructor |
| 43 | 1 | 1 | 386µs | 14.7ms | Class::MOP::Class::add_around_method_modifier |
| 46 | 1 | 1 | 328µs | 1.87ms | Class::MOP::Class::_inline_create_instance |
| 46 | 1 | 1 | 318µs | 626µs | Class::MOP::Class::_inline_preserve_weak_metaclasses |
| 20 | 1 | 1 | 284µs | 1.09ms | Class::MOP::Class::_superclasses_updated |
| 46 | 1 | 1 | 280µs | 2.15ms | Class::MOP::Class::_inline_generate_instance |
| 62 | 2 | 1 | 250µs | 250µs | Class::MOP::Class::_add_inlined_method |
| 18 | 1 | 1 | 189µs | 370µs | Class::MOP::Class::_class_metaclass_is_compatible |
| 8 | 2 | 2 | 136µs | 459µs | Class::MOP::Class::class_precedence_list (recurses: max depth 1, inclusive time 152µs) |
| 2 | 1 | 1 | 133µs | 433µs | Class::MOP::Class::remove_attribute |
| 103 | 4 | 3 | 122µs | 122µs | Class::MOP::Class::is_mutable |
| 18 | 1 | 1 | 102µs | 472µs | Class::MOP::Class::_check_class_metaclass_compatibility |
| 2 | 1 | 1 | 98µs | 2.96ms | Class::MOP::Class::create |
| 30 | 1 | 1 | 96µs | 96µs | Class::MOP::Class::_inline_params |
| 71 | 1 | 1 | 85µs | 85µs | Class::MOP::Class::is_immutable |
| 30 | 1 | 1 | 77µs | 77µs | Class::MOP::Class::_generate_fallback_constructor |
| 20 | 1 | 1 | 71µs | 71µs | Class::MOP::Class::_superclass_metas |
| 20 | 1 | 1 | 50µs | 50µs | Class::MOP::Class::update_meta_instance_dependencies |
| 30 | 1 | 1 | 36µs | 36µs | Class::MOP::Class::_inline_extra_init |
| 1 | 1 | 1 | 36µs | 178µs | Class::MOP::Class::BEGIN@18 |
| 1 | 1 | 1 | 16µs | 37µs | Class::MOP::Class::BEGIN@4 |
| 1 | 1 | 1 | 14µs | 488µs | Class::MOP::Class::add_before_method_modifier |
| 1 | 1 | 1 | 14µs | 5.01ms | Class::MOP::Class::BEGIN@20 |
| 1 | 1 | 1 | 14µs | 44µs | Class::MOP::Class::BEGIN@16 |
| 1 | 1 | 1 | 13µs | 58µs | Class::MOP::Class::BEGIN@17 |
| 1 | 1 | 1 | 13µs | 50µs | Class::MOP::Class::BEGIN@13 |
| 1 | 1 | 1 | 12µs | 28µs | Class::MOP::Class::BEGIN@14 |
| 1 | 1 | 1 | 11µs | 42µs | Class::MOP::Class::BEGIN@15 |
| 1 | 1 | 1 | 11µs | 19µs | Class::MOP::Class::BEGIN@5 |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::__ANON__[:210] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::__ANON__[:900] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::__ANON__[:904] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_anon_cache_key |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_anon_package_prefix |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_clone_instance |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_fix_class_metaclass_incompatibility |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_fix_single_metaclass_incompatibility |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_fixup_attributes_after_rebless |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_force_rebless_instance |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_inline_clear_mop_slot |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_inline_get_mop_slot |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_inline_rebless_instance |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_inline_set_mop_slot |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_inlined_methods |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_rebless_as_mutable |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_remove_generated_metaobjects |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_remove_inlined_code |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::_restore_metaobjects_from |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::add_after_method_modifier |
| 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::create_anon_class |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::direct_subclasses |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::get_all_method_names |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::immutable_options |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::is_anon_class |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::is_pristine |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::make_mutable |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::rebless_instance |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::rebless_instance_away |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::rebless_instance_back |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::reinitialize |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::remove_dependent_meta_instance |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::remove_meta_instance_dependencies |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Class::subclasses |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Class::MOP::Class; | ||||
| 2 | 1 | 2µs | our $VERSION = '2.1403'; | ||
| 3 | |||||
| 4 | 2 | 28µs | 2 | 58µs | # spent 37µs (16+21) within Class::MOP::Class::BEGIN@4 which was called:
# once (16µs+21µs) by Class::MOP::BEGIN@18 at line 4 # spent 37µs making 1 call to Class::MOP::Class::BEGIN@4
# spent 21µs making 1 call to strict::import |
| 5 | 2 | 33µs | 2 | 27µs | # spent 19µs (11+8) within Class::MOP::Class::BEGIN@5 which was called:
# once (11µs+8µs) by Class::MOP::BEGIN@18 at line 5 # spent 19µs making 1 call to Class::MOP::Class::BEGIN@5
# spent 8µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 2 | 129µs | 1 | 1.53ms | # spent 1.53ms (1.40+130µs) within Class::MOP::Class::BEGIN@7 which was called:
# once (1.40ms+130µs) by Class::MOP::BEGIN@18 at line 7 # spent 1.53ms making 1 call to Class::MOP::Class::BEGIN@7 |
| 8 | 2 | 179µs | 1 | 1.86ms | # spent 1.86ms (1.67+185µs) within Class::MOP::Class::BEGIN@8 which was called:
# once (1.67ms+185µs) by Class::MOP::BEGIN@18 at line 8 # spent 1.86ms making 1 call to Class::MOP::Class::BEGIN@8 |
| 9 | 2 | 188µs | 1 | 9.26ms | # spent 9.26ms (2.00+7.26) within Class::MOP::Class::BEGIN@9 which was called:
# once (2.00ms+7.26ms) by Class::MOP::BEGIN@18 at line 9 # spent 9.26ms making 1 call to Class::MOP::Class::BEGIN@9 |
| 10 | 2 | 201µs | 1 | 2.24ms | # spent 2.24ms (1.04+1.19) within Class::MOP::Class::BEGIN@10 which was called:
# once (1.04ms+1.19ms) by Class::MOP::BEGIN@18 at line 10 # spent 2.24ms making 1 call to Class::MOP::Class::BEGIN@10 |
| 11 | 2 | 164µs | 1 | 525µs | # spent 525µs (422+103) within Class::MOP::Class::BEGIN@11 which was called:
# once (422µs+103µs) by Class::MOP::BEGIN@18 at line 11 # spent 525µs making 1 call to Class::MOP::Class::BEGIN@11 |
| 12 | |||||
| 13 | 2 | 40µs | 2 | 88µs | # spent 50µs (13+37) within Class::MOP::Class::BEGIN@13 which was called:
# once (13µs+37µs) by Class::MOP::BEGIN@18 at line 13 # spent 50µs making 1 call to Class::MOP::Class::BEGIN@13
# spent 37µs making 1 call to Exporter::import |
| 14 | 2 | 36µs | 2 | 45µs | # spent 28µs (12+17) within Class::MOP::Class::BEGIN@14 which was called:
# once (12µs+17µs) by Class::MOP::BEGIN@18 at line 14 # spent 28µs making 1 call to Class::MOP::Class::BEGIN@14
# spent 17µs making 1 call to Module::Runtime::import |
| 15 | 2 | 37µs | 2 | 73µs | # spent 42µs (11+31) within Class::MOP::Class::BEGIN@15 which was called:
# once (11µs+31µs) by Class::MOP::BEGIN@18 at line 15 # spent 42µs making 1 call to Class::MOP::Class::BEGIN@15
# spent 31µs making 1 call to Exporter::import |
| 16 | 2 | 40µs | 2 | 75µs | # spent 44µs (14+31) within Class::MOP::Class::BEGIN@16 which was called:
# once (14µs+31µs) by Class::MOP::BEGIN@18 at line 16 # spent 44µs making 1 call to Class::MOP::Class::BEGIN@16
# spent 30µs making 1 call to Exporter::import |
| 17 | 2 | 45µs | 2 | 102µs | # spent 58µs (13+44) within Class::MOP::Class::BEGIN@17 which was called:
# once (13µs+44µs) by Class::MOP::BEGIN@18 at line 17 # spent 58µs making 1 call to Class::MOP::Class::BEGIN@17
# spent 44µs making 1 call to Exporter::import |
| 18 | 3 | 92µs | 3 | 216µs | # spent 178µs (36+142) within Class::MOP::Class::BEGIN@18 which was called:
# once (36µs+142µs) by Class::MOP::BEGIN@18 at line 18 # spent 178µs making 1 call to Class::MOP::Class::BEGIN@18
# spent 22µs making 1 call to UNIVERSAL::VERSION
# spent 16µs making 1 call to List::Util::import |
| 19 | |||||
| 20 | 2 | 10µs | # spent 5.01ms (14µs+4.99) within Class::MOP::Class::BEGIN@20 which was called:
# once (14µs+4.99ms) by Class::MOP::BEGIN@18 at line 23 | ||
| 21 | 'Class::MOP::Mixin::HasAttributes', | ||||
| 22 | 'Class::MOP::Mixin::HasMethods', | ||||
| 23 | 1 | 8.80ms | 2 | 10.0ms | 'Class::MOP::Mixin::HasOverloads'; # spent 5.01ms making 1 call to Class::MOP::Class::BEGIN@20
# spent 4.99ms making 1 call to parent::import |
| 24 | |||||
| 25 | # Creation | ||||
| 26 | |||||
| 27 | # spent 50.0ms (13.9+36.1) within Class::MOP::Class::initialize which was called 2896 times, avg 17µs/call:
# 1185 times (5.16ms+1.17ms) by Class::MOP::Class::get_all_attributes at line 936, avg 5µs/call
# 445 times (2.28ms+4.13ms) by Bio::Roary::AnalyseGroups::meta or Bio::Roary::AnnotateGroups::meta or Bio::Roary::CommandLine::RoaryPostAnalysis::meta or Bio::Roary::ContigsToGeneIDsFromGFF::meta or Bio::Roary::External::ProteinMuscleAlignmentFromNucleotides::meta or Bio::Roary::GeneNamesFromGFF::meta or Bio::Roary::GroupLabels::meta or Bio::Roary::GroupStatistics::meta or Bio::Roary::InflateClusters::meta or Bio::Roary::OrderGenes::meta or Bio::Roary::Output::EmblGroups::meta or Bio::Roary::Output::GroupsMultifastaNucleotide::meta or Bio::Roary::Output::GroupsMultifastasNucleotide::meta or Bio::Roary::Output::NumberOfGroups::meta or Bio::Roary::PostAnalysis::meta or Bio::Roary::SplitGroups::meta or Class::MOP::Mixin::meta or Class::MOP::Object::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 42 of Class/MOP/Method/Meta.pm, avg 14µs/call
# 439 times (2.07ms+664µs) by Class::MOP::Class::find_method_by_name at line 1133, avg 6µs/call
# 207 times (912µs+842µs) by Class::MOP::Method::Accessor::_new at line 51 of Class/MOP/Method/Accessor.pm, avg 8µs/call
# 182 times (904µs+233µs) by Class::MOP::Class::find_next_method_by_name at line 1181, avg 6µs/call
# 98 times (404µs+118µs) by Class::MOP::Class::find_all_methods_by_name at line 1164, avg 5µs/call
# 70 times (357µs+85µs) by Class::MOP::Class::find_attribute_by_name at line 926, avg 6µs/call
# 65 times (329µs+-203µs) by Class::MOP::Class::_fix_metaclass_incompatibility at line 291, avg 2µs/call
# 59 times (479µs+9.36ms) by Class::MOP::Mixin::meta at line 12 of Class/MOP/Mixin.pm, avg 167µs/call
# 24 times (104µs+975µs) by Class::MOP::Method::_new at line 55 of Class/MOP/Method.pm, avg 45µs/call
# 20 times (79µs+37µs) by Moose::Meta::Method::_new at line 7 of (eval 25)[Eval/Closure.pm:125], avg 6µs/call
# 19 times (169µs+1.64ms) by metaclass::import at line 38 of metaclass.pm, avg 95µs/call
# 18 times (204µs+13.6ms) by Moose::Meta::Class::initialize at line 64 of Moose/Meta/Class.pm, avg 767µs/call
# 15 times (83µs+21µs) by Class::MOP::Class::get_all_methods at line 1144, avg 7µs/call
# 12 times (118µs+2.64ms) by Class::MOP::MiniTrait::apply at line 14 of Class/MOP/MiniTrait.pm, avg 230µs/call
# 12 times (59µs+12µs) by Class::MOP::Attribute::has_value at line 332 of Class/MOP/Attribute.pm, avg 6µs/call
# 12 times (51µs+17µs) by Class::MOP::Attribute::get_raw_value at line 311 of Class/MOP/Attribute.pm, avg 6µs/call
# 7 times (50µs+519µs) by Moose::BEGIN@43 at line 12 of Moose/Meta/Attribute/Native.pm, avg 81µs/call
# 4 times (20µs+8µs) by Class::MOP::Class::class_precedence_list at line 1036, avg 7µs/call
# 2 times (22µs+249µs) by Class::MOP::Package::create at line 67 of Class/MOP/Package.pm, avg 135µs/call
# once (4µs+1µs) by Class::MOP::Attribute::_new at line 69 of Class/MOP/Attribute.pm | ||||
| 28 | 14480 | 11.9ms | my $class = shift; | ||
| 29 | |||||
| 30 | my $package_name; | ||||
| 31 | |||||
| 32 | if ( @_ % 2 ) { | ||||
| 33 | $package_name = shift; | ||||
| 34 | } else { | ||||
| 35 | my %options = @_; | ||||
| 36 | $package_name = $options{package}; | ||||
| 37 | } | ||||
| 38 | |||||
| 39 | ($package_name && !ref($package_name)) | ||||
| 40 | || ($class||__PACKAGE__)->_throw_exception( InitializeTakesUnBlessedPackageName => package_name => $package_name ); | ||||
| 41 | 2980 | 36.7ms | return Class::MOP::get_metaclass_by_name($package_name) # spent 33.3ms making 84 calls to Class::MOP::Class::_construct_class_instance, avg 396µs/call, recursion: max depth 1, sum of overlapping time 421µs
# spent 3.85ms making 2896 calls to Class::MOP::get_metaclass_by_name, avg 1µs/call | ||
| 42 | || $class->_construct_class_instance(package => $package_name, @_); | ||||
| 43 | } | ||||
| 44 | |||||
| 45 | sub reinitialize { | ||||
| 46 | my ( $class, @args ) = @_; | ||||
| 47 | unshift @args, "package" if @args % 2; | ||||
| 48 | my %options = @args; | ||||
| 49 | my $old_metaclass = blessed($options{package}) | ||||
| 50 | ? $options{package} | ||||
| 51 | : Class::MOP::get_metaclass_by_name($options{package}); | ||||
| 52 | $options{weaken} = Class::MOP::metaclass_is_weak($old_metaclass->name) | ||||
| 53 | if !exists $options{weaken} | ||||
| 54 | && blessed($old_metaclass) | ||||
| 55 | && $old_metaclass->isa('Class::MOP::Class'); | ||||
| 56 | $old_metaclass->_remove_generated_metaobjects | ||||
| 57 | if $old_metaclass && $old_metaclass->isa('Class::MOP::Class'); | ||||
| 58 | my $new_metaclass = $class->SUPER::reinitialize(%options); | ||||
| 59 | $new_metaclass->_restore_metaobjects_from($old_metaclass) | ||||
| 60 | if $old_metaclass && $old_metaclass->isa('Class::MOP::Class'); | ||||
| 61 | return $new_metaclass; | ||||
| 62 | } | ||||
| 63 | |||||
| 64 | # NOTE: (meta-circularity) | ||||
| 65 | # this is a special form of _construct_instance | ||||
| 66 | # (see below), which is used to construct class | ||||
| 67 | # meta-object instances for any Class::MOP::* | ||||
| 68 | # class. All other classes will use the more | ||||
| 69 | # normal &construct_instance. | ||||
| 70 | # spent 32.8ms (2.07+30.8) within Class::MOP::Class::_construct_class_instance which was called 84 times, avg 391µs/call:
# 84 times (2.07ms+30.8ms) by Class::MOP::Class::initialize at line 41, avg 391µs/call | ||||
| 71 | 1026 | 1.67ms | my $class = shift; | ||
| 72 | my $options = @_ == 1 ? $_[0] : {@_}; | ||||
| 73 | my $package_name = $options->{package}; | ||||
| 74 | (defined $package_name && $package_name) | ||||
| 75 | || $class->_throw_exception("ConstructClassInstanceTakesPackageName"); | ||||
| 76 | # NOTE: | ||||
| 77 | # return the metaclass if we have it cached, | ||||
| 78 | # and it is still defined (it has not been | ||||
| 79 | # reaped by DESTROY yet, which can happen | ||||
| 80 | # annoyingly enough during global destruction) | ||||
| 81 | |||||
| 82 | 84 | 90µs | if (defined(my $meta = Class::MOP::get_metaclass_by_name($package_name))) { # spent 90µs making 84 calls to Class::MOP::get_metaclass_by_name, avg 1µs/call | ||
| 83 | return $meta; | ||||
| 84 | } | ||||
| 85 | |||||
| 86 | $class | ||||
| 87 | 9 | 152µs | = ref $class # spent 152µs making 9 calls to Class::MOP::Class::_real_ref_name, avg 17µs/call | ||
| 88 | ? $class->_real_ref_name | ||||
| 89 | : $class; | ||||
| 90 | |||||
| 91 | # now create the metaclass | ||||
| 92 | my $meta; | ||||
| 93 | 66 | 992µs | if ($class eq 'Class::MOP::Class') { # spent 992µs making 66 calls to Class::MOP::Class::_new, avg 15µs/call | ||
| 94 | $meta = $class->_new($options); | ||||
| 95 | } | ||||
| 96 | else { | ||||
| 97 | # NOTE: | ||||
| 98 | # it is safe to use meta here because | ||||
| 99 | # class will always be a subclass of | ||||
| 100 | # Class::MOP::Class, which defines meta | ||||
| 101 | 36 | 11.3ms | $meta = $class->meta->_construct_instance($options) # spent 11.1ms making 18 calls to Class::MOP::Class::_construct_instance, avg 616µs/call
# spent 249µs making 18 calls to Class::MOP::Object::meta, avg 14µs/call | ||
| 102 | } | ||||
| 103 | |||||
| 104 | # and check the metaclass compatibility | ||||
| 105 | 84 | 18.1ms | $meta->_check_metaclass_compatibility(); # spent 18.4ms making 84 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 219µs/call, recursion: max depth 1, sum of overlapping time 331µs | ||
| 106 | |||||
| 107 | 84 | 242µs | Class::MOP::store_metaclass_by_name($package_name, $meta); # spent 242µs making 84 calls to Class::MOP::store_metaclass_by_name, avg 3µs/call | ||
| 108 | |||||
| 109 | # NOTE: | ||||
| 110 | # we need to weaken any anon classes | ||||
| 111 | # so that they can call DESTROY properly | ||||
| 112 | Class::MOP::weaken_metaclass($package_name) if $options->{weaken}; | ||||
| 113 | |||||
| 114 | $meta; | ||||
| 115 | } | ||||
| 116 | |||||
| 117 | # spent 897µs (533+364) within Class::MOP::Class::_real_ref_name which was called 94 times, avg 10µs/call:
# 65 times (397µs+244µs) by Class::MOP::Class::_class_metaclass_can_be_made_compatible at line 336, avg 10µs/call
# 18 times (64µs+13µs) by Class::MOP::Class::_class_metaclass_is_compatible at line 250, avg 4µs/call
# 9 times (58µs+95µs) by Class::MOP::Class::_construct_class_instance at line 87, avg 17µs/call
# 2 times (15µs+12µs) by Class::MOP::Class::_immutable_metaclass at line 1364, avg 14µs/call | ||||
| 118 | 188 | 461µs | my $self = shift; | ||
| 119 | |||||
| 120 | # NOTE: we need to deal with the possibility of class immutability here, | ||||
| 121 | # and then get the name of the class appropriately | ||||
| 122 | 117 | 364µs | return $self->is_immutable # spent 218µs making 23 calls to Class::MOP::Class::Immutable::Class::MOP::Class::is_immutable, avg 10µs/call
# spent 85µs making 71 calls to Class::MOP::Class::is_immutable, avg 1µs/call
# spent 61µs making 23 calls to Class::MOP::Class::Immutable::Trait::_get_mutable_metaclass_name, avg 3µs/call | ||
| 123 | ? $self->_get_mutable_metaclass_name() | ||||
| 124 | : ref $self; | ||||
| 125 | } | ||||
| 126 | |||||
| 127 | # spent 992µs within Class::MOP::Class::_new which was called 66 times, avg 15µs/call:
# 66 times (992µs+0s) by Class::MOP::Class::_construct_class_instance at line 93, avg 15µs/call | ||||
| 128 | 264 | 1.04ms | my $class = shift; | ||
| 129 | |||||
| 130 | return Class::MOP::Class->initialize($class)->new_object(@_) | ||||
| 131 | if $class ne __PACKAGE__; | ||||
| 132 | |||||
| 133 | my $options = @_ == 1 ? $_[0] : {@_}; | ||||
| 134 | |||||
| 135 | return bless { | ||||
| 136 | # inherited from Class::MOP::Package | ||||
| 137 | 'package' => $options->{package}, | ||||
| 138 | |||||
| 139 | # NOTE: | ||||
| 140 | # since the following attributes will | ||||
| 141 | # actually be loaded from the symbol | ||||
| 142 | # table, and actually bypass the instance | ||||
| 143 | # entirely, we can just leave these things | ||||
| 144 | # listed here for reference, because they | ||||
| 145 | # should not actually have a value associated | ||||
| 146 | # with the slot. | ||||
| 147 | 'namespace' => \undef, | ||||
| 148 | 'methods' => {}, | ||||
| 149 | |||||
| 150 | # inherited from Class::MOP::Module | ||||
| 151 | 'version' => \undef, | ||||
| 152 | 'authority' => \undef, | ||||
| 153 | |||||
| 154 | # defined in Class::MOP::Class | ||||
| 155 | 'superclasses' => \undef, | ||||
| 156 | |||||
| 157 | 'attributes' => {}, | ||||
| 158 | 'attribute_metaclass' => | ||||
| 159 | ( $options->{'attribute_metaclass'} || 'Class::MOP::Attribute' ), | ||||
| 160 | 'method_metaclass' => | ||||
| 161 | ( $options->{'method_metaclass'} || 'Class::MOP::Method' ), | ||||
| 162 | 'wrapped_method_metaclass' => ( | ||||
| 163 | $options->{'wrapped_method_metaclass'} | ||||
| 164 | || 'Class::MOP::Method::Wrapped' | ||||
| 165 | ), | ||||
| 166 | 'instance_metaclass' => | ||||
| 167 | ( $options->{'instance_metaclass'} || 'Class::MOP::Instance' ), | ||||
| 168 | 'immutable_trait' => ( | ||||
| 169 | $options->{'immutable_trait'} | ||||
| 170 | || 'Class::MOP::Class::Immutable::Trait' | ||||
| 171 | ), | ||||
| 172 | 'constructor_name' => ( $options->{constructor_name} || 'new' ), | ||||
| 173 | 'constructor_class' => ( | ||||
| 174 | $options->{constructor_class} || 'Class::MOP::Method::Constructor' | ||||
| 175 | ), | ||||
| 176 | 'destructor_class' => $options->{destructor_class}, | ||||
| 177 | }, $class; | ||||
| 178 | } | ||||
| 179 | |||||
| 180 | ## Metaclass compatibility | ||||
| 181 | { | ||||
| 182 | 2 | 8µs | my %base_metaclass = ( | ||
| 183 | attribute_metaclass => 'Class::MOP::Attribute', | ||||
| 184 | method_metaclass => 'Class::MOP::Method', | ||||
| 185 | wrapped_method_metaclass => 'Class::MOP::Method::Wrapped', | ||||
| 186 | instance_metaclass => 'Class::MOP::Instance', | ||||
| 187 | constructor_class => 'Class::MOP::Method::Constructor', | ||||
| 188 | destructor_class => 'Class::MOP::Method::Destructor', | ||||
| 189 | ); | ||||
| 190 | |||||
| 191 | 119 | 594µs | # spent 479µs within Class::MOP::Class::_base_metaclasses which was called 119 times, avg 4µs/call:
# 47 times (224µs+0s) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 324, avg 5µs/call
# 36 times (131µs+0s) by Moose::Meta::Class::_base_metaclasses at line 628 of Moose/Meta/Class.pm, avg 4µs/call
# 36 times (123µs+0s) by Class::MOP::Class::_check_metaclass_compatibility at line 202, avg 3µs/call | ||
| 192 | } | ||||
| 193 | |||||
| 194 | # spent 30.1ms (2.16+28.0) within Class::MOP::Class::_check_metaclass_compatibility which was called 104 times, avg 290µs/call:
# 84 times (1.05ms+17.0ms) by Class::MOP::Class::_construct_class_instance at line 105, avg 215µs/call
# 20 times (1.11ms+11.0ms) by Class::MOP::Class::superclasses at line 966, avg 603µs/call | ||||
| 195 | 748 | 1.73ms | my $self = shift; | ||
| 196 | |||||
| 197 | 104 | 4.47ms | my @superclasses = $self->superclasses # spent 3.02ms making 68 calls to Class::MOP::Class::superclasses, avg 44µs/call, recursion: max depth 1, sum of overlapping time 36µs
# spent 2.14ms making 36 calls to Moose::Meta::Class::superclasses, avg 59µs/call, recursion: max depth 2, sum of overlapping time 656µs | ||
| 198 | or return; | ||||
| 199 | |||||
| 200 | 54 | 17.4ms | $self->_fix_metaclass_incompatibility(@superclasses); # spent 17.6ms making 54 calls to Class::MOP::Class::_fix_metaclass_incompatibility, avg 325µs/call, recursion: max depth 1, sum of overlapping time 198µs | ||
| 201 | |||||
| 202 | 54 | 739µs | my %base_metaclass = $self->_base_metaclasses; # spent 616µs making 18 calls to Moose::Meta::Class::_base_metaclasses, avg 34µs/call
# spent 123µs making 36 calls to Class::MOP::Class::_base_metaclasses, avg 3µs/call | ||
| 203 | |||||
| 204 | # this is always okay ... | ||||
| 205 | return | ||||
| 206 | if ref($self) eq 'Class::MOP::Class' | ||||
| 207 | && all { | ||||
| 208 | 432 | 767µs | 216 | 158µs | my $meta = $self->$_; # spent 31µs making 36 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 850ns/call
# spent 29µs making 36 calls to Class::MOP::Class::instance_metaclass, avg 806ns/call
# spent 26µs making 36 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 714ns/call
# spent 25µs making 36 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 697ns/call
# spent 24µs making 36 calls to Class::MOP::Class::constructor_class, avg 681ns/call
# spent 23µs making 36 calls to Class::MOP::Class::destructor_class, avg 639ns/call |
| 209 | 1 | 255µs | !defined($meta) || $meta eq $base_metaclass{$_}; | ||
| 210 | } | ||||
| 211 | 36 | 966µs | keys %base_metaclass; # spent 966µs making 36 calls to List::Util::all, avg 27µs/call | ||
| 212 | |||||
| 213 | for my $superclass (@superclasses) { | ||||
| 214 | 18 | 472µs | $self->_check_class_metaclass_compatibility($superclass); # spent 472µs making 18 calls to Class::MOP::Class::_check_class_metaclass_compatibility, avg 26µs/call | ||
| 215 | } | ||||
| 216 | |||||
| 217 | for my $metaclass_type ( keys %base_metaclass ) { | ||||
| 218 | 108 | 110µs | next unless defined $self->$metaclass_type; # spent 31µs making 18 calls to Moose::Meta::Class::constructor_class, avg 2µs/call
# spent 28µs making 18 calls to Moose::Meta::Class::destructor_class, avg 2µs/call
# spent 14µs making 18 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 750ns/call
# spent 13µs making 18 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 722ns/call
# spent 12µs making 18 calls to Class::MOP::Class::instance_metaclass, avg 689ns/call
# spent 12µs making 18 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 667ns/call | ||
| 219 | for my $superclass (@superclasses) { | ||||
| 220 | 108 | 3.29ms | $self->_check_single_metaclass_compatibility( $metaclass_type, # spent 3.29ms making 108 calls to Class::MOP::Class::_check_single_metaclass_compatibility, avg 30µs/call | ||
| 221 | $superclass ); | ||||
| 222 | } | ||||
| 223 | } | ||||
| 224 | } | ||||
| 225 | |||||
| 226 | # spent 472µs (102+370) within Class::MOP::Class::_check_class_metaclass_compatibility which was called 18 times, avg 26µs/call:
# 18 times (102µs+370µs) by Class::MOP::Class::_check_metaclass_compatibility at line 214, avg 26µs/call | ||||
| 227 | 54 | 86µs | my $self = shift; | ||
| 228 | my ( $superclass_name ) = @_; | ||||
| 229 | |||||
| 230 | 18 | 370µs | if (!$self->_class_metaclass_is_compatible($superclass_name)) { # spent 370µs making 18 calls to Class::MOP::Class::_class_metaclass_is_compatible, avg 21µs/call | ||
| 231 | my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name); | ||||
| 232 | |||||
| 233 | my $super_meta_type = $super_meta->_real_ref_name; | ||||
| 234 | |||||
| 235 | $self->_throw_exception( IncompatibleMetaclassOfSuperclass => class_name => $self->name, | ||||
| 236 | class_meta_type => ref( $self ), | ||||
| 237 | superclass_name => $superclass_name, | ||||
| 238 | superclass_meta_type => $super_meta_type | ||||
| 239 | ); | ||||
| 240 | } | ||||
| 241 | } | ||||
| 242 | |||||
| 243 | # spent 370µs (189+181) within Class::MOP::Class::_class_metaclass_is_compatible which was called 18 times, avg 21µs/call:
# 18 times (189µs+181µs) by Class::MOP::Class::_check_class_metaclass_compatibility at line 230, avg 21µs/call | ||||
| 244 | 90 | 138µs | my $self = shift; | ||
| 245 | my ( $superclass_name ) = @_; | ||||
| 246 | |||||
| 247 | 18 | 22µs | my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name) # spent 22µs making 18 calls to Class::MOP::get_metaclass_by_name, avg 1µs/call | ||
| 248 | || return 1; | ||||
| 249 | |||||
| 250 | 18 | 77µs | my $super_meta_name = $super_meta->_real_ref_name; # spent 77µs making 18 calls to Class::MOP::Class::_real_ref_name, avg 4µs/call | ||
| 251 | |||||
| 252 | 18 | 83µs | return $self->_is_compatible_with($super_meta_name); # spent 83µs making 18 calls to Class::MOP::Object::_is_compatible_with, avg 5µs/call | ||
| 253 | } | ||||
| 254 | |||||
| 255 | # spent 3.29ms (439µs+2.85) within Class::MOP::Class::_check_single_metaclass_compatibility which was called 108 times, avg 30µs/call:
# 108 times (439µs+2.85ms) by Class::MOP::Class::_check_metaclass_compatibility at line 220, avg 30µs/call | ||||
| 256 | 324 | 381µs | my $self = shift; | ||
| 257 | my ( $metaclass_type, $superclass_name ) = @_; | ||||
| 258 | |||||
| 259 | 108 | 2.85ms | if (!$self->_single_metaclass_is_compatible($metaclass_type, $superclass_name)) { # spent 2.85ms making 108 calls to Class::MOP::Class::_single_metaclass_is_compatible, avg 26µs/call | ||
| 260 | my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name); | ||||
| 261 | |||||
| 262 | $self->_throw_exception( MetaclassTypeIncompatible => class_name => $self->name, | ||||
| 263 | superclass_name => $superclass_name, | ||||
| 264 | metaclass_type => $metaclass_type | ||||
| 265 | ); | ||||
| 266 | } | ||||
| 267 | } | ||||
| 268 | |||||
| 269 | # spent 2.85ms (1.75+1.10) within Class::MOP::Class::_single_metaclass_is_compatible which was called 108 times, avg 26µs/call:
# 108 times (1.75ms+1.10ms) by Class::MOP::Class::_check_single_metaclass_compatibility at line 259, avg 26µs/call | ||||
| 270 | 756 | 1.64ms | my $self = shift; | ||
| 271 | my ( $metaclass_type, $superclass_name ) = @_; | ||||
| 272 | |||||
| 273 | 108 | 100µs | my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name) # spent 100µs making 108 calls to Class::MOP::get_metaclass_by_name, avg 930ns/call | ||
| 274 | || return 1; | ||||
| 275 | |||||
| 276 | # for instance, Moose::Meta::Class has a error_class attribute, but | ||||
| 277 | # Class::MOP::Class doesn't - this shouldn't be an error | ||||
| 278 | 108 | 84µs | return 1 unless $super_meta->can($metaclass_type); # spent 84µs making 108 calls to UNIVERSAL::can, avg 782ns/call | ||
| 279 | # for instance, Moose::Meta::Class has a destructor_class, but | ||||
| 280 | # Class::MOP::Class doesn't - this shouldn't be an error | ||||
| 281 | 108 | 93µs | return 1 unless defined $super_meta->$metaclass_type; # spent 27µs making 18 calls to Moose::Meta::Class::constructor_class, avg 1µs/call
# spent 26µs making 18 calls to Moose::Meta::Class::destructor_class, avg 1µs/call
# spent 11µs making 18 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 606ns/call
# spent 10µs making 18 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 567ns/call
# spent 10µs making 18 calls to Class::MOP::Class::instance_metaclass, avg 556ns/call
# spent 9µs making 18 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 517ns/call | ||
| 282 | # if metaclass is defined in superclass but not here, it's not compatible | ||||
| 283 | # this is a really odd case | ||||
| 284 | 108 | 85µs | return 0 unless defined $self->$metaclass_type; # spent 27µs making 18 calls to Moose::Meta::Class::constructor_class, avg 1µs/call
# spent 25µs making 18 calls to Moose::Meta::Class::destructor_class, avg 1µs/call
# spent 9µs making 18 calls to Class::MOP::Class::instance_metaclass, avg 506ns/call
# spent 8µs making 18 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 467ns/call
# spent 8µs making 18 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 461ns/call
# spent 8µs making 18 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 422ns/call | ||
| 285 | |||||
| 286 | 324 | 733µs | return $self->$metaclass_type->_is_compatible_with($super_meta->$metaclass_type); # spent 570µs making 108 calls to Class::MOP::Object::_is_compatible_with, avg 5µs/call
# spent 50µs making 36 calls to Moose::Meta::Class::constructor_class, avg 1µs/call
# spent 49µs making 36 calls to Moose::Meta::Class::destructor_class, avg 1µs/call
# spent 17µs making 36 calls to Class::MOP::Class::instance_metaclass, avg 472ns/call
# spent 16µs making 36 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 450ns/call
# spent 16µs making 36 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 431ns/call
# spent 15µs making 36 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 417ns/call | ||
| 287 | } | ||||
| 288 | |||||
| 289 | # spent 17.4ms (895µs+16.5) within Class::MOP::Class::_fix_metaclass_incompatibility which was called 54 times, avg 321µs/call:
# 54 times (895µs+16.5ms) by Class::MOP::Class::_check_metaclass_compatibility at line 200, avg 321µs/call | ||||
| 290 | 400 | 733µs | my $self = shift; | ||
| 291 | 65 | 126µs | my @supers = map { Class::MOP::Class->initialize($_) } @_; # spent 851µs making 65 calls to Class::MOP::Class::initialize, avg 13µs/call, recursion: max depth 2, sum of overlapping time 725µs | ||
| 292 | |||||
| 293 | my $necessary = 0; | ||||
| 294 | for my $super (@supers) { | ||||
| 295 | 65 | 15.8ms | $necessary = 1 # spent 15.8ms making 65 calls to Class::MOP::Class::_can_fix_metaclass_incompatibility, avg 243µs/call | ||
| 296 | if $self->_can_fix_metaclass_incompatibility($super); | ||||
| 297 | } | ||||
| 298 | return unless $necessary; | ||||
| 299 | |||||
| 300 | for my $super (@supers) { | ||||
| 301 | if (!$self->_class_metaclass_is_compatible($super->name)) { | ||||
| 302 | $self->_fix_class_metaclass_incompatibility($super); | ||||
| 303 | } | ||||
| 304 | } | ||||
| 305 | |||||
| 306 | my %base_metaclass = $self->_base_metaclasses; | ||||
| 307 | for my $metaclass_type (keys %base_metaclass) { | ||||
| 308 | for my $super (@supers) { | ||||
| 309 | if (!$self->_single_metaclass_is_compatible($metaclass_type, $super->name)) { | ||||
| 310 | $self->_fix_single_metaclass_incompatibility( | ||||
| 311 | $metaclass_type, $super | ||||
| 312 | ); | ||||
| 313 | } | ||||
| 314 | } | ||||
| 315 | } | ||||
| 316 | } | ||||
| 317 | |||||
| 318 | # spent 15.8ms (2.10+13.7) within Class::MOP::Class::_can_fix_metaclass_incompatibility which was called 65 times, avg 243µs/call:
# 65 times (2.10ms+13.7ms) by Class::MOP::Class::_fix_metaclass_incompatibility at line 295, avg 243µs/call | ||||
| 319 | 780 | 1.55ms | my $self = shift; | ||
| 320 | my ($super_meta) = @_; | ||||
| 321 | |||||
| 322 | 65 | 2.05ms | return 1 if $self->_class_metaclass_can_be_made_compatible($super_meta); # spent 2.05ms making 65 calls to Class::MOP::Class::_class_metaclass_can_be_made_compatible, avg 32µs/call | ||
| 323 | |||||
| 324 | 65 | 1.00ms | my %base_metaclass = $self->_base_metaclasses; # spent 778µs making 18 calls to Moose::Meta::Class::_base_metaclasses, avg 43µs/call
# spent 224µs making 47 calls to Class::MOP::Class::_base_metaclasses, avg 5µs/call | ||
| 325 | for my $metaclass_type (keys %base_metaclass) { | ||||
| 326 | 390 | 10.7ms | return 1 if $self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type); # spent 10.7ms making 390 calls to Class::MOP::Class::_single_metaclass_can_be_made_compatible, avg 27µs/call | ||
| 327 | } | ||||
| 328 | |||||
| 329 | return; | ||||
| 330 | } | ||||
| 331 | |||||
| 332 | # spent 2.05ms (516µs+1.53) within Class::MOP::Class::_class_metaclass_can_be_made_compatible which was called 65 times, avg 32µs/call:
# 65 times (516µs+1.53ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 322, avg 32µs/call | ||||
| 333 | 195 | 465µs | my $self = shift; | ||
| 334 | my ($super_meta) = @_; | ||||
| 335 | |||||
| 336 | 130 | 1.53ms | return $self->_can_be_made_compatible_with($super_meta->_real_ref_name); # spent 894µs making 65 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 14µs/call
# spent 641µs making 65 calls to Class::MOP::Class::_real_ref_name, avg 10µs/call | ||
| 337 | } | ||||
| 338 | |||||
| 339 | # spent 10.7ms (5.64+5.01) within Class::MOP::Class::_single_metaclass_can_be_made_compatible which was called 390 times, avg 27µs/call:
# 390 times (5.64ms+5.01ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 326, avg 27µs/call | ||||
| 340 | 3026 | 6.37ms | my $self = shift; | ||
| 341 | my ($super_meta, $metaclass_type) = @_; | ||||
| 342 | |||||
| 343 | 390 | 452µs | my $specific_meta = $self->$metaclass_type; # spent 69µs making 65 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 1µs/call
# spent 66µs making 65 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 1µs/call
# spent 64µs making 18 calls to Moose::Meta::Class::constructor_class, avg 4µs/call
# spent 64µs making 65 calls to Class::MOP::Class::instance_metaclass, avg 985ns/call
# spent 61µs making 65 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 943ns/call
# spent 49µs making 18 calls to Moose::Meta::Class::destructor_class, avg 3µs/call
# spent 41µs making 47 calls to Class::MOP::Class::constructor_class, avg 872ns/call
# spent 38µs making 47 calls to Class::MOP::Class::destructor_class, avg 817ns/call | ||
| 344 | |||||
| 345 | 390 | 393µs | return unless $super_meta->can($metaclass_type); # spent 393µs making 390 calls to UNIVERSAL::can, avg 1µs/call | ||
| 346 | 390 | 341µs | my $super_specific_meta = $super_meta->$metaclass_type; # spent 56µs making 65 calls to Class::MOP::Class::instance_metaclass, avg 855ns/call
# spent 55µs making 65 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 845ns/call
# spent 50µs making 65 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 777ns/call
# spent 46µs making 65 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 712ns/call
# spent 38µs making 47 calls to Class::MOP::Class::constructor_class, avg 817ns/call
# spent 37µs making 47 calls to Class::MOP::Class::destructor_class, avg 781ns/call
# spent 29µs making 18 calls to Moose::Meta::Class::constructor_class, avg 2µs/call
# spent 29µs making 18 calls to Moose::Meta::Class::destructor_class, avg 2µs/call | ||
| 347 | |||||
| 348 | # for instance, Moose::Meta::Class has a destructor_class, but | ||||
| 349 | # Class::MOP::Class doesn't - this shouldn't be an error | ||||
| 350 | return unless defined $super_specific_meta; | ||||
| 351 | |||||
| 352 | # if metaclass is defined in superclass but not here, it's fixable | ||||
| 353 | # this is a really odd case | ||||
| 354 | return 1 unless defined $specific_meta; | ||||
| 355 | |||||
| 356 | 343 | 3.82ms | return 1 if $specific_meta->_can_be_made_compatible_with($super_specific_meta); # spent 3.82ms making 343 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 11µs/call | ||
| 357 | } | ||||
| 358 | |||||
| 359 | sub _fix_class_metaclass_incompatibility { | ||||
| 360 | my $self = shift; | ||||
| 361 | my ( $super_meta ) = @_; | ||||
| 362 | |||||
| 363 | if ($self->_class_metaclass_can_be_made_compatible($super_meta)) { | ||||
| 364 | ($self->is_pristine) | ||||
| 365 | || $self->_throw_exception( CannotFixMetaclassCompatibility => class_name => $self->name, | ||||
| 366 | superclass => $super_meta | ||||
| 367 | ); | ||||
| 368 | |||||
| 369 | my $super_meta_name = $super_meta->_real_ref_name; | ||||
| 370 | |||||
| 371 | $self->_make_compatible_with($super_meta_name); | ||||
| 372 | } | ||||
| 373 | } | ||||
| 374 | |||||
| 375 | sub _fix_single_metaclass_incompatibility { | ||||
| 376 | my $self = shift; | ||||
| 377 | my ( $metaclass_type, $super_meta ) = @_; | ||||
| 378 | |||||
| 379 | if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) { | ||||
| 380 | ($self->is_pristine) | ||||
| 381 | || $self->_throw_exception( CannotFixMetaclassCompatibility => class_name => $self->name, | ||||
| 382 | superclass => $super_meta, | ||||
| 383 | metaclass_type => $metaclass_type | ||||
| 384 | ); | ||||
| 385 | |||||
| 386 | my $new_metaclass = $self->$metaclass_type | ||||
| 387 | ? $self->$metaclass_type->_get_compatible_metaclass($super_meta->$metaclass_type) | ||||
| 388 | : $super_meta->$metaclass_type; | ||||
| 389 | $self->{$metaclass_type} = $new_metaclass; | ||||
| 390 | } | ||||
| 391 | } | ||||
| 392 | |||||
| 393 | sub _restore_metaobjects_from { | ||||
| 394 | my $self = shift; | ||||
| 395 | my ($old_meta) = @_; | ||||
| 396 | |||||
| 397 | $self->_restore_metamethods_from($old_meta); | ||||
| 398 | $self->_restore_metaattributes_from($old_meta); | ||||
| 399 | } | ||||
| 400 | |||||
| 401 | sub _remove_generated_metaobjects { | ||||
| 402 | my $self = shift; | ||||
| 403 | |||||
| 404 | for my $attr (map { $self->get_attribute($_) } $self->get_attribute_list) { | ||||
| 405 | $attr->remove_accessors; | ||||
| 406 | } | ||||
| 407 | } | ||||
| 408 | |||||
| 409 | # creating classes with MOP ... | ||||
| 410 | |||||
| 411 | # spent 2.96ms (98µs+2.86) within Class::MOP::Class::create which was called 2 times, avg 1.48ms/call:
# 2 times (98µs+2.86ms) by Class::MOP::Class::_immutable_metaclass at line 1366, avg 1.48ms/call | ||||
| 412 | 36 | 86µs | my $class = shift; | ||
| 413 | my @args = @_; | ||||
| 414 | |||||
| 415 | unshift @args, 'package' if @args % 2 == 1; | ||||
| 416 | my %options = @args; | ||||
| 417 | |||||
| 418 | (ref $options{superclasses} eq 'ARRAY') | ||||
| 419 | || __PACKAGE__->_throw_exception( CreateMOPClassTakesArrayRefOfSuperclasses => class => $class, | ||||
| 420 | params => \%options | ||||
| 421 | ) | ||||
| 422 | if exists $options{superclasses}; | ||||
| 423 | |||||
| 424 | (ref $options{attributes} eq 'ARRAY') | ||||
| 425 | || __PACKAGE__->_throw_exception( CreateMOPClassTakesArrayRefOfAttributes => class => $class, | ||||
| 426 | params => \%options | ||||
| 427 | ) | ||||
| 428 | if exists $options{attributes}; | ||||
| 429 | |||||
| 430 | (ref $options{methods} eq 'HASH') | ||||
| 431 | || __PACKAGE__->_throw_exception( CreateMOPClassTakesHashRefOfMethods => class => $class, | ||||
| 432 | params => \%options | ||||
| 433 | ) | ||||
| 434 | if exists $options{methods}; | ||||
| 435 | |||||
| 436 | my $package = delete $options{package}; | ||||
| 437 | my $superclasses = delete $options{superclasses}; | ||||
| 438 | my $attributes = delete $options{attributes}; | ||||
| 439 | my $methods = delete $options{methods}; | ||||
| 440 | my $meta_name = exists $options{meta_name} | ||||
| 441 | ? delete $options{meta_name} | ||||
| 442 | : 'meta'; | ||||
| 443 | |||||
| 444 | 2 | 475µs | my $meta = $class->SUPER::create($package => %options); # spent 475µs making 2 calls to Class::MOP::Module::create, avg 238µs/call | ||
| 445 | |||||
| 446 | 2 | 1.40ms | $meta->_add_meta_method($meta_name) # spent 1.40ms making 2 calls to Class::MOP::Mixin::HasMethods::_add_meta_method, avg 700µs/call | ||
| 447 | if defined $meta_name; | ||||
| 448 | |||||
| 449 | 2 | 986µs | $meta->superclasses(@{$superclasses}) # spent 986µs making 2 calls to Class::MOP::Class::superclasses, avg 493µs/call | ||
| 450 | if defined $superclasses; | ||||
| 451 | # NOTE: | ||||
| 452 | # process attributes first, so that they can | ||||
| 453 | # install accessors, but locally defined methods | ||||
| 454 | # can then overwrite them. It is maybe a little odd, but | ||||
| 455 | # I think this should be the order of things. | ||||
| 456 | if (defined $attributes) { | ||||
| 457 | foreach my $attr (@{$attributes}) { | ||||
| 458 | $meta->add_attribute($attr); | ||||
| 459 | } | ||||
| 460 | } | ||||
| 461 | if (defined $methods) { | ||||
| 462 | foreach my $method_name (keys %{$methods}) { | ||||
| 463 | $meta->add_method($method_name, $methods->{$method_name}); | ||||
| 464 | } | ||||
| 465 | } | ||||
| 466 | return $meta; | ||||
| 467 | } | ||||
| 468 | |||||
| 469 | # XXX: something more intelligent here? | ||||
| 470 | sub _anon_package_prefix { 'Class::MOP::Class::__ANON__::SERIAL::' } | ||||
| 471 | |||||
| 472 | sub create_anon_class { shift->create_anon(@_) } | ||||
| 473 | sub is_anon_class { shift->is_anon(@_) } | ||||
| 474 | |||||
| 475 | sub _anon_cache_key { | ||||
| 476 | my $class = shift; | ||||
| 477 | my %options = @_; | ||||
| 478 | # Makes something like Super::Class|Super::Class::2 | ||||
| 479 | return join '=' => ( | ||||
| 480 | join( '|', sort @{ $options{superclasses} || [] } ), | ||||
| 481 | ); | ||||
| 482 | } | ||||
| 483 | |||||
| 484 | # Instance Construction & Cloning | ||||
| 485 | |||||
| 486 | # spent 51.5ms (2.25+49.3) within Class::MOP::Class::new_object which was called 253 times, avg 204µs/call:
# 207 times (1.78ms+38.8ms) by Class::MOP::Method::Accessor::_new at line 51 of Class/MOP/Method/Accessor.pm, avg 196µs/call
# 24 times (228µs+4.71ms) by Class::MOP::Method::_new at line 55 of Class/MOP/Method.pm, avg 206µs/call
# 20 times (215µs+4.79ms) by Moose::Meta::Method::_new at line 7 of (eval 25)[Eval/Closure.pm:125], avg 250µs/call
# once (15µs+661µs) by Class::MOP::Attribute::_new at line 69 of Class/MOP/Attribute.pm
# once (14µs+284µs) by Class::MOP::Object::_new at line 23 of Class/MOP/Object.pm | ||||
| 487 | 759 | 2.72ms | my $class = shift; | ||
| 488 | |||||
| 489 | # NOTE: | ||||
| 490 | # we need to protect the integrity of the | ||||
| 491 | # Class::MOP::Class singletons here, so we | ||||
| 492 | # delegate this to &construct_class_instance | ||||
| 493 | # which will deal with the singletons | ||||
| 494 | 506 | 527µs | return $class->_construct_class_instance(@_) # spent 382µs making 253 calls to UNIVERSAL::isa, avg 2µs/call
# spent 146µs making 253 calls to Class::MOP::Package::name, avg 575ns/call | ||
| 495 | if $class->name->isa('Class::MOP::Class'); | ||||
| 496 | 253 | 48.8ms | return $class->_construct_instance(@_); # spent 48.8ms making 253 calls to Class::MOP::Class::_construct_instance, avg 193µs/call | ||
| 497 | } | ||||
| 498 | |||||
| 499 | # spent 59.8ms (11.0+48.9) within Class::MOP::Class::_construct_instance which was called 271 times, avg 221µs/call:
# 253 times (9.68ms+39.1ms) by Class::MOP::Class::new_object at line 496, avg 193µs/call
# 18 times (1.30ms+9.78ms) by Class::MOP::Class::_construct_class_instance at line 101, avg 616µs/call | ||||
| 500 | 4876 | 8.62ms | my $class = shift; | ||
| 501 | my $params = @_ == 1 ? $_[0] : {@_}; | ||||
| 502 | 271 | 3.79ms | my $meta_instance = $class->get_meta_instance(); # spent 2.43ms making 242 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 10µs/call
# spent 1.36ms making 29 calls to Class::MOP::Class::get_meta_instance, avg 47µs/call | ||
| 503 | # FIXME: | ||||
| 504 | # the code below is almost certainly incorrect | ||||
| 505 | # but this is foreign inheritance, so we might | ||||
| 506 | # have to kludge it in the end. | ||||
| 507 | my $instance; | ||||
| 508 | 271 | 325µs | if (my $instance_class = blessed($params->{__INSTANCE__})) { # spent 325µs making 271 calls to Scalar::Util::blessed, avg 1µs/call | ||
| 509 | ($instance_class eq $class->name) | ||||
| 510 | || $class->_throw_exception( InstanceBlessedIntoWrongClass => class_name => $class->name, | ||||
| 511 | params => $params, | ||||
| 512 | instance => $params->{__INSTANCE__} | ||||
| 513 | ); | ||||
| 514 | $instance = $params->{__INSTANCE__}; | ||||
| 515 | } | ||||
| 516 | elsif (exists $params->{__INSTANCE__}) { | ||||
| 517 | $class->_throw_exception( InstanceMustBeABlessedReference => class_name => $class->name, | ||||
| 518 | params => $params, | ||||
| 519 | instance => $params->{__INSTANCE__} | ||||
| 520 | ); | ||||
| 521 | } | ||||
| 522 | else { | ||||
| 523 | 271 | 4.04ms | $instance = $meta_instance->create_instance(); # spent 4.04ms making 271 calls to Class::MOP::Instance::create_instance, avg 15µs/call | ||
| 524 | } | ||||
| 525 | 271 | 5.00ms | foreach my $attr ($class->get_all_attributes()) { # spent 2.53ms making 29 calls to Class::MOP::Class::get_all_attributes, avg 87µs/call
# spent 2.47ms making 242 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 10µs/call | ||
| 526 | 2437 | 34.3ms | $attr->initialize_instance_slot($meta_instance, $instance, $params); # spent 34.3ms making 2437 calls to Class::MOP::Attribute::initialize_instance_slot, avg 14µs/call | ||
| 527 | } | ||||
| 528 | 542 | 1.40ms | if (Class::MOP::metaclass_is_weak($class->name)) { # spent 1.22ms making 271 calls to Class::MOP::metaclass_is_weak, avg 5µs/call
# spent 172µs making 271 calls to Class::MOP::Package::name, avg 633ns/call | ||
| 529 | $meta_instance->_set_mop_slot($instance, $class); | ||||
| 530 | } | ||||
| 531 | return $instance; | ||||
| 532 | } | ||||
| 533 | |||||
| 534 | # spent 100ms (834µs+99.3) within Class::MOP::Class::_inline_new_object which was called 46 times, avg 2.18ms/call:
# 46 times (834µs+99.3ms) by Class::MOP::Method::Constructor::_generate_constructor_method_inline at line 98 of Class/MOP/Method/Constructor.pm, avg 2.18ms/call | ||||
| 535 | 92 | 647µs | my $self = shift; | ||
| 536 | |||||
| 537 | return ( | ||||
| 538 | 276 | 99.3ms | 'my $class = shift;', # spent 87.2ms making 46 calls to Class::MOP::Class::_inline_slot_initializers, avg 1.90ms/call
# spent 6.48ms making 16 calls to Moose::Meta::Class::_inline_extra_init, avg 405µs/call
# spent 2.15ms making 46 calls to Class::MOP::Class::_inline_generate_instance, avg 47µs/call
# spent 2.09ms making 16 calls to Moose::Meta::Class::_inline_params, avg 131µs/call
# spent 626µs making 46 calls to Class::MOP::Class::_inline_preserve_weak_metaclasses, avg 14µs/call
# spent 571µs making 46 calls to Class::MOP::Class::_inline_fallback_constructor, avg 12µs/call
# spent 96µs making 30 calls to Class::MOP::Class::_inline_params, avg 3µs/call
# spent 36µs making 30 calls to Class::MOP::Class::_inline_extra_init, avg 1µs/call | ||
| 539 | '$class = Scalar::Util::blessed($class) || $class;', | ||||
| 540 | $self->_inline_fallback_constructor('$class'), | ||||
| 541 | $self->_inline_params('$params', '$class'), | ||||
| 542 | $self->_inline_generate_instance('$instance', '$class'), | ||||
| 543 | $self->_inline_slot_initializers, | ||||
| 544 | $self->_inline_preserve_weak_metaclasses, | ||||
| 545 | $self->_inline_extra_init, | ||||
| 546 | 'return $instance', | ||||
| 547 | ); | ||||
| 548 | } | ||||
| 549 | |||||
| 550 | # spent 571µs (405+166) within Class::MOP::Class::_inline_fallback_constructor which was called 46 times, avg 12µs/call:
# 46 times (405µs+166µs) by Class::MOP::Class::_inline_new_object at line 538, avg 12µs/call | ||||
| 551 | 138 | 392µs | my $self = shift; | ||
| 552 | my ($class) = @_; | ||||
| 553 | return ( | ||||
| 554 | 92 | 166µs | 'return ' . $self->_generate_fallback_constructor($class), # spent 77µs making 30 calls to Class::MOP::Class::_generate_fallback_constructor, avg 3µs/call
# spent 59µs making 16 calls to Moose::Meta::Class::_generate_fallback_constructor, avg 4µs/call
# spent 30µs making 46 calls to Class::MOP::Package::name, avg 663ns/call | ||
| 555 | 'if ' . $class . ' ne \'' . $self->name . '\';', | ||||
| 556 | ); | ||||
| 557 | } | ||||
| 558 | |||||
| 559 | # spent 77µs within Class::MOP::Class::_generate_fallback_constructor which was called 30 times, avg 3µs/call:
# 30 times (77µs+0s) by Class::MOP::Class::_inline_fallback_constructor at line 554, avg 3µs/call | ||||
| 560 | 90 | 110µs | my $self = shift; | ||
| 561 | my ($class) = @_; | ||||
| 562 | return 'Class::MOP::Class->initialize(' . $class . ')->new_object(@_)', | ||||
| 563 | } | ||||
| 564 | |||||
| 565 | # spent 96µs within Class::MOP::Class::_inline_params which was called 30 times, avg 3µs/call:
# 30 times (96µs+0s) by Class::MOP::Class::_inline_new_object at line 538, avg 3µs/call | ||||
| 566 | 90 | 114µs | my $self = shift; | ||
| 567 | my ($params, $class) = @_; | ||||
| 568 | return ( | ||||
| 569 | 'my ' . $params . ' = @_ == 1 ? $_[0] : {@_};', | ||||
| 570 | ); | ||||
| 571 | } | ||||
| 572 | |||||
| 573 | # spent 2.15ms (280µs+1.87) within Class::MOP::Class::_inline_generate_instance which was called 46 times, avg 47µs/call:
# 46 times (280µs+1.87ms) by Class::MOP::Class::_inline_new_object at line 538, avg 47µs/call | ||||
| 574 | 138 | 253µs | my $self = shift; | ||
| 575 | my ($inst, $class) = @_; | ||||
| 576 | return ( | ||||
| 577 | 46 | 1.87ms | 'my ' . $inst . ' = ' . $self->_inline_create_instance($class) . ';', # spent 1.87ms making 46 calls to Class::MOP::Class::_inline_create_instance, avg 41µs/call | ||
| 578 | ); | ||||
| 579 | } | ||||
| 580 | |||||
| 581 | # spent 1.87ms (328µs+1.54) within Class::MOP::Class::_inline_create_instance which was called 46 times, avg 41µs/call:
# 46 times (328µs+1.54ms) by Class::MOP::Class::_inline_generate_instance at line 577, avg 41µs/call | ||||
| 582 | 92 | 251µs | my $self = shift; | ||
| 583 | |||||
| 584 | 92 | 1.54ms | return $self->get_meta_instance->inline_create_instance(@_); # spent 1.40ms making 46 calls to Class::MOP::Class::get_meta_instance, avg 30µs/call
# spent 142µs making 46 calls to Class::MOP::Instance::inline_create_instance, avg 3µs/call | ||
| 585 | } | ||||
| 586 | |||||
| 587 | # spent 87.2ms (1.71+85.5) within Class::MOP::Class::_inline_slot_initializers which was called 46 times, avg 1.90ms/call:
# 46 times (1.71ms+85.5ms) by Class::MOP::Class::_inline_new_object at line 538, avg 1.90ms/call | ||||
| 588 | 1829 | 5.44ms | my $self = shift; | ||
| 589 | |||||
| 590 | my $idx = 0; | ||||
| 591 | |||||
| 592 | 2913 | 79.3ms | return map { $self->_inline_slot_initializer($_, $idx++) } # spent 54.1ms making 187 calls to Moose::Meta::Class::_inline_slot_initializer, avg 289µs/call
# spent 24.3ms making 282 calls to Class::MOP::Class::_inline_slot_initializer, avg 86µs/call
# spent 912µs making 2444 calls to Class::MOP::Mixin::AttributeCore::name, avg 373ns/call | ||
| 593 | 92 | 7.17ms | sort { $a->name cmp $b->name } $self->get_all_attributes; # spent 4.33ms making 46 calls to Class::MOP::Class::CORE:sort, avg 94µs/call
# spent 2.84ms making 46 calls to Class::MOP::Class::get_all_attributes, avg 62µs/call | ||
| 594 | } | ||||
| 595 | |||||
| 596 | # spent 73.9ms (6.00+67.9) within Class::MOP::Class::_inline_slot_initializer which was called 469 times, avg 158µs/call:
# 282 times (3.31ms+21.0ms) by Class::MOP::Class::_inline_slot_initializers at line 592, avg 86µs/call
# 187 times (2.69ms+47.0ms) by Moose::Meta::Class::_inline_slot_initializer at line 365 of Moose/Meta/Class.pm, avg 266µs/call | ||||
| 597 | 2782 | 5.58ms | my $self = shift; | ||
| 598 | my ($attr, $idx) = @_; | ||||
| 599 | |||||
| 600 | 480 | 1.23ms | if (defined(my $init_arg = $attr->init_arg)) { # spent 932µs making 11 calls to Class::MOP::Class::_inline_init_attr_from_default, avg 85µs/call
# spent 301µs making 469 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 642ns/call | ||
| 601 | 458 | 44.0ms | my @source = ( # spent 30.7ms making 187 calls to Moose::Meta::Class::_inline_init_attr_from_constructor, avg 164µs/call
# spent 13.3ms making 271 calls to Class::MOP::Class::_inline_init_attr_from_constructor, avg 49µs/call | ||
| 602 | 'if (exists $params->{\'' . $init_arg . '\'}) {', | ||||
| 603 | $self->_inline_init_attr_from_constructor($attr, $idx), | ||||
| 604 | '}', | ||||
| 605 | ); | ||||
| 606 | 458 | 22.7ms | if (my @default = $self->_inline_init_attr_from_default($attr, $idx)) { # spent 16.1ms making 187 calls to Moose::Meta::Class::_inline_init_attr_from_default, avg 86µs/call
# spent 6.57ms making 271 calls to Class::MOP::Class::_inline_init_attr_from_default, avg 24µs/call | ||
| 607 | push @source, ( | ||||
| 608 | 'else {', | ||||
| 609 | @default, | ||||
| 610 | '}', | ||||
| 611 | ); | ||||
| 612 | } | ||||
| 613 | return @source; | ||||
| 614 | } | ||||
| 615 | elsif (my @default = $self->_inline_init_attr_from_default($attr, $idx)) { | ||||
| 616 | return ( | ||||
| 617 | '{', | ||||
| 618 | @default, | ||||
| 619 | '}', | ||||
| 620 | ); | ||||
| 621 | } | ||||
| 622 | else { | ||||
| 623 | return (); | ||||
| 624 | } | ||||
| 625 | } | ||||
| 626 | |||||
| 627 | # spent 13.3ms (2.66+10.6) within Class::MOP::Class::_inline_init_attr_from_constructor which was called 271 times, avg 49µs/call:
# 271 times (2.66ms+10.6ms) by Class::MOP::Class::_inline_slot_initializer at line 601, avg 49µs/call | ||||
| 628 | 1355 | 2.34ms | my $self = shift; | ||
| 629 | my ($attr, $idx) = @_; | ||||
| 630 | |||||
| 631 | 542 | 10.1ms | my @initial_value = $attr->_inline_set_value( # spent 9.27ms making 269 calls to Class::MOP::Attribute::_inline_set_value, avg 34µs/call
# spent 732µs making 2 calls to Moose::Meta::Attribute::_inline_set_value, avg 366µs/call
# spent 121µs making 271 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 446ns/call | ||
| 632 | '$instance', '$params->{\'' . $attr->init_arg . '\'}', | ||||
| 633 | ); | ||||
| 634 | |||||
| 635 | 271 | 485µs | push @initial_value, ( # spent 485µs making 271 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 2µs/call | ||
| 636 | '$attrs->[' . $idx . ']->set_initial_value(', | ||||
| 637 | '$instance,', | ||||
| 638 | $attr->_inline_instance_get('$instance'), | ||||
| 639 | ');', | ||||
| 640 | ) if $attr->has_initializer; | ||||
| 641 | |||||
| 642 | return @initial_value; | ||||
| 643 | } | ||||
| 644 | |||||
| 645 | # spent 7.51ms (1.84+5.67) within Class::MOP::Class::_inline_init_attr_from_default which was called 282 times, avg 27µs/call:
# 271 times (1.73ms+4.85ms) by Class::MOP::Class::_inline_slot_initializer at line 606, avg 24µs/call
# 11 times (111µs+822µs) by Class::MOP::Class::_inline_slot_initializer at line 600, avg 85µs/call | ||||
| 646 | 1425 | 1.47ms | my $self = shift; | ||
| 647 | my ($attr, $idx) = @_; | ||||
| 648 | |||||
| 649 | 282 | 2.64ms | my $default = $self->_inline_default_value($attr, $idx); # spent 2.64ms making 282 calls to Class::MOP::Class::_inline_default_value, avg 9µs/call | ||
| 650 | return unless $default; | ||||
| 651 | |||||
| 652 | 99 | 2.86ms | my @initial_value = $attr->_inline_set_value('$instance', $default); # spent 2.86ms making 99 calls to Class::MOP::Attribute::_inline_set_value, avg 29µs/call | ||
| 653 | |||||
| 654 | 99 | 166µs | push @initial_value, ( # spent 166µs making 99 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 2µs/call | ||
| 655 | '$attrs->[' . $idx . ']->set_initial_value(', | ||||
| 656 | '$instance,', | ||||
| 657 | $attr->_inline_instance_get('$instance'), | ||||
| 658 | ');', | ||||
| 659 | ) if $attr->has_initializer; | ||||
| 660 | |||||
| 661 | return @initial_value; | ||||
| 662 | } | ||||
| 663 | |||||
| 664 | # spent 3.94ms (2.59+1.36) within Class::MOP::Class::_inline_default_value which was called 405 times, avg 10µs/call:
# 282 times (1.71ms+931µs) by Class::MOP::Class::_inline_init_attr_from_default at line 649, avg 9µs/call
# 123 times (878µs+425µs) by Moose::Meta::Class::_inline_init_attr_from_default at line 422 of Moose/Meta/Class.pm, avg 11µs/call | ||||
| 665 | 1541 | 1.88ms | my $self = shift; | ||
| 666 | my ($attr, $index) = @_; | ||||
| 667 | |||||
| 668 | 810 | 1.36ms | if ($attr->has_default) { # spent 524µs making 405 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 1µs/call
# spent 504µs making 178 calls to Class::MOP::Mixin::AttributeCore::is_default_a_coderef, avg 3µs/call
# spent 327µs making 227 calls to Class::MOP::Mixin::AttributeCore::has_builder, avg 1µs/call | ||
| 669 | # NOTE: | ||||
| 670 | # default values can either be CODE refs | ||||
| 671 | # in which case we need to call them. Or | ||||
| 672 | # they can be scalars (strings/numbers) | ||||
| 673 | # in which case we can just deal with them | ||||
| 674 | # in the code we eval. | ||||
| 675 | if ($attr->is_default_a_coderef) { | ||||
| 676 | return '$defaults->[' . $index . ']->($instance)'; | ||||
| 677 | } | ||||
| 678 | else { | ||||
| 679 | return '$defaults->[' . $index . ']'; | ||||
| 680 | } | ||||
| 681 | } | ||||
| 682 | elsif ($attr->has_builder) { | ||||
| 683 | return '$instance->' . $attr->builder; | ||||
| 684 | } | ||||
| 685 | else { | ||||
| 686 | return; | ||||
| 687 | } | ||||
| 688 | } | ||||
| 689 | |||||
| 690 | # spent 626µs (318+308) within Class::MOP::Class::_inline_preserve_weak_metaclasses which was called 46 times, avg 14µs/call:
# 46 times (318µs+308µs) by Class::MOP::Class::_inline_new_object at line 538, avg 14µs/call | ||||
| 691 | 138 | 347µs | my $self = shift; | ||
| 692 | 92 | 308µs | if (Class::MOP::metaclass_is_weak($self->name)) { # spent 268µs making 46 calls to Class::MOP::metaclass_is_weak, avg 6µs/call
# spent 40µs making 46 calls to Class::MOP::Package::name, avg 861ns/call | ||
| 693 | return ( | ||||
| 694 | $self->_inline_set_mop_slot( | ||||
| 695 | '$instance', 'Class::MOP::class_of($class)' | ||||
| 696 | ) . ';' | ||||
| 697 | ); | ||||
| 698 | } | ||||
| 699 | else { | ||||
| 700 | return (); | ||||
| 701 | } | ||||
| 702 | } | ||||
| 703 | |||||
| 704 | 30 | 53µs | # spent 36µs within Class::MOP::Class::_inline_extra_init which was called 30 times, avg 1µs/call:
# 30 times (36µs+0s) by Class::MOP::Class::_inline_new_object at line 538, avg 1µs/call | ||
| 705 | |||||
| 706 | # spent 9.81ms (1.69+8.12) within Class::MOP::Class::_eval_environment which was called 46 times, avg 213µs/call:
# 30 times (999µs+5.18ms) by Class::MOP::Method::Constructor::_eval_environment at line 86 of Class/MOP/Method/Constructor.pm, avg 206µs/call
# 16 times (688µs+2.94ms) by Moose::Meta::Class::_eval_environment at line 542 of Moose/Meta/Class.pm, avg 227µs/call | ||||
| 707 | 1875 | 5.49ms | my $self = shift; | ||
| 708 | |||||
| 709 | 2536 | 8.28ms | my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes; # spent 4.50ms making 46 calls to Class::MOP::Class::CORE:sort, avg 98µs/call
# spent 2.80ms making 46 calls to Class::MOP::Class::get_all_attributes, avg 61µs/call
# spent 982µs making 2444 calls to Class::MOP::Mixin::AttributeCore::name, avg 402ns/call | ||
| 710 | |||||
| 711 | 469 | 827µs | my $defaults = [map { $_->default } @attrs]; # spent 827µs making 469 calls to Class::MOP::Mixin::AttributeCore::default, avg 2µs/call | ||
| 712 | |||||
| 713 | return { | ||||
| 714 | '$defaults' => \$defaults, | ||||
| 715 | }; | ||||
| 716 | } | ||||
| 717 | |||||
| 718 | |||||
| 719 | # spent 37.4ms (2.03+35.3) within Class::MOP::Class::get_meta_instance which was called 988 times, avg 38µs/call:
# 523 times (883µs+9.43ms) by Class::MOP::Attribute::_inline_instance_set at line 301 of Class/MOP/Attribute.pm, avg 20µs/call
# 266 times (779µs+20.9ms) by Class::MOP::Attribute::_inline_instance_get at line 324 of Class/MOP/Attribute.pm, avg 81µs/call
# 87 times (115µs+0s) by Class::MOP::Attribute::_inline_instance_has at line 345 of Class/MOP/Attribute.pm, avg 1µs/call
# 46 times (82µs+1.32ms) by Class::MOP::Class::_inline_create_instance at line 584, avg 30µs/call
# 29 times (83µs+1.27ms) by Class::MOP::Class::_construct_instance at line 502, avg 47µs/call
# 22 times (63µs+2.25ms) by Class::MOP::Class:::around at line 77 of Class/MOP/Class/Immutable/Trait.pm, avg 105µs/call
# 8 times (11µs+0s) by Class::MOP::Attribute::_inline_instance_clear at line 366 of Class/MOP/Attribute.pm, avg 1µs/call
# 3 times (5µs+0s) by Class::MOP::Attribute::has_value at line 332 of Class/MOP/Attribute.pm, avg 2µs/call
# 2 times (3µs+0s) by Class::MOP::Attribute::get_raw_value at line 311 of Class/MOP/Attribute.pm, avg 2µs/call
# once (5µs+201µs) by Moose::Exporter::BEGIN@8 at line 733 of Class/MOP.pm
# once (1µs+0s) by Moose::Meta::Attribute::_inline_weaken_value at line 737 of Moose/Meta/Attribute.pm | ||||
| 720 | 1976 | 2.46ms | my $self = shift; | ||
| 721 | 237 | 35.3ms | $self->{'_meta_instance'} ||= $self->_create_meta_instance(); # spent 35.3ms making 237 calls to Class::MOP::Class::_create_meta_instance, avg 149µs/call | ||
| 722 | } | ||||
| 723 | |||||
| 724 | # spent 35.3ms (3.05+32.3) within Class::MOP::Class::_create_meta_instance which was called 237 times, avg 149µs/call:
# 237 times (3.05ms+32.3ms) by Class::MOP::Class::get_meta_instance at line 721, avg 149µs/call | ||||
| 725 | 948 | 2.79ms | my $self = shift; | ||
| 726 | |||||
| 727 | 711 | 32.0ms | my $instance = $self->instance_metaclass->new( # spent 20.1ms making 237 calls to Class::MOP::Instance::new, avg 85µs/call
# spent 10.6ms making 225 calls to Class::MOP::Class::get_all_attributes, avg 47µs/call
# spent 1.13ms making 12 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 94µs/call
# spent 142µs making 237 calls to Class::MOP::Class::instance_metaclass, avg 600ns/call | ||
| 728 | associated_metaclass => $self, | ||||
| 729 | attributes => [ $self->get_all_attributes() ], | ||||
| 730 | ); | ||||
| 731 | |||||
| 732 | 237 | 286µs | $self->add_meta_instance_dependencies() # spent 286µs making 237 calls to Class::MOP::Instance::is_dependent_on_superclasses, avg 1µs/call | ||
| 733 | if $instance->is_dependent_on_superclasses(); | ||||
| 734 | |||||
| 735 | return $instance; | ||||
| 736 | } | ||||
| 737 | |||||
| 738 | # TODO: this is actually not being used! | ||||
| 739 | sub _inline_rebless_instance { | ||||
| 740 | my $self = shift; | ||||
| 741 | |||||
| 742 | return $self->get_meta_instance->inline_rebless_instance_structure(@_); | ||||
| 743 | } | ||||
| 744 | |||||
| 745 | sub _inline_get_mop_slot { | ||||
| 746 | my $self = shift; | ||||
| 747 | |||||
| 748 | return $self->get_meta_instance->_inline_get_mop_slot(@_); | ||||
| 749 | } | ||||
| 750 | |||||
| 751 | sub _inline_set_mop_slot { | ||||
| 752 | my $self = shift; | ||||
| 753 | |||||
| 754 | return $self->get_meta_instance->_inline_set_mop_slot(@_); | ||||
| 755 | } | ||||
| 756 | |||||
| 757 | sub _inline_clear_mop_slot { | ||||
| 758 | my $self = shift; | ||||
| 759 | |||||
| 760 | return $self->get_meta_instance->_inline_clear_mop_slot(@_); | ||||
| 761 | } | ||||
| 762 | |||||
| 763 | sub clone_object { | ||||
| 764 | my $class = shift; | ||||
| 765 | my $instance = shift; | ||||
| 766 | (blessed($instance) && $instance->isa($class->name)) | ||||
| 767 | || $class->_throw_exception( CloneObjectExpectsAnInstanceOfMetaclass => class_name => $class->name, | ||||
| 768 | instance => $instance, | ||||
| 769 | ); | ||||
| 770 | # NOTE: | ||||
| 771 | # we need to protect the integrity of the | ||||
| 772 | # Class::MOP::Class singletons here, they | ||||
| 773 | # should not be cloned. | ||||
| 774 | return $instance if $instance->isa('Class::MOP::Class'); | ||||
| 775 | $class->_clone_instance($instance, @_); | ||||
| 776 | } | ||||
| 777 | |||||
| 778 | sub _clone_instance { | ||||
| 779 | my ($class, $instance, %params) = @_; | ||||
| 780 | (blessed($instance)) | ||||
| 781 | || $class->_throw_exception( OnlyInstancesCanBeCloned => class_name => $class->name, | ||||
| 782 | instance => $instance, | ||||
| 783 | params => \%params | ||||
| 784 | ); | ||||
| 785 | my $meta_instance = $class->get_meta_instance(); | ||||
| 786 | my $clone = $meta_instance->clone_instance($instance); | ||||
| 787 | foreach my $attr ($class->get_all_attributes()) { | ||||
| 788 | if ( defined( my $init_arg = $attr->init_arg ) ) { | ||||
| 789 | if (exists $params{$init_arg}) { | ||||
| 790 | $attr->set_value($clone, $params{$init_arg}); | ||||
| 791 | } | ||||
| 792 | } | ||||
| 793 | } | ||||
| 794 | return $clone; | ||||
| 795 | } | ||||
| 796 | |||||
| 797 | sub _force_rebless_instance { | ||||
| 798 | my ($self, $instance, %params) = @_; | ||||
| 799 | my $old_metaclass = Class::MOP::class_of($instance); | ||||
| 800 | |||||
| 801 | $old_metaclass->rebless_instance_away($instance, $self, %params) | ||||
| 802 | if $old_metaclass; | ||||
| 803 | |||||
| 804 | my $meta_instance = $self->get_meta_instance; | ||||
| 805 | |||||
| 806 | if (Class::MOP::metaclass_is_weak($old_metaclass->name)) { | ||||
| 807 | $meta_instance->_clear_mop_slot($instance); | ||||
| 808 | } | ||||
| 809 | |||||
| 810 | # rebless! | ||||
| 811 | # we use $_[1] here because of t/cmop/rebless_overload.t regressions | ||||
| 812 | # on 5.8.8 | ||||
| 813 | $meta_instance->rebless_instance_structure($_[1], $self); | ||||
| 814 | |||||
| 815 | $self->_fixup_attributes_after_rebless($instance, $old_metaclass, %params); | ||||
| 816 | |||||
| 817 | if (Class::MOP::metaclass_is_weak($self->name)) { | ||||
| 818 | $meta_instance->_set_mop_slot($instance, $self); | ||||
| 819 | } | ||||
| 820 | } | ||||
| 821 | |||||
| 822 | sub rebless_instance { | ||||
| 823 | my ($self, $instance, %params) = @_; | ||||
| 824 | my $old_metaclass = Class::MOP::class_of($instance); | ||||
| 825 | |||||
| 826 | my $old_class = $old_metaclass ? $old_metaclass->name : blessed($instance); | ||||
| 827 | $self->name->isa($old_class) | ||||
| 828 | || $self->_throw_exception( CanReblessOnlyIntoASubclass => class_name => $self->name, | ||||
| 829 | instance => $instance, | ||||
| 830 | instance_class => blessed( $instance ), | ||||
| 831 | params => \%params, | ||||
| 832 | ); | ||||
| 833 | |||||
| 834 | $self->_force_rebless_instance($_[1], %params); | ||||
| 835 | |||||
| 836 | return $instance; | ||||
| 837 | } | ||||
| 838 | |||||
| 839 | sub rebless_instance_back { | ||||
| 840 | my ( $self, $instance ) = @_; | ||||
| 841 | my $old_metaclass = Class::MOP::class_of($instance); | ||||
| 842 | my $old_class | ||||
| 843 | = $old_metaclass ? $old_metaclass->name : blessed($instance); | ||||
| 844 | $old_class->isa( $self->name ) | ||||
| 845 | || $self->_throw_exception( CanReblessOnlyIntoASuperclass => class_name => $self->name, | ||||
| 846 | instance => $instance, | ||||
| 847 | instance_class => blessed( $instance ), | ||||
| 848 | ); | ||||
| 849 | |||||
| 850 | $self->_force_rebless_instance($_[1]); | ||||
| 851 | |||||
| 852 | return $instance; | ||||
| 853 | } | ||||
| 854 | |||||
| 855 | sub rebless_instance_away { | ||||
| 856 | # this intentionally does nothing, it is just a hook | ||||
| 857 | } | ||||
| 858 | |||||
| 859 | sub _fixup_attributes_after_rebless { | ||||
| 860 | my $self = shift; | ||||
| 861 | my ($instance, $rebless_from, %params) = @_; | ||||
| 862 | my $meta_instance = $self->get_meta_instance; | ||||
| 863 | |||||
| 864 | for my $attr ( $rebless_from->get_all_attributes ) { | ||||
| 865 | next if $self->find_attribute_by_name( $attr->name ); | ||||
| 866 | $meta_instance->deinitialize_slot( $instance, $_ ) for $attr->slots; | ||||
| 867 | } | ||||
| 868 | |||||
| 869 | foreach my $attr ( $self->get_all_attributes ) { | ||||
| 870 | if ( $attr->has_value($instance) ) { | ||||
| 871 | if ( defined( my $init_arg = $attr->init_arg ) ) { | ||||
| 872 | $params{$init_arg} = $attr->get_value($instance) | ||||
| 873 | unless exists $params{$init_arg}; | ||||
| 874 | } | ||||
| 875 | else { | ||||
| 876 | $attr->set_value($instance, $attr->get_value($instance)); | ||||
| 877 | } | ||||
| 878 | } | ||||
| 879 | } | ||||
| 880 | |||||
| 881 | foreach my $attr ($self->get_all_attributes) { | ||||
| 882 | $attr->initialize_instance_slot($meta_instance, $instance, \%params); | ||||
| 883 | } | ||||
| 884 | } | ||||
| 885 | |||||
| 886 | # spent 5.02ms (1.49+3.53) within Class::MOP::Class::_attach_attribute which was called 320 times, avg 16µs/call:
# 320 times (1.49ms+3.53ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 22 of Class/MOP/Mixin/HasAttributes.pm, avg 16µs/call | ||||
| 887 | 640 | 1.33ms | my ($self, $attribute) = @_; | ||
| 888 | 320 | 3.53ms | $attribute->attach_to_class($self); # spent 3.53ms making 320 calls to Class::MOP::Attribute::attach_to_class, avg 11µs/call | ||
| 889 | } | ||||
| 890 | |||||
| 891 | # spent 343ms (4.15+339) within Class::MOP::Class::_post_add_attribute which was called 320 times, avg 1.07ms/call:
# 320 times (4.15ms+339ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 39 of Class/MOP/Mixin/HasAttributes.pm, avg 1.07ms/call | ||||
| 892 | 960 | 3.32ms | my ( $self, $attribute ) = @_; | ||
| 893 | |||||
| 894 | 320 | 3.21ms | $self->invalidate_meta_instances; # spent 3.21ms making 320 calls to Class::MOP::Class::invalidate_meta_instances, avg 10µs/call | ||
| 895 | |||||
| 896 | # invalidate package flag here | ||||
| 897 | try { | ||||
| 898 | 640 | 2.03ms | local $SIG{__DIE__}; | ||
| 899 | 320 | 324ms | $attribute->install_accessors; # spent 283ms making 190 calls to Moose::Meta::Attribute::install_accessors, avg 1.49ms/call
# spent 41.7ms making 130 calls to Class::MOP::Attribute::install_accessors, avg 321µs/call | ||
| 900 | } | ||||
| 901 | catch { | ||||
| 902 | $self->remove_attribute( $attribute->name ); | ||||
| 903 | die $_; | ||||
| 904 | 640 | 336ms | }; # spent 335ms making 320 calls to Try::Tiny::try, avg 1.05ms/call
# spent 1.26ms making 320 calls to Try::Tiny::catch, avg 4µs/call | ||
| 905 | } | ||||
| 906 | |||||
| 907 | # spent 433µs (133+300) within Class::MOP::Class::remove_attribute which was called 2 times, avg 216µs/call:
# 2 times (133µs+300µs) by Class::MOP::Mixin::HasAttributes::add_attribute at line 26 of Class/MOP/Mixin/HasAttributes.pm, avg 216µs/call | ||||
| 908 | 12 | 119µs | my $self = shift; | ||
| 909 | |||||
| 910 | 2 | 21µs | my $removed_attribute = $self->SUPER::remove_attribute(@_) # spent 21µs making 2 calls to Class::MOP::Mixin::HasAttributes::remove_attribute, avg 11µs/call | ||
| 911 | or return; | ||||
| 912 | |||||
| 913 | 2 | 20µs | $self->invalidate_meta_instances; # spent 20µs making 2 calls to Class::MOP::Class::invalidate_meta_instances, avg 10µs/call | ||
| 914 | |||||
| 915 | 2 | 255µs | $removed_attribute->remove_accessors; # spent 255µs making 2 calls to Moose::Meta::Attribute::remove_accessors, avg 128µs/call | ||
| 916 | 2 | 4µs | $removed_attribute->detach_from_class; # spent 4µs making 2 calls to Class::MOP::Attribute::detach_from_class, avg 2µs/call | ||
| 917 | |||||
| 918 | return$removed_attribute; | ||||
| 919 | } | ||||
| 920 | |||||
| 921 | # spent 3.43ms (1.13+2.30) within Class::MOP::Class::find_attribute_by_name which was called 70 times, avg 49µs/call:
# 70 times (1.13ms+2.30ms) by Class::MOP::Class::_immutable_metaclass at line 1343, avg 49µs/call | ||||
| 922 | 280 | 885µs | my ( $self, $attr_name ) = @_; | ||
| 923 | |||||
| 924 | 70 | 907µs | foreach my $class ( $self->linearized_isa ) { # spent 865µs making 66 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 13µs/call
# spent 41µs making 4 calls to Class::MOP::Class::linearized_isa, avg 10µs/call | ||
| 925 | # fetch the meta-class ... | ||||
| 926 | 70 | 442µs | my $meta = Class::MOP::Class->initialize($class); # spent 442µs making 70 calls to Class::MOP::Class::initialize, avg 6µs/call | ||
| 927 | 140 | 955µs | return $meta->get_attribute($attr_name) # spent 513µs making 70 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 7µs/call
# spent 442µs making 70 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 6µs/call | ||
| 928 | if $meta->has_attribute($attr_name); | ||||
| 929 | } | ||||
| 930 | |||||
| 931 | return; | ||||
| 932 | } | ||||
| 933 | |||||
| 934 | # spent 21.8ms (11.2+10.6) within Class::MOP::Class::get_all_attributes which was called 395 times, avg 55µs/call:
# 225 times (5.51ms+5.13ms) by Class::MOP::Class::_create_meta_instance at line 727, avg 47µs/call
# 46 times (1.50ms+1.34ms) by Class::MOP::Class::_inline_slot_initializers at line 593, avg 62µs/call
# 46 times (1.42ms+1.38ms) by Class::MOP::Class::_eval_environment at line 709, avg 61µs/call
# 29 times (1.28ms+1.24ms) by Class::MOP::Class::_construct_instance at line 525, avg 87µs/call
# 16 times (610µs+846µs) by Class::MOP::Class:::around at line 71 of Class/MOP/Class/Immutable/Trait.pm, avg 91µs/call
# 16 times (457µs+372µs) by Moose::Meta::Class::_inline_triggers at line 459 of Moose/Meta/Class.pm, avg 52µs/call
# 16 times (334µs+290µs) by Moose::Meta::Class::_eval_environment at line 497 of Moose/Meta/Class.pm, avg 39µs/call
# once (58µs+41µs) by Moose::Meta::Attribute::new at line 58 of Moose/Meta/Attribute.pm | ||||
| 935 | 3555 | 10.3ms | my $self = shift; | ||
| 936 | 2765 | 10.5ms | my %attrs = map { %{ Class::MOP::Class->initialize($_)->_attribute_map } } # spent 6.49ms making 1185 calls to Class::MOP::Class::initialize, avg 5µs/call, recursion: max depth 1, sum of overlapping time 163µs
# spent 2.99ms making 379 calls to Class::MOP::Class::linearized_isa, avg 8µs/call
# spent 808µs making 1185 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 682ns/call
# spent 347µs making 16 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 22µs/call | ||
| 937 | reverse $self->linearized_isa; | ||||
| 938 | return values %attrs; | ||||
| 939 | } | ||||
| 940 | |||||
| 941 | # Inheritance | ||||
| 942 | |||||
| 943 | sub superclasses { | ||||
| 944 | 796 | 1.61ms | my $self = shift; | ||
| 945 | |||||
| 946 | 169 | 4.29ms | my $isa = $self->get_or_add_package_symbol('@ISA'); # spent 4.29ms making 169 calls to Class::MOP::Package::get_or_add_package_symbol, avg 25µs/call | ||
| 947 | |||||
| 948 | if (@_) { | ||||
| 949 | my @supers = @_; | ||||
| 950 | @{$isa} = @supers; | ||||
| 951 | |||||
| 952 | # NOTE: | ||||
| 953 | # on 5.8 and below, we need to call | ||||
| 954 | # a method to get Perl to detect | ||||
| 955 | # a cycle in the class hierarchy | ||||
| 956 | 20 | 19µs | my $class = $self->name; # spent 19µs making 20 calls to Class::MOP::Package::name, avg 945ns/call | ||
| 957 | 20 | 24µs | $class->isa($class); # spent 24µs making 20 calls to UNIVERSAL::isa, avg 1µs/call | ||
| 958 | |||||
| 959 | # NOTE: | ||||
| 960 | # we need to check the metaclass | ||||
| 961 | # compatibility here so that we can | ||||
| 962 | # be sure that the superclass is | ||||
| 963 | # not potentially creating an issues | ||||
| 964 | # we don't know about | ||||
| 965 | |||||
| 966 | 20 | 12.1ms | $self->_check_metaclass_compatibility(); # spent 12.1ms making 20 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 603µs/call | ||
| 967 | 20 | 1.09ms | $self->_superclasses_updated(); # spent 1.09ms making 20 calls to Class::MOP::Class::_superclasses_updated, avg 54µs/call | ||
| 968 | } | ||||
| 969 | |||||
| 970 | return @{$isa}; | ||||
| 971 | } | ||||
| 972 | |||||
| 973 | # spent 1.09ms (284µs+805µs) within Class::MOP::Class::_superclasses_updated which was called 20 times, avg 54µs/call:
# 20 times (284µs+805µs) by Class::MOP::Class::superclasses at line 967, avg 54µs/call | ||||
| 974 | 80 | 215µs | my $self = shift; | ||
| 975 | 20 | 50µs | $self->update_meta_instance_dependencies(); # spent 50µs making 20 calls to Class::MOP::Class::update_meta_instance_dependencies, avg 3µs/call | ||
| 976 | # keep strong references to all our parents, so they don't disappear if | ||||
| 977 | # they are anon classes and don't have any direct instances | ||||
| 978 | 20 | 95µs | $self->_superclass_metas( # spent 95µs making 20 calls to Class::MOP::class_of, avg 5µs/call | ||
| 979 | 40 | 71µs | map { Class::MOP::class_of($_) } $self->superclasses # spent 71µs making 20 calls to Class::MOP::Class::_superclass_metas, avg 4µs/call
# spent 35µs making 2 calls to Class::MOP::Class::superclasses, avg 18µs/call, recursion: max depth 1, sum of overlapping time 35µs
# spent 554µs making 18 calls to Moose::Meta::Class::superclasses, avg 31µs/call, recursion: max depth 2, sum of overlapping time 554µs | ||
| 980 | ); | ||||
| 981 | } | ||||
| 982 | |||||
| 983 | # spent 71µs within Class::MOP::Class::_superclass_metas which was called 20 times, avg 4µs/call:
# 20 times (71µs+0s) by Class::MOP::Class::_superclasses_updated at line 979, avg 4µs/call | ||||
| 984 | 40 | 81µs | my $self = shift; | ||
| 985 | $self->{_superclass_metas} = [@_]; | ||||
| 986 | } | ||||
| 987 | |||||
| 988 | sub subclasses { | ||||
| 989 | my $self = shift; | ||||
| 990 | my $super_class = $self->name; | ||||
| 991 | |||||
| 992 | return @{ $super_class->mro::get_isarev() }; | ||||
| 993 | } | ||||
| 994 | |||||
| 995 | sub direct_subclasses { | ||||
| 996 | my $self = shift; | ||||
| 997 | my $super_class = $self->name; | ||||
| 998 | |||||
| 999 | return grep { | ||||
| 1000 | grep { | ||||
| 1001 | $_ eq $super_class | ||||
| 1002 | } Class::MOP::Class->initialize($_)->superclasses | ||||
| 1003 | } $self->subclasses; | ||||
| 1004 | } | ||||
| 1005 | |||||
| 1006 | # spent 5.34ms (3.45+1.89) within Class::MOP::Class::linearized_isa which was called 679 times, avg 8µs/call:
# 379 times (1.92ms+1.07ms) by Class::MOP::Class::get_all_attributes at line 936, avg 8µs/call
# 280 times (1.39ms+756µs) by Class::MOP::Class::_method_lookup_order at line 1045, avg 8µs/call
# 16 times (109µs+52µs) by Class::MOP::Class:::around at line 53 of Class/MOP/Class/Immutable/Trait.pm, avg 10µs/call
# 4 times (28µs+13µs) by Class::MOP::Class::find_attribute_by_name at line 924, avg 10µs/call | ||||
| 1007 | 679 | 5.98ms | 1358 | 1.89ms | return @{ mro::get_linear_isa( (shift)->name ) }; # spent 1.55ms making 679 calls to mro::get_linear_isa, avg 2µs/call
# spent 347µs making 679 calls to Class::MOP::Package::name, avg 510ns/call |
| 1008 | } | ||||
| 1009 | |||||
| 1010 | # spent 459µs (136+323) within Class::MOP::Class::class_precedence_list which was called 8 times, avg 57µs/call:
# 4 times (99µs+359µs) by Moose::Meta::Class::excludes_role at line 257 of Moose/Meta/Class.pm, avg 115µs/call
# 4 times (36µs+-36µs) by Class::MOP::Class::class_precedence_list at line 1036, avg 0s/call | ||||
| 1011 | 44 | 154µs | my $self = shift; | ||
| 1012 | 8 | 5µs | my $name = $self->name; # spent 5µs making 8 calls to Class::MOP::Package::name, avg 575ns/call | ||
| 1013 | |||||
| 1014 | 8 | 6µs | unless (Class::MOP::IS_RUNNING_ON_5_10()) { # spent 6µs making 8 calls to Class::MOP::__ANON__, avg 700ns/call | ||
| 1015 | # NOTE: | ||||
| 1016 | # We need to check for circular inheritance here | ||||
| 1017 | # if we are not on 5.10, cause 5.8 detects it late. | ||||
| 1018 | # This will do nothing if all is well, and blow up | ||||
| 1019 | # otherwise. Yes, it's an ugly hack, better | ||||
| 1020 | # suggestions are welcome. | ||||
| 1021 | # - SL | ||||
| 1022 | ($name || return)->isa('This is a test for circular inheritance') | ||||
| 1023 | } | ||||
| 1024 | |||||
| 1025 | # if our mro is c3, we can | ||||
| 1026 | # just grab the linear_isa | ||||
| 1027 | 8 | 22µs | if (mro::get_mro($name) eq 'c3') { # spent 22µs making 8 calls to mro::get_mro, avg 3µs/call | ||
| 1028 | return @{ mro::get_linear_isa($name) } | ||||
| 1029 | } | ||||
| 1030 | else { | ||||
| 1031 | # NOTE: | ||||
| 1032 | # we can't grab the linear_isa for dfs | ||||
| 1033 | # since it has all the duplicates | ||||
| 1034 | # already removed. | ||||
| 1035 | return ( | ||||
| 1036 | 8 | 28µs | $name, # spent 28µs making 4 calls to Class::MOP::Class::initialize, avg 7µs/call
# spent 152µs making 4 calls to Class::MOP::Class::class_precedence_list, avg 38µs/call, recursion: max depth 1, sum of overlapping time 152µs | ||
| 1037 | map { | ||||
| 1038 | 8 | 263µs | Class::MOP::Class->initialize($_)->class_precedence_list() # spent 263µs making 8 calls to Moose::Meta::Class::superclasses, avg 33µs/call | ||
| 1039 | } $self->superclasses() | ||||
| 1040 | ); | ||||
| 1041 | } | ||||
| 1042 | } | ||||
| 1043 | |||||
| 1044 | # spent 3.19ms (1.05+2.14) within Class::MOP::Class::_method_lookup_order which was called 280 times, avg 11µs/call:
# 136 times (526µs+1.08ms) by Class::MOP::Class::find_method_by_name at line 1132, avg 12µs/call
# 105 times (382µs+771µs) by Class::MOP::Class::find_next_method_by_name at line 1178, avg 11µs/call
# 32 times (104µs+194µs) by Class::MOP::Class::find_all_methods_by_name at line 1162, avg 9µs/call
# 7 times (37µs+95µs) by Class::MOP::Class::get_all_methods at line 1143, avg 19µs/call | ||||
| 1045 | 280 | 875µs | 280 | 2.14ms | return (shift->linearized_isa, 'UNIVERSAL'); # spent 2.14ms making 280 calls to Class::MOP::Class::linearized_isa, avg 8µs/call |
| 1046 | } | ||||
| 1047 | |||||
| 1048 | ## Methods | ||||
| 1049 | |||||
| 1050 | { | ||||
| 1051 | 1 | 400ns | # spent 13.7ms (949µs+12.8) within Class::MOP::Class::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Class/MOP/Class.pm:1082] which was called 44 times, avg 312µs/call:
# 43 times (920µs+12.3ms) by Class::MOP::Class::add_around_method_modifier at line 1108, avg 309µs/call
# once (29µs+428µs) by Class::MOP::Class::add_before_method_modifier at line 1088 | ||
| 1052 | 394 | 819µs | my ($self, $method_name) = @_; | ||
| 1053 | 44 | 32µs | my $wrapped_metaclass = $self->wrapped_method_metaclass; # spent 32µs making 44 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 739ns/call | ||
| 1054 | # fetch it locally | ||||
| 1055 | 44 | 1.14ms | my $method = $self->get_method($method_name); # spent 1.14ms making 44 calls to Class::MOP::Mixin::HasMethods::get_method, avg 26µs/call | ||
| 1056 | # if we don't have local ... | ||||
| 1057 | unless ($method) { | ||||
| 1058 | # try to find the next method | ||||
| 1059 | 43 | 4.73ms | $method = $self->find_next_method_by_name($method_name); # spent 4.73ms making 43 calls to Class::MOP::Class::find_next_method_by_name, avg 110µs/call | ||
| 1060 | # die if it does not exist | ||||
| 1061 | (defined $method) | ||||
| 1062 | || $self->_throw_exception( MethodNameNotFoundInInheritanceHierarchy => class_name => $self->name, | ||||
| 1063 | method_name => $method_name | ||||
| 1064 | ); | ||||
| 1065 | # and now make sure to wrap it | ||||
| 1066 | # even if it is already wrapped | ||||
| 1067 | # because we need a new sub ref | ||||
| 1068 | 86 | 3.17ms | $method = $wrapped_metaclass->wrap($method, # spent 3.13ms making 43 calls to Class::MOP::Method::Wrapped::wrap, avg 73µs/call
# spent 36µs making 43 calls to Class::MOP::Package::name, avg 847ns/call | ||
| 1069 | package_name => $self->name, | ||||
| 1070 | name => $method_name, | ||||
| 1071 | ); | ||||
| 1072 | } | ||||
| 1073 | else { | ||||
| 1074 | # now make sure we wrap it properly | ||||
| 1075 | 3 | 130µs | $method = $wrapped_metaclass->wrap($method, # spent 128µs making 1 call to Class::MOP::Method::Wrapped::wrap
# spent 2µs making 1 call to UNIVERSAL::isa
# spent 600ns making 1 call to Class::MOP::Package::name | ||
| 1076 | package_name => $self->name, | ||||
| 1077 | name => $method_name, | ||||
| 1078 | ) unless $method->isa($wrapped_metaclass); | ||||
| 1079 | } | ||||
| 1080 | 44 | 3.57ms | $self->add_method($method_name => $method); # spent 3.57ms making 44 calls to Class::MOP::Mixin::HasMethods::add_method, avg 81µs/call | ||
| 1081 | return $method; | ||||
| 1082 | 1 | 5µs | }; | ||
| 1083 | |||||
| 1084 | # spent 488µs (14+473) within Class::MOP::Class::add_before_method_modifier which was called:
# once (14µs+473µs) by Moose::Util::add_method_modifier at line 285 of Moose/Util.pm | ||||
| 1085 | 4 | 16µs | my ($self, $method_name, $method_modifier) = @_; | ||
| 1086 | (defined $method_name && length $method_name) | ||||
| 1087 | || $self->_throw_exception( MethodModifierNeedsMethodName => class_name => $self->name ); | ||||
| 1088 | 1 | 457µs | my $method = $fetch_and_prepare_method->($self, $method_name); # spent 457µs making 1 call to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:1082] | ||
| 1089 | 2 | 17µs | $method->add_before_modifier( # spent 14µs making 1 call to Class::MOP::Method::Wrapped::add_before_modifier
# spent 2µs making 1 call to Sub::Name::subname | ||
| 1090 | subname(':before' => $method_modifier) | ||||
| 1091 | ); | ||||
| 1092 | } | ||||
| 1093 | |||||
| 1094 | sub add_after_method_modifier { | ||||
| 1095 | my ($self, $method_name, $method_modifier) = @_; | ||||
| 1096 | (defined $method_name && length $method_name) | ||||
| 1097 | || $self->_throw_exception( MethodModifierNeedsMethodName => class_name => $self->name ); | ||||
| 1098 | my $method = $fetch_and_prepare_method->($self, $method_name); | ||||
| 1099 | $method->add_after_modifier( | ||||
| 1100 | subname(':after' => $method_modifier) | ||||
| 1101 | ); | ||||
| 1102 | } | ||||
| 1103 | |||||
| 1104 | # spent 14.7ms (386µs+14.3) within Class::MOP::Class::add_around_method_modifier which was called 43 times, avg 341µs/call:
# 43 times (386µs+14.3ms) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 341µs/call | ||||
| 1105 | 172 | 437µs | my ($self, $method_name, $method_modifier) = @_; | ||
| 1106 | (defined $method_name && length $method_name) | ||||
| 1107 | || $self->_throw_exception( MethodModifierNeedsMethodName => class_name => $self->name ); | ||||
| 1108 | 43 | 13.3ms | my $method = $fetch_and_prepare_method->($self, $method_name); # spent 13.3ms making 43 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:1082], avg 309µs/call | ||
| 1109 | 86 | 1.02ms | $method->add_around_modifier( # spent 913µs making 43 calls to Class::MOP::Method::Wrapped::add_around_modifier, avg 21µs/call
# spent 107µs making 43 calls to Sub::Name::subname, avg 2µs/call | ||
| 1110 | subname(':around' => $method_modifier) | ||||
| 1111 | ); | ||||
| 1112 | } | ||||
| 1113 | |||||
| 1114 | # NOTE: | ||||
| 1115 | # the methods above used to be named like this: | ||||
| 1116 | # ${pkg}::${method}:(before|after|around) | ||||
| 1117 | # but this proved problematic when using one modifier | ||||
| 1118 | # to wrap multiple methods (something which is likely | ||||
| 1119 | # to happen pretty regularly IMO). So instead of naming | ||||
| 1120 | # it like this, I have chosen to just name them purely | ||||
| 1121 | # with their modifier names, like so: | ||||
| 1122 | # :(before|after|around) | ||||
| 1123 | # The fact is that in a stack trace, it will be fairly | ||||
| 1124 | # evident from the context what method they are attached | ||||
| 1125 | # to, and so don't need the fully qualified name. | ||||
| 1126 | } | ||||
| 1127 | |||||
| 1128 | # spent 20.5ms (3.41+17.1) within Class::MOP::Class::find_method_by_name which was called 136 times, avg 151µs/call:
# 56 times (1.85ms+11.1ms) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 231µs/call
# 41 times (805µs+3.21ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 19 of Class/MOP/Mixin/HasMethods.pm, avg 98µs/call
# 16 times (339µs+1.28ms) by Moose::Meta::Class::_inline_BUILDARGS at line 325 of Moose/Meta/Class.pm, avg 101µs/call
# 16 times (304µs+1.06ms) by Moose::Meta::Method::Destructor::is_needed at line 66 of Moose/Meta/Method/Destructor.pm, avg 85µs/call
# 7 times (112µs+475µs) by Moose::BEGIN@43 at line 16 of Moose/Meta/Attribute/Native.pm, avg 84µs/call | ||||
| 1129 | 1345 | 2.49ms | my ($self, $method_name) = @_; | ||
| 1130 | (defined $method_name && length $method_name) | ||||
| 1131 | || $self->_throw_exception( MethodNameNotGiven => class_name => $self->name ); | ||||
| 1132 | 136 | 1.61ms | foreach my $class ($self->_method_lookup_order) { # spent 1.61ms making 136 calls to Class::MOP::Class::_method_lookup_order, avg 12µs/call | ||
| 1133 | 878 | 15.5ms | my $method = Class::MOP::Class->initialize($class)->get_method($method_name); # spent 12.8ms making 439 calls to Class::MOP::Mixin::HasMethods::get_method, avg 29µs/call
# spent 2.74ms making 439 calls to Class::MOP::Class::initialize, avg 6µs/call | ||
| 1134 | return $method if defined $method; | ||||
| 1135 | } | ||||
| 1136 | return; | ||||
| 1137 | } | ||||
| 1138 | |||||
| 1139 | # spent 4.96ms (448µs+4.52) within Class::MOP::Class::get_all_methods which was called 7 times, avg 709µs/call:
# 7 times (448µs+4.52ms) by Class::MOP::MiniTrait::apply at line 17 of Class/MOP/MiniTrait.pm, avg 709µs/call | ||||
| 1140 | 58 | 466µs | my $self = shift; | ||
| 1141 | |||||
| 1142 | my %methods; | ||||
| 1143 | 7 | 132µs | for my $class ( reverse $self->_method_lookup_order ) { # spent 132µs making 7 calls to Class::MOP::Class::_method_lookup_order, avg 19µs/call | ||
| 1144 | 15 | 104µs | my $meta = Class::MOP::Class->initialize($class); # spent 104µs making 15 calls to Class::MOP::Class::initialize, avg 7µs/call | ||
| 1145 | |||||
| 1146 | 101 | 4.28ms | $methods{ $_->name } = $_ for $meta->_get_local_methods; # spent 4.22ms making 15 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 281µs/call
# spent 62µs making 86 calls to Class::MOP::Method::name, avg 720ns/call | ||
| 1147 | } | ||||
| 1148 | |||||
| 1149 | return values %methods; | ||||
| 1150 | } | ||||
| 1151 | |||||
| 1152 | sub get_all_method_names { | ||||
| 1153 | my $self = shift; | ||||
| 1154 | map { $_->name } $self->get_all_methods; | ||||
| 1155 | } | ||||
| 1156 | |||||
| 1157 | # spent 4.23ms (835µs+3.40) within Class::MOP::Class::find_all_methods_by_name which was called 32 times, avg 132µs/call:
# 16 times (442µs+1.98ms) by Moose::Meta::Class::_inline_BUILDALL at line 483 of Moose/Meta/Class.pm, avg 152µs/call
# 16 times (393µs+1.41ms) by Moose::Meta::Method::Destructor::_generate_DEMOLISHALL at line 116 of Moose/Meta/Method/Destructor.pm, avg 113µs/call | ||||
| 1158 | 356 | 620µs | my ($self, $method_name) = @_; | ||
| 1159 | (defined $method_name && length $method_name) | ||||
| 1160 | || $self->_throw_exception( MethodNameNotGiven => class_name => $self->name ); | ||||
| 1161 | my @methods; | ||||
| 1162 | 32 | 298µs | foreach my $class ($self->_method_lookup_order) { # spent 298µs making 32 calls to Class::MOP::Class::_method_lookup_order, avg 9µs/call | ||
| 1163 | # fetch the meta-class ... | ||||
| 1164 | 98 | 522µs | my $meta = Class::MOP::Class->initialize($class); # spent 522µs making 98 calls to Class::MOP::Class::initialize, avg 5µs/call | ||
| 1165 | 101 | 2.58ms | push @methods => { # spent 2.26ms making 98 calls to Class::MOP::Mixin::HasMethods::has_method, avg 23µs/call
# spent 312µs making 3 calls to Class::MOP::Mixin::HasMethods::get_method, avg 104µs/call | ||
| 1166 | name => $method_name, | ||||
| 1167 | class => $class, | ||||
| 1168 | code => $meta->get_method($method_name) | ||||
| 1169 | } if $meta->has_method($method_name); | ||||
| 1170 | } | ||||
| 1171 | return @methods; | ||||
| 1172 | } | ||||
| 1173 | |||||
| 1174 | # spent 9.51ms (2.04+7.47) within Class::MOP::Class::find_next_method_by_name which was called 105 times, avg 91µs/call:
# 62 times (1.05ms+3.72ms) by Class::MOP::Method::Inlined::can_be_inlined at line 34 of Class/MOP/Method/Inlined.pm, avg 77µs/call
# 43 times (981µs+3.75ms) by Class::MOP::Class::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Class/MOP/Class.pm:1082] at line 1059, avg 110µs/call | ||||
| 1175 | 891 | 1.61ms | my ($self, $method_name) = @_; | ||
| 1176 | (defined $method_name && length $method_name) | ||||
| 1177 | || $self->_throw_exception( MethodNameNotGiven => class_name => $self->name ); | ||||
| 1178 | 105 | 1.15ms | my @cpl = ($self->_method_lookup_order); # spent 1.15ms making 105 calls to Class::MOP::Class::_method_lookup_order, avg 11µs/call | ||
| 1179 | shift @cpl; # discard ourselves | ||||
| 1180 | foreach my $class (@cpl) { | ||||
| 1181 | 364 | 6.32ms | my $method = Class::MOP::Class->initialize($class)->get_method($method_name); # spent 5.18ms making 182 calls to Class::MOP::Mixin::HasMethods::get_method, avg 28µs/call
# spent 1.14ms making 182 calls to Class::MOP::Class::initialize, avg 6µs/call | ||
| 1182 | return $method if defined $method; | ||||
| 1183 | } | ||||
| 1184 | return; | ||||
| 1185 | } | ||||
| 1186 | |||||
| 1187 | # spent 50µs within Class::MOP::Class::update_meta_instance_dependencies which was called 20 times, avg 3µs/call:
# 20 times (50µs+0s) by Class::MOP::Class::_superclasses_updated at line 975, avg 3µs/call | ||||
| 1188 | 40 | 64µs | my $self = shift; | ||
| 1189 | |||||
| 1190 | if ( $self->{meta_instance_dependencies} ) { | ||||
| 1191 | return $self->add_meta_instance_dependencies; | ||||
| 1192 | } | ||||
| 1193 | } | ||||
| 1194 | |||||
| 1195 | sub add_meta_instance_dependencies { | ||||
| 1196 | my $self = shift; | ||||
| 1197 | |||||
| 1198 | $self->remove_meta_instance_dependencies; | ||||
| 1199 | |||||
| 1200 | my @attrs = $self->get_all_attributes(); | ||||
| 1201 | |||||
| 1202 | my %seen; | ||||
| 1203 | my @classes = grep { not $seen{ $_->name }++ } | ||||
| 1204 | map { $_->associated_class } @attrs; | ||||
| 1205 | |||||
| 1206 | foreach my $class (@classes) { | ||||
| 1207 | $class->add_dependent_meta_instance($self); | ||||
| 1208 | } | ||||
| 1209 | |||||
| 1210 | $self->{meta_instance_dependencies} = \@classes; | ||||
| 1211 | } | ||||
| 1212 | |||||
| 1213 | sub remove_meta_instance_dependencies { | ||||
| 1214 | my $self = shift; | ||||
| 1215 | |||||
| 1216 | if ( my $classes = delete $self->{meta_instance_dependencies} ) { | ||||
| 1217 | foreach my $class (@$classes) { | ||||
| 1218 | $class->remove_dependent_meta_instance($self); | ||||
| 1219 | } | ||||
| 1220 | |||||
| 1221 | return $classes; | ||||
| 1222 | } | ||||
| 1223 | |||||
| 1224 | return; | ||||
| 1225 | |||||
| 1226 | } | ||||
| 1227 | |||||
| 1228 | sub add_dependent_meta_instance { | ||||
| 1229 | my ( $self, $metaclass ) = @_; | ||||
| 1230 | push @{ $self->{dependent_meta_instances} }, $metaclass; | ||||
| 1231 | } | ||||
| 1232 | |||||
| 1233 | sub remove_dependent_meta_instance { | ||||
| 1234 | my ( $self, $metaclass ) = @_; | ||||
| 1235 | my $name = $metaclass->name; | ||||
| 1236 | @$_ = grep { $_->name ne $name } @$_ | ||||
| 1237 | for $self->{dependent_meta_instances}; | ||||
| 1238 | } | ||||
| 1239 | |||||
| 1240 | # spent 3.23ms (2.65+582µs) within Class::MOP::Class::invalidate_meta_instances which was called 322 times, avg 10µs/call:
# 320 times (2.63ms+579µs) by Class::MOP::Class::_post_add_attribute at line 894, avg 10µs/call
# 2 times (17µs+2µs) by Class::MOP::Class::remove_attribute at line 913, avg 10µs/call | ||||
| 1241 | 644 | 2.46ms | my $self = shift; | ||
| 1242 | $_->invalidate_meta_instance() | ||||
| 1243 | 322 | 582µs | for $self, @{ $self->{dependent_meta_instances} }; # spent 582µs making 322 calls to Class::MOP::Class::invalidate_meta_instance, avg 2µs/call | ||
| 1244 | } | ||||
| 1245 | |||||
| 1246 | # spent 582µs within Class::MOP::Class::invalidate_meta_instance which was called 322 times, avg 2µs/call:
# 322 times (582µs+0s) by Class::MOP::Class::invalidate_meta_instances at line 1243, avg 2µs/call | ||||
| 1247 | 644 | 898µs | my $self = shift; | ||
| 1248 | undef $self->{_meta_instance}; | ||||
| 1249 | } | ||||
| 1250 | |||||
| 1251 | # check if we can reinitialize | ||||
| 1252 | sub is_pristine { | ||||
| 1253 | my $self = shift; | ||||
| 1254 | |||||
| 1255 | # if any local attr is defined | ||||
| 1256 | return if $self->get_attribute_list; | ||||
| 1257 | |||||
| 1258 | # or any non-declared methods | ||||
| 1259 | for my $method ( map { $self->get_method($_) } $self->get_method_list ) { | ||||
| 1260 | return if $method->isa("Class::MOP::Method::Generated"); | ||||
| 1261 | # FIXME do we need to enforce this too? return unless $method->isa( $self->method_metaclass ); | ||||
| 1262 | } | ||||
| 1263 | |||||
| 1264 | return 1; | ||||
| 1265 | } | ||||
| 1266 | |||||
| 1267 | ## Class closing | ||||
| 1268 | |||||
| 1269 | 103 | 214µs | # spent 122µs within Class::MOP::Class::is_mutable which was called 103 times, avg 1µs/call:
# 70 times (97µs+0s) by Class::MOP::Class::make_immutable at line 1293, avg 1µs/call
# 21 times (14µs+0s) by Bio::Roary::CommandLine::RoaryPostAnalysis::BEGIN@11 at line 238 of Moose.pm, avg 643ns/call
# 9 times (9µs+0s) by Moose::Meta::Attribute::BEGIN@16 at line 712 of Moose/Util/TypeConstraints.pm, avg 956ns/call
# 3 times (2µs+0s) by Bio::Roary::CommandLine::RoaryPostAnalysis::BEGIN@11 at line 274 of Moose.pm, avg 833ns/call | ||
| 1270 | 71 | 174µs | # spent 85µs within Class::MOP::Class::is_immutable which was called 71 times, avg 1µs/call:
# 71 times (85µs+0s) by Class::MOP::Class::_real_ref_name at line 122, avg 1µs/call | ||
| 1271 | |||||
| 1272 | sub immutable_options { %{ $_[0]{__immutable}{options} || {} } } | ||||
| 1273 | |||||
| 1274 | # spent 1.58ms (1.22+363µs) within Class::MOP::Class::_immutable_options which was called 70 times, avg 23µs/call:
# 54 times (917µs+191µs) by Class::MOP::Class::make_immutable at line 1297, avg 21µs/call
# 16 times (299µs+172µs) by Moose::Meta::Class::_immutable_options at line 757 of Moose/Meta/Class.pm, avg 29µs/call | ||||
| 1275 | 140 | 1.42ms | my ( $self, @args ) = @_; | ||
| 1276 | |||||
| 1277 | return ( | ||||
| 1278 | 280 | 363µs | inline_accessors => 1, # spent 75µs making 70 calls to Class::MOP::Class::constructor_name, avg 1µs/call
# spent 56µs making 16 calls to Moose::Meta::Class::immutable_trait, avg 4µs/call
# spent 56µs making 54 calls to Class::MOP::Class::immutable_trait, avg 1µs/call
# spent 48µs making 16 calls to Moose::Meta::Class::destructor_class, avg 3µs/call
# spent 46µs making 16 calls to Moose::Meta::Class::constructor_class, avg 3µs/call
# spent 44µs making 54 calls to Class::MOP::Class::constructor_class, avg 820ns/call
# spent 37µs making 54 calls to Class::MOP::Class::destructor_class, avg 693ns/call | ||
| 1279 | inline_constructor => 1, | ||||
| 1280 | inline_destructor => 0, | ||||
| 1281 | debug => 0, | ||||
| 1282 | immutable_trait => $self->immutable_trait, | ||||
| 1283 | constructor_name => $self->constructor_name, | ||||
| 1284 | constructor_class => $self->constructor_class, | ||||
| 1285 | destructor_class => $self->destructor_class, | ||||
| 1286 | @args, | ||||
| 1287 | ); | ||||
| 1288 | } | ||||
| 1289 | |||||
| 1290 | # spent 301ms (1.70+299) within Class::MOP::Class::make_immutable which was called 70 times, avg 4.29ms/call:
# 21 times (469µs+75.7ms) by Bio::Roary::CommandLine::RoaryPostAnalysis::BEGIN@11 at line 243 of Moose.pm, avg 3.63ms/call
# 14 times (349µs+21.9ms) by Moose::Exporter::BEGIN@8 at line 748 of Class/MOP.pm, avg 1.59ms/call
# 9 times (220µs+40.9ms) by Moose::Meta::Attribute::BEGIN@16 at line 717 of Moose/Util/TypeConstraints.pm, avg 4.57ms/call
# 5 times (114µs+793µs) by Moose::Exporter::BEGIN@8 at line 775 of Class/MOP.pm, avg 181µs/call
# 3 times (46µs+8.02ms) by Bio::Roary::CommandLine::RoaryPostAnalysis::BEGIN@11 at line 279 of Moose.pm, avg 2.69ms/call
# 2 times (62µs+-62µs) by Class::MOP::Class::_immutable_metaclass at line 1373, avg 0s/call
# once (34µs+20.9ms) by Bio::Roary::CommandLine::RoaryPostAnalysis::BEGIN@13 at line 226 of lib/Bio/Roary/PostAnalysis.pm
# once (31µs+20.2ms) by Bio::Roary::PostAnalysis::BEGIN@13 at line 107 of lib/Bio/Roary/InflateClusters.pm
# once (25µs+15.3ms) by Bio::Roary::Main::RoaryPostAnalysis::BEGIN@17 at line 187 of lib/Bio/Roary/CommandLine/RoaryPostAnalysis.pm
# once (27µs+10.4ms) by Bio::Roary::PostAnalysis::BEGIN@19 at line 117 of lib/Bio/Roary/Output/NumberOfGroups.pm
# once (25µs+9.27ms) by Bio::Roary::PostAnalysis::BEGIN@22 at line 319 of lib/Bio/Roary/SplitGroups.pm
# once (26µs+9.18ms) by Bio::Roary::CommandLine::RoaryPostAnalysis::BEGIN@15 at line 89 of lib/Bio/Roary/External/ProteinMuscleAlignmentFromNucleotides.pm
# once (33µs+8.80ms) by Bio::Roary::PostAnalysis::BEGIN@17 at line 203 of lib/Bio/Roary/GroupStatistics.pm
# once (26µs+8.11ms) by Bio::Roary::PostAnalysis::BEGIN@16 at line 326 of lib/Bio/Roary/AnnotateGroups.pm
# once (24µs+7.19ms) by Bio::Roary::PostAnalysis::BEGIN@21 at line 240 of lib/Bio/Roary/Output/EmblGroups.pm
# once (28µs+7.11ms) by Bio::Roary::PostAnalysis::BEGIN@18 at line 76 of lib/Bio/Roary/Output/GroupsMultifastasNucleotide.pm
# once (34µs+7.04ms) by Bio::Roary::PostAnalysis::BEGIN@20 at line 353 of lib/Bio/Roary/OrderGenes.pm
# once (25µs+6.64ms) by Bio::Roary::OrderGenes::BEGIN@21 at line 143 of lib/Bio/Roary/ContigsToGeneIDsFromGFF.pm
# once (23µs+6.00ms) by Bio::Roary::PostAnalysis::BEGIN@14 at line 143 of lib/Bio/Roary/AnalyseGroups.pm
# once (27µs+5.79ms) by Bio::Roary::Output::GroupsMultifastasNucleotide::BEGIN@23 at line 149 of lib/Bio/Roary/Output/GroupsMultifastaNucleotide.pm
# once (25µs+5.43ms) by Bio::Roary::AnnotateGroups::BEGIN@21 at line 66 of lib/Bio/Roary/GeneNamesFromGFF.pm
# once (25µs+4.29ms) by Bio::Roary::PostAnalysis::BEGIN@15 at line 60 of lib/Bio/Roary/GroupLabels.pm | ||||
| 1291 | 420 | 1.52ms | my ( $self, @args ) = @_; | ||
| 1292 | |||||
| 1293 | 70 | 97µs | return $self unless $self->is_mutable; # spent 97µs making 70 calls to Class::MOP::Class::is_mutable, avg 1µs/call | ||
| 1294 | |||||
| 1295 | my ($file, $line) = (caller)[1..2]; | ||||
| 1296 | |||||
| 1297 | 140 | 258ms | $self->_initialize_immutable( # spent 257ms making 70 calls to Class::MOP::Class::_initialize_immutable, avg 3.67ms/call
# spent 1.11ms making 54 calls to Class::MOP::Class::_immutable_options, avg 21µs/call
# spent 622µs making 16 calls to Moose::Meta::Class::_immutable_options, avg 39µs/call | ||
| 1298 | file => $file, | ||||
| 1299 | line => $line, | ||||
| 1300 | $self->_immutable_options(@args), | ||||
| 1301 | ); | ||||
| 1302 | 70 | 40.7ms | $self->_rebless_as_immutable(@args); # spent 41.0ms making 70 calls to Class::MOP::Class::_rebless_as_immutable, avg 585µs/call, recursion: max depth 1, sum of overlapping time 284µs | ||
| 1303 | |||||
| 1304 | return $self; | ||||
| 1305 | } | ||||
| 1306 | |||||
| 1307 | sub make_mutable { | ||||
| 1308 | my $self = shift; | ||||
| 1309 | |||||
| 1310 | if ( $self->is_immutable ) { | ||||
| 1311 | my @args = $self->immutable_options; | ||||
| 1312 | $self->_rebless_as_mutable(); | ||||
| 1313 | $self->_remove_inlined_code(@args); | ||||
| 1314 | delete $self->{__immutable}; | ||||
| 1315 | return $self; | ||||
| 1316 | } | ||||
| 1317 | else { | ||||
| 1318 | return; | ||||
| 1319 | } | ||||
| 1320 | } | ||||
| 1321 | |||||
| 1322 | # spent 40.7ms (914µs+39.8) within Class::MOP::Class::_rebless_as_immutable which was called 70 times, avg 581µs/call:
# 70 times (914µs+39.8ms) by Class::MOP::Class::make_immutable at line 1302, avg 581µs/call | ||||
| 1323 | 210 | 870µs | my ( $self, @args ) = @_; | ||
| 1324 | |||||
| 1325 | $self->{__immutable}{original_class} = ref $self; | ||||
| 1326 | |||||
| 1327 | 70 | 39.8ms | bless $self => $self->_immutable_metaclass(@args); # spent 40.1ms making 70 calls to Class::MOP::Class::_immutable_metaclass, avg 572µs/call, recursion: max depth 1, sum of overlapping time 227µs | ||
| 1328 | } | ||||
| 1329 | |||||
| 1330 | # spent 39.8ms (1.71+38.1) within Class::MOP::Class::_immutable_metaclass which was called 70 times, avg 569µs/call:
# 70 times (1.71ms+38.1ms) by Class::MOP::Class::_rebless_as_immutable at line 1327, avg 569µs/call | ||||
| 1331 | 570 | 1.49ms | my ( $self, %args ) = @_; | ||
| 1332 | |||||
| 1333 | if ( my $class = $args{immutable_metaclass} ) { | ||||
| 1334 | return $class; | ||||
| 1335 | } | ||||
| 1336 | |||||
| 1337 | 70 | 109µs | my $trait = $args{immutable_trait} = $self->immutable_trait # spent 58µs making 16 calls to Moose::Meta::Class::immutable_trait, avg 4µs/call
# spent 50µs making 54 calls to Class::MOP::Class::immutable_trait, avg 928ns/call | ||
| 1338 | || $self->_throw_exception( NoImmutableTraitSpecifiedForClass => class_name => $self->name, | ||||
| 1339 | params => \%args | ||||
| 1340 | ); | ||||
| 1341 | |||||
| 1342 | 70 | 992µs | my $meta = $self->meta; # spent 992µs making 70 calls to Class::MOP::Object::meta, avg 14µs/call | ||
| 1343 | 70 | 3.43ms | my $meta_attr = $meta->find_attribute_by_name("immutable_trait"); # spent 3.43ms making 70 calls to Class::MOP::Class::find_attribute_by_name, avg 49µs/call | ||
| 1344 | |||||
| 1345 | my $class_name; | ||||
| 1346 | |||||
| 1347 | 70 | 234µs | if ( $meta_attr and $trait eq $meta_attr->default ) { # spent 234µs making 70 calls to Class::MOP::Mixin::AttributeCore::default, avg 3µs/call | ||
| 1348 | # if the trait is the same as the default we try and pick a | ||||
| 1349 | # predictable name for the immutable metaclass | ||||
| 1350 | $class_name = 'Class::MOP::Class::Immutable::' . ref($self); | ||||
| 1351 | } | ||||
| 1352 | else { | ||||
| 1353 | $class_name = join '::', 'Class::MOP::Class::Immutable::CustomTrait', | ||||
| 1354 | $trait, 'ForMetaClass', ref($self); | ||||
| 1355 | } | ||||
| 1356 | |||||
| 1357 | 70 | 210µs | return $class_name # spent 210µs making 70 calls to Class::MOP::does_metaclass_exist, avg 3µs/call | ||
| 1358 | if Class::MOP::does_metaclass_exist($class_name); | ||||
| 1359 | |||||
| 1360 | # If the metaclass is a subclass of CMOP::Class which has had | ||||
| 1361 | # metaclass roles applied (via Moose), then we want to make sure | ||||
| 1362 | # that we preserve that anonymous class (see Fey::ORM for an | ||||
| 1363 | # example of where this matters). | ||||
| 1364 | 2 | 27µs | my $meta_name = $meta->_real_ref_name; # spent 27µs making 2 calls to Class::MOP::Class::_real_ref_name, avg 14µs/call | ||
| 1365 | |||||
| 1366 | 2 | 2.96ms | my $immutable_meta = $meta_name->create( # spent 2.96ms making 2 calls to Class::MOP::Class::create, avg 1.48ms/call | ||
| 1367 | $class_name, | ||||
| 1368 | superclasses => [ ref $self ], | ||||
| 1369 | ); | ||||
| 1370 | |||||
| 1371 | 2 | 29.9ms | Class::MOP::MiniTrait::apply( $immutable_meta, $trait ); # spent 29.9ms making 2 calls to Class::MOP::MiniTrait::apply, avg 15.0ms/call | ||
| 1372 | |||||
| 1373 | 2 | 0s | $immutable_meta->make_immutable( # spent 464µs making 2 calls to Class::MOP::Class::make_immutable, avg 232µs/call, recursion: max depth 1, sum of overlapping time 464µs | ||
| 1374 | inline_constructor => 0, | ||||
| 1375 | inline_accessors => 0, | ||||
| 1376 | ); | ||||
| 1377 | |||||
| 1378 | return $class_name; | ||||
| 1379 | } | ||||
| 1380 | |||||
| 1381 | sub _remove_inlined_code { | ||||
| 1382 | my $self = shift; | ||||
| 1383 | |||||
| 1384 | $self->remove_method( $_->name ) for $self->_inlined_methods; | ||||
| 1385 | |||||
| 1386 | delete $self->{__immutable}{inlined_methods}; | ||||
| 1387 | } | ||||
| 1388 | |||||
| 1389 | sub _inlined_methods { @{ $_[0]{__immutable}{inlined_methods} || [] } } | ||||
| 1390 | |||||
| 1391 | sub _add_inlined_method { | ||||
| 1392 | 124 | 304µs | my ( $self, $method ) = @_; | ||
| 1393 | |||||
| 1394 | push @{ $self->{__immutable}{inlined_methods} ||= [] }, $method; | ||||
| 1395 | } | ||||
| 1396 | |||||
| 1397 | # spent 257ms (1.07+256) within Class::MOP::Class::_initialize_immutable which was called 70 times, avg 3.67ms/call:
# 70 times (1.07ms+256ms) by Class::MOP::Class::make_immutable at line 1297, avg 3.67ms/call | ||||
| 1398 | 210 | 1.02ms | my ( $self, %args ) = @_; | ||
| 1399 | |||||
| 1400 | $self->{__immutable}{options} = \%args; | ||||
| 1401 | 70 | 256ms | $self->_install_inlined_code(%args); # spent 256ms making 70 calls to Class::MOP::Class::_install_inlined_code, avg 3.65ms/call | ||
| 1402 | } | ||||
| 1403 | |||||
| 1404 | # spent 256ms (1.01+255) within Class::MOP::Class::_install_inlined_code which was called 70 times, avg 3.65ms/call:
# 70 times (1.01ms+255ms) by Class::MOP::Class::_initialize_immutable at line 1401, avg 3.65ms/call | ||||
| 1405 | 280 | 973µs | my ( $self, %args ) = @_; | ||
| 1406 | |||||
| 1407 | # FIXME | ||||
| 1408 | 33 | 52.7ms | $self->_inline_accessors(%args) if $args{inline_accessors}; # spent 52.7ms making 33 calls to Class::MOP::Class::_inline_accessors, avg 1.60ms/call | ||
| 1409 | 46 | 188ms | $self->_inline_constructor(%args) if $args{inline_constructor}; # spent 188ms making 46 calls to Class::MOP::Class::_inline_constructor, avg 4.09ms/call | ||
| 1410 | 16 | 13.7ms | $self->_inline_destructor(%args) if $args{inline_destructor}; # spent 13.7ms making 16 calls to Class::MOP::Class::_inline_destructor, avg 855µs/call | ||
| 1411 | } | ||||
| 1412 | |||||
| 1413 | sub _rebless_as_mutable { | ||||
| 1414 | my $self = shift; | ||||
| 1415 | |||||
| 1416 | bless $self, $self->_get_mutable_metaclass_name; | ||||
| 1417 | |||||
| 1418 | return $self; | ||||
| 1419 | } | ||||
| 1420 | |||||
| 1421 | # spent 52.7ms (605µs+52.1) within Class::MOP::Class::_inline_accessors which was called 33 times, avg 1.60ms/call:
# 33 times (605µs+52.1ms) by Class::MOP::Class::_install_inlined_code at line 1408, avg 1.60ms/call | ||||
| 1422 | 142 | 449µs | my $self = shift; | ||
| 1423 | |||||
| 1424 | 33 | 201µs | foreach my $attr_name ( $self->get_attribute_list ) { # spent 201µs making 33 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 6µs/call | ||
| 1425 | 152 | 51.9ms | $self->get_attribute($attr_name)->install_accessors(1); # spent 50.2ms making 75 calls to Class::MOP::Attribute::install_accessors, avg 670µs/call
# spent 1.25ms making 1 call to Moose::Meta::Attribute::install_accessors
# spent 424µs making 76 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 6µs/call | ||
| 1426 | } | ||||
| 1427 | } | ||||
| 1428 | |||||
| 1429 | # spent 188ms (1.76+186) within Class::MOP::Class::_inline_constructor which was called 46 times, avg 4.09ms/call:
# 46 times (1.76ms+186ms) by Class::MOP::Class::_install_inlined_code at line 1409, avg 4.09ms/call | ||||
| 1430 | 552 | 1.55ms | my ( $self, %args ) = @_; | ||
| 1431 | |||||
| 1432 | my $name = $args{constructor_name}; | ||||
| 1433 | # A class may not even have a constructor, and that's okay. | ||||
| 1434 | return unless defined $name; | ||||
| 1435 | |||||
| 1436 | 46 | 1.33ms | if ( $self->has_method($name) && !$args{replace_constructor} ) { # spent 1.33ms making 46 calls to Class::MOP::Mixin::HasMethods::has_method, avg 29µs/call | ||
| 1437 | my $class = $self->name; | ||||
| 1438 | warn "Not inlining a constructor for $class since it defines" | ||||
| 1439 | . " its own constructor.\n" | ||||
| 1440 | . "If you are certain you don't need to inline your" | ||||
| 1441 | . " constructor, specify inline_constructor => 0 in your" | ||||
| 1442 | . " call to $class->meta->make_immutable\n"; | ||||
| 1443 | return; | ||||
| 1444 | } | ||||
| 1445 | |||||
| 1446 | my $constructor_class = $args{constructor_class}; | ||||
| 1447 | |||||
| 1448 | { | ||||
| 1449 | local $@; | ||||
| 1450 | 46 | 3.23ms | use_package_optimistically($constructor_class); # spent 3.23ms making 46 calls to Module::Runtime::use_package_optimistically, avg 70µs/call | ||
| 1451 | } | ||||
| 1452 | |||||
| 1453 | 138 | 172ms | my $constructor = $constructor_class->new( # spent 115ms making 16 calls to Moose::Meta::Method::Constructor::new, avg 7.16ms/call
# spent 57.1ms making 30 calls to Class::MOP::Method::Constructor::new, avg 1.90ms/call
# spent 60µs making 92 calls to Class::MOP::Package::name, avg 658ns/call | ||
| 1454 | options => \%args, | ||||
| 1455 | metaclass => $self, | ||||
| 1456 | is_inline => 1, | ||||
| 1457 | package_name => $self->name, | ||||
| 1458 | name => $name, | ||||
| 1459 | definition_context => { | ||||
| 1460 | description => "constructor " . $self->name . "::" . $name, | ||||
| 1461 | file => $args{file}, | ||||
| 1462 | line => $args{line}, | ||||
| 1463 | }, | ||||
| 1464 | ); | ||||
| 1465 | |||||
| 1466 | 46 | 5.75ms | if ( $args{replace_constructor} or $constructor->can_be_inlined ) { # spent 5.75ms making 46 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 125µs/call | ||
| 1467 | 46 | 4.08ms | $self->add_method( $name => $constructor ); # spent 4.08ms making 46 calls to Class::MOP::Mixin::HasMethods::add_method, avg 89µs/call | ||
| 1468 | 46 | 207µs | $self->_add_inlined_method($constructor); # spent 207µs making 46 calls to Class::MOP::Class::_add_inlined_method, avg 4µs/call | ||
| 1469 | } | ||||
| 1470 | } | ||||
| 1471 | |||||
| 1472 | # spent 13.7ms (790µs+12.9) within Class::MOP::Class::_inline_destructor which was called 16 times, avg 855µs/call:
# 16 times (790µs+12.9ms) by Class::MOP::Class::_install_inlined_code at line 1410, avg 855µs/call | ||||
| 1473 | 192 | 708µs | my ( $self, %args ) = @_; | ||
| 1474 | |||||
| 1475 | ( exists $args{destructor_class} && defined $args{destructor_class} ) | ||||
| 1476 | || $self->_throw_exception( NoDestructorClassSpecified => class_name => $self->name, | ||||
| 1477 | params => \%args, | ||||
| 1478 | ); | ||||
| 1479 | |||||
| 1480 | 16 | 423µs | if ( $self->has_method('DESTROY') && ! $args{replace_destructor} ) { # spent 423µs making 16 calls to Class::MOP::Mixin::HasMethods::has_method, avg 26µs/call | ||
| 1481 | my $class = $self->name; | ||||
| 1482 | warn "Not inlining a destructor for $class since it defines" | ||||
| 1483 | . " its own destructor.\n"; | ||||
| 1484 | return; | ||||
| 1485 | } | ||||
| 1486 | |||||
| 1487 | my $destructor_class = $args{destructor_class}; | ||||
| 1488 | |||||
| 1489 | { | ||||
| 1490 | local $@; | ||||
| 1491 | 16 | 1.16ms | use_package_optimistically($destructor_class); # spent 1.16ms making 16 calls to Module::Runtime::use_package_optimistically, avg 73µs/call | ||
| 1492 | } | ||||
| 1493 | |||||
| 1494 | 16 | 1.60ms | return unless $destructor_class->is_needed($self); # spent 1.60ms making 16 calls to Moose::Meta::Method::Destructor::is_needed, avg 100µs/call | ||
| 1495 | |||||
| 1496 | 48 | 7.31ms | my $destructor = $destructor_class->new( # spent 7.29ms making 16 calls to Moose::Meta::Method::Destructor::new, avg 456µs/call
# spent 18µs making 32 calls to Class::MOP::Package::name, avg 566ns/call | ||
| 1497 | options => \%args, | ||||
| 1498 | metaclass => $self, | ||||
| 1499 | package_name => $self->name, | ||||
| 1500 | name => 'DESTROY', | ||||
| 1501 | definition_context => { | ||||
| 1502 | description => "destructor " . $self->name . "::DESTROY", | ||||
| 1503 | file => $args{file}, | ||||
| 1504 | line => $args{line}, | ||||
| 1505 | }, | ||||
| 1506 | ); | ||||
| 1507 | |||||
| 1508 | 16 | 1.14ms | if ( $args{replace_destructor} or $destructor->can_be_inlined ) { # spent 1.14ms making 16 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 72µs/call | ||
| 1509 | 16 | 1.20ms | $self->add_method( 'DESTROY' => $destructor ); # spent 1.20ms making 16 calls to Class::MOP::Mixin::HasMethods::add_method, avg 75µs/call | ||
| 1510 | 16 | 43µs | $self->_add_inlined_method($destructor); # spent 43µs making 16 calls to Class::MOP::Class::_add_inlined_method, avg 3µs/call | ||
| 1511 | } | ||||
| 1512 | } | ||||
| 1513 | |||||
| 1514 | 1 | 14µs | 1; | ||
| 1515 | |||||
| 1516 | # ABSTRACT: Class Meta Object | ||||
| 1517 | |||||
| 1518 | __END__ | ||||
sub Class::MOP::Class::CORE:sort; # opcode |