← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 22:00:36 2010
Reported on Wed Nov 17 22:10:31 2010

Filename/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Class.pm
StatementsExecuted 123254 statements in 1.49s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
66652513222ms969msClass::MOP::Class::::initializeClass::MOP::Class::initialize (recurses: max depth 1, inclusive time 23.1ms)
730107135ms314msClass::MOP::Class::::get_all_attributesClass::MOP::Class::get_all_attributes
39021113ms938msClass::MOP::Class::::_construct_instanceClass::MOP::Class::_construct_instance
114111106ms193msClass::MOP::Class::::_single_metaclass_is_compatibleClass::MOP::Class::_single_metaclass_is_compatible
139911101ms206msClass::MOP::Class::::_single_metaclass_can_be_made_compatibleClass::MOP::Class::_single_metaclass_can_be_made_compatible
2862166.6ms763msClass::MOP::Class::::_check_metaclass_compatibilityClass::MOP::Class::_check_metaclass_compatibility (recurses: max depth 1, inclusive time 3.19ms)
14057242.8ms66.5msClass::MOP::Class::::linearized_isaClass::MOP::Class::linearized_isa
2061138.0ms311msClass::MOP::Class::::_can_fix_metaclass_incompatibilityClass::MOP::Class::_can_fix_metaclass_incompatibility
2776631.6ms202msClass::MOP::Class::::find_method_by_nameClass::MOP::Class::find_method_by_name
11411130.6ms223msClass::MOP::Class::::_check_single_metaclass_compatibilityClass::MOP::Class::_check_single_metaclass_compatibility
2663329.2ms157msClass::MOP::Class::::find_next_method_by_nameClass::MOP::Class::find_next_method_by_name
3992227.5ms239msClass::MOP::Class::::_inline_slot_initializerClass::MOP::Class::_inline_slot_initializer
2944325.1ms99.5msClass::MOP::Class::::class_precedence_listClass::MOP::Class::class_precedence_list (recurses: max depth 4, inclusive time 74.6ms)
1751121.3ms708msClass::MOP::Class::::_construct_class_instanceClass::MOP::Class::_construct_class_instance (recurses: max depth 1, inclusive time 715µs)
731118.8ms27.3msClass::MOP::Class::::CORE:sortClass::MOP::Class::CORE:sort (opcode)
3992216.2ms25.0msClass::MOP::Class::::_inline_default_valueClass::MOP::Class::_inline_default_value
2561114.6ms80.1msClass::MOP::Class::::_inline_init_attr_from_constructorClass::MOP::Class::_inline_init_attr_from_constructor
1313114.4ms218msClass::MOP::Class::::__ANON__[:1108]Class::MOP::Class::__ANON__[:1108]
2795513.7ms562msClass::MOP::Class::::new_objectClass::MOP::Class::new_object
1851112.9ms335msClass::MOP::Class::::_fix_metaclass_incompatibilityClass::MOP::Class::_fix_metaclass_incompatibility (recurses: max depth 1, inclusive time 2.32ms)
1881112.4ms2.27sClass::MOP::Class::::_post_add_attributeClass::MOP::Class::_post_add_attribute
78411511.9ms148msClass::MOP::Class::::get_meta_instanceClass::MOP::Class::get_meta_instance
812211.0ms61.9msClass::MOP::Class::::find_all_methods_by_nameClass::MOP::Class::find_all_methods_by_name
3824110.8ms17.1msClass::MOP::Class::::_real_ref_nameClass::MOP::Class::_real_ref_name
731110.7ms907msClass::MOP::Class::::_inline_constructorClass::MOP::Class::_inline_constructor
2672110.2ms42.9msClass::MOP::Class::::_inline_init_attr_from_defaultClass::MOP::Class::_inline_init_attr_from_default
941110.1ms307msClass::MOP::Class::::_immutable_metaclassClass::MOP::Class::_immutable_metaclass (recurses: max depth 1, inclusive time 1.57ms)
138119.75ms136msClass::MOP::Class::::_create_meta_instanceClass::MOP::Class::_create_meta_instance
103339.64ms32.6msClass::MOP::Class::::find_attribute_by_nameClass::MOP::Class::find_attribute_by_name
73119.45ms323msClass::MOP::Class::::_inline_slot_initializersClass::MOP::Class::_inline_slot_initializers
163118.99ms22.5msClass::MOP::Class::::_class_metaclass_is_compatibleClass::MOP::Class::_class_metaclass_is_compatible
42118.91ms555msClass::MOP::Class::::reinitializeClass::MOP::Class::reinitialize
188118.41ms2.23sClass::MOP::Class::::__ANON__[:932]Class::MOP::Class::__ANON__[:932]
111118.24ms38.8msClass::MOP::Class::::_superclasses_updatedClass::MOP::Class::_superclasses_updated
9448467.96ms1.68sClass::MOP::Class::::make_immutableClass::MOP::Class::make_immutable (recurses: max depth 1, inclusive time 5.76ms)
206117.65ms29.3msClass::MOP::Class::::_class_metaclass_can_be_made_compatibleClass::MOP::Class::_class_metaclass_can_be_made_compatible
188117.53ms9.87msClass::MOP::Class::::invalidate_meta_instancesClass::MOP::Class::invalidate_meta_instances
391327.24ms7.24msClass::MOP::Class::::_base_metaclassesClass::MOP::Class::_base_metaclasses
43117.08ms190msClass::MOP::Class::::_inline_destructorClass::MOP::Class::_inline_destructor
94226.81ms9.98msClass::MOP::Class::::_immutable_optionsClass::MOP::Class::_immutable_options
73116.52ms491msClass::MOP::Class::::_inline_new_objectClass::MOP::Class::_inline_new_object
94116.15ms1.35sClass::MOP::Class::::_install_inlined_codeClass::MOP::Class::_install_inlined_code
114336.04ms219msClass::MOP::Class::::add_around_method_modifierClass::MOP::Class::add_around_method_modifier
94115.37ms1.35sClass::MOP::Class::::_initialize_immutableClass::MOP::Class::_initialize_immutable
1115.18ms5.88msClass::MOP::Class::::BEGIN@7Class::MOP::Class::BEGIN@7
1114.84ms36.3msClass::MOP::Class::::BEGIN@9Class::MOP::Class::BEGIN@9
188114.53ms16.2msClass::MOP::Class::::_attach_attributeClass::MOP::Class::_attach_attribute
163114.44ms27.0msClass::MOP::Class::::_check_class_metaclass_compatibilityClass::MOP::Class::_check_class_metaclass_compatibility
94114.41ms311msClass::MOP::Class::::_rebless_as_immutableClass::MOP::Class::_rebless_as_immutable (recurses: max depth 1, inclusive time 1.77ms)
1114.27ms5.12msClass::MOP::Class::::BEGIN@8Class::MOP::Class::BEGIN@8
25224.25ms329msClass::MOP::Class::::createClass::MOP::Class::create
64114.07ms4.07msClass::MOP::Class::::_newClass::MOP::Class::_new
73113.18ms4.93msClass::MOP::Class::::_inline_fallback_constructorClass::MOP::Class::_inline_fallback_constructor
32113.06ms243msClass::MOP::Class::::_inline_accessorsClass::MOP::Class::_inline_accessors
1112.92ms7.37msClass::MOP::Class::::BEGIN@10Class::MOP::Class::BEGIN@10
73112.83ms24.2msClass::MOP::Class::::_inline_create_instanceClass::MOP::Class::_inline_create_instance
73112.58ms4.98msClass::MOP::Class::::_inline_preserve_weak_metaclassesClass::MOP::Class::_inline_preserve_weak_metaclasses
320112.41ms2.41msClass::MOP::Class::::is_immutableClass::MOP::Class::is_immutable
188112.34ms2.34msClass::MOP::Class::::invalidate_meta_instanceClass::MOP::Class::invalidate_meta_instance
73112.29ms26.5msClass::MOP::Class::::_inline_generate_instanceClass::MOP::Class::_inline_generate_instance
112212.22ms2.22msClass::MOP::Class::::_add_inlined_methodClass::MOP::Class::_add_inlined_method
42112.03ms2.75msClass::MOP::Class::::DESTROYClass::MOP::Class::DESTROY
1112.03ms4.58msClass::MOP::Class::::BEGIN@18Class::MOP::Class::BEGIN@18
111111.91ms1.91msClass::MOP::Class::::_superclass_metasClass::MOP::Class::_superclass_metas
9111.83ms17.3msClass::MOP::Class::::get_all_methodsClass::MOP::Class::get_all_methods
42111.81ms177msClass::MOP::Class::::_restore_metaobjects_fromClass::MOP::Class::_restore_metaobjects_from
42111.40ms1.81msClass::MOP::Class::::is_anon_classClass::MOP::Class::is_anon_class
111111.30ms1.30msClass::MOP::Class::::update_meta_instance_dependenciesClass::MOP::Class::update_meta_instance_dependencies
42111.25ms2.65msClass::MOP::Class::::_remove_generated_metaobjectsClass::MOP::Class::_remove_generated_metaobjects
1111.19ms4.90msClass::MOP::Class::::BEGIN@16Class::MOP::Class::BEGIN@16
1111.09ms1.28msClass::MOP::Class::::BEGIN@11Class::MOP::Class::BEGIN@11
22111.01ms995msClass::MOP::Class::::create_anon_classClass::MOP::Class::create_anon_class
12533868µs868µsClass::MOP::Class::::is_mutableClass::MOP::Class::is_mutable
1111587µs19.2msClass::MOP::Class::::add_before_method_modifierClass::MOP::Class::add_before_method_modifier
3111561µs561µsClass::MOP::Class::::_inline_paramsClass::MOP::Class::_inline_params
3111553µs553µsClass::MOP::Class::::_generate_fallback_constructorClass::MOP::Class::_generate_fallback_constructor
611343µs5.35msClass::MOP::Class::::add_after_method_modifierClass::MOP::Class::add_after_method_modifier
111343µs1.07msClass::MOP::Class::::_clone_instanceClass::MOP::Class::_clone_instance
8421292µs292µsClass::MOP::Class::::CORE:matchClass::MOP::Class::CORE:match (opcode)
3111233µs233µsClass::MOP::Class::::_inline_extra_initClass::MOP::Class::_inline_extra_init
11199µs1.20msClass::MOP::Class::::clone_objectClass::MOP::Class::clone_object
11198µs117µsClass::MOP::Class::::BEGIN@4Class::MOP::Class::BEGIN@4
11188µs164µsClass::MOP::Class::::BEGIN@433Class::MOP::Class::BEGIN@433
22169µs69µsClass::MOP::Class::::CORE:regcompClass::MOP::Class::CORE:regcomp (opcode)
11152µs118µsClass::MOP::Class::::BEGIN@468Class::MOP::Class::BEGIN@468
11146µs18.1msClass::MOP::Class::::BEGIN@24Class::MOP::Class::BEGIN@24
11143µs103µsClass::MOP::Class::::BEGIN@455Class::MOP::Class::BEGIN@455
11143µs248µsClass::MOP::Class::::BEGIN@17Class::MOP::Class::BEGIN@17
11140µs202µsClass::MOP::Class::::BEGIN@13Class::MOP::Class::BEGIN@13
11139µs108µsClass::MOP::Class::::BEGIN@5Class::MOP::Class::BEGIN@5
11139µs219µsClass::MOP::Class::::BEGIN@14Class::MOP::Class::BEGIN@14
11136µs165µsClass::MOP::Class::::BEGIN@15Class::MOP::Class::BEGIN@15
0000s0sClass::MOP::Class::::__ANON__[:214]Class::MOP::Class::__ANON__[:214]
0000s0sClass::MOP::Class::::__ANON__[:936]Class::MOP::Class::__ANON__[:936]
0000s0sClass::MOP::Class::::_fix_class_metaclass_incompatibilityClass::MOP::Class::_fix_class_metaclass_incompatibility
0000s0sClass::MOP::Class::::_fix_single_metaclass_incompatibilityClass::MOP::Class::_fix_single_metaclass_incompatibility
0000s0sClass::MOP::Class::::_fixup_attributes_after_reblessClass::MOP::Class::_fixup_attributes_after_rebless
0000s0sClass::MOP::Class::::_force_rebless_instanceClass::MOP::Class::_force_rebless_instance
0000s0sClass::MOP::Class::::_inline_clear_mop_slotClass::MOP::Class::_inline_clear_mop_slot
0000s0sClass::MOP::Class::::_inline_get_mop_slotClass::MOP::Class::_inline_get_mop_slot
0000s0sClass::MOP::Class::::_inline_rebless_instanceClass::MOP::Class::_inline_rebless_instance
0000s0sClass::MOP::Class::::_inline_set_mop_slotClass::MOP::Class::_inline_set_mop_slot
0000s0sClass::MOP::Class::::_inlined_methodsClass::MOP::Class::_inlined_methods
0000s0sClass::MOP::Class::::_rebless_as_mutableClass::MOP::Class::_rebless_as_mutable
0000s0sClass::MOP::Class::::_remove_inlined_codeClass::MOP::Class::_remove_inlined_code
0000s0sClass::MOP::Class::::add_dependent_meta_instanceClass::MOP::Class::add_dependent_meta_instance
0000s0sClass::MOP::Class::::add_meta_instance_dependenciesClass::MOP::Class::add_meta_instance_dependencies
0000s0sClass::MOP::Class::::direct_subclassesClass::MOP::Class::direct_subclasses
0000s0sClass::MOP::Class::::get_all_method_namesClass::MOP::Class::get_all_method_names
0000s0sClass::MOP::Class::::immutable_optionsClass::MOP::Class::immutable_options
0000s0sClass::MOP::Class::::is_pristineClass::MOP::Class::is_pristine
0000s0sClass::MOP::Class::::make_mutableClass::MOP::Class::make_mutable
0000s0sClass::MOP::Class::::rebless_instanceClass::MOP::Class::rebless_instance
0000s0sClass::MOP::Class::::rebless_instance_awayClass::MOP::Class::rebless_instance_away
0000s0sClass::MOP::Class::::rebless_instance_backClass::MOP::Class::rebless_instance_back
0000s0sClass::MOP::Class::::remove_attributeClass::MOP::Class::remove_attribute
0000s0sClass::MOP::Class::::remove_dependent_meta_instanceClass::MOP::Class::remove_dependent_meta_instance
0000s0sClass::MOP::Class::::remove_meta_instance_dependenciesClass::MOP::Class::remove_meta_instance_dependencies
0000s0sClass::MOP::Class::::subclassesClass::MOP::Class::subclasses
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1
2package Class::MOP::Class;
3
43101µs2136µs
# spent 117µs (98+19) within Class::MOP::Class::BEGIN@4 which was called: # once (98µs+19µs) by Class::MOP::BEGIN@19 at line 4
use strict;
# spent 117µs making 1 call to Class::MOP::Class::BEGIN@4 # spent 19µs making 1 call to strict::import
5398µs2177µs
# spent 108µs (39+69) within Class::MOP::Class::BEGIN@5 which was called: # once (39µs+69µs) by Class::MOP::BEGIN@19 at line 5
use warnings;
# spent 108µs making 1 call to Class::MOP::Class::BEGIN@5 # spent 69µs making 1 call to warnings::import
6
73456µs15.88ms
# spent 5.88ms (5.18+701µs) within Class::MOP::Class::BEGIN@7 which was called: # once (5.18ms+701µs) by Class::MOP::BEGIN@19 at line 7
use Class::MOP::Instance;
# spent 5.88ms making 1 call to Class::MOP::Class::BEGIN@7
83535µs15.12ms
# spent 5.12ms (4.27+854µs) within Class::MOP::Class::BEGIN@8 which was called: # once (4.27ms+854µs) by Class::MOP::BEGIN@19 at line 8
use Class::MOP::Method::Wrapped;
# spent 5.12ms making 1 call to Class::MOP::Class::BEGIN@8
93455µs136.3ms
# spent 36.3ms (4.84+31.5) within Class::MOP::Class::BEGIN@9 which was called: # once (4.84ms+31.5ms) by Class::MOP::BEGIN@19 at line 9
use Class::MOP::Method::Accessor;
# spent 36.3ms making 1 call to Class::MOP::Class::BEGIN@9
103455µs17.37ms
# spent 7.37ms (2.92+4.44) within Class::MOP::Class::BEGIN@10 which was called: # once (2.92ms+4.44ms) by Class::MOP::BEGIN@19 at line 10
use Class::MOP::Method::Constructor;
# spent 7.37ms making 1 call to Class::MOP::Class::BEGIN@10
113467µs11.28ms
# spent 1.28ms (1.09+195µs) within Class::MOP::Class::BEGIN@11 which was called: # once (1.09ms+195µs) by Class::MOP::BEGIN@19 at line 11
use Class::MOP::MiniTrait;
# spent 1.28ms making 1 call to Class::MOP::Class::BEGIN@11
12
133118µs2364µs
# spent 202µs (40+162) within Class::MOP::Class::BEGIN@13 which was called: # once (40µs+162µs) by Class::MOP::BEGIN@19 at line 13
use Carp 'confess';
# spent 202µs making 1 call to Class::MOP::Class::BEGIN@13 # spent 162µs making 1 call to Exporter::import
143116µs2400µs
# spent 219µs (39+181) within Class::MOP::Class::BEGIN@14 which was called: # once (39µs+181µs) by Class::MOP::BEGIN@19 at line 14
use Scalar::Util 'blessed', 'reftype', 'weaken';
# spent 219µs making 1 call to Class::MOP::Class::BEGIN@14 # spent 181µs making 1 call to Exporter::import
153103µs2294µs
# spent 165µs (36+129) within Class::MOP::Class::BEGIN@15 which was called: # once (36µs+129µs) by Class::MOP::BEGIN@19 at line 15
use Sub::Name 'subname';
# spent 165µs making 1 call to Class::MOP::Class::BEGIN@15 # spent 129µs making 1 call to Exporter::import
163637µs25.70ms
# spent 4.90ms (1.19+3.70) within Class::MOP::Class::BEGIN@16 which was called: # once (1.19ms+3.70ms) by Class::MOP::BEGIN@19 at line 16
use Devel::GlobalDestruction 'in_global_destruction';
# spent 4.90ms making 1 call to Class::MOP::Class::BEGIN@16 # spent 807µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
173113µs2453µs
# spent 248µs (43+205) within Class::MOP::Class::BEGIN@17 which was called: # once (43µs+205µs) by Class::MOP::BEGIN@19 at line 17
use Try::Tiny;
# spent 248µs making 1 call to Class::MOP::Class::BEGIN@17 # spent 205µs making 1 call to Exporter::import
183756µs25.17ms
# spent 4.58ms (2.03+2.55) within Class::MOP::Class::BEGIN@18 which was called: # once (2.03ms+2.55ms) by Class::MOP::BEGIN@19 at line 18
use List::MoreUtils 'all';
# spent 4.58ms making 1 call to Class::MOP::Class::BEGIN@18 # spent 588µs making 1 call to Exporter::import
19
2015µsour $VERSION = '1.11';
21188µs$VERSION = eval $VERSION;
# spent 12µs executing statements in string eval
2214µsour $AUTHORITY = 'cpan:STEVAN';
23
2410s
# spent 18.1ms (46µs+18.1) within Class::MOP::Class::BEGIN@24 which was called: # once (46µs+18.1ms) by Class::MOP::BEGIN@19 at line 26
use base 'Class::MOP::Module',
# spent 18.1ms making 1 call to base::import, recursion: max depth 1, sum of overlapping time 18.1ms
25 'Class::MOP::Mixin::HasAttributes',
2635.85ms118.1ms 'Class::MOP::Mixin::HasMethods';
# spent 18.1ms making 1 call to Class::MOP::Class::BEGIN@24
27
28# Creation
29
30
# spent 969ms (222+747) within Class::MOP::Class::initialize which was called 6665 times, avg 145µs/call: # 3137 times (97.9ms+13.3ms) by Class::MOP::Class::get_all_attributes at line 968, avg 35µs/call # 752 times (24.9ms+6.95ms) by Class::MOP::Class::find_method_by_name at line 1159, avg 42µs/call # 641 times (22.6ms+19.2ms) by Class::MOP::Class::__ANON__::SERIAL::11::meta or Class::MOP::Class::__ANON__::SERIAL::15::meta or Class::MOP::Class::__ANON__::SERIAL::19::meta or Class::MOP::Class::__ANON__::SERIAL::1::meta or Class::MOP::Class::__ANON__::SERIAL::2::meta or Class::MOP::Class::__ANON__::SERIAL::5::meta or Class::MOP::Class::__ANON__::SERIAL::8::meta or Class::MOP::Mixin::meta or Class::MOP::Object::meta or Markdent::Dialect::Standard::BlockParser::meta or Markdent::Dialect::Standard::SpanParser::meta or Markdent::Event::AutoLink::meta or Markdent::Event::EndBlockquote::meta or Markdent::Event::EndCode::meta or Markdent::Event::EndDocument::meta or Markdent::Event::EndEmphasis::meta or Markdent::Event::EndHTMLTag::meta or Markdent::Event::EndHeader::meta or Markdent::Event::EndLink::meta or Markdent::Event::EndListItem::meta or Markdent::Event::EndOrderedList::meta or Markdent::Event::EndParagraph::meta or Markdent::Event::EndStrong::meta or Markdent::Event::EndUnorderedList::meta or Markdent::Event::HTMLBlock::meta or Markdent::Event::HTMLComment::meta or Markdent::Event::HTMLCommentBlock::meta or Markdent::Event::HTMLEntity::meta or Markdent::Event::HTMLTag::meta or Markdent::Event::HorizontalRule::meta or Markdent::Event::Image::meta or Markdent::Event::Preformatted::meta or Markdent::Event::StartBlockquote::meta or Markdent::Event::StartCode::meta or Markdent::Event::StartDocument::meta or Markdent::Event::StartEmphasis::meta or Markdent::Event::StartHTMLTag::meta or Markdent::Event::StartHeader::meta or Markdent::Event::StartLink::meta or Markdent::Event::StartListItem::meta or Markdent::Event::StartOrderedList::meta or Markdent::Event::StartParagraph::meta or Markdent::Event::StartStrong::meta or Markdent::Event::StartUnorderedList::meta or Markdent::Event::Text::meta or Markdent::Handler::HTMLStream::Document::meta or Markdent::Parser::meta or Moose::Meta::Role::Application::RoleSummation::meta or Moose::Meta::Role::Application::ToClass::meta or Moose::Meta::Role::Application::ToInstance::meta or Moose::Meta::Role::Application::ToRole::meta or Moose::Meta::Role::Application::meta or Moose::Meta::Role::Composite::meta or Moose::Meta::Role::Method::Required::meta or Moose::Meta::Role::meta or Moose::Meta::TypeCoercion::Union::meta or Moose::Meta::TypeCoercion::meta or Moose::Meta::TypeConstraint::Class::meta or Moose::Meta::TypeConstraint::DuckType::meta or Moose::Meta::TypeConstraint::Enum::meta or Moose::Meta::TypeConstraint::Parameterizable::meta or Moose::Meta::TypeConstraint::Parameterized::meta or Moose::Meta::TypeConstraint::Registry::meta or Moose::Meta::TypeConstraint::Role::meta or Moose::Meta::TypeConstraint::Union::meta or Moose::Meta::TypeConstraint::meta or MooseX::Role::Parameterized::Meta::Parameter::meta or MooseX::Role::Parameterized::Meta::Role::Parameterizable::meta or MooseX::Role::Parameterized::Meta::Role::Parameterized::meta or MooseX::Role::Parameterized::Parameters::meta at line 44 of Class/MOP/Method/Meta.pm, avg 65µs/call # 547 times (18.1ms+5.38ms) by Class::MOP::Class::find_next_method_by_name at line 1208, avg 43µs/call # 253 times (7.96ms+2.24ms) by Class::MOP::Class::find_all_methods_by_name at line 1191, avg 40µs/call # 232 times (7.70ms+2.23ms) by Class::MOP::Class::class_precedence_list at line 1068, avg 43µs/call # 209 times (6.64ms+2.02ms) by Moose::Meta::Attribute::_new or Moose::Meta::Method::_new or Moose::Meta::Role::_new at line 4 of generated method (unknown origin), avg 41µs/call # 206 times (7.26ms+1.46ms) by Class::MOP::Class::_fix_metaclass_incompatibility at line 298, avg 42µs/call # 194 times (6.04ms+1.66ms) by Class::MOP::Class::find_attribute_by_name at line 958, avg 40µs/call # 111 times (7.69ms+627ms) by Moose::Meta::Class::initialize at line 68 of Moose/Meta/Class.pm, avg 5.71ms/call # 98 times (3.33ms+1.05ms) by Class::MOP::Attribute::set_initial_value at line 259 of Class/MOP/Attribute.pm, avg 45µs/call # 80 times (2.90ms+830µs) by Moose::Util::MetaRole::_make_new_class at line 157 of Moose/Util/MetaRole.pm, avg 47µs/call # 49 times (2.36ms+586µs) by namespace::autoclean::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/namespace/autoclean.pm:57] at line 44 of namespace/autoclean.pm, avg 60µs/call # 33 times (1.39ms+25.4ms) by Class::MOP::Object::meta at line 18 of Class/MOP/Object.pm, avg 812µs/call # 26 times (834µs+7.58ms) by Class::MOP::Method::_new at line 54 of Class/MOP/Method.pm, avg 324µs/call # 19 times (996µs+7.73ms) by metaclass::import at line 45 of metaclass.pm, avg 459µs/call # 18 times (692µs+6.40ms) by Class::MOP::Mixin::meta at line 14 of Class/MOP/Mixin.pm, avg 394µs/call # 15 times (701µs+12.7ms) by Class::MOP::MiniTrait::apply at line 15 of Class/MOP/MiniTrait.pm, avg 896µs/call # 14 times (552µs+159µs) by Class::MOP::Attribute::get_raw_value at line 295 of Class/MOP/Attribute.pm, avg 51µs/call # 11 times (329µs+89µs) by Class::MOP::Class::get_all_methods at line 1170, avg 38µs/call # 8 times (282µs+87µs) by Class::MOP::Attribute::has_value at line 316 of Class/MOP/Attribute.pm, avg 46µs/call # 7 times (325µs+2.67ms) by Moose::BEGIN@38 at line 11 of Moose/Meta/Attribute/Native.pm, avg 428µs/call # 2 times (89µs+873µs) by Class::MOP::Class::create at line 513, avg 481µs/call # 2 times (57µs+17µs) by Class::MOP::Attribute::set_raw_value at line 272 of Class/MOP/Attribute.pm, avg 37µs/call # once (32µs+10µs) by Class::MOP::Attribute::_new at line 62 of Class/MOP/Attribute.pm
sub initialize {
3133325211ms my $class = shift;
32
33 my $package_name;
34
35 if ( @_ % 2 ) {
36 $package_name = shift;
37 } else {
38 my %options = @_;
39 $package_name = $options{package};
40 }
41
42 ($package_name && !ref($package_name))
43 || confess "You must pass a package name and it cannot be blessed";
44
456840770ms return Class::MOP::get_metaclass_by_name($package_name)
# spent 709ms making 175 calls to Class::MOP::Class::_construct_class_instance, avg 4.05ms/call, recursion: max depth 1, sum of overlapping time 715µs # spent 61.9ms making 6665 calls to Class::MOP::get_metaclass_by_name, avg 9µs/call
46 || $class->_construct_class_instance(package => $package_name, @_);
47}
48
49
# spent 555ms (8.91+546) within Class::MOP::Class::reinitialize which was called 42 times, avg 13.2ms/call: # 42 times (8.91ms+546ms) by Moose::Meta::Class::reinitialize at line 157 of Moose/Meta/Class.pm, avg 13.2ms/call
sub reinitialize {
5037810.2ms my ( $class, @args ) = @_;
51 unshift @args, "package" if @args % 2;
52 my %options = @args;
5342278µs my $old_metaclass = blessed($options{package})
# spent 278µs making 42 calls to Scalar::Util::blessed, avg 7µs/call
54 ? $options{package}
55 : Class::MOP::get_metaclass_by_name($options{package});
561681.68ms $options{weaken} = Class::MOP::metaclass_is_weak($old_metaclass->name)
# spent 1.01ms making 42 calls to Class::MOP::metaclass_is_weak, avg 24µs/call # spent 250µs making 42 calls to UNIVERSAL::isa, avg 6µs/call # spent 231µs making 42 calls to Scalar::Util::blessed, avg 6µs/call # spent 189µs making 42 calls to Class::MOP::Package::name, avg 4µs/call
57 if !exists $options{weaken}
58 && blessed($old_metaclass)
59 && $old_metaclass->isa('Class::MOP::Class');
60842.87ms $old_metaclass->_remove_generated_metaobjects
# spent 2.65ms making 42 calls to Class::MOP::Class::_remove_generated_metaobjects, avg 63µs/call # spent 220µs making 42 calls to UNIVERSAL::isa, avg 5µs/call
61 if $old_metaclass && $old_metaclass->isa('Class::MOP::Class');
6242363ms my $new_metaclass = $class->SUPER::reinitialize(%options);
# spent 363ms making 42 calls to Class::MOP::Package::reinitialize, avg 8.65ms/call
6384178ms $new_metaclass->_restore_metaobjects_from($old_metaclass)
# spent 177ms making 42 calls to Class::MOP::Class::_restore_metaobjects_from, avg 4.22ms/call # spent 297µs making 42 calls to UNIVERSAL::isa, avg 7µs/call
64 if $old_metaclass && $old_metaclass->isa('Class::MOP::Class');
65 return $new_metaclass;
66}
67
68# NOTE: (meta-circularity)
69# this is a special form of _construct_instance
70# (see below), which is used to construct class
71# meta-object instances for any Class::MOP::*
72# class. All other classes will use the more
73# normal &construct_instance.
74
# spent 708ms (21.3+687) within Class::MOP::Class::_construct_class_instance which was called 175 times, avg 4.05ms/call: # 175 times (21.3ms+687ms) by Class::MOP::Class::initialize at line 45, avg 4.05ms/call
sub _construct_class_instance {
75210016.8ms my $class = shift;
76 my $options = @_ == 1 ? $_[0] : {@_};
77 my $package_name = $options->{package};
78 (defined $package_name && $package_name)
79 || confess "You must pass a package name";
80 # NOTE:
81 # return the metaclass if we have it cached,
82 # and it is still defined (it has not been
83 # reaped by DESTROY yet, which can happen
84 # annoyingly enough during global destruction)
85
861751.38ms if (defined(my $meta = Class::MOP::get_metaclass_by_name($package_name))) {
# spent 1.38ms making 175 calls to Class::MOP::get_metaclass_by_name, avg 8µs/call
87 return $meta;
88 }
89
90 $class
91101.01ms = ref $class
# spent 1.01ms making 10 calls to Class::MOP::Class::_real_ref_name, avg 101µs/call
92 ? $class->_real_ref_name
93 : $class;
94
95 # now create the metaclass
96 my $meta;
971112.91ms644.07ms if ($class eq 'Class::MOP::Class') {
# spent 4.07ms making 64 calls to Class::MOP::Class::_new, avg 64µs/call
98 $meta = $class->_new($options);
99 }
100 else {
101 # NOTE:
102 # it is safe to use meta here because
103 # class will always be a subclass of
104 # Class::MOP::Class, which defines meta
105222406ms $meta = $class->meta->_construct_instance($options)
# spent 396ms making 111 calls to Class::MOP::Class::_construct_instance, avg 3.57ms/call # spent 6.53ms making 73 calls to Class::MOP::Object::meta, avg 89µs/call # spent 3.12ms making 38 calls to Class::MOP::Class::__ANON__::SERIAL::2::meta, avg 82µs/call
106 }
107
108 # and check the metaclass compatibility
109175270ms $meta->_check_metaclass_compatibility();
# spent 273ms making 175 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 1.56ms/call, recursion: max depth 1, sum of overlapping time 3.19ms
110
1111752.39ms Class::MOP::store_metaclass_by_name($package_name, $meta);
# spent 2.39ms making 175 calls to Class::MOP::store_metaclass_by_name, avg 14µs/call
112
113 # NOTE:
114 # we need to weaken any anon classes
115 # so that they can call DESTROY properly
116257µs Class::MOP::weaken_metaclass($package_name) if $options->{weaken};
# spent 57µs making 2 calls to Class::MOP::weaken_metaclass, avg 29µs/call
117
118 $meta;
119}
120
121
# spent 17.1ms (10.8+6.34) within Class::MOP::Class::_real_ref_name which was called 382 times, avg 45µs/call: # 206 times (5.84ms+3.38ms) by Class::MOP::Class::_class_metaclass_can_be_made_compatible at line 343, avg 45µs/call # 163 times (4.50ms+2.25ms) by Class::MOP::Class::_class_metaclass_is_compatible at line 253, avg 41µs/call # 10 times (367µs+645µs) by Class::MOP::Class::_construct_class_instance at line 91, avg 101µs/call # 3 times (90µs+71µs) by Class::MOP::Class::_immutable_metaclass at line 1385, avg 54µs/call
sub _real_ref_name {
12276410.2ms my $self = shift;
123
124 # NOTE: we need to deal with the possibility of class immutability here,
125 # and then get the name of the class appropriately
1264446.34ms return $self->is_immutable
# spent 2.74ms making 56 calls to Class::MOP::Class::Immutable::Class::MOP::Class::is_immutable, avg 49µs/call # spent 2.41ms making 320 calls to Class::MOP::Class::is_immutable, avg 8µs/call # spent 890µs making 62 calls to Class::MOP::Class::Immutable::Trait::_get_mutable_metaclass_name, avg 14µs/call # spent 300µs making 6 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::is_immutable, avg 50µs/call
127 ? $self->_get_mutable_metaclass_name()
128 : ref $self;
129}
130
131
# spent 4.07ms within Class::MOP::Class::_new which was called 64 times, avg 64µs/call: # 64 times (4.07ms+0s) by Class::MOP::Class::_construct_class_instance at line 97, avg 64µs/call
sub _new {
1322564.32ms my $class = shift;
133
134 return Class::MOP::Class->initialize($class)->new_object(@_)
135 if $class ne __PACKAGE__;
136
137 my $options = @_ == 1 ? $_[0] : {@_};
138
139 return bless {
140 # inherited from Class::MOP::Package
141 'package' => $options->{package},
142
143 # NOTE:
144 # since the following attributes will
145 # actually be loaded from the symbol
146 # table, and actually bypass the instance
147 # entirely, we can just leave these things
148 # listed here for reference, because they
149 # should not actually have a value associated
150 # with the slot.
151 'namespace' => \undef,
152 'methods' => {},
153
154 # inherited from Class::MOP::Module
155 'version' => \undef,
156 'authority' => \undef,
157
158 # defined in Class::MOP::Class
159 'superclasses' => \undef,
160
161 'attributes' => {},
162 'attribute_metaclass' =>
163 ( $options->{'attribute_metaclass'} || 'Class::MOP::Attribute' ),
164 'method_metaclass' =>
165 ( $options->{'method_metaclass'} || 'Class::MOP::Method' ),
166 'wrapped_method_metaclass' => (
167 $options->{'wrapped_method_metaclass'}
168 || 'Class::MOP::Method::Wrapped'
169 ),
170 'instance_metaclass' =>
171 ( $options->{'instance_metaclass'} || 'Class::MOP::Instance' ),
172 'immutable_trait' => (
173 $options->{'immutable_trait'}
174 || 'Class::MOP::Class::Immutable::Trait'
175 ),
176 'constructor_name' => ( $options->{constructor_name} || 'new' ),
177 'constructor_class' => (
178 $options->{constructor_class} || 'Class::MOP::Method::Constructor'
179 ),
180 'destructor_class' => $options->{destructor_class},
181 }, $class;
182}
183
184## Metaclass compatibility
185{
186222µs my %base_metaclass = (
187 attribute_metaclass => 'Class::MOP::Attribute',
188 method_metaclass => 'Class::MOP::Method',
189 wrapped_method_metaclass => 'Class::MOP::Method::Wrapped',
190 instance_metaclass => 'Class::MOP::Instance',
191 constructor_class => 'Class::MOP::Method::Constructor',
192 destructor_class => 'Class::MOP::Method::Destructor',
193 );
194
1953919.03ms
# spent 7.24ms within Class::MOP::Class::_base_metaclasses which was called 391 times, avg 19µs/call: # 314 times (5.93ms+0s) by Moose::Meta::Class::_base_metaclasses at line 538 of Moose/Meta/Class.pm, avg 19µs/call # 43 times (765µs+0s) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 331, avg 18µs/call # 34 times (543µs+0s) by Class::MOP::Class::_check_metaclass_compatibility at line 206, avg 16µs/call
sub _base_metaclasses { %base_metaclass }
196}
197
198
# spent 763ms (66.6+697) within Class::MOP::Class::_check_metaclass_compatibility which was called 286 times, avg 2.67ms/call: # 175 times (22.3ms+247ms) by Class::MOP::Class::_construct_class_instance at line 109, avg 1.54ms/call # 111 times (44.3ms+449ms) by Class::MOP::Class::superclasses at line 998, avg 4.45ms/call
sub _check_metaclass_compatibility {
199142919.4ms my $self = shift;
200
20128642.5ms my @superclasses = $self->superclasses
# spent 52.4ms making 220 calls to Moose::Meta::Class::superclasses, avg 238µs/call, recursion: max depth 1, sum of overlapping time 20.5ms # spent 11.0ms making 66 calls to Class::MOP::Class::superclasses, avg 166µs/call, recursion: max depth 1, sum of overlapping time 428µs
202 or return;
203
204185335ms $self->_fix_metaclass_incompatibility(@superclasses);
# spent 337ms making 185 calls to Class::MOP::Class::_fix_metaclass_incompatibility, avg 1.82ms/call, recursion: max depth 1, sum of overlapping time 2.32ms
205
20618533.8ms my %base_metaclass = $self->_base_metaclasses;
# spent 33.2ms making 151 calls to Moose::Meta::Class::_base_metaclasses, avg 220µs/call # spent 543µs making 34 calls to Class::MOP::Class::_base_metaclasses, avg 16µs/call
207
208 # this is always okay ...
209 return
210 if ref($self) eq 'Class::MOP::Class'
211 && all {
2124084.21ms2041.05ms my $meta = $self->$_;
# spent 189µs making 34 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 6µs/call # spent 180µs making 34 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call # spent 177µs making 34 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call # spent 168µs making 34 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call # spent 167µs making 34 calls to Class::MOP::Class::constructor_class, avg 5µs/call # spent 166µs making 34 calls to Class::MOP::Class::destructor_class, avg 5µs/call
21311.22ms !defined($meta) || $meta eq $base_metaclass{$_};
214 }
215345.09ms keys %base_metaclass;
# spent 5.09ms making 34 calls to List::MoreUtils::all, avg 150µs/call
216
217 for my $superclass (@superclasses) {
2181632.75ms16327.0ms $self->_check_class_metaclass_compatibility($superclass);
# spent 27.0ms making 163 calls to Class::MOP::Class::_check_class_metaclass_compatibility, avg 165µs/call
219 }
220
221 for my $metaclass_type ( keys %base_metaclass ) {
222211425.6ms105710.2ms next unless defined $self->$metaclass_type;
# spent 2.20ms making 151 calls to Moose::Meta::Class::error_class, avg 15µs/call # spent 2.12ms making 151 calls to Moose::Meta::Class::constructor_class, avg 14µs/call # spent 2.10ms making 151 calls to Moose::Meta::Class::destructor_class, avg 14µs/call # spent 1.02ms making 151 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 7µs/call # spent 977µs making 151 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 6µs/call # spent 900µs making 151 calls to Class::MOP::Class::instance_metaclass, avg 6µs/call # spent 835µs making 151 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 6µs/call
223 for my $superclass (@superclasses) {
224114117.0ms1141223ms $self->_check_single_metaclass_compatibility( $metaclass_type,
# spent 223ms making 1141 calls to Class::MOP::Class::_check_single_metaclass_compatibility, avg 196µs/call
225 $superclass );
226 }
227 }
228}
229
230
# spent 27.0ms (4.44+22.5) within Class::MOP::Class::_check_class_metaclass_compatibility which was called 163 times, avg 165µs/call: # 163 times (4.44ms+22.5ms) by Class::MOP::Class::_check_metaclass_compatibility at line 218, avg 165µs/call
sub _check_class_metaclass_compatibility {
2314894.13ms my $self = shift;
232 my ( $superclass_name ) = @_;
233
23416322.5ms if (!$self->_class_metaclass_is_compatible($superclass_name)) {
# spent 22.5ms making 163 calls to Class::MOP::Class::_class_metaclass_is_compatible, avg 138µs/call
235 my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name);
236
237 my $super_meta_type = $super_meta->_real_ref_name;
238
239 confess "The metaclass of " . $self->name . " ("
240 . (ref($self)) . ")" . " is not compatible with "
241 . "the metaclass of its superclass, "
242 . $superclass_name . " (" . ($super_meta_type) . ")";
243 }
244}
245
246
# spent 22.5ms (8.99+13.5) within Class::MOP::Class::_class_metaclass_is_compatible which was called 163 times, avg 138µs/call: # 163 times (8.99ms+13.5ms) by Class::MOP::Class::_check_class_metaclass_compatibility at line 234, avg 138µs/call
sub _class_metaclass_is_compatible {
2478157.98ms my $self = shift;
248 my ( $superclass_name ) = @_;
249
2501631.65ms my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name)
# spent 1.65ms making 163 calls to Class::MOP::get_metaclass_by_name, avg 10µs/call
251 || return 1;
252
2531636.75ms my $super_meta_name = $super_meta->_real_ref_name;
# spent 6.75ms making 163 calls to Class::MOP::Class::_real_ref_name, avg 41µs/call
254
2551635.15ms return $self->_is_compatible_with($super_meta_name);
# spent 5.15ms making 163 calls to Class::MOP::Object::_is_compatible_with, avg 32µs/call
256}
257
258
# spent 223ms (30.6+193) within Class::MOP::Class::_check_single_metaclass_compatibility which was called 1141 times, avg 196µs/call: # 1141 times (30.6ms+193ms) by Class::MOP::Class::_check_metaclass_compatibility at line 224, avg 196µs/call
sub _check_single_metaclass_compatibility {
259342329.4ms my $self = shift;
260 my ( $metaclass_type, $superclass_name ) = @_;
261
2621141193ms if (!$self->_single_metaclass_is_compatible($metaclass_type, $superclass_name)) {
# spent 193ms making 1141 calls to Class::MOP::Class::_single_metaclass_is_compatible, avg 169µs/call
263 my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name);
264 my $metaclass_type_name = $metaclass_type;
265 $metaclass_type_name =~ s/_(?:meta)?class$//;
266 $metaclass_type_name =~ s/_/ /g;
267 confess "The $metaclass_type_name metaclass for "
268 . $self->name . " (" . ($self->$metaclass_type)
269 . ")" . " is not compatible with the "
270 . "$metaclass_type_name metaclass of its "
271 . "superclass, $superclass_name ("
272 . ($super_meta->$metaclass_type) . ")";
273 }
274}
275
276
# spent 193ms (106+86.7) within Class::MOP::Class::_single_metaclass_is_compatible which was called 1141 times, avg 169µs/call: # 1141 times (106ms+86.7ms) by Class::MOP::Class::_check_single_metaclass_compatibility at line 262, avg 169µs/call
sub _single_metaclass_is_compatible {
2777842117ms my $self = shift;
278 my ( $metaclass_type, $superclass_name ) = @_;
279
28011419.60ms my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name)
# spent 9.60ms making 1141 calls to Class::MOP::get_metaclass_by_name, avg 8µs/call
281 || return 1;
282
283 # for instance, Moose::Meta::Class has a error_class attribute, but
284 # Class::MOP::Class doesn't - this shouldn't be an error
28511417.31ms return 1 unless $super_meta->can($metaclass_type);
# spent 7.31ms making 1141 calls to UNIVERSAL::can, avg 6µs/call
286 # for instance, Moose::Meta::Class has a destructor_class, but
287 # Class::MOP::Class doesn't - this shouldn't be an error
28811128.80ms return 1 unless defined $super_meta->$metaclass_type;
# spent 1.71ms making 134 calls to Moose::Meta::Class::error_class, avg 13µs/call # spent 1.62ms making 134 calls to Moose::Meta::Class::destructor_class, avg 12µs/call # spent 1.61ms making 134 calls to Moose::Meta::Class::constructor_class, avg 12µs/call # spent 950µs making 163 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 6µs/call # spent 885µs making 163 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call # spent 883µs making 163 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call # spent 849µs making 163 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call # spent 154µs making 29 calls to Class::MOP::Class::constructor_class, avg 5µs/call # spent 147µs making 29 calls to Class::MOP::Class::destructor_class, avg 5µs/call
289 # if metaclass is defined in superclass but not here, it's not compatible
290 # this is a really odd case
29110838.37ms return 0 unless defined $self->$metaclass_type;
# spent 1.95ms making 163 calls to Moose::Meta::Class::constructor_class, avg 12µs/call # spent 1.64ms making 134 calls to Moose::Meta::Class::error_class, avg 12µs/call # spent 1.59ms making 134 calls to Moose::Meta::Class::destructor_class, avg 12µs/call # spent 817µs making 163 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call # spent 803µs making 163 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 5µs/call # spent 802µs making 163 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call # spent 771µs making 163 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call
292
293324952.6ms return $self->$metaclass_type->_is_compatible_with($super_meta->$metaclass_type);
# spent 36.9ms making 1083 calls to Class::MOP::Object::_is_compatible_with, avg 34µs/call # spent 3.44ms making 297 calls to Moose::Meta::Class::constructor_class, avg 12µs/call # spent 3.15ms making 268 calls to Moose::Meta::Class::error_class, avg 12µs/call # spent 3.08ms making 268 calls to Moose::Meta::Class::destructor_class, avg 11µs/call # spent 1.53ms making 326 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call # spent 1.50ms making 326 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 5µs/call # spent 1.48ms making 326 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call # spent 1.43ms making 326 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 4µs/call # spent 147µs making 29 calls to Class::MOP::Class::constructor_class, avg 5µs/call
294}
295
296
# spent 335ms (12.9+322) within Class::MOP::Class::_fix_metaclass_incompatibility which was called 185 times, avg 1.81ms/call: # 185 times (12.9ms+322ms) by Class::MOP::Class::_check_metaclass_compatibility at line 204, avg 1.81ms/call
sub _fix_metaclass_incompatibility {
2979256.13ms my $self = shift;
2982062.52ms2068.73ms my @supers = map { Class::MOP::Class->initialize($_) } @_;
# spent 13.0ms making 206 calls to Class::MOP::Class::initialize, avg 63µs/call, recursion: max depth 1, sum of overlapping time 4.32ms
299
300 my $necessary = 0;
301 for my $super (@supers) {
3022063.37ms206311ms $necessary = 1
# spent 311ms making 206 calls to Class::MOP::Class::_can_fix_metaclass_incompatibility, avg 1.51ms/call
303 if $self->_can_fix_metaclass_incompatibility($super);
304 }
305 return unless $necessary;
306
307 for my $super (@supers) {
308 if (!$self->_class_metaclass_is_compatible($super->name)) {
309 $self->_fix_class_metaclass_incompatibility($super);
310 }
311 }
312
313 my %base_metaclass = $self->_base_metaclasses;
314 for my $metaclass_type (keys %base_metaclass) {
315 for my $super (@supers) {
316 if (!$self->_single_metaclass_is_compatible($metaclass_type, $super->name)) {
317 $self->_fix_single_metaclass_incompatibility(
318 $metaclass_type, $super
319 );
320 }
321 }
322 }
323}
324
325
# spent 311ms (38.0+273) within Class::MOP::Class::_can_fix_metaclass_incompatibility which was called 206 times, avg 1.51ms/call: # 206 times (38.0ms+273ms) by Class::MOP::Class::_fix_metaclass_incompatibility at line 302, avg 1.51ms/call
sub _can_fix_metaclass_incompatibility {
326123614.3ms my $self = shift;
327 my ($super_meta) = @_;
328
32920629.3ms return 1 if $self->_class_metaclass_can_be_made_compatible($super_meta);
# spent 29.3ms making 206 calls to Class::MOP::Class::_class_metaclass_can_be_made_compatible, avg 142µs/call
330
33120638.0ms my %base_metaclass = $self->_base_metaclasses;
# spent 37.2ms making 163 calls to Moose::Meta::Class::_base_metaclasses, avg 228µs/call # spent 765µs making 43 calls to Class::MOP::Class::_base_metaclasses, avg 18µs/call
332 for my $metaclass_type (keys %base_metaclass) {
333139920.5ms1399206ms return 1 if $self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type);
# spent 206ms making 1399 calls to Class::MOP::Class::_single_metaclass_can_be_made_compatible, avg 147µs/call
334 }
335
336 return;
337}
338
339
# spent 29.3ms (7.65+21.6) within Class::MOP::Class::_class_metaclass_can_be_made_compatible which was called 206 times, avg 142µs/call: # 206 times (7.65ms+21.6ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 329, avg 142µs/call
sub _class_metaclass_can_be_made_compatible {
3406187.48ms my $self = shift;
341 my ($super_meta) = @_;
342
34341221.6ms return $self->_can_be_made_compatible_with($super_meta->_real_ref_name);
# spent 12.4ms making 206 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 60µs/call # spent 9.21ms making 206 calls to Class::MOP::Class::_real_ref_name, avg 45µs/call
344}
345
346
# spent 206ms (101+105) within Class::MOP::Class::_single_metaclass_can_be_made_compatible which was called 1399 times, avg 147µs/call: # 1399 times (101ms+105ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 333, avg 147µs/call
sub _single_metaclass_can_be_made_compatible {
34710932116ms my $self = shift;
348 my ($super_meta, $metaclass_type) = @_;
349
350139912.6ms my $specific_meta = $self->$metaclass_type;
# spent 2.51ms making 163 calls to Moose::Meta::Class::error_class, avg 15µs/call # spent 2.48ms making 163 calls to Moose::Meta::Class::constructor_class, avg 15µs/call # spent 2.23ms making 163 calls to Moose::Meta::Class::destructor_class, avg 14µs/call # spent 1.40ms making 206 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 7µs/call # spent 1.26ms making 206 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 6µs/call # spent 1.26ms making 206 calls to Class::MOP::Class::instance_metaclass, avg 6µs/call # spent 1.07ms making 206 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call # spent 217µs making 43 calls to Class::MOP::Class::constructor_class, avg 5µs/call # spent 206µs making 43 calls to Class::MOP::Class::destructor_class, avg 5µs/call
351
35213999.29ms return unless $super_meta->can($metaclass_type);
# spent 9.29ms making 1399 calls to UNIVERSAL::can, avg 7µs/call
353137010.2ms my $super_specific_meta = $super_meta->$metaclass_type;
# spent 1.71ms making 134 calls to Moose::Meta::Class::error_class, avg 13µs/call # spent 1.65ms making 134 calls to Moose::Meta::Class::destructor_class, avg 12µs/call # spent 1.64ms making 134 calls to Moose::Meta::Class::constructor_class, avg 12µs/call # spent 1.14ms making 206 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 6µs/call # spent 1.11ms making 206 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call # spent 1.09ms making 206 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call # spent 1.08ms making 206 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call # spent 377µs making 72 calls to Class::MOP::Class::constructor_class, avg 5µs/call # spent 372µs making 72 calls to Class::MOP::Class::destructor_class, avg 5µs/call
354
355 # for instance, Moose::Meta::Class has a destructor_class, but
356 # Class::MOP::Class doesn't - this shouldn't be an error
357 return unless defined $super_specific_meta;
358
359 # if metaclass is defined in superclass but not here, it's fixable
360 # this is a really odd case
361 return 1 unless defined $specific_meta;
362
363129872.7ms return 1 if $specific_meta->_can_be_made_compatible_with($super_specific_meta);
# spent 72.7ms making 1298 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 56µs/call
364}
365
366sub _fix_class_metaclass_incompatibility {
367 my $self = shift;
368 my ( $super_meta ) = @_;
369
370 if ($self->_class_metaclass_can_be_made_compatible($super_meta)) {
371 ($self->is_pristine)
372 || confess "Can't fix metaclass incompatibility for "
373 . $self->name
374 . " because it is not pristine.";
375
376 my $super_meta_name = $super_meta->_real_ref_name;
377
378 $self->_make_compatible_with($super_meta_name);
379 }
380}
381
382sub _fix_single_metaclass_incompatibility {
383 my $self = shift;
384 my ( $metaclass_type, $super_meta ) = @_;
385
386 if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) {
387 ($self->is_pristine)
388 || confess "Can't fix metaclass incompatibility for "
389 . $self->name
390 . " because it is not pristine.";
391
392 my $new_metaclass = $self->$metaclass_type
393 ? $self->$metaclass_type->_get_compatible_metaclass($super_meta->$metaclass_type)
394 : $super_meta->$metaclass_type;
395 $self->{$metaclass_type} = $new_metaclass;
396 }
397}
398
399
# spent 177ms (1.81+175) within Class::MOP::Class::_restore_metaobjects_from which was called 42 times, avg 4.22ms/call: # 42 times (1.81ms+175ms) by Class::MOP::Class::reinitialize at line 63, avg 4.22ms/call
sub _restore_metaobjects_from {
4001681.74ms my $self = shift;
401 my ($old_meta) = @_;
402
40342172ms $self->_restore_metamethods_from($old_meta);
# spent 172ms making 42 calls to Class::MOP::Mixin::HasMethods::_restore_metamethods_from, avg 4.10ms/call
404423.33ms $self->_restore_metaattributes_from($old_meta);
# spent 3.33ms making 42 calls to Class::MOP::Mixin::HasAttributes::_restore_metaattributes_from, avg 79µs/call
405}
406
407
# spent 2.65ms (1.25+1.40) within Class::MOP::Class::_remove_generated_metaobjects which was called 42 times, avg 63µs/call: # 42 times (1.25ms+1.40ms) by Class::MOP::Class::reinitialize at line 60, avg 63µs/call
sub _remove_generated_metaobjects {
408841.20ms my $self = shift;
409
410421.40ms for my $attr (map { $self->get_attribute($_) } $self->get_attribute_list) {
# spent 1.40ms making 42 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 33µs/call
411 $attr->remove_accessors;
412 }
413}
414
415## ANON classes
416
417{
418 # NOTE:
419 # this should be sufficient, if you have a
420 # use case where it is not, write a test and
421 # I will change it.
42239µs my $ANON_CLASS_SERIAL = 0;
423
424 # NOTE:
425 # we need a sufficiently annoying prefix
426 # this should suffice for now, this is
427 # used in a couple of places below, so
428 # need to put it up here for now.
429 my $ANON_CLASS_PREFIX = 'Class::MOP::Class::__ANON__::SERIAL::';
430
431
# spent 1.81ms (1.40+414µs) within Class::MOP::Class::is_anon_class which was called 42 times, avg 43µs/call: # 42 times (1.40ms+414µs) by Moose::Meta::Class::reinitialize at line 153 of Moose/Meta/Class.pm, avg 43µs/call
sub is_anon_class {
432841.85ms my $self = shift;
4333478µs2241µs
# spent 164µs (88+77) within Class::MOP::Class::BEGIN@433 which was called: # once (88µs+77µs) by Class::MOP::BEGIN@19 at line 433
no warnings 'uninitialized';
# spent 164µs making 1 call to Class::MOP::Class::BEGIN@433 # spent 76µs making 1 call to warnings::unimport
43485414µs $self->name =~ /^$ANON_CLASS_PREFIX/o;
# spent 209µs making 42 calls to Class::MOP::Package::name, avg 5µs/call # spent 170µs making 42 calls to Class::MOP::Class::CORE:match, avg 4µs/call # spent 34µs making 1 call to Class::MOP::Class::CORE:regcomp
435 }
436
437
# spent 995ms (1.01+994) within Class::MOP::Class::create_anon_class which was called 22 times, avg 45.2ms/call: # 22 times (1.01ms+994ms) by Moose::Meta::Class::create_anon_class at line 111 of Moose/Meta/Class.pm, avg 45.2ms/call
sub create_anon_class {
43888969µs my ($class, %options) = @_;
439 $options{weaken} = 1 unless exists $options{weaken};
440 my $package_name = $ANON_CLASS_PREFIX . ++$ANON_CLASS_SERIAL;
44122994ms return $class->create($package_name, %options);
# spent 994ms making 22 calls to Moose::Meta::Class::create, avg 45.2ms/call
442 }
443
444 # NOTE:
445 # this will only get called for
446 # anon-classes, all other calls
447 # are assumed to occur during
448 # global destruction and so don't
449 # really need to be handled explicitly
450
# spent 2.75ms (2.03+713µs) within Class::MOP::Class::DESTROY which was called 42 times, avg 65µs/call: # 42 times (2.03ms+713µs) by Moose::Util::MetaRole::apply_metaroles at line 627 of Moose/Exporter.pm, avg 65µs/call
sub DESTROY {
4511683.51ms my $self = shift;
452
45342329µs return if in_global_destruction(); # it'll happen soon anyway and this just makes things more complicated
# spent 329µs making 42 calls to Devel::GlobalDestruction::in_global_destruction, avg 8µs/call
454
4553268µs2164µs
# spent 103µs (43+60) within Class::MOP::Class::BEGIN@455 which was called: # once (43µs+60µs) by Class::MOP::BEGIN@19 at line 455
no warnings 'uninitialized';
# spent 103µs making 1 call to Class::MOP::Class::BEGIN@455 # spent 60µs making 1 call to warnings::unimport
45642229µs my $name = $self->name;
# spent 229µs making 42 calls to Class::MOP::Package::name, avg 5µs/call
45743156µs return unless $name =~ /^$ANON_CLASS_PREFIX/o;
# spent 121µs making 42 calls to Class::MOP::Class::CORE:match, avg 3µs/call # spent 35µs making 1 call to Class::MOP::Class::CORE:regcomp
458
459 # Moose does a weird thing where it replaces the metaclass for
460 # class when fixing metaclass incompatibility. In that case,
461 # we don't want to clean out the namespace now. We can detect
462 # that because Moose will explicitly update the singleton
463 # cache in Class::MOP.
464 my $current_meta = Class::MOP::get_metaclass_by_name($name);
465 return if $current_meta ne $self;
466
467 my ($serial_id) = ($name =~ /^$ANON_CLASS_PREFIX(\d+)/o);
468316.5ms2183µs
# spent 118µs (52+65) within Class::MOP::Class::BEGIN@468 which was called: # once (52µs+65µs) by Class::MOP::BEGIN@19 at line 468
no strict 'refs';
# spent 118µs making 1 call to Class::MOP::Class::BEGIN@468 # spent 66µs making 1 call to strict::unimport
469 @{$name . '::ISA'} = ();
470 %{$name . '::'} = ();
471 delete ${$ANON_CLASS_PREFIX}{$serial_id . '::'};
472
473 Class::MOP::remove_metaclass_by_name($name);
474 }
475
476}
477
478# creating classes with MOP ...
479
480
# spent 329ms (4.25+325) within Class::MOP::Class::create which was called 25 times, avg 13.2ms/call: # 23 times (3.91ms+314ms) by Moose::Meta::Class::create at line 85 of Moose/Meta/Class.pm, avg 13.8ms/call # 2 times (344µs+10.5ms) by Class::MOP::Class::_immutable_metaclass at line 1387, avg 5.43ms/call
sub create {
4814254.05ms my ( $class, @args ) = @_;
482
483 unshift @args, 'package' if @args % 2 == 1;
484
485 my (%options) = @args;
486 my $package_name = $options{package};
487
488 (ref $options{superclasses} eq 'ARRAY')
489 || confess "You must pass an ARRAY ref of superclasses"
490 if exists $options{superclasses};
491
492 (ref $options{attributes} eq 'ARRAY')
493 || confess "You must pass an ARRAY ref of attributes"
494 if exists $options{attributes};
495
496 (ref $options{methods} eq 'HASH')
497 || confess "You must pass a HASH ref of methods"
498 if exists $options{methods};
499
500 $options{meta_name} = 'meta'
501 unless exists $options{meta_name};
502
503 my (%initialize_options) = @args;
504 delete @initialize_options{qw(
505 package
506 superclasses
507 attributes
508 methods
509 meta_name
510 version
511 authority
512 )};
5132593.7ms my $meta = $class->initialize( $package_name => %initialize_options );
# spent 92.7ms making 23 calls to Moose::Meta::Class::initialize, avg 4.03ms/call # spent 962µs making 2 calls to Class::MOP::Class::initialize, avg 481µs/call
514
515253.06ms $meta->_instantiate_module( $options{version}, $options{authority} );
# spent 3.06ms making 25 calls to Class::MOP::Module::_instantiate_module, avg 122µs/call
516
5172567.6ms $meta->_add_meta_method($options{meta_name})
# spent 67.6ms making 25 calls to Class::MOP::Mixin::HasMethods::_add_meta_method, avg 2.70ms/call
518 if defined $options{meta_name};
519
52025160ms $meta->superclasses(@{$options{superclasses}})
# spent 156ms making 23 calls to Moose::Meta::Class::superclasses, avg 6.78ms/call # spent 4.43ms making 2 calls to Class::MOP::Class::superclasses, avg 2.21ms/call
521 if exists $options{superclasses};
522 # NOTE:
523 # process attributes first, so that they can
524 # install accessors, but locally defined methods
525 # can then overwrite them. It is maybe a little odd, but
526 # I think this should be the order of things.
527 if (exists $options{attributes}) {
528 foreach my $attr (@{$options{attributes}}) {
529 $meta->add_attribute($attr);
530 }
531 }
532 if (exists $options{methods}) {
533 foreach my $method_name (keys %{$options{methods}}) {
534 $meta->add_method($method_name, $options{methods}->{$method_name});
535 }
536 }
537 return $meta;
538}
539
540# Instance Construction & Cloning
541
542
# spent 562ms (13.7+548) within Class::MOP::Class::new_object which was called 279 times, avg 2.01ms/call: # 150 times (7.19ms+187ms) by Moose::Meta::Method::_new at line 4 of generated method (unknown origin), avg 1.30ms/call # 101 times (5.08ms+325ms) by Moose::Meta::Class::new_object at line 256 of Moose/Meta/Class.pm, avg 3.27ms/call # 26 times (1.27ms+31.1ms) by Class::MOP::Method::_new at line 54 of Class/MOP/Method.pm, avg 1.25ms/call # once (67µs+4.21ms) by Class::MOP::Attribute::_new at line 62 of Class/MOP/Attribute.pm # once (54µs+1.36ms) by Class::MOP::Object::_new at line 22 of Class/MOP/Object.pm
sub new_object {
54383719.7ms my $class = shift;
544
545 # NOTE:
546 # we need to protect the integrity of the
547 # Class::MOP::Class singletons here, so we
548 # delegate this to &construct_class_instance
549 # which will deal with the singletons
5505585.96ms return $class->_construct_class_instance(@_)
# spent 4.32ms making 279 calls to UNIVERSAL::isa, avg 15µs/call # spent 1.64ms making 279 calls to Class::MOP::Package::name, avg 6µs/call
551 if $class->name->isa('Class::MOP::Class');
552279543ms return $class->_construct_instance(@_);
# spent 543ms making 279 calls to Class::MOP::Class::_construct_instance, avg 1.94ms/call
553}
554
555
# spent 938ms (113+825) within Class::MOP::Class::_construct_instance which was called 390 times, avg 2.41ms/call: # 279 times (69.6ms+473ms) by Class::MOP::Class::new_object at line 552, avg 1.94ms/call # 111 times (43.7ms+352ms) by Class::MOP::Class::_construct_class_instance at line 105, avg 3.57ms/call
sub _construct_instance {
556312043.1ms my $class = shift;
557 my $params = @_ == 1 ? $_[0] : {@_};
55839023.5ms my $meta_instance = $class->get_meta_instance();
# spent 15.0ms making 254 calls to Class::MOP::Class::get_meta_instance, avg 59µs/call # spent 5.70ms making 92 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 62µs/call # spent 2.80ms making 44 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::get_meta_instance, avg 64µs/call
559 # FIXME:
560 # the code below is almost certainly incorrect
561 # but this is foreign inheritance, so we might
562 # have to kludge it in the end.
563 my $instance;
5643905.28ms3902.83ms if (my $instance_class = blessed($params->{__INSTANCE__})) {
# spent 2.83ms making 390 calls to Scalar::Util::blessed, avg 7µs/call
565 ($instance_class eq $class->name)
566 || confess "Objects passed as the __INSTANCE__ parameter must "
567 . "already be blessed into the correct class, but "
568 . "$params->{__INSTANCE__} is not a " . $class->name;
569 $instance = $params->{__INSTANCE__};
570 }
571 elsif (exists $params->{__INSTANCE__}) {
572 confess "The __INSTANCE__ parameter must be a blessed reference, not "
573 . $params->{__INSTANCE__};
574 }
575 else {
57639022.7ms $instance = $meta_instance->create_instance();
# spent 22.7ms making 390 calls to Class::MOP::Instance::create_instance, avg 58µs/call
577 }
578390141ms foreach my $attr ($class->get_all_attributes()) {
# spent 130ms making 254 calls to Class::MOP::Class::get_all_attributes, avg 511µs/call # spent 6.91ms making 92 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 75µs/call # spent 4.52ms making 44 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::get_all_attributes, avg 103µs/call
579441461.0ms4414621ms $attr->initialize_instance_slot($meta_instance, $instance, $params);
# spent 555ms making 4304 calls to Class::MOP::Attribute::initialize_instance_slot, avg 129µs/call # spent 65.8ms making 110 calls to Moose::Meta::Attribute::initialize_instance_slot, avg 598µs/call
580 }
58182214.1ms if (Class::MOP::metaclass_is_weak($class->name)) {
# spent 9.97ms making 390 calls to Class::MOP::metaclass_is_weak, avg 26µs/call # spent 2.36ms making 390 calls to Class::MOP::Package::name, avg 6µs/call # spent 1.81ms making 42 calls to Class::MOP::Instance::_set_mop_slot, avg 43µs/call
582 $meta_instance->_set_mop_slot($instance, $class);
583 }
584 return $instance;
585}
586
587
# spent 491ms (6.52+485) within Class::MOP::Class::_inline_new_object which was called 73 times, avg 6.73ms/call: # 73 times (6.52ms+485ms) by Class::MOP::Method::Constructor::_generate_constructor_method_inline at line 112 of Class/MOP/Method/Constructor.pm, avg 6.73ms/call
sub _inline_new_object {
5881465.86ms my $self = shift;
589
590 return (
591438485ms 'my $class = shift;',
# spent 323ms making 73 calls to Class::MOP::Class::_inline_slot_initializers, avg 4.42ms/call # spent 86.6ms making 42 calls to Moose::Meta::Class::_inline_extra_init, avg 2.06ms/call # spent 37.9ms making 42 calls to Moose::Meta::Class::_inline_params, avg 902µs/call # spent 26.5ms making 73 calls to Class::MOP::Class::_inline_generate_instance, avg 363µs/call # spent 4.98ms making 73 calls to Class::MOP::Class::_inline_preserve_weak_metaclasses, avg 68µs/call # spent 4.93ms making 73 calls to Class::MOP::Class::_inline_fallback_constructor, avg 68µs/call # spent 561µs making 31 calls to Class::MOP::Class::_inline_params, avg 18µs/call # spent 233µs making 31 calls to Class::MOP::Class::_inline_extra_init, avg 8µs/call
592 '$class = Scalar::Util::blessed($class) || $class;',
593 $self->_inline_fallback_constructor('$class'),
594 $self->_inline_params('$params', '$class'),
595 $self->_inline_generate_instance('$instance', '$class'),
596 $self->_inline_slot_initializers,
597 $self->_inline_preserve_weak_metaclasses,
598 $self->_inline_extra_init,
599 'return $instance',
600 );
601}
602
603
# spent 4.93ms (3.18+1.75) within Class::MOP::Class::_inline_fallback_constructor which was called 73 times, avg 68µs/call: # 73 times (3.18ms+1.75ms) by Class::MOP::Class::_inline_new_object at line 591, avg 68µs/call
sub _inline_fallback_constructor {
6042193.43ms my $self = shift;
605 my ($class) = @_;
606 return (
6071461.75ms 'return ' . $self->_generate_fallback_constructor($class),
# spent 807µs making 42 calls to Moose::Meta::Class::_generate_fallback_constructor, avg 19µs/call # spent 553µs making 31 calls to Class::MOP::Class::_generate_fallback_constructor, avg 18µs/call # spent 391µs making 73 calls to Class::MOP::Package::name, avg 5µs/call
608 'if ' . $class . ' ne \'' . $self->name . '\';',
609 );
610}
611
612
# spent 553µs within Class::MOP::Class::_generate_fallback_constructor which was called 31 times, avg 18µs/call: # 31 times (553µs+0s) by Class::MOP::Class::_inline_fallback_constructor at line 607, avg 18µs/call
sub _generate_fallback_constructor {
61393717µs my $self = shift;
614 my ($class) = @_;
615 return 'Class::MOP::Class->initialize(' . $class . ')->new_object(@_)',
616}
617
618
# spent 561µs within Class::MOP::Class::_inline_params which was called 31 times, avg 18µs/call: # 31 times (561µs+0s) by Class::MOP::Class::_inline_new_object at line 591, avg 18µs/call
sub _inline_params {
61993650µs my $self = shift;
620 my ($params, $class) = @_;
621 return (
622 'my ' . $params . ' = @_ == 1 ? $_[0] : {@_};',
623 );
624}
625
626
# spent 26.5ms (2.29+24.2) within Class::MOP::Class::_inline_generate_instance which was called 73 times, avg 363µs/call: # 73 times (2.29ms+24.2ms) by Class::MOP::Class::_inline_new_object at line 591, avg 363µs/call
sub _inline_generate_instance {
6272192.15ms my $self = shift;
628 my ($inst, $class) = @_;
629 return (
6307324.2ms 'my ' . $inst . ' = ' . $self->_inline_create_instance($class) . ';',
# spent 24.2ms making 73 calls to Class::MOP::Class::_inline_create_instance, avg 331µs/call
631 );
632}
633
634
# spent 24.2ms (2.83+21.4) within Class::MOP::Class::_inline_create_instance which was called 73 times, avg 331µs/call: # 73 times (2.83ms+21.4ms) by Class::MOP::Class::_inline_generate_instance at line 630, avg 331µs/call
sub _inline_create_instance {
6351462.50ms my $self = shift;
636
63714621.4ms return $self->get_meta_instance->inline_create_instance(@_);
# spent 20.3ms making 73 calls to Class::MOP::Class::get_meta_instance, avg 277µs/call # spent 1.10ms making 73 calls to Class::MOP::Instance::inline_create_instance, avg 15µs/call
638}
639
640
# spent 323ms (9.45+314) within Class::MOP::Class::_inline_slot_initializers which was called 73 times, avg 4.42ms/call: # 73 times (9.45ms+314ms) by Class::MOP::Class::_inline_new_object at line 591, avg 4.42ms/call
sub _inline_slot_initializers {
641120931.0ms my $self = shift;
642
643 my $idx = 0;
644
6452379268ms return map { $self->_inline_slot_initializer($_, $idx++) }
# spent 142ms making 267 calls to Class::MOP::Class::_inline_slot_initializer, avg 532µs/call # spent 118ms making 132 calls to Moose::Meta::Class::_inline_slot_initializer, avg 893µs/call # spent 8.56ms making 1980 calls to Class::MOP::Mixin::AttributeCore::name, avg 4µs/call
6463994.82ms14653.7ms sort { $a->name cmp $b->name } $self->get_all_attributes;
# spent 27.3ms making 73 calls to Class::MOP::Class::CORE:sort, avg 374µs/call # spent 26.3ms making 73 calls to Class::MOP::Class::get_all_attributes, avg 361µs/call
647}
648
649
# spent 239ms (27.5+212) within Class::MOP::Class::_inline_slot_initializer which was called 399 times, avg 599µs/call: # 267 times (17.5ms+125ms) by Class::MOP::Class::_inline_slot_initializers at line 645, avg 532µs/call # 132 times (10.1ms+87.0ms) by Moose::Meta::Class::_inline_slot_initializer at line 344 of Moose/Meta/Class.pm, avg 735µs/call
sub _inline_slot_initializer {
650119710.6ms my $self = shift;
651 my ($attr, $idx) = @_;
652
653111318.3ms42816.7ms if (defined(my $init_arg = $attr->init_arg)) {
# spent 9.65ms making 18 calls to Moose::Meta::Class::_inline_init_attr_from_default, avg 536µs/call # spent 4.90ms making 11 calls to Class::MOP::Class::_inline_init_attr_from_default, avg 446µs/call # spent 2.19ms making 399 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 5µs/call
654370130ms my @source = (
# spent 80.1ms making 256 calls to Class::MOP::Class::_inline_init_attr_from_constructor, avg 313µs/call # spent 49.8ms making 114 calls to Moose::Meta::Class::_inline_init_attr_from_constructor, avg 437µs/call
655 'if (exists $params->{\'' . $init_arg . '\'}) {',
656 $self->_inline_init_attr_from_constructor($attr, $idx),
657 '}',
658 );
65937064.9ms if (my @default = $self->_inline_init_attr_from_default($attr, $idx)) {
# spent 38.0ms making 256 calls to Class::MOP::Class::_inline_init_attr_from_default, avg 148µs/call # spent 26.9ms making 114 calls to Moose::Meta::Class::_inline_init_attr_from_default, avg 236µs/call
660 push @source, (
661 'else {',
662 @default,
663 '}',
664 );
665 }
666 return @source;
667 }
668 elsif (my @default = $self->_inline_init_attr_from_default($attr, $idx)) {
669 return (
670 '{',
671 @default,
672 '}',
673 );
674 }
675 else {
676 return ();
677 }
678}
679
680
# spent 80.1ms (14.6+65.5) within Class::MOP::Class::_inline_init_attr_from_constructor which was called 256 times, avg 313µs/call: # 256 times (14.6ms+65.5ms) by Class::MOP::Class::_inline_slot_initializer at line 654, avg 313µs/call
sub _inline_init_attr_from_constructor {
681128014.6ms my $self = shift;
682 my ($attr, $idx) = @_;
683
68451262.8ms my @initial_value = $attr->_inline_set_value(
# spent 56.1ms making 254 calls to Class::MOP::Attribute::_inline_set_value, avg 221µs/call # spent 5.55ms making 2 calls to Moose::Meta::Attribute::_inline_set_value, avg 2.78ms/call # spent 1.17ms making 256 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 5µs/call
685 '$instance', '$params->{\'' . $attr->init_arg . '\'}',
686 );
687
6882562.67ms push @initial_value, (
# spent 2.67ms making 256 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 10µs/call
689 '$attrs->[' . $idx . ']->set_initial_value(',
690 '$instance,',
691 $attr->_inline_instance_get('$instance'),
692 ');',
693 ) if $attr->has_initializer;
694
695 return @initial_value;
696}
697
698
# spent 42.9ms (10.2+32.7) within Class::MOP::Class::_inline_init_attr_from_default which was called 267 times, avg 161µs/call: # 256 times (9.55ms+28.4ms) by Class::MOP::Class::_inline_slot_initializer at line 659, avg 148µs/call # 11 times (675µs+4.23ms) by Class::MOP::Class::_inline_slot_initializer at line 653, avg 446µs/call
sub _inline_init_attr_from_default {
69913359.34ms my $self = shift;
700 my ($attr, $idx) = @_;
701
70226715.7ms my $default = $self->_inline_default_value($attr, $idx);
# spent 15.7ms making 267 calls to Class::MOP::Class::_inline_default_value, avg 59µs/call
703 return unless $default;
704
7058916.1ms my @initial_value = $attr->_inline_set_value('$instance', $default);
# spent 16.1ms making 89 calls to Class::MOP::Attribute::_inline_set_value, avg 180µs/call
706
70789870µs push @initial_value, (
# spent 870µs making 89 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 10µs/call
708 '$attrs->[' . $idx . ']->set_initial_value(',
709 '$instance,',
710 $attr->_inline_instance_get('$instance'),
711 ');',
712 ) if $attr->has_initializer;
713
714 return @initial_value;
715}
716
717
# spent 25.0ms (16.2+8.87) within Class::MOP::Class::_inline_default_value which was called 399 times, avg 63µs/call: # 267 times (10.1ms+5.64ms) by Class::MOP::Class::_inline_init_attr_from_default at line 702, avg 59µs/call # 132 times (6.07ms+3.23ms) by Moose::Meta::Class::_inline_init_attr_from_default at line 396 of Moose/Meta/Class.pm, avg 70µs/call
sub _inline_default_value {
718119711.0ms my $self = shift;
719 my ($attr, $index) = @_;
720
7213053.60ms8028.87ms if ($attr->has_default) {
# spent 3.69ms making 399 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 9µs/call # spent 2.64ms making 151 calls to Class::MOP::Mixin::AttributeCore::is_default_a_coderef, avg 17µs/call # spent 2.51ms making 248 calls to Class::MOP::Mixin::AttributeCore::has_builder, avg 10µs/call # spent 22µs making 4 calls to Class::MOP::Mixin::AttributeCore::builder, avg 6µs/call
722 # NOTE:
723 # default values can either be CODE refs
724 # in which case we need to call them. Or
725 # they can be scalars (strings/numbers)
726 # in which case we can just deal with them
727 # in the code we eval.
728 if ($attr->is_default_a_coderef) {
729 return '$defaults->[' . $index . ']->($instance)';
730 }
731 else {
732 return '$defaults->[' . $index . ']';
733 }
734 }
735 elsif ($attr->has_builder) {
736 return '$instance->' . $attr->builder;
737 }
738 else {
739 return;
740 }
741}
742
743
# spent 4.98ms (2.58+2.40) within Class::MOP::Class::_inline_preserve_weak_metaclasses which was called 73 times, avg 68µs/call: # 73 times (2.58ms+2.40ms) by Class::MOP::Class::_inline_new_object at line 591, avg 68µs/call
sub _inline_preserve_weak_metaclasses {
7441462.22ms my $self = shift;
74573795µs1462.40ms if (Class::MOP::metaclass_is_weak($self->name)) {
# spent 1.97ms making 73 calls to Class::MOP::metaclass_is_weak, avg 27µs/call # spent 429µs making 73 calls to Class::MOP::Package::name, avg 6µs/call
746 return (
747 $self->_inline_set_mop_slot(
748 '$instance', 'Class::MOP::class_of($class)'
749 ) . ';'
750 );
751 }
752 else {
753 return ();
754 }
755}
756
75731301µs
# spent 233µs within Class::MOP::Class::_inline_extra_init which was called 31 times, avg 8µs/call: # 31 times (233µs+0s) by Class::MOP::Class::_inline_new_object at line 591, avg 8µs/call
sub _inline_extra_init { }
758
759
760
# spent 148ms (11.9+136) within Class::MOP::Class::get_meta_instance which was called 784 times, avg 188µs/call: # 254 times (3.58ms+11.4ms) by Class::MOP::Class::_construct_instance at line 558, avg 59µs/call # 229 times (3.13ms+26.4ms) by Class::MOP::Attribute::_inline_instance_set at line 285 of Class/MOP/Attribute.pm, avg 129µs/call # 155 times (2.86ms+65.8ms) by Class::MOP::Attribute::_inline_instance_get at line 308 of Class/MOP/Attribute.pm, avg 443µs/call # 73 times (1.29ms+19.0ms) by Class::MOP::Class::_inline_create_instance at line 637, avg 277µs/call # 31 times (399µs+0s) by Class::MOP::Attribute::_inline_instance_has at line 329 of Class/MOP/Attribute.pm, avg 13µs/call # 24 times (450µs+12.5ms) by Class::MOP::Class:::around at line 74 of Class/MOP/Class/Immutable/Trait.pm, avg 540µs/call # 12 times (158µs+0s) by Class::MOP::Attribute::set_initial_value at line 259 of Class/MOP/Attribute.pm, avg 13µs/call # 3 times (37µs+0s) by Class::MOP::Attribute::get_raw_value at line 295 of Class/MOP/Attribute.pm, avg 12µs/call # once (24µs+714µs) by MooseX::Types::Combine::BEGIN@12 at line 684 of Class/MOP.pm # once (14µs+0s) by Class::MOP::Attribute::has_value at line 316 of Class/MOP/Attribute.pm # once (12µs+0s) by Moose::Meta::Attribute::_inline_weaken_value at line 676 of Moose/Meta/Attribute.pm
sub get_meta_instance {
761156814.3ms my $self = shift;
762138136ms $self->{'_meta_instance'} ||= $self->_create_meta_instance();
# spent 136ms making 138 calls to Class::MOP::Class::_create_meta_instance, avg 984µs/call
763}
764
765
# spent 136ms (9.75+126) within Class::MOP::Class::_create_meta_instance which was called 138 times, avg 984µs/call: # 138 times (9.75ms+126ms) by Class::MOP::Class::get_meta_instance at line 762, avg 984µs/call
sub _create_meta_instance {
7665529.79ms my $self = shift;
767
768414125ms my $instance = $self->instance_metaclass->new(
# spent 67.0ms making 138 calls to Class::MOP::Instance::new, avg 486µs/call # spent 51.1ms making 126 calls to Class::MOP::Class::get_all_attributes, avg 406µs/call # spent 5.89ms making 12 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 491µs/call # spent 780µs making 138 calls to Class::MOP::Class::instance_metaclass, avg 6µs/call
769 associated_metaclass => $self,
770 attributes => [ $self->get_all_attributes() ],
771 );
772
7731381.15ms $self->add_meta_instance_dependencies()
# spent 1.15ms making 138 calls to Class::MOP::Instance::is_dependent_on_superclasses, avg 8µs/call
774 if $instance->is_dependent_on_superclasses();
775
776 return $instance;
777}
778
779sub _inline_rebless_instance {
780 my $self = shift;
781
782 return $self->get_meta_instance->inline_rebless_instance_structure(@_);
783}
784
785sub _inline_get_mop_slot {
786 my $self = shift;
787
788 return $self->get_meta_instance->_inline_get_mop_slot(@_);
789}
790
791sub _inline_set_mop_slot {
792 my $self = shift;
793
794 return $self->get_meta_instance->_inline_set_mop_slot(@_);
795}
796
797sub _inline_clear_mop_slot {
798 my $self = shift;
799
800 return $self->get_meta_instance->_inline_clear_mop_slot(@_);
801}
802
803
# spent 1.20ms (99µs+1.10) within Class::MOP::Class::clone_object which was called: # once (99µs+1.10ms) by Class::MOP::Attribute::clone at line 516 of Class/MOP.pm
sub clone_object {
8045121µs my $class = shift;
805 my $instance = shift;
806317µs (blessed($instance) && $instance->isa($class->name))
# spent 6µs making 1 call to Scalar::Util::blessed # spent 6µs making 1 call to Class::MOP::Package::name # spent 5µs making 1 call to UNIVERSAL::isa
807 || confess "You must pass an instance of the metaclass (" . (ref $class ? $class->name : $class) . "), not ($instance)";
808
809 # NOTE:
810 # we need to protect the integrity of the
811 # Class::MOP::Class singletons here, they
812 # should not be cloned.
81318µs return $instance if $instance->isa('Class::MOP::Class');
# spent 8µs making 1 call to UNIVERSAL::isa
81411.07ms $class->_clone_instance($instance, @_);
# spent 1.07ms making 1 call to Class::MOP::Class::_clone_instance
815}
816
817
# spent 1.07ms (343µs+731µs) within Class::MOP::Class::_clone_instance which was called: # once (343µs+731µs) by Class::MOP::Class::clone_object at line 814
sub _clone_instance {
818695µs my ($class, $instance, %params) = @_;
81916µs (blessed($instance))
# spent 6µs making 1 call to Scalar::Util::blessed
820 || confess "You can only clone instances, ($instance) is not a blessed instance";
821192µs my $meta_instance = $class->get_meta_instance();
8221117µs my $clone = $meta_instance->clone_instance($instance);
# spent 117µs making 1 call to Class::MOP::Instance::clone_instance
823159µs foreach my $attr ($class->get_all_attributes()) {
82414308µs16457µs if ( defined( my $init_arg = $attr->init_arg ) ) {
# spent 384µs making 2 calls to Class::MOP::Attribute::set_value, avg 192µs/call # spent 73µs making 14 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 5µs/call
825 if (exists $params{$init_arg}) {
826 $attr->set_value($clone, $params{$init_arg});
827 }
828 }
829 }
830 return $clone;
831}
832
833sub _force_rebless_instance {
834 my ($self, $instance, %params) = @_;
835 my $old_metaclass = Class::MOP::class_of($instance);
836
837 $old_metaclass->rebless_instance_away($instance, $self, %params)
838 if $old_metaclass;
839
840 my $meta_instance = $self->get_meta_instance;
841
842 if (Class::MOP::metaclass_is_weak($old_metaclass->name)) {
843 $meta_instance->_clear_mop_slot($instance);
844 }
845
846 # rebless!
847 # we use $_[1] here because of t/306_rebless_overload.t regressions on 5.8.8
848 $meta_instance->rebless_instance_structure($_[1], $self);
849
850 $self->_fixup_attributes_after_rebless($instance, $old_metaclass, %params);
851
852 if (Class::MOP::metaclass_is_weak($self->name)) {
853 $meta_instance->_set_mop_slot($instance, $self);
854 }
855}
856
857sub rebless_instance {
858 my ($self, $instance, %params) = @_;
859 my $old_metaclass = Class::MOP::class_of($instance);
860
861 my $old_class = $old_metaclass ? $old_metaclass->name : blessed($instance);
862 $self->name->isa($old_class)
863 || confess "You may rebless only into a subclass of ($old_class), of which (". $self->name .") isn't.";
864
865 $self->_force_rebless_instance($_[1], %params);
866
867 return $instance;
868}
869
870sub rebless_instance_back {
871 my ( $self, $instance ) = @_;
872 my $old_metaclass = Class::MOP::class_of($instance);
873
874 my $old_class
875 = $old_metaclass ? $old_metaclass->name : blessed($instance);
876 $old_class->isa( $self->name )
877 || confess
878 "You may rebless only into a superclass of ($old_class), of which ("
879 . $self->name
880 . ") isn't.";
881
882 $self->_force_rebless_instance($_[1]);
883
884 return $instance;
885}
886
887sub rebless_instance_away {
888 # this intentionally does nothing, it is just a hook
889}
890
891sub _fixup_attributes_after_rebless {
892 my $self = shift;
893 my ($instance, $rebless_from, %params) = @_;
894 my $meta_instance = $self->get_meta_instance;
895
896 for my $attr ( $rebless_from->get_all_attributes ) {
897 next if $self->find_attribute_by_name( $attr->name );
898 $meta_instance->deinitialize_slot( $instance, $_ ) for $attr->slots;
899 }
900
901 foreach my $attr ( $self->get_all_attributes ) {
902 if ( $attr->has_value($instance) ) {
903 if ( defined( my $init_arg = $attr->init_arg ) ) {
904 $params{$init_arg} = $attr->get_value($instance)
905 unless exists $params{$init_arg};
906 }
907 else {
908 $attr->set_value($instance, $attr->get_value($instance));
909 }
910 }
911 }
912
913 foreach my $attr ($self->get_all_attributes) {
914 $attr->initialize_instance_slot($meta_instance, $instance, \%params);
915 }
916}
917
918
# spent 16.2ms (4.53+11.6) within Class::MOP::Class::_attach_attribute which was called 188 times, avg 86µs/call: # 188 times (4.53ms+11.6ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 25 of Class/MOP/Mixin/HasAttributes.pm, avg 86µs/call
sub _attach_attribute {
9193764.62ms my ($self, $attribute) = @_;
92018811.6ms $attribute->attach_to_class($self);
# spent 11.6ms making 188 calls to Class::MOP::Attribute::attach_to_class, avg 62µs/call
921}
922
923
# spent 2.27s (12.4ms+2.26) within Class::MOP::Class::_post_add_attribute which was called 188 times, avg 12.1ms/call: # 188 times (12.4ms+2.26s) by Class::MOP::Mixin::HasAttributes::add_attribute at line 42 of Class/MOP/Mixin/HasAttributes.pm, avg 12.1ms/call
sub _post_add_attribute {
92456411.4ms my ( $self, $attribute ) = @_;
925
9261889.87ms $self->invalidate_meta_instances;
# spent 9.87ms making 188 calls to Class::MOP::Class::invalidate_meta_instances, avg 53µs/call
927
928 # invalidate package flag here
929
# spent 2.23s (8.41ms+2.22) within Class::MOP::Class::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Class.pm:932] which was called 188 times, avg 11.9ms/call: # 188 times (8.41ms+2.22s) by Try::Tiny::try at line 76 of Try/Tiny.pm, avg 11.9ms/call
try {
9303768.28ms local $SIG{__DIE__};
9311882.22s $attribute->install_accessors;
# spent 471ms making 2 calls to Class::MOP::Class::__ANON__::SERIAL::5::install_accessors, avg 235ms/call # spent 435ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::15::install_accessors # spent 433ms making 66 calls to Moose::Meta::Attribute::install_accessors, avg 6.56ms/call # spent 287ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::19::install_accessors # spent 218ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::11::install_accessors # spent 216ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::8::install_accessors # spent 163ms making 116 calls to Class::MOP::Attribute::install_accessors, avg 1.40ms/call
932 }
933 catch {
934 $self->remove_attribute( $attribute->name );
935 die $_;
9363762.08s };
# spent 2.25s making 188 calls to Try::Tiny::try, avg 12.0ms/call, recursion: max depth 1, sum of overlapping time 176ms # spent 3.97ms making 188 calls to Try::Tiny::catch, avg 21µs/call
937}
938
939sub remove_attribute {
940 my $self = shift;
941
942 my $removed_attribute = $self->SUPER::remove_attribute(@_)
943 or return;
944
945 $self->invalidate_meta_instances;
946
947 $removed_attribute->remove_accessors;
948 $removed_attribute->detach_from_class;
949
950 return$removed_attribute;
951}
952
953
# spent 32.6ms (9.64+23.0) within Class::MOP::Class::find_attribute_by_name which was called 103 times, avg 317µs/call: # 94 times (7.56ms+17.9ms) by Class::MOP::Class::_immutable_metaclass at line 1364, avg 271µs/call # 8 times (1.84ms+4.51ms) by Moose::Util::MetaRole::_make_new_metaclass at line 117 of Moose/Util/MetaRole.pm, avg 794µs/call # once (239µs+561µs) by Moose::Meta::Class::_process_inherited_attribute at line 627 of Moose/Meta/Class.pm
sub find_attribute_by_name {
9542101.74ms my ( $self, $attr_name ) = @_;
955
9561035.89ms foreach my $class ( $self->linearized_isa ) {
# spent 3.83ms making 61 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 63µs/call # spent 2.06ms making 42 calls to Class::MOP::Class::linearized_isa, avg 49µs/call
957 # fetch the meta-class ...
9583886.79ms1947.70ms my $meta = Class::MOP::Class->initialize($class);
# spent 7.70ms making 194 calls to Class::MOP::Class::initialize, avg 40µs/call
9592939.39ms return $meta->get_attribute($attr_name)
# spent 6.33ms making 194 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 33µs/call # spent 3.06ms making 99 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 31µs/call
960 if $meta->has_attribute($attr_name);
961 }
962
963 return;
964}
965
966
# spent 314ms (135+179) within Class::MOP::Class::get_all_attributes which was called 730 times, avg 430µs/call: # 254 times (56.2ms+73.6ms) by Class::MOP::Class::_construct_instance at line 578, avg 511µs/call # 126 times (22.2ms+28.9ms) by Class::MOP::Class::_create_meta_instance at line 768, avg 406µs/call # 73 times (11.1ms+15.3ms) by Class::MOP::Method::Constructor::_attributes at line 79 of Class/MOP/Method/Constructor.pm, avg 361µs/call # 73 times (11.2ms+15.1ms) by Class::MOP::Class::_inline_slot_initializers at line 646, avg 361µs/call # 57 times (9.83ms+13.0ms) by Moose::Meta::Class::new_object at line 258 of Moose/Meta/Class.pm, avg 400µs/call # 42 times (6.32ms+8.53ms) by Moose::Meta::Class::_inline_triggers at line 432 of Moose/Meta/Class.pm, avg 354µs/call # 37 times (4.85ms+6.56ms) by Class::MOP::Class:::around at line 24 of MooseX/StrictConstructor/Role/Meta/Class.pm, avg 308µs/call # 34 times (4.62ms+6.28ms) by Markdent::Role::Event::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Markdent/Role/Event.pm:88] at line 43 of Markdent/Role/Event.pm, avg 321µs/call # 18 times (3.60ms+5.69ms) by Class::MOP::Class:::around at line 68 of Class/MOP/Class/Immutable/Trait.pm, avg 516µs/call # 16 times (5.34ms+6.00ms) by Moose::Meta::Attribute::new at line 69 of Moose/Meta/Attribute.pm, avg 709µs/call
sub get_all_attributes {
967219042.0ms my $self = shift;
9686274105ms7004165ms my %attrs = map { %{ Class::MOP::Class->initialize($_)->_attribute_map } }
# spent 126ms making 3137 calls to Class::MOP::Class::initialize, avg 40µs/call, recursion: max depth 1, sum of overlapping time 14.4ms # spent 33.1ms making 712 calls to Class::MOP::Class::linearized_isa, avg 47µs/call # spent 18.2ms making 3137 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 6µs/call # spent 1.69ms making 15 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 113µs/call # spent 376µs making 3 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::linearized_isa, avg 125µs/call
969 reverse $self->linearized_isa;
970 return values %attrs;
971}
972
973# Inheritance
974
975sub superclasses {
976355629.2ms my $self = shift;
977
97888976.0ms my $isa = $self->get_or_add_package_symbol('@ISA');
# spent 76.0ms making 889 calls to Class::MOP::Package::get_or_add_package_symbol, avg 86µs/call
979
98066617.0ms if (@_) {
981 my @supers = @_;
982 @{$isa} = @supers;
983
984 # NOTE:
985 # on 5.8 and below, we need to call
986 # a method to get Perl to detect
987 # a cycle in the class hierarchy
988111730µs my $class = $self->name;
# spent 730µs making 111 calls to Class::MOP::Package::name, avg 7µs/call
9891111.04ms $class->isa($class);
# spent 1.04ms making 111 calls to UNIVERSAL::isa, avg 9µs/call
990
991 # NOTE:
992 # we need to check the metaclass
993 # compatibility here so that we can
994 # be sure that the superclass is
995 # not potentially creating an issues
996 # we don't know about
997
998111494ms $self->_check_metaclass_compatibility();
# spent 494ms making 111 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 4.45ms/call
99911138.8ms $self->_superclasses_updated();
# spent 38.8ms making 111 calls to Class::MOP::Class::_superclasses_updated, avg 349µs/call
1000 }
1001
1002 return @{$isa};
1003}
1004
1005
# spent 38.8ms (8.24+30.5) within Class::MOP::Class::_superclasses_updated which was called 111 times, avg 349µs/call: # 111 times (8.24ms+30.5ms) by Class::MOP::Class::superclasses at line 999, avg 349µs/call
sub _superclasses_updated {
10063335.45ms my $self = shift;
10071111.30ms $self->update_meta_instance_dependencies();
# spent 1.30ms making 111 calls to Class::MOP::Class::update_meta_instance_dependencies, avg 12µs/call
1008 # keep strong references to all our parents, so they don't disappear if
1009 # they are anon classes and don't have any direct instances
10101234.25ms $self->_superclass_metas(
# spent 4.25ms making 123 calls to Class::MOP::class_of, avg 35µs/call
10111231.32ms2221.91ms map { Class::MOP::class_of($_) } $self->superclasses
# spent 1.91ms making 111 calls to Class::MOP::Class::_superclass_metas, avg 17µs/call # spent 196µs making 2 calls to Class::MOP::Class::superclasses, avg 98µs/call, recursion: max depth 1, sum of overlapping time 196µs # spent 22.8ms making 109 calls to Moose::Meta::Class::superclasses, avg 210µs/call, recursion: max depth 1, sum of overlapping time 22.8ms
1012 );
1013}
1014
1015
# spent 1.91ms within Class::MOP::Class::_superclass_metas which was called 111 times, avg 17µs/call: # 111 times (1.91ms+0s) by Class::MOP::Class::_superclasses_updated at line 1011, avg 17µs/call
sub _superclass_metas {
10162222.22ms my $self = shift;
1017 $self->{_superclass_metas} = [@_];
1018}
1019
1020sub subclasses {
1021 my $self = shift;
1022 my $super_class = $self->name;
1023
1024 return @{ $super_class->mro::get_isarev() };
1025}
1026
1027sub direct_subclasses {
1028 my $self = shift;
1029 my $super_class = $self->name;
1030
1031 return grep {
1032 grep {
1033 $_ eq $super_class
1034 } Class::MOP::Class->initialize($_)->superclasses
1035 } $self->subclasses;
1036}
1037
1038
# spent 66.5ms (42.8+23.7) within Class::MOP::Class::linearized_isa which was called 1405 times, avg 47µs/call: # 712 times (21.1ms+12.0ms) by Class::MOP::Class::get_all_attributes at line 968, avg 47µs/call # 277 times (8.80ms+4.64ms) by Class::MOP::Class::find_method_by_name at line 1158, avg 49µs/call # 266 times (8.48ms+4.54ms) by Class::MOP::Class::find_next_method_by_name at line 1205, avg 49µs/call # 81 times (2.29ms+1.28ms) by Class::MOP::Class::find_all_methods_by_name at line 1189, avg 44µs/call # 42 times (1.29ms+774µs) by Class::MOP::Class::find_attribute_by_name at line 956, avg 49µs/call # 18 times (564µs+309µs) by Class::MOP::Class:::around at line 50 of Class/MOP/Class/Immutable/Trait.pm, avg 49µs/call # 9 times (253µs+153µs) by Class::MOP::Class::get_all_methods at line 1169, avg 45µs/call
sub linearized_isa {
1039140570.5ms281023.7ms return @{ mro::get_linear_isa( (shift)->name ) };
# spent 16.4ms making 1405 calls to mro::get_linear_isa, avg 12µs/call # spent 7.26ms making 1405 calls to Class::MOP::Package::name, avg 5µs/call
1040}
1041
1042
# spent 99.5ms (25.1+74.5) within Class::MOP::Class::class_precedence_list which was called 294 times, avg 338µs/call: # 159 times (11.7ms+-11.7ms) by Class::MOP::Class::class_precedence_list at line 1068, avg 0s/call # 73 times (7.53ms+66.4ms) by Moose::Meta::Class::excludes_role at line 239 of Moose/Meta/Class.pm, avg 1.01ms/call # 44 times (4.28ms+21.3ms) by Moose::Meta::Class::does_role at line 219 of Moose/Meta/Class.pm, avg 581µs/call # 18 times (1.55ms+-1.55ms) by Class::MOP::Class:::around at line 43 of Class/MOP/Class/Immutable/Trait.pm, avg 0s/call
sub class_precedence_list {
1043117617.8ms my $self = shift;
10442941.65ms my $name = $self->name;
# spent 1.65ms making 294 calls to Class::MOP::Package::name, avg 6µs/call
1045
10462941.53ms unless (Class::MOP::IS_RUNNING_ON_5_10()) {
# spent 1.53ms making 294 calls to Class::MOP::__ANON__, avg 5µs/call
1047 # NOTE:
1048 # We need to check for circular inheritance here
1049 # if we are are not on 5.10, cause 5.8 detects it
1050 # late. This will do nothing if all is well, and
1051 # blow up otherwise. Yes, it's an ugly hack, better
1052 # suggestions are welcome.
1053 # - SL
1054 ($name || return)->isa('This is a test for circular inheritance')
1055 }
1056
1057 # if our mro is c3, we can
1058 # just grab the linear_isa
10592947.61ms2943.65ms if (mro::get_mro($name) eq 'c3') {
# spent 3.65ms making 294 calls to mro::get_mro, avg 12µs/call
1060 return @{ mro::get_linear_isa($name) }
1061 }
1062 else {
1063 # NOTE:
1064 # we can't grab the linear_isa for dfs
1065 # since it has all the duplicates
1066 # already removed.
1067 return (
106846420.0ms $name,
# spent 19.7ms making 73 calls to Class::MOP::Class::Immutable::Class::MOP::Class::class_precedence_list, avg 270µs/call, recursion: max depth 4, sum of overlapping time 9.57ms # spent 9.93ms making 232 calls to Class::MOP::Class::initialize, avg 43µs/call # spent 59.6ms making 159 calls to Class::MOP::Class::class_precedence_list, avg 375µs/call, recursion: max depth 2, sum of overlapping time 59.6ms
1069 map {
10702325.12ms29453.1ms Class::MOP::Class->initialize($_)->class_precedence_list()
# spent 49.2ms making 264 calls to Moose::Meta::Class::superclasses, avg 186µs/call # spent 2.75ms making 18 calls to Class::MOP::Class::Immutable::Class::MOP::Class::superclasses, avg 153µs/call # spent 1.11ms making 12 calls to Class::MOP::Class::superclasses, avg 92µs/call
1071 } $self->superclasses()
1072 );
1073 }
1074}
1075
1076## Methods
1077
1078{
107914µs
# spent 218ms (14.4+204) within Class::MOP::Class::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Class.pm:1108] which was called 131 times, avg 1.67ms/call: # 114 times (12.7ms+184ms) by Class::MOP::Class::add_around_method_modifier at line 1134, avg 1.72ms/call # 11 times (1.22ms+16.5ms) by Class::MOP::Class::add_before_method_modifier at line 1114, avg 1.61ms/call # 6 times (514µs+3.96ms) by Class::MOP::Class::add_after_method_modifier at line 1124, avg 746µs/call
my $fetch_and_prepare_method = sub {
10807869.05ms my ($self, $method_name) = @_;
1081131812µs my $wrapped_metaclass = $self->wrapped_method_metaclass;
# spent 812µs making 131 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 6µs/call
1082 # fetch it locally
108313119.6ms my $method = $self->get_method($method_name);
# spent 19.6ms making 131 calls to Class::MOP::Mixin::HasMethods::get_method, avg 149µs/call
1084 # if we dont have local ...
10853696.03ms unless ($method) {
1086 # try to find the next method
108711988.0ms $method = $self->find_next_method_by_name($method_name);
# spent 88.0ms making 119 calls to Class::MOP::Class::find_next_method_by_name, avg 739µs/call
1088 # die if it does not exist
1089 (defined $method)
1090 || confess "The method '$method_name' was not found in the inheritance hierarchy for " . $self->name;
1091 # and now make sure to wrap it
1092 # even if it is already wrapped
1093 # because we need a new sub ref
109423838.4ms $method = $wrapped_metaclass->wrap($method,
# spent 37.7ms making 119 calls to Class::MOP::Method::Wrapped::wrap, avg 316µs/call # spent 760µs making 119 calls to Class::MOP::Package::name, avg 6µs/call
1095 package_name => $self->name,
1096 name => $method_name,
1097 );
1098 }
1099 else {
1100 # now make sure we wrap it properly
1101262.26ms $method = $wrapped_metaclass->wrap($method,
# spent 2.10ms making 7 calls to Class::MOP::Method::Wrapped::wrap, avg 300µs/call # spent 124µs making 12 calls to UNIVERSAL::isa, avg 10µs/call # spent 35µs making 7 calls to Class::MOP::Package::name, avg 5µs/call
1102 package_name => $self->name,
1103 name => $method_name,
1104 ) unless $method->isa($wrapped_metaclass);
1105 }
110613155.0ms $self->add_method($method_name => $method);
# spent 55.0ms making 131 calls to Class::MOP::Mixin::HasMethods::add_method, avg 420µs/call
1107 return $method;
1108115µs };
1109
1110
# spent 19.2ms (587µs+18.6) within Class::MOP::Class::add_before_method_modifier which was called 11 times, avg 1.75ms/call: # 11 times (587µs+18.6ms) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 221 of Moose/Meta/Role/Application/ToClass.pm, avg 1.75ms/call
sub add_before_method_modifier {
111144706µs my ($self, $method_name, $method_modifier) = @_;
1112 (defined $method_name && length $method_name)
1113 || confess "You must pass in a method name";
11141117.7ms my $method = $fetch_and_prepare_method->($self, $method_name);
# spent 17.7ms making 11 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:1108], avg 1.61ms/call
111522905µs $method->add_before_modifier(
# spent 758µs making 11 calls to Class::MOP::Method::Wrapped::add_before_modifier, avg 69µs/call # spent 147µs making 11 calls to Sub::Name::subname, avg 13µs/call
1116 subname(':before' => $method_modifier)
1117 );
1118 }
1119
1120
# spent 5.35ms (343µs+5.01) within Class::MOP::Class::add_after_method_modifier which was called 6 times, avg 892µs/call: # 6 times (343µs+5.01ms) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 221 of Moose/Meta/Role/Application/ToClass.pm, avg 892µs/call
sub add_after_method_modifier {
112124408µs my ($self, $method_name, $method_modifier) = @_;
1122 (defined $method_name && length $method_name)
1123 || confess "You must pass in a method name";
112464.48ms my $method = $fetch_and_prepare_method->($self, $method_name);
# spent 4.48ms making 6 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:1108], avg 746µs/call
112512533µs $method->add_after_modifier(
# spent 448µs making 6 calls to Class::MOP::Method::Wrapped::add_after_modifier, avg 75µs/call # spent 85µs making 6 calls to Sub::Name::subname, avg 14µs/call
1126 subname(':after' => $method_modifier)
1127 );
1128 }
1129
1130
# spent 219ms (6.04+213) within Class::MOP::Class::add_around_method_modifier which was called 114 times, avg 1.92ms/call: # 68 times (3.52ms+127ms) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 1.92ms/call # 45 times (2.47ms+85.1ms) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 221 of Moose/Meta/Role/Application/ToClass.pm, avg 1.94ms/call # once (51µs+1.44ms) by Moose::Util::add_method_modifier at line 244 of Moose/Util.pm
sub add_around_method_modifier {
11314567.45ms my ($self, $method_name, $method_modifier) = @_;
1132 (defined $method_name && length $method_name)
1133 || confess "You must pass in a method name";
1134114196ms my $method = $fetch_and_prepare_method->($self, $method_name);
# spent 196ms making 114 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:1108], avg 1.72ms/call
113522817.0ms $method->add_around_modifier(
# spent 15.4ms making 114 calls to Class::MOP::Method::Wrapped::add_around_modifier, avg 135µs/call # spent 1.61ms making 114 calls to Sub::Name::subname, avg 14µs/call
1136 subname(':around' => $method_modifier)
1137 );
1138 }
1139
1140 # NOTE:
1141 # the methods above used to be named like this:
1142 # ${pkg}::${method}:(before|after|around)
1143 # but this proved problematic when using one modifier
1144 # to wrap multiple methods (something which is likely
1145 # to happen pretty regularly IMO). So instead of naming
1146 # it like this, I have chosen to just name them purely
1147 # with their modifier names, like so:
1148 # :(before|after|around)
1149 # The fact is that in a stack trace, it will be fairly
1150 # evident from the context what method they are attached
1151 # to, and so don't need the fully qualified name.
1152}
1153
1154
# spent 202ms (31.6+171) within Class::MOP::Class::find_method_by_name which was called 277 times, avg 730µs/call: # 92 times (6.22ms+23.7ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 23 of Class/MOP/Mixin/HasMethods.pm, avg 326µs/call # 80 times (12.3ms+83.3ms) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 1.20ms/call # 43 times (6.34ms+29.4ms) by Moose::Meta::Method::Destructor::is_needed at line 62 of Moose/Meta/Method/Destructor.pm, avg 832µs/call # 42 times (5.39ms+26.5ms) by Moose::Meta::Class::_inline_BUILDARGS at line 303 of Moose/Meta/Class.pm, avg 760µs/call # 13 times (856µs+5.93ms) by Moose::Meta::Role::Application::ToClass::check_required_methods at line 64 of Moose/Meta/Role/Application/ToClass.pm, avg 522µs/call # 7 times (442µs+1.61ms) by Moose::BEGIN@38 at line 14 of Moose/Meta/Attribute/Native.pm, avg 294µs/call
sub find_method_by_name {
11559477.31ms my ($self, $method_name) = @_;
1156 (defined $method_name && length $method_name)
1157 || confess "You must define a method name to find";
115827713.4ms foreach my $class ($self->linearized_isa) {
# spent 13.4ms making 277 calls to Class::MOP::Class::linearized_isa, avg 49µs/call
1159150421.1ms1504157ms my $method = Class::MOP::Class->initialize($class)->get_method($method_name);
# spent 125ms making 752 calls to Class::MOP::Mixin::HasMethods::get_method, avg 167µs/call # spent 31.9ms making 752 calls to Class::MOP::Class::initialize, avg 42µs/call
1160 return $method if defined $method;
1161 }
1162 return;
1163}
1164
1165
# spent 17.3ms (1.83+15.4) within Class::MOP::Class::get_all_methods which was called 9 times, avg 1.92ms/call: # 9 times (1.83ms+15.4ms) by Class::MOP::MiniTrait::apply at line 18 of Class/MOP/MiniTrait.pm, avg 1.92ms/call
sub get_all_methods {
116636355µs my $self = shift;
1167
1168 my %methods;
11699407µs for my $class ( reverse $self->linearized_isa ) {
# spent 407µs making 9 calls to Class::MOP::Class::linearized_isa, avg 45µs/call
1170331.83ms11418µs my $meta = Class::MOP::Class->initialize($class);
# spent 418µs making 11 calls to Class::MOP::Class::initialize, avg 38µs/call
1171
11729114.6ms $methods{ $_->name } = $_ for $meta->_get_local_methods;
# spent 14.2ms making 11 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 1.29ms/call # spent 394µs making 80 calls to Class::MOP::Method::name, avg 5µs/call
1173 }
1174
1175 return values %methods;
1176}
1177
1178sub get_all_method_names {
1179 my $self = shift;
1180 my %uniq;
1181 return grep { !$uniq{$_}++ } map { Class::MOP::Class->initialize($_)->get_method_list } $self->linearized_isa;
1182}
1183
1184
# spent 61.9ms (11.0+50.9) within Class::MOP::Class::find_all_methods_by_name which was called 81 times, avg 765µs/call: # 42 times (5.99ms+28.7ms) by Moose::Meta::Class::_inline_BUILDALL at line 456 of Moose/Meta/Class.pm, avg 825µs/call # 39 times (5.05ms+22.2ms) by Moose::Meta::Method::Destructor::_generate_DEMOLISHALL at line 118 of Moose/Meta/Method/Destructor.pm, avg 699µs/call
sub find_all_methods_by_name {
11854052.95ms my ($self, $method_name) = @_;
1186 (defined $method_name && length $method_name)
1187 || confess "You must define a method name to find";
1188 my @methods;
1189813.58ms foreach my $class ($self->linearized_isa) {
# spent 3.58ms making 81 calls to Class::MOP::Class::linearized_isa, avg 44µs/call
1190 # fetch the meta-class ...
11915066.76ms25310.2ms my $meta = Class::MOP::Class->initialize($class);
# spent 10.2ms making 253 calls to Class::MOP::Class::initialize, avg 40µs/call
119225437.1ms push @methods => {
# spent 37.0ms making 253 calls to Class::MOP::Mixin::HasMethods::has_method, avg 146µs/call # spent 79µs making 1 call to Class::MOP::Mixin::HasMethods::get_method
1193 name => $method_name,
1194 class => $class,
1195 code => $meta->get_method($method_name)
1196 } if $meta->has_method($method_name);
1197 }
1198 return @methods;
1199}
1200
1201
# spent 157ms (29.2+128) within Class::MOP::Class::find_next_method_by_name which was called 266 times, avg 590µs/call: # 119 times (14.9ms+73.1ms) by Class::MOP::Class::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Class.pm:1108] at line 1087, avg 739µs/call # 111 times (11.3ms+44.8ms) by Class::MOP::Method::Inlined::can_be_inlined at line 38 of Class/MOP/Method/Inlined.pm, avg 505µs/call # 36 times (3.05ms+9.83ms) by Moose::Meta::Method::Overridden::new at line 23 of Moose/Meta/Method/Overridden.pm, avg 358µs/call
sub find_next_method_by_name {
120213359.26ms my ($self, $method_name) = @_;
1203 (defined $method_name && length $method_name)
1204 || confess "You must define a method name to find";
120526613.0ms my @cpl = $self->linearized_isa;
# spent 13.0ms making 266 calls to Class::MOP::Class::linearized_isa, avg 49µs/call
1206 shift @cpl; # discard ourselves
1207 foreach my $class (@cpl) {
1208109417.5ms1094115ms my $method = Class::MOP::Class->initialize($class)->get_method($method_name);
# spent 91.2ms making 547 calls to Class::MOP::Mixin::HasMethods::get_method, avg 167µs/call # spent 23.5ms making 547 calls to Class::MOP::Class::initialize, avg 43µs/call
1209 return $method if defined $method;
1210 }
1211 return;
1212}
1213
1214
# spent 1.30ms within Class::MOP::Class::update_meta_instance_dependencies which was called 111 times, avg 12µs/call: # 111 times (1.30ms+0s) by Class::MOP::Class::_superclasses_updated at line 1007, avg 12µs/call
sub update_meta_instance_dependencies {
12152221.84ms my $self = shift;
1216
1217 if ( $self->{meta_instance_dependencies} ) {
1218 return $self->add_meta_instance_dependencies;
1219 }
1220}
1221
1222sub add_meta_instance_dependencies {
1223 my $self = shift;
1224
1225 $self->remove_meta_instance_dependencies;
1226
1227 my @attrs = $self->get_all_attributes();
1228
1229 my %seen;
1230 my @classes = grep { not $seen{ $_->name }++ }
1231 map { $_->associated_class } @attrs;
1232
1233 foreach my $class (@classes) {
1234 $class->add_dependent_meta_instance($self);
1235 }
1236
1237 $self->{meta_instance_dependencies} = \@classes;
1238}
1239
1240sub remove_meta_instance_dependencies {
1241 my $self = shift;
1242
1243 if ( my $classes = delete $self->{meta_instance_dependencies} ) {
1244 foreach my $class (@$classes) {
1245 $class->remove_dependent_meta_instance($self);
1246 }
1247
1248 return $classes;
1249 }
1250
1251 return;
1252
1253}
1254
1255sub add_dependent_meta_instance {
1256 my ( $self, $metaclass ) = @_;
1257 push @{ $self->{dependent_meta_instances} }, $metaclass;
1258}
1259
1260sub remove_dependent_meta_instance {
1261 my ( $self, $metaclass ) = @_;
1262 my $name = $metaclass->name;
1263 @$_ = grep { $_->name ne $name } @$_
1264 for $self->{dependent_meta_instances};
1265}
1266
1267
# spent 9.87ms (7.53+2.34) within Class::MOP::Class::invalidate_meta_instances which was called 188 times, avg 53µs/call: # 188 times (7.53ms+2.34ms) by Class::MOP::Class::_post_add_attribute at line 926, avg 53µs/call
sub invalidate_meta_instances {
12685647.36ms my $self = shift;
1269 $_->invalidate_meta_instance()
12701882.34ms for $self, @{ $self->{dependent_meta_instances} };
# spent 2.34ms making 188 calls to Class::MOP::Class::invalidate_meta_instance, avg 12µs/call
1271}
1272
1273
# spent 2.34ms within Class::MOP::Class::invalidate_meta_instance which was called 188 times, avg 12µs/call: # 188 times (2.34ms+0s) by Class::MOP::Class::invalidate_meta_instances at line 1270, avg 12µs/call
sub invalidate_meta_instance {
12743763.07ms my $self = shift;
1275 undef $self->{_meta_instance};
1276}
1277
1278# check if we can reinitialize
1279sub is_pristine {
1280 my $self = shift;
1281
1282 # if any local attr is defined
1283 return if $self->get_attribute_list;
1284
1285 # or any non-declared methods
1286 for my $method ( map { $self->get_method($_) } $self->get_method_list ) {
1287 return if $method->isa("Class::MOP::Method::Generated");
1288 # FIXME do we need to enforce this too? return unless $method->isa( $self->method_metaclass );
1289 }
1290
1291 return 1;
1292}
1293
1294## Class closing
1295
12961251.45ms
# spent 868µs within Class::MOP::Class::is_mutable which was called 125 times, avg 7µs/call: # 94 times (676µs+0s) by Class::MOP::Class::make_immutable at line 1320, avg 7µs/call # 22 times (135µs+0s) by MooseX::Types::BEGIN@2 at line 231 of Moose.pm, avg 6µs/call # 9 times (57µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 688 of Moose/Util/TypeConstraints.pm, avg 6µs/call
sub is_mutable { 1 }
12973203.76ms
# spent 2.41ms within Class::MOP::Class::is_immutable which was called 320 times, avg 8µs/call: # 320 times (2.41ms+0s) by Class::MOP::Class::_real_ref_name at line 126, avg 8µs/call
sub is_immutable { 0 }
1298
1299sub immutable_options { %{ $_[0]{__immutable}{options} || {} } }
1300
1301
# spent 9.98ms (6.81+3.18) within Class::MOP::Class::_immutable_options which was called 94 times, avg 106µs/call: # 51 times (3.28ms+968µs) by Class::MOP::Class::make_immutable at line 1321, avg 83µs/call # 43 times (3.52ms+2.21ms) by Moose::Meta::Class::_immutable_options at line 645 of Moose/Meta/Class.pm, avg 133µs/call
sub _immutable_options {
13021887.81ms my ( $self, @args ) = @_;
1303
1304 return (
13053763.18ms inline_accessors => 1,
# spent 655µs making 43 calls to Moose::Meta::Class::immutable_trait, avg 15µs/call # spent 621µs making 43 calls to Moose::Meta::Class::constructor_class, avg 14µs/call # spent 613µs making 43 calls to Moose::Meta::Class::destructor_class, avg 14µs/call # spent 570µs making 94 calls to Class::MOP::Class::constructor_name, avg 6µs/call # spent 273µs making 51 calls to Class::MOP::Class::immutable_trait, avg 5µs/call # spent 222µs making 51 calls to Class::MOP::Class::destructor_class, avg 4µs/call # spent 222µs making 51 calls to Class::MOP::Class::constructor_class, avg 4µs/call
1306 inline_constructor => 1,
1307 inline_destructor => 0,
1308 debug => 0,
1309 immutable_trait => $self->immutable_trait,
1310 constructor_name => $self->constructor_name,
1311 constructor_class => $self->constructor_class,
1312 destructor_class => $self->destructor_class,
1313 @args,
1314 );
1315}
1316
1317
# spent 1.68s (7.96ms+1.67) within Class::MOP::Class::make_immutable which was called 94 times, avg 17.9ms/call: # 22 times (1.92ms+406ms) by MooseX::Types::BEGIN@2 at line 236 of Moose.pm, avg 18.6ms/call # 13 times (978µs+85.8ms) by MooseX::Types::Combine::BEGIN@12 at line 699 of Class/MOP.pm, avg 6.68ms/call # 9 times (751µs+176ms) by Moose::Meta::Attribute::BEGIN@20 at line 693 of Moose/Util/TypeConstraints.pm, avg 19.7ms/call # 4 times (269µs+2.30ms) by MooseX::Types::Combine::BEGIN@12 at line 724 of Class/MOP.pm, avg 643µs/call # 3 times (260µs+-260µs) by Class::MOP::Class::_immutable_metaclass at line 1394, avg 0s/call # once (183µs+112ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@10 at line 15 of Markdent/Event/StartDocument.pm # once (123µs+105ms) by Markdent::Simple::Document::BEGIN@9 at line 48 of Markdent/Handler/HTMLStream/Document.pm # once (90µs+47.8ms) by MooseX::Role::Parameterized::Meta::Role::Parameterizable::BEGIN@8 at line 22 of MooseX/Role/Parameterized/Meta/Parameter.pm # once (82µs+47.2ms) by MooseX::Role::Parameterized::BEGIN@8 at line 130 of MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm # once (80µs+46.7ms) by MooseX::Types::BEGIN@2 at line 268 of Moose.pm # once (84µs+45.0ms) by MooseX::Role::Parameterized::Meta::Role::Parameterizable::BEGIN@7 at line 8 of MooseX/Role/Parameterized/Meta/Role/Parameterized.pm # once (121µs+26.0ms) by Markdent::Simple::Document::BEGIN@10 at line 198 of Markdent/Parser.pm # once (84µs+25.6ms) by Markdent::Parser::BEGIN@11 at line 895 of Markdent/Dialect/Standard/SpanParser.pm # once (97µs+25.5ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@21 at line 47 of Markdent/Event/Image.pm # once (87µs+23.6ms) by Markdent::Parser::BEGIN@10 at line 748 of Markdent/Dialect/Standard/BlockParser.pm # once (94µs+22.7ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@24 at line 29 of Markdent/Event/StartHTMLTag.pm # once (81µs+20.0ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@25 at line 43 of Markdent/Event/StartLink.pm # once (98µs+18.7ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@14 at line 23 of Markdent/Event/StartHeader.pm # once (82µs+18.5ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@27 at line 35 of Markdent/Event/Text.pm # once (80µs+17.0ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@20 at line 29 of Markdent/Event/HTMLTag.pm # once (81µs+17.0ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@19 at line 23 of Markdent/Event/HTMLEntity.pm # once (79µs+16.7ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@26 at line 29 of Markdent/Event/StartStrong.pm # once (81µs+15.2ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@15 at line 23 of Markdent/Event/EndHTMLTag.pm # once (82µs+14.8ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@18 at line 23 of Markdent/Event/HTMLComment.pm # once (82µs+14.8ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@26 at line 23 of Markdent/Event/HTMLCommentBlock.pm # once (85µs+14.8ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@25 at line 23 of Markdent/Event/HTMLBlock.pm # once (81µs+14.7ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@23 at line 29 of Markdent/Event/StartEmphasis.pm # once (82µs+14.7ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@13 at line 29 of Markdent/Event/EndCode.pm # once (90µs+14.7ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@14 at line 29 of Markdent/Event/EndEmphasis.pm # once (81µs+14.7ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@15 at line 23 of Markdent/Event/EndHeader.pm # once (85µs+14.7ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@22 at line 29 of Markdent/Event/StartCode.pm # once (83µs+14.7ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@12 at line 23 of Markdent/Event/AutoLink.pm # once (79µs+14.7ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@17 at line 29 of Markdent/Event/EndStrong.pm # once (97µs+14.6ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@11 at line 15 of Markdent/Event/EndDocument.pm # once (82µs+14.6ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@27 at line 23 of Markdent/Event/Preformatted.pm # once (82µs+14.2ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@17 at line 15 of Markdent/Event/EndListItem.pm # once (93µs+13.8ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@22 at line 15 of Markdent/Event/StartUnorderedList.pm # once (81µs+13.6ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@21 at line 15 of Markdent/Event/EndParagraph.pm # once (81µs+13.5ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@19 at line 15 of Markdent/Event/EndOrderedList.pm # once (81µs+13.5ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@20 at line 15 of Markdent/Event/StartParagraph.pm # once (82µs+13.5ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@23 at line 15 of Markdent/Event/EndUnorderedList.pm # once (80µs+13.5ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@16 at line 17 of Markdent/Event/EndLink.pm # once (81µs+13.5ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@16 at line 15 of Markdent/Event/StartListItem.pm # once (80µs+13.4ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@18 at line 15 of Markdent/Event/StartOrderedList.pm # once (82µs+13.4ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@24 at line 15 of Markdent/Event/HorizontalRule.pm # once (84µs+13.4ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@13 at line 15 of Markdent/Event/EndBlockquote.pm # once (79µs+13.4ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@12 at line 15 of Markdent/Event/StartBlockquote.pm # once (80µs+11.0ms) by MooseX::Role::Parameterized::Meta::Trait::Parameterized::BEGIN@6 at line 6 of MooseX/Role/Parameterized/Parameters.pm
sub make_immutable {
13181881.65ms my ( $self, @args ) = @_;
1319
13202825.90ms94676µs if ( $self->is_mutable ) {
# spent 676µs making 94 calls to Class::MOP::Class::is_mutable, avg 7µs/call
13211881.36s $self->_initialize_immutable( $self->_immutable_options(@args) );
# spent 1.35s making 94 calls to Class::MOP::Class::_initialize_immutable, avg 14.4ms/call # spent 7.61ms making 43 calls to Moose::Meta::Class::_immutable_options, avg 177µs/call # spent 4.25ms making 51 calls to Class::MOP::Class::_immutable_options, avg 83µs/call
132294311ms $self->_rebless_as_immutable(@args);
# spent 313ms making 94 calls to Class::MOP::Class::_rebless_as_immutable, avg 3.33ms/call, recursion: max depth 1, sum of overlapping time 1.77ms
1323 return $self;
1324 }
1325 else {
1326 return;
1327 }
1328}
1329
1330sub make_mutable {
1331 my $self = shift;
1332
1333 if ( $self->is_immutable ) {
1334 my @args = $self->immutable_options;
1335 $self->_rebless_as_mutable();
1336 $self->_remove_inlined_code(@args);
1337 delete $self->{__immutable};
1338 return $self;
1339 }
1340 else {
1341 return;
1342 }
1343}
1344
1345
# spent 311ms (4.41+306) within Class::MOP::Class::_rebless_as_immutable which was called 94 times, avg 3.31ms/call: # 94 times (4.41ms+306ms) by Class::MOP::Class::make_immutable at line 1322, avg 3.31ms/call
sub _rebless_as_immutable {
13462824.30ms my ( $self, @args ) = @_;
1347
1348 $self->{__immutable}{original_class} = ref $self;
1349
135094307ms bless $self => $self->_immutable_metaclass(@args);
# spent 308ms making 94 calls to Class::MOP::Class::_immutable_metaclass, avg 3.28ms/call, recursion: max depth 1, sum of overlapping time 1.57ms
1351}
1352
1353
# spent 307ms (10.1+297) within Class::MOP::Class::_immutable_metaclass which was called 94 times, avg 3.26ms/call: # 94 times (10.1ms+297ms) by Class::MOP::Class::_rebless_as_immutable at line 1350, avg 3.26ms/call
sub _immutable_metaclass {
135476711.5ms my ( $self, %args ) = @_;
1355
1356 if ( my $class = $args{immutable_metaclass} ) {
1357 return $class;
1358 }
1359
136094953µs my $trait = $args{immutable_trait} = $self->immutable_trait
# spent 669µs making 43 calls to Moose::Meta::Class::immutable_trait, avg 16µs/call # spent 284µs making 51 calls to Class::MOP::Class::immutable_trait, avg 6µs/call
1361 || confess "no immutable trait specified for $self";
1362
1363947.94ms my $meta = $self->meta;
# spent 4.70ms making 57 calls to Class::MOP::Object::meta, avg 83µs/call # spent 3.24ms making 37 calls to Class::MOP::Class::__ANON__::SERIAL::2::meta, avg 88µs/call
13649425.5ms my $meta_attr = $meta->find_attribute_by_name("immutable_trait");
# spent 25.5ms making 94 calls to Class::MOP::Class::find_attribute_by_name, avg 271µs/call
1365
1366 my $class_name;
1367
1368941.62ms if ( $meta_attr and $trait eq $meta_attr->default ) {
# spent 1.62ms making 94 calls to Class::MOP::Mixin::AttributeCore::default, avg 17µs/call
1369 # if the trait is the same as the default we try and pick a
1370 # predictable name for the immutable metaclass
1371 $class_name = 'Class::MOP::Class::Immutable::' . ref($self);
1372 }
1373 else {
1374 $class_name = join '::', 'Class::MOP::Class::Immutable::CustomTrait',
1375 $trait, 'ForMetaClass', ref($self);
1376 }
1377
1378941.68ms return $class_name
# spent 1.68ms making 94 calls to Class::MOP::is_class_loaded, avg 18µs/call
1379 if Class::MOP::is_class_loaded($class_name);
1380
1381 # If the metaclass is a subclass of CMOP::Class which has had
1382 # metaclass roles applied (via Moose), then we want to make sure
1383 # that we preserve that anonymous class (see Fey::ORM for an
1384 # example of where this matters).
13853161µs my $meta_name = $meta->_real_ref_name;
# spent 161µs making 3 calls to Class::MOP::Class::_real_ref_name, avg 54µs/call
1386
1387322.9ms my $immutable_meta = $meta_name->create(
# spent 12.0ms making 1 call to Moose::Meta::Class::create # spent 10.9ms making 2 calls to Class::MOP::Class::create, avg 5.43ms/call
1388 $class_name,
1389 superclasses => [ ref $self ],
1390 );
1391
13923232ms Class::MOP::MiniTrait::apply( $immutable_meta, $trait );
# spent 232ms making 3 calls to Class::MOP::MiniTrait::apply, avg 77.2ms/call
1393
139430s $immutable_meta->make_immutable(
# spent 5.76ms making 3 calls to Class::MOP::Class::make_immutable, avg 1.92ms/call, recursion: max depth 1, sum of overlapping time 5.76ms
1395 inline_constructor => 0,
1396 inline_accessors => 0,
1397 );
1398
1399 return $class_name;
1400}
1401
1402sub _remove_inlined_code {
1403 my $self = shift;
1404
1405 $self->remove_method( $_->name ) for $self->_inlined_methods;
1406
1407 delete $self->{__immutable}{inlined_methods};
1408}
1409
1410sub _inlined_methods { @{ $_[0]{__immutable}{inlined_methods} || [] } }
1411
1412
# spent 2.22ms within Class::MOP::Class::_add_inlined_method which was called 112 times, avg 20µs/call: # 73 times (1.52ms+0s) by Class::MOP::Class::_inline_constructor at line 1481, avg 21µs/call # 39 times (708µs+0s) by Class::MOP::Class::_inline_destructor at line 1514, avg 18µs/call
sub _add_inlined_method {
14132242.47ms my ( $self, $method ) = @_;
1414
1415 push @{ $self->{__immutable}{inlined_methods} ||= [] }, $method;
1416}
1417
1418
# spent 1.35s (5.37ms+1.35) within Class::MOP::Class::_initialize_immutable which was called 94 times, avg 14.4ms/call: # 94 times (5.37ms+1.35s) by Class::MOP::Class::make_immutable at line 1321, avg 14.4ms/call
sub _initialize_immutable {
14192825.28ms my ( $self, %args ) = @_;
1420
1421 $self->{__immutable}{options} = \%args;
1422941.35s $self->_install_inlined_code(%args);
# spent 1.35s making 94 calls to Class::MOP::Class::_install_inlined_code, avg 14.3ms/call
1423}
1424
1425
# spent 1.35s (6.15ms+1.34) within Class::MOP::Class::_install_inlined_code which was called 94 times, avg 14.3ms/call: # 94 times (6.15ms+1.34s) by Class::MOP::Class::_initialize_immutable at line 1422, avg 14.3ms/call
sub _install_inlined_code {
14263766.06ms my ( $self, %args ) = @_;
1427
1428 # FIXME
142932243ms $self->_inline_accessors(%args) if $args{inline_accessors};
# spent 243ms making 32 calls to Class::MOP::Class::_inline_accessors, avg 7.60ms/call
143073907ms $self->_inline_constructor(%args) if $args{inline_constructor};
# spent 907ms making 73 calls to Class::MOP::Class::_inline_constructor, avg 12.4ms/call
143143190ms $self->_inline_destructor(%args) if $args{inline_destructor};
# spent 190ms making 43 calls to Class::MOP::Class::_inline_destructor, avg 4.41ms/call
1432}
1433
1434sub _rebless_as_mutable {
1435 my $self = shift;
1436
1437 bless $self, $self->_get_mutable_metaclass_name;
1438
1439 return $self;
1440}
1441
1442
# spent 243ms (3.06+240) within Class::MOP::Class::_inline_accessors which was called 32 times, avg 7.60ms/call: # 32 times (3.06ms+240ms) by Class::MOP::Class::_install_inlined_code at line 1429, avg 7.60ms/call
sub _inline_accessors {
144364935µs my $self = shift;
1444
1445321.05ms foreach my $attr_name ( $self->get_attribute_list ) {
# spent 1.05ms making 32 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 33µs/call
1446691.78ms138239ms $self->get_attribute($attr_name)->install_accessors(1);
# spent 230ms making 68 calls to Class::MOP::Attribute::install_accessors, avg 3.39ms/call # spent 6.30ms making 1 call to Moose::Meta::Attribute::install_accessors # spent 2.38ms making 69 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 35µs/call
1447 }
1448}
1449
1450
# spent 907ms (10.7+896) within Class::MOP::Class::_inline_constructor which was called 73 times, avg 12.4ms/call: # 73 times (10.7ms+896ms) by Class::MOP::Class::_install_inlined_code at line 1430, avg 12.4ms/call
sub _inline_constructor {
14515848.29ms my ( $self, %args ) = @_;
1452
1453 my $name = $args{constructor_name};
1454 # A class may not even have a constructor, and that's okay.
1455 return unless defined $name;
1456
14577318.8ms if ( $self->has_method($name) && !$args{replace_constructor} ) {
# spent 18.8ms making 73 calls to Class::MOP::Mixin::HasMethods::has_method, avg 258µs/call
1458 my $class = $self->name;
1459 warn "Not inlining a constructor for $class since it defines"
1460 . " its own constructor.\n"
1461 . "If you are certain you don't need to inline your"
1462 . " constructor, specify inline_constructor => 0 in your"
1463 . " call to $class->meta->make_immutable\n";
1464 return;
1465 }
1466
1467 my $constructor_class = $args{constructor_class};
1468
1469739.66ms Class::MOP::load_class($constructor_class);
# spent 18.5ms making 73 calls to Class::MOP::load_class, avg 254µs/call, recursion: max depth 2, sum of overlapping time 8.87ms
1470
1471146774ms my $constructor = $constructor_class->new(
# spent 461ms making 42 calls to Moose::Meta::Method::Constructor::new, avg 11.0ms/call # spent 312ms making 31 calls to Class::MOP::Method::Constructor::new, avg 10.1ms/call # spent 453µs making 73 calls to Class::MOP::Package::name, avg 6µs/call
1472 options => \%args,
1473 metaclass => $self,
1474 is_inline => 1,
1475 package_name => $self->name,
1476 name => $name,
1477 );
1478
14791461.95ms7252.6ms if ( $args{replace_constructor} or $constructor->can_be_inlined ) {
# spent 52.6ms making 72 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 730µs/call
14807330.9ms $self->add_method( $name => $constructor );
# spent 30.9ms making 73 calls to Class::MOP::Mixin::HasMethods::add_method, avg 423µs/call
1481731.52ms $self->_add_inlined_method($constructor);
# spent 1.52ms making 73 calls to Class::MOP::Class::_add_inlined_method, avg 21µs/call
1482 }
1483}
1484
1485
# spent 190ms (7.08+183) within Class::MOP::Class::_inline_destructor which was called 43 times, avg 4.41ms/call: # 43 times (7.08ms+183ms) by Class::MOP::Class::_install_inlined_code at line 1431, avg 4.41ms/call
sub _inline_destructor {
14863365.70ms my ( $self, %args ) = @_;
1487
1488 ( exists $args{destructor_class} && defined $args{destructor_class} )
1489 || confess "The 'inline_destructor' option is present, but "
1490 . "no destructor class was specified";
1491
1492436.53ms if ( $self->has_method('DESTROY') && ! $args{replace_destructor} ) {
# spent 6.53ms making 43 calls to Class::MOP::Mixin::HasMethods::has_method, avg 152µs/call
1493 my $class = $self->name;
1494 warn "Not inlining a destructor for $class since it defines"
1495 . " its own destructor.\n";
1496 return;
1497 }
1498
1499 my $destructor_class = $args{destructor_class};
1500
1501439.88ms Class::MOP::load_class($destructor_class);
# spent 10.8ms making 43 calls to Class::MOP::load_class, avg 252µs/call, recursion: max depth 2, sum of overlapping time 970µs
1502
15034338.7ms return unless $destructor_class->is_needed($self);
# spent 38.7ms making 43 calls to Moose::Meta::Method::Destructor::is_needed, avg 900µs/call
1504
15057883.8ms my $destructor = $destructor_class->new(
# spent 83.5ms making 39 calls to Moose::Meta::Method::Destructor::new, avg 2.14ms/call # spent 240µs making 39 calls to Class::MOP::Package::name, avg 6µs/call
1506 options => \%args,
1507 metaclass => $self,
1508 package_name => $self->name,
1509 name => 'DESTROY'
1510 );
1511
1512781.11ms3925.6ms if ( $args{replace_destructor} or $destructor->can_be_inlined ) {
# spent 25.6ms making 39 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 657µs/call
15133916.3ms $self->add_method( 'DESTROY' => $destructor );
# spent 16.3ms making 39 calls to Class::MOP::Mixin::HasMethods::add_method, avg 419µs/call
151439708µs $self->_add_inlined_method($destructor);
# spent 708µs making 39 calls to Class::MOP::Class::_add_inlined_method, avg 18µs/call
1515 }
1516}
1517
1518125µs1;
1519
1520__END__
 
# spent 292µs within Class::MOP::Class::CORE:match which was called 84 times, avg 3µs/call: # 42 times (170µs+0s) by Class::MOP::Class::is_anon_class at line 434, avg 4µs/call # 42 times (121µs+0s) by Class::MOP::Class::DESTROY at line 457, avg 3µs/call
sub Class::MOP::Class::CORE:match; # opcode
# spent 69µs within Class::MOP::Class::CORE:regcomp which was called 2 times, avg 34µs/call: # once (35µs+0s) by Class::MOP::Class::DESTROY at line 457 # once (34µs+0s) by Class::MOP::Class::is_anon_class at line 434
sub Class::MOP::Class::CORE:regcomp; # opcode
# spent 27.3ms (18.8+8.56) within Class::MOP::Class::CORE:sort which was called 73 times, avg 374µs/call: # 73 times (18.8ms+8.56ms) by Class::MOP::Class::_inline_slot_initializers at line 646, avg 374µs/call
sub Class::MOP::Class::CORE:sort; # opcode