← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:45:08 2010
Reported on Wed Nov 17 22:09:57 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP/Class.pm
StatementsExecuted 114768 statements in 1.40s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
64542513213ms1.03sClass::MOP::Class::::initializeClass::MOP::Class::initialize (recurses: max depth 1, inclusive time 10.1ms)
44021153ms1.01sClass::MOP::Class::::_construct_instanceClass::MOP::Class::_construct_instance
139211126ms239msClass::MOP::Class::::_single_metaclass_can_be_made_compatibleClass::MOP::Class::_single_metaclass_can_be_made_compatible
60876121ms284msClass::MOP::Class::::get_all_attributesClass::MOP::Class::get_all_attributes
113411117ms219msClass::MOP::Class::::_single_metaclass_is_compatibleClass::MOP::Class::_single_metaclass_is_compatible
2842192.7ms885msClass::MOP::Class::::_check_metaclass_compatibilityClass::MOP::Class::_check_metaclass_compatibility (recurses: max depth 1, inclusive time 3.85ms)
2051137.0ms343msClass::MOP::Class::::_can_fix_metaclass_incompatibilityClass::MOP::Class::_can_fix_metaclass_incompatibility
12037235.4ms56.0msClass::MOP::Class::::linearized_isaClass::MOP::Class::linearized_isa
11341130.1ms249msClass::MOP::Class::::_check_single_metaclass_compatibilityClass::MOP::Class::_check_single_metaclass_compatibility
2486627.9ms237msClass::MOP::Class::::find_method_by_nameClass::MOP::Class::find_method_by_name
2533327.4ms189msClass::MOP::Class::::find_next_method_by_nameClass::MOP::Class::find_next_method_by_name
2954325.1ms119msClass::MOP::Class::::class_precedence_listClass::MOP::Class::class_precedence_list (recurses: max depth 4, inclusive time 93.2ms)
1783321.7ms76.6msClass::MOP::Class::::find_attribute_by_nameClass::MOP::Class::find_attribute_by_name
1741121.3ms765msClass::MOP::Class::::_construct_class_instanceClass::MOP::Class::_construct_class_instance (recurses: max depth 1, inclusive time 990µs)
3305516.3ms641msClass::MOP::Class::::new_objectClass::MOP::Class::new_object
1163114.3ms224msClass::MOP::Class::::__ANON__[:967]Class::MOP::Class::__ANON__[:967]
1621113.3ms27.7msClass::MOP::Class::::_class_metaclass_is_compatibleClass::MOP::Class::_class_metaclass_is_compatible
1841112.6ms366msClass::MOP::Class::::_fix_metaclass_incompatibilityClass::MOP::Class::_fix_metaclass_incompatibility (recurses: max depth 1, inclusive time 2.59ms)
78711512.2ms150msClass::MOP::Class::::get_meta_instanceClass::MOP::Class::get_meta_instance
1871111.9ms1.60sClass::MOP::Class::::_post_add_attributeClass::MOP::Class::_post_add_attribute
812211.4ms84.9msClass::MOP::Class::::find_all_methods_by_nameClass::MOP::Class::find_all_methods_by_name
3794110.9ms17.6msClass::MOP::Class::::_real_ref_nameClass::MOP::Class::_real_ref_name
731110.9ms712msClass::MOP::Class::::_inline_constructorClass::MOP::Class::_inline_constructor
1371110.0ms138msClass::MOP::Class::::_create_meta_instanceClass::MOP::Class::_create_meta_instance
93119.74ms252msClass::MOP::Class::::_immutable_metaclassClass::MOP::Class::_immutable_metaclass (recurses: max depth 1, inclusive time 937µs)
42119.24ms611msClass::MOP::Class::::reinitializeClass::MOP::Class::reinitialize
187118.33ms1.56sClass::MOP::Class::::__ANON__[:790]Class::MOP::Class::__ANON__[:790]
110118.08ms46.3msClass::MOP::Class::::_superclasses_updatedClass::MOP::Class::_superclasses_updated
9348467.61ms1.39sClass::MOP::Class::::make_immutableClass::MOP::Class::make_immutable (recurses: max depth 1, inclusive time 1.68ms)
187117.42ms9.66msClass::MOP::Class::::invalidate_meta_instancesClass::MOP::Class::invalidate_meta_instances
205117.28ms28.7msClass::MOP::Class::::_class_metaclass_can_be_made_compatibleClass::MOP::Class::_class_metaclass_can_be_made_compatible
93227.14ms11.3msClass::MOP::Class::::_immutable_optionsClass::MOP::Class::_immutable_options
389327.10ms7.10msClass::MOP::Class::::_base_metaclassesClass::MOP::Class::_base_metaclasses
42116.82ms199msClass::MOP::Class::::_inline_destructorClass::MOP::Class::_inline_destructor
93115.70ms1.10sClass::MOP::Class::::_install_inlined_codeClass::MOP::Class::_install_inlined_code
1115.34ms6.05msClass::MOP::Class::::BEGIN@7Class::MOP::Class::BEGIN@7
93115.33ms1.11sClass::MOP::Class::::_initialize_immutableClass::MOP::Class::_initialize_immutable
99335.28ms218msClass::MOP::Class::::add_around_method_modifierClass::MOP::Class::add_around_method_modifier
162114.65ms32.4msClass::MOP::Class::::_check_class_metaclass_compatibilityClass::MOP::Class::_check_class_metaclass_compatibility
187114.44ms15.7msClass::MOP::Class::::_attach_attributeClass::MOP::Class::_attach_attribute
1114.29ms8.64msClass::MOP::Class::::BEGIN@10Class::MOP::Class::BEGIN@10
24224.21ms343msClass::MOP::Class::::createClass::MOP::Class::create
1114.19ms5.04msClass::MOP::Class::::BEGIN@8Class::MOP::Class::BEGIN@8
1114.03ms8.46msClass::MOP::Class::::BEGIN@9Class::MOP::Class::BEGIN@9
93113.93ms256msClass::MOP::Class::::_rebless_as_immutableClass::MOP::Class::_rebless_as_immutable (recurses: max depth 1, inclusive time 1.09ms)
64113.75ms3.75msClass::MOP::Class::::_newClass::MOP::Class::_new
32113.15ms187msClass::MOP::Class::::_inline_accessorsClass::MOP::Class::_inline_accessors
73222.88ms23.6msClass::MOP::Class::::inline_create_instanceClass::MOP::Class::inline_create_instance
317112.51ms2.51msClass::MOP::Class::::is_immutableClass::MOP::Class::is_immutable
42112.35ms214msClass::MOP::Class::::_restore_metaobjects_fromClass::MOP::Class::_restore_metaobjects_from
112212.26ms2.26msClass::MOP::Class::::_add_inlined_methodClass::MOP::Class::_add_inlined_method
187112.24ms2.24msClass::MOP::Class::::invalidate_meta_instanceClass::MOP::Class::invalidate_meta_instance
42112.04ms2.80msClass::MOP::Class::::DESTROYClass::MOP::Class::DESTROY
1112.00ms4.28msClass::MOP::Class::::BEGIN@18Class::MOP::Class::BEGIN@18
110111.77ms1.77msClass::MOP::Class::::_superclass_metasClass::MOP::Class::_superclass_metas
8111.49ms27.4msClass::MOP::Class::::get_all_methodsClass::MOP::Class::get_all_methods
42111.46ms3.05msClass::MOP::Class::::_remove_generated_metaobjectsClass::MOP::Class::_remove_generated_metaobjects
42111.35ms1.81msClass::MOP::Class::::is_anon_classClass::MOP::Class::is_anon_class
110111.28ms1.28msClass::MOP::Class::::update_meta_instance_dependenciesClass::MOP::Class::update_meta_instance_dependencies
1111.05ms1.40msClass::MOP::Class::::BEGIN@11Class::MOP::Class::BEGIN@11
22111.05ms1.17sClass::MOP::Class::::create_anon_classClass::MOP::Class::create_anon_class
1111.04ms15.4msClass::MOP::Class::::BEGIN@16Class::MOP::Class::BEGIN@16
12433896µs896µsClass::MOP::Class::::is_mutableClass::MOP::Class::is_mutable
7311892µs892µsClass::MOP::Class::::reset_package_cache_flagClass::MOP::Class::reset_package_cache_flag
1111610µs22.4msClass::MOP::Class::::add_before_method_modifierClass::MOP::Class::add_before_method_modifier
111371µs1.16msClass::MOP::Class::::_clone_instanceClass::MOP::Class::_clone_instance
611338µs6.72msClass::MOP::Class::::add_after_method_modifierClass::MOP::Class::add_after_method_modifier
8421300µs300µsClass::MOP::Class::::CORE:matchClass::MOP::Class::CORE:match (opcode)
111111µs1.30msClass::MOP::Class::::clone_objectClass::MOP::Class::clone_object
22185µs85µsClass::MOP::Class::::CORE:regcompClass::MOP::Class::CORE:regcomp (opcode)
11172µs91µsClass::MOP::Class::::BEGIN@4Class::MOP::Class::BEGIN@4
11155µs132µsClass::MOP::Class::::BEGIN@445Class::MOP::Class::BEGIN@445
11154µs259µsClass::MOP::Class::::BEGIN@17Class::MOP::Class::BEGIN@17
11151µs14.6msClass::MOP::Class::::BEGIN@24Class::MOP::Class::BEGIN@24
11149µs119µsClass::MOP::Class::::BEGIN@480Class::MOP::Class::BEGIN@480
11140µs99µsClass::MOP::Class::::BEGIN@467Class::MOP::Class::BEGIN@467
11140µs201µsClass::MOP::Class::::BEGIN@13Class::MOP::Class::BEGIN@13
11139µs185µsClass::MOP::Class::::BEGIN@15Class::MOP::Class::BEGIN@15
11138µs221µsClass::MOP::Class::::BEGIN@14Class::MOP::Class::BEGIN@14
11137µs106µsClass::MOP::Class::::BEGIN@5Class::MOP::Class::BEGIN@5
0000s0sClass::MOP::Class::::__ANON__[:226]Class::MOP::Class::__ANON__[:226]
0000s0sClass::MOP::Class::::__ANON__[:794]Class::MOP::Class::__ANON__[:794]
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_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::::inline_rebless_instanceClass::MOP::Class::inline_rebless_instance
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
0000s0sClass::MOP::Class::::update_package_cache_flagClass::MOP::Class::update_package_cache_flag
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
4397µs2110µs
# spent 91µs (72+19) within Class::MOP::Class::BEGIN@4 which was called: # once (72µs+19µs) by Class::MOP::BEGIN@19 at line 4
use strict;
# spent 91µs making 1 call to Class::MOP::Class::BEGIN@4 # spent 19µs making 1 call to strict::import
5395µs2175µs
# spent 106µs (37+69) within Class::MOP::Class::BEGIN@5 which was called: # once (37µs+69µs) by Class::MOP::BEGIN@19 at line 5
use warnings;
# spent 106µs making 1 call to Class::MOP::Class::BEGIN@5 # spent 69µs making 1 call to warnings::import
6
73436µs16.05ms
# spent 6.05ms (5.34+712µs) within Class::MOP::Class::BEGIN@7 which was called: # once (5.34ms+712µs) by Class::MOP::BEGIN@19 at line 7
use Class::MOP::Instance;
# spent 6.05ms making 1 call to Class::MOP::Class::BEGIN@7
83459µs15.04ms
# spent 5.04ms (4.19+855µs) within Class::MOP::Class::BEGIN@8 which was called: # once (4.19ms+855µs) by Class::MOP::BEGIN@19 at line 8
use Class::MOP::Method::Wrapped;
# spent 5.04ms making 1 call to Class::MOP::Class::BEGIN@8
93486µs18.46ms
# spent 8.46ms (4.03+4.43) within Class::MOP::Class::BEGIN@9 which was called: # once (4.03ms+4.43ms) by Class::MOP::BEGIN@19 at line 9
use Class::MOP::Method::Accessor;
# spent 8.46ms making 1 call to Class::MOP::Class::BEGIN@9
103485µs18.64ms
# spent 8.64ms (4.29+4.34) within Class::MOP::Class::BEGIN@10 which was called: # once (4.29ms+4.34ms) by Class::MOP::BEGIN@19 at line 10
use Class::MOP::Method::Constructor;
# spent 8.64ms making 1 call to Class::MOP::Class::BEGIN@10
113599µs11.40ms
# spent 1.40ms (1.05+347µs) within Class::MOP::Class::BEGIN@11 which was called: # once (1.05ms+347µs) by Class::MOP::BEGIN@19 at line 11
use Class::MOP::MiniTrait;
# spent 1.40ms making 1 call to Class::MOP::Class::BEGIN@11
12
133115µs2362µs
# spent 201µs (40+161) within Class::MOP::Class::BEGIN@13 which was called: # once (40µs+161µs) by Class::MOP::BEGIN@19 at line 13
use Carp 'confess';
# spent 201µs making 1 call to Class::MOP::Class::BEGIN@13 # spent 161µs making 1 call to Exporter::import
143177µs2404µs
# spent 221µs (38+183) within Class::MOP::Class::BEGIN@14 which was called: # once (38µs+183µs) by Class::MOP::BEGIN@19 at line 14
use Scalar::Util 'blessed', 'reftype', 'weaken';
# spent 221µs making 1 call to Class::MOP::Class::BEGIN@14 # spent 183µs making 1 call to Exporter::import
153110µs2331µs
# spent 185µs (39+146) within Class::MOP::Class::BEGIN@15 which was called: # once (39µs+146µs) by Class::MOP::BEGIN@19 at line 15
use Sub::Name 'subname';
# spent 185µs making 1 call to Class::MOP::Class::BEGIN@15 # spent 146µs making 1 call to Exporter::import
163475µs216.2ms
# spent 15.4ms (1.04+14.3) within Class::MOP::Class::BEGIN@16 which was called: # once (1.04ms+14.3ms) by Class::MOP::BEGIN@19 at line 16
use Devel::GlobalDestruction 'in_global_destruction';
# spent 15.4ms making 1 call to Class::MOP::Class::BEGIN@16 # spent 854µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
173113µs2464µs
# spent 259µs (54+205) within Class::MOP::Class::BEGIN@17 which was called: # once (54µs+205µs) by Class::MOP::BEGIN@19 at line 17
use Try::Tiny;
# spent 259µs making 1 call to Class::MOP::Class::BEGIN@17 # spent 205µs making 1 call to Exporter::import
183656µs24.85ms
# spent 4.28ms (2.00+2.27) within Class::MOP::Class::BEGIN@18 which was called: # once (2.00ms+2.27ms) by Class::MOP::BEGIN@19 at line 18
use List::MoreUtils 'all';
# spent 4.28ms making 1 call to Class::MOP::Class::BEGIN@18 # spent 570µs making 1 call to Exporter::import
19
2015µsour $VERSION = '1.11';
21193µs$VERSION = eval $VERSION;
# spent 13µs executing statements in string eval
2214µsour $AUTHORITY = 'cpan:STEVAN';
23
2410s
# spent 14.6ms (51µs+14.5) within Class::MOP::Class::BEGIN@24 which was called: # once (51µs+14.5ms) by Class::MOP::BEGIN@19 at line 26
use base 'Class::MOP::Module',
# spent 14.5ms making 1 call to base::import, recursion: max depth 1, sum of overlapping time 14.5ms
25 'Class::MOP::Mixin::HasAttributes',
2636.06ms114.6ms 'Class::MOP::Mixin::HasMethods';
# spent 14.6ms making 1 call to Class::MOP::Class::BEGIN@24
27
28# Creation
29
30
# spent 1.03s (213ms+817ms) within Class::MOP::Class::initialize which was called 6454 times, avg 160µs/call: # 2686 times (83.5ms+22.6ms) by Class::MOP::Class::get_all_attributes at line 826, avg 39µs/call # 757 times (27.0ms+22.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::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 # 611 times (21.1ms+5.95ms) by Class::MOP::Class::find_method_by_name at line 1018, avg 44µs/call # 498 times (15.2ms+4.40ms) by Class::MOP::Class::find_attribute_by_name at line 816, avg 39µs/call # 474 times (15.8ms+4.81ms) by Class::MOP::Class::find_next_method_by_name at line 1067, avg 43µs/call # 260 times (8.20ms+2.52ms) by Moose::Meta::Attribute::_new or Moose::Meta::Method::_new or Moose::Meta::Role::_new at line 4 of (eval 76)[Class/MOP/Method/Generated.pm:53], avg 41µs/call # 253 times (8.22ms+2.29ms) by Class::MOP::Class::find_all_methods_by_name at line 1050, avg 42µs/call # 232 times (7.61ms+2.32ms) by Class::MOP::Class::class_precedence_list at line 927, avg 43µs/call # 205 times (7.03ms+1.82ms) by Class::MOP::Class::_fix_metaclass_incompatibility at line 310, avg 43µs/call # 110 times (5.69ms+674ms) by Moose::Meta::Class::initialize at line 68 of Moose/Meta/Class.pm, avg 6.18ms/call # 98 times (3.42ms+1.02ms) by Class::MOP::Attribute::set_initial_value at line 253 of Class/MOP/Attribute.pm, avg 45µs/call # 80 times (2.75ms+886µs) by Moose::Util::MetaRole::_make_new_class at line 157 of Moose/Util/MetaRole.pm, avg 45µs/call # 49 times (2.26ms+599µ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 58µs/call # 33 times (1.28ms+25.1ms) by Class::MOP::Object::meta at line 18 of Class/MOP/Object.pm, avg 799µs/call # 26 times (811µs+8.49ms) by Class::MOP::Method::_new at line 54 of Class/MOP/Method.pm, avg 358µs/call # 19 times (1.02ms+11.2ms) by metaclass::import at line 45 of metaclass.pm, avg 643µs/call # 18 times (679µs+7.02ms) by Class::MOP::Mixin::meta at line 14 of Class/MOP/Mixin.pm, avg 428µs/call # 14 times (680µs+14.7ms) by Class::MOP::MiniTrait::apply at line 15 of Class/MOP/MiniTrait.pm, avg 1.10ms/call # 9 times (280µs+74µs) by Class::MOP::Class::get_all_methods at line 1029, avg 39µs/call # 8 times (235µs+71µs) by Class::MOP::Attribute::get_raw_value at line 274 of Class/MOP/Attribute.pm, avg 38µs/call # 7 times (340µs+3.80ms) by Moose::BEGIN@38 at line 11 of Moose/Meta/Attribute/Native.pm, avg 591µs/call # 2 times (89µs+1.16ms) by Class::MOP::Class::create at line 525, avg 626µs/call # 2 times (88µs+28µs) by Class::MOP::Attribute::has_value at line 282 of Class/MOP/Attribute.pm, avg 58µs/call # 2 times (59µs+17µs) by Class::MOP::Attribute::set_raw_value at line 266 of Class/MOP/Attribute.pm, avg 38µs/call # once (31µs+9µs) by Class::MOP::Attribute::_new at line 62 of Class/MOP/Attribute.pm
sub initialize {
3132270205ms 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
456628826ms return Class::MOP::get_metaclass_by_name($package_name)
# spent 766ms making 174 calls to Class::MOP::Class::_construct_class_instance, avg 4.40ms/call, recursion: max depth 1, sum of overlapping time 990µs # spent 60.5ms making 6454 calls to Class::MOP::get_metaclass_by_name, avg 9µs/call
46 || $class->_construct_class_instance(package => $package_name, @_);
47}
48
49
# spent 611ms (9.24+601) within Class::MOP::Class::reinitialize which was called 42 times, avg 14.5ms/call: # 42 times (9.24ms+601ms) by Moose::Meta::Class::reinitialize at line 157 of Moose/Meta/Class.pm, avg 14.5ms/call
sub reinitialize {
5037810.7ms my ( $class, @args ) = @_;
51 unshift @args, "package" if @args % 2;
52 my %options = @args;
5342301µs my $old_metaclass = blessed($options{package})
# spent 301µ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.81ms $options{weaken} = Class::MOP::metaclass_is_weak($old_metaclass->name)
# spent 1.08ms making 42 calls to Class::MOP::metaclass_is_weak, avg 26µs/call # spent 290µs making 42 calls to UNIVERSAL::isa, avg 7µs/call # spent 238µs making 42 calls to Scalar::Util::blessed, avg 6µs/call # spent 205µs making 42 calls to Class::MOP::Package::name, avg 5µs/call
57 if !exists $options{weaken}
58 && blessed($old_metaclass)
59 && $old_metaclass->isa('Class::MOP::Class');
60843.30ms $old_metaclass->_remove_generated_metaobjects
# spent 3.05ms making 42 calls to Class::MOP::Class::_remove_generated_metaobjects, avg 73µs/call # spent 254µs making 42 calls to UNIVERSAL::isa, avg 6µs/call
61 if $old_metaclass && $old_metaclass->isa('Class::MOP::Class');
6242381ms my $new_metaclass = $class->SUPER::reinitialize(%options);
# spent 381ms making 42 calls to Class::MOP::Package::reinitialize, avg 9.08ms/call
6384215ms $new_metaclass->_restore_metaobjects_from($old_metaclass)
# spent 214ms making 42 calls to Class::MOP::Class::_restore_metaobjects_from, avg 5.11ms/call # spent 299µ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 765ms (21.3+744) within Class::MOP::Class::_construct_class_instance which was called 174 times, avg 4.40ms/call: # 174 times (21.3ms+744ms) by Class::MOP::Class::initialize at line 45, avg 4.40ms/call
sub _construct_class_instance {
75219819.2ms 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
861741.42ms if (defined(my $meta = Class::MOP::get_metaclass_by_name($package_name))) {
# spent 1.42ms making 174 calls to Class::MOP::get_metaclass_by_name, avg 8µs/call
87 return $meta;
88 }
89
90 $class
91101.06ms = ref $class
# spent 1.06ms making 10 calls to Class::MOP::Class::_real_ref_name, avg 106µs/call
92 ? $class->_real_ref_name
93 : $class;
94
95 # now create the metaclass
96 my $meta;
97643.75ms if ($class eq 'Class::MOP::Class') {
# spent 3.75ms making 64 calls to Class::MOP::Class::_new, avg 59µ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
105220399ms $meta = $class->meta->_construct_instance($options)
# spent 389ms making 110 calls to Class::MOP::Class::_construct_instance, avg 3.54ms/call # spent 9.09ms making 110 calls to Class::MOP::Object::meta, avg 83µs/call
106 }
107
108 # and check the metaclass compatibility
109174334ms $meta->_check_metaclass_compatibility();
# spent 338ms making 174 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 1.94ms/call, recursion: max depth 1, sum of overlapping time 3.85ms
110
1111742.36ms Class::MOP::store_metaclass_by_name($package_name, $meta);
# spent 2.36ms making 174 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
116261µs Class::MOP::weaken_metaclass($package_name) if $options->{weaken};
# spent 61µs making 2 calls to Class::MOP::weaken_metaclass, avg 30µs/call
117
118 $meta;
119}
120
121
# spent 17.6ms (10.9+6.72) within Class::MOP::Class::_real_ref_name which was called 379 times, avg 47µs/call: # 205 times (5.70ms+3.61ms) by Class::MOP::Class::_class_metaclass_can_be_made_compatible at line 355, avg 45µs/call # 162 times (4.78ms+2.36ms) by Class::MOP::Class::_class_metaclass_is_compatible at line 265, avg 44µs/call # 10 times (376µs+688µs) by Class::MOP::Class::_construct_class_instance at line 91, avg 106µs/call # 2 times (64µs+65µs) by Class::MOP::Class::_immutable_metaclass at line 1244, avg 64µs/call
sub _real_ref_name {
12275810.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
1264416.72ms return $self->is_immutable
# spent 2.87ms making 56 calls to Class::MOP::Class::Immutable::Class::MOP::Class::is_immutable, avg 51µs/call # spent 2.51ms making 317 calls to Class::MOP::Class::is_immutable, avg 8µs/call # spent 953µs making 62 calls to Class::MOP::Class::Immutable::Trait::_get_mutable_metaclass_name, avg 15µs/call # spent 384µs making 6 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::is_immutable, avg 64µs/call
127 ? $self->_get_mutable_metaclass_name()
128 : ref $self;
129}
130
131
# spent 3.75ms within Class::MOP::Class::_new which was called 64 times, avg 59µs/call: # 64 times (3.75ms+0s) by Class::MOP::Class::_construct_class_instance at line 97, avg 59µs/call
sub _new {
1322564.04ms 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
184731.08ms
# spent 892µs within Class::MOP::Class::reset_package_cache_flag which was called 73 times, avg 12µs/call: # 73 times (892µs+0s) by Moose::Meta::Role::Application::ToClass::apply_methods at line 190 of Moose/Meta/Role/Application/ToClass.pm, avg 12µs/call
sub reset_package_cache_flag { (shift)->{'_package_cache_flag'} = undef }
185sub update_package_cache_flag {
186 my $self = shift;
187 # NOTE:
188 # we can manually update the cache number
189 # since we are actually adding the method
190 # to our cache as well. This avoids us
191 # having to regenerate the method_map.
192 # - SL
193 $self->{'_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name);
194}
195
196## Metaclass compatibility
197{
198222µs my %base_metaclass = (
199 attribute_metaclass => 'Class::MOP::Attribute',
200 method_metaclass => 'Class::MOP::Method',
201 wrapped_method_metaclass => 'Class::MOP::Method::Wrapped',
202 instance_metaclass => 'Class::MOP::Instance',
203 constructor_class => 'Class::MOP::Method::Constructor',
204 destructor_class => 'Class::MOP::Method::Destructor',
205 );
206
2073898.83ms
# spent 7.10ms within Class::MOP::Class::_base_metaclasses which was called 389 times, avg 18µs/call: # 312 times (5.82ms+0s) by Moose::Meta::Class::_base_metaclasses at line 354 of Moose/Meta/Class.pm, avg 19µs/call # 43 times (765µs+0s) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 343, avg 18µs/call # 34 times (507µs+0s) by Class::MOP::Class::_check_metaclass_compatibility at line 218, avg 15µs/call
sub _base_metaclasses { %base_metaclass }
208}
209
210
# spent 885ms (92.7+792) within Class::MOP::Class::_check_metaclass_compatibility which was called 284 times, avg 3.11ms/call: # 174 times (23.4ms+310ms) by Class::MOP::Class::_construct_class_instance at line 109, avg 1.92ms/call # 110 times (69.3ms+481ms) by Class::MOP::Class::superclasses at line 857, avg 5.01ms/call
sub _check_metaclass_compatibility {
211481685.0ms my $self = shift;
212
21328464.9ms my @superclasses = $self->superclasses
# spent 72.8ms making 218 calls to Moose::Meta::Class::superclasses, avg 334µs/call, recursion: max depth 1, sum of overlapping time 26.5ms # spent 19.2ms making 66 calls to Class::MOP::Class::superclasses, avg 291µs/call, recursion: max depth 1, sum of overlapping time 560µs
214 or return;
215
216184366ms $self->_fix_metaclass_incompatibility(@superclasses);
# spent 369ms making 184 calls to Class::MOP::Class::_fix_metaclass_incompatibility, avg 2.00ms/call, recursion: max depth 1, sum of overlapping time 2.59ms
217
21818434.0ms my %base_metaclass = $self->_base_metaclasses;
# spent 33.5ms making 150 calls to Moose::Meta::Class::_base_metaclasses, avg 224µs/call # spent 507µs making 34 calls to Class::MOP::Class::_base_metaclasses, avg 15µs/call
219
220 # this is always okay ...
221 return
222 if ref($self) eq 'Class::MOP::Class'
223 && all {
2244082.92ms2041.93ms my $meta = $self->$_;
# spent 366µs making 34 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 11µs/call # spent 329µs making 34 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 10µs/call # spent 325µs making 34 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 10µs/call # spent 318µs making 34 calls to Class::MOP::Class::constructor_class, avg 9µs/call # spent 310µs making 34 calls to Class::MOP::Class::instance_metaclass, avg 9µs/call # spent 281µs making 34 calls to Class::MOP::Class::destructor_class, avg 8µs/call
22511.21ms !defined($meta) || $meta eq $base_metaclass{$_};
226 }
227346.35ms keys %base_metaclass;
# spent 6.35ms making 34 calls to List::MoreUtils::all, avg 187µs/call
228
229 for my $superclass (@superclasses) {
23016232.4ms $self->_check_class_metaclass_compatibility($superclass);
# spent 32.4ms making 162 calls to Class::MOP::Class::_check_class_metaclass_compatibility, avg 200µs/call
231 }
232
233 for my $metaclass_type ( keys %base_metaclass ) {
234105013.5ms next unless defined $self->$metaclass_type;
# spent 2.20ms making 150 calls to Moose::Meta::Class::error_class, avg 15µs/call # spent 2.07ms making 150 calls to Moose::Meta::Class::constructor_class, avg 14µs/call # spent 2.04ms making 150 calls to Moose::Meta::Class::destructor_class, avg 14µs/call # spent 1.86ms making 150 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 12µs/call # spent 1.84ms making 150 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 12µs/call # spent 1.77ms making 150 calls to Class::MOP::Class::instance_metaclass, avg 12µs/call # spent 1.76ms making 150 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 12µs/call
235 for my $superclass (@superclasses) {
2361134249ms $self->_check_single_metaclass_compatibility( $metaclass_type,
# spent 249ms making 1134 calls to Class::MOP::Class::_check_single_metaclass_compatibility, avg 219µs/call
237 $superclass );
238 }
239 }
240}
241
242
# spent 32.4ms (4.65+27.7) within Class::MOP::Class::_check_class_metaclass_compatibility which was called 162 times, avg 200µs/call: # 162 times (4.65ms+27.7ms) by Class::MOP::Class::_check_metaclass_compatibility at line 230, avg 200µs/call
sub _check_class_metaclass_compatibility {
2434864.25ms my $self = shift;
244 my ( $superclass_name ) = @_;
245
24616227.7ms if (!$self->_class_metaclass_is_compatible($superclass_name)) {
# spent 27.7ms making 162 calls to Class::MOP::Class::_class_metaclass_is_compatible, avg 171µs/call
247 my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name);
248
249 my $super_meta_type = $super_meta->_real_ref_name;
250
251 confess "The metaclass of " . $self->name . " ("
252 . (ref($self)) . ")" . " is not compatible with "
253 . "the metaclass of its superclass, "
254 . $superclass_name . " (" . ($super_meta_type) . ")";
255 }
256}
257
258
# spent 27.7ms (13.3+14.4) within Class::MOP::Class::_class_metaclass_is_compatible which was called 162 times, avg 171µs/call: # 162 times (13.3ms+14.4ms) by Class::MOP::Class::_check_class_metaclass_compatibility at line 246, avg 171µs/call
sub _class_metaclass_is_compatible {
2598108.17ms my $self = shift;
260 my ( $superclass_name ) = @_;
261
2621621.73ms my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name)
# spent 1.73ms making 162 calls to Class::MOP::get_metaclass_by_name, avg 11µs/call
263 || return 1;
264
2651627.14ms my $super_meta_name = $super_meta->_real_ref_name;
# spent 7.14ms making 162 calls to Class::MOP::Class::_real_ref_name, avg 44µs/call
266
2671625.54ms return $self->_is_compatible_with($super_meta_name);
# spent 5.54ms making 162 calls to Class::MOP::Object::_is_compatible_with, avg 34µs/call
268}
269
270
# spent 249ms (30.1+219) within Class::MOP::Class::_check_single_metaclass_compatibility which was called 1134 times, avg 219µs/call: # 1134 times (30.1ms+219ms) by Class::MOP::Class::_check_metaclass_compatibility at line 236, avg 219µs/call
sub _check_single_metaclass_compatibility {
271340228.6ms my $self = shift;
272 my ( $metaclass_type, $superclass_name ) = @_;
273
2741134219ms if (!$self->_single_metaclass_is_compatible($metaclass_type, $superclass_name)) {
# spent 219ms making 1134 calls to Class::MOP::Class::_single_metaclass_is_compatible, avg 193µs/call
275 my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name);
276 my $metaclass_type_name = $metaclass_type;
277 $metaclass_type_name =~ s/_(?:meta)?class$//;
278 $metaclass_type_name =~ s/_/ /g;
279 confess "The $metaclass_type_name metaclass for "
280 . $self->name . " (" . ($self->$metaclass_type)
281 . ")" . " is not compatible with the "
282 . "$metaclass_type_name metaclass of its "
283 . "superclass, $superclass_name ("
284 . ($super_meta->$metaclass_type) . ")";
285 }
286}
287
288
# spent 219ms (117+102) within Class::MOP::Class::_single_metaclass_is_compatible which was called 1134 times, avg 193µs/call: # 1134 times (117ms+102ms) by Class::MOP::Class::_check_single_metaclass_compatibility at line 274, avg 193µs/call
sub _single_metaclass_is_compatible {
2897793105ms my $self = shift;
290 my ( $metaclass_type, $superclass_name ) = @_;
291
29211349.51ms my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name)
# spent 9.51ms making 1134 calls to Class::MOP::get_metaclass_by_name, avg 8µs/call
293 || return 1;
294
295 # for instance, Moose::Meta::Class has a error_class attribute, but
296 # Class::MOP::Class doesn't - this shouldn't be an error
29711347.28ms return 1 unless $super_meta->can($metaclass_type);
# spent 7.28ms making 1134 calls to UNIVERSAL::can, avg 6µs/call
298 # for instance, Moose::Meta::Class has a destructor_class, but
299 # Class::MOP::Class doesn't - this shouldn't be an error
300110512.3ms return 1 unless defined $super_meta->$metaclass_type;
# spent 1.72ms making 162 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 11µs/call # spent 1.70ms making 162 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 11µs/call # spent 1.69ms making 133 calls to Moose::Meta::Class::constructor_class, avg 13µs/call # spent 1.67ms making 162 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 10µs/call # spent 1.67ms making 133 calls to Moose::Meta::Class::destructor_class, avg 13µs/call # spent 1.65ms making 133 calls to Moose::Meta::Class::error_class, avg 12µs/call # spent 1.64ms making 162 calls to Class::MOP::Class::instance_metaclass, avg 10µs/call # spent 285µs making 29 calls to Class::MOP::Class::constructor_class, avg 10µs/call # spent 261µs making 29 calls to Class::MOP::Class::destructor_class, avg 9µs/call
301 # if metaclass is defined in superclass but not here, it's not compatible
302 # this is a really odd case
303107611.6ms return 0 unless defined $self->$metaclass_type;
# spent 1.99ms making 162 calls to Moose::Meta::Class::constructor_class, avg 12µs/call # spent 1.65ms making 162 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 10µs/call # spent 1.64ms making 133 calls to Moose::Meta::Class::error_class, avg 12µs/call # spent 1.63ms making 133 calls to Moose::Meta::Class::destructor_class, avg 12µs/call # spent 1.59ms making 162 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 10µs/call # spent 1.58ms making 162 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 10µs/call # spent 1.51ms making 162 calls to Class::MOP::Class::instance_metaclass, avg 9µs/call
304
305322861.3ms return $self->$metaclass_type->_is_compatible_with($super_meta->$metaclass_type);
# spent 38.9ms making 1076 calls to Class::MOP::Object::_is_compatible_with, avg 36µs/call # spent 3.49ms making 295 calls to Moose::Meta::Class::constructor_class, avg 12µs/call # spent 3.20ms making 324 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 10µs/call # spent 3.17ms making 324 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 10µs/call # spent 3.14ms making 266 calls to Moose::Meta::Class::error_class, avg 12µs/call # spent 3.09ms making 266 calls to Moose::Meta::Class::destructor_class, avg 12µs/call # spent 3.07ms making 324 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 9µs/call # spent 3.00ms making 324 calls to Class::MOP::Class::instance_metaclass, avg 9µs/call # spent 274µs making 29 calls to Class::MOP::Class::constructor_class, avg 9µs/call
306}
307
308
# spent 366ms (12.6+353) within Class::MOP::Class::_fix_metaclass_incompatibility which was called 184 times, avg 1.99ms/call: # 184 times (12.6ms+353ms) by Class::MOP::Class::_check_metaclass_compatibility at line 216, avg 1.99ms/call
sub _fix_metaclass_incompatibility {
309133011.9ms my $self = shift;
3102058.85ms my @supers = map { Class::MOP::Class->initialize($_) } @_;
# spent 13.4ms making 205 calls to Class::MOP::Class::initialize, avg 65µs/call, recursion: max depth 1, sum of overlapping time 4.58ms
311
312 my $necessary = 0;
313 for my $super (@supers) {
314205343ms $necessary = 1
# spent 343ms making 205 calls to Class::MOP::Class::_can_fix_metaclass_incompatibility, avg 1.67ms/call
315 if $self->_can_fix_metaclass_incompatibility($super);
316 }
317 return unless $necessary;
318
319 for my $super (@supers) {
320 if (!$self->_class_metaclass_is_compatible($super->name)) {
321 $self->_fix_class_metaclass_incompatibility($super);
322 }
323 }
324
325 my %base_metaclass = $self->_base_metaclasses;
326 for my $metaclass_type (keys %base_metaclass) {
327 for my $super (@supers) {
328 if (!$self->_single_metaclass_is_compatible($metaclass_type, $super->name)) {
329 $self->_fix_single_metaclass_incompatibility(
330 $metaclass_type, $super
331 );
332 }
333 }
334 }
335}
336
337
# spent 343ms (37.0+306) within Class::MOP::Class::_can_fix_metaclass_incompatibility which was called 205 times, avg 1.67ms/call: # 205 times (37.0ms+306ms) by Class::MOP::Class::_fix_metaclass_incompatibility at line 314, avg 1.67ms/call
sub _can_fix_metaclass_incompatibility {
338262233.1ms my $self = shift;
339 my ($super_meta) = @_;
340
34120528.7ms return 1 if $self->_class_metaclass_can_be_made_compatible($super_meta);
# spent 28.7ms making 205 calls to Class::MOP::Class::_class_metaclass_can_be_made_compatible, avg 140µs/call
342
34320538.3ms my %base_metaclass = $self->_base_metaclasses;
# spent 37.5ms making 162 calls to Moose::Meta::Class::_base_metaclasses, avg 232µs/call # spent 765µs making 43 calls to Class::MOP::Class::_base_metaclasses, avg 18µs/call
344 for my $metaclass_type (keys %base_metaclass) {
3451392239ms return 1 if $self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type);
# spent 239ms making 1392 calls to Class::MOP::Class::_single_metaclass_can_be_made_compatible, avg 171µs/call
346 }
347
348 return;
349}
350
351
# spent 28.7ms (7.28+21.4) within Class::MOP::Class::_class_metaclass_can_be_made_compatible which was called 205 times, avg 140µs/call: # 205 times (7.28ms+21.4ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 341, avg 140µs/call
sub _class_metaclass_can_be_made_compatible {
3526157.16ms my $self = shift;
353 my ($super_meta) = @_;
354
35541021.4ms return $self->_can_be_made_compatible_with($super_meta->_real_ref_name);
# spent 12.1ms making 205 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 59µs/call # spent 9.30ms making 205 calls to Class::MOP::Class::_real_ref_name, avg 45µs/call
356}
357
358
# spent 239ms (126+113) within Class::MOP::Class::_single_metaclass_can_be_made_compatible which was called 1392 times, avg 171µs/call: # 1392 times (126ms+113ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 345, avg 171µs/call
sub _single_metaclass_can_be_made_compatible {
35910876124ms my $self = shift;
360 my ($super_meta, $metaclass_type) = @_;
361
362139216.4ms my $specific_meta = $self->$metaclass_type;
# spent 2.46ms making 205 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 12µs/call # spent 2.36ms making 205 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 12µs/call # spent 2.35ms making 205 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 11µs/call # spent 2.30ms making 162 calls to Moose::Meta::Class::error_class, avg 14µs/call # spent 2.11ms making 162 calls to Moose::Meta::Class::destructor_class, avg 13µs/call # spent 2.09ms making 162 calls to Moose::Meta::Class::constructor_class, avg 13µs/call # spent 2.02ms making 205 calls to Class::MOP::Class::instance_metaclass, avg 10µs/call # spent 374µs making 43 calls to Class::MOP::Class::constructor_class, avg 9µs/call # spent 334µs making 43 calls to Class::MOP::Class::destructor_class, avg 8µs/call
363
36413929.08ms return unless $super_meta->can($metaclass_type);
# spent 9.08ms making 1392 calls to UNIVERSAL::can, avg 7µs/call
365136314.6ms my $super_specific_meta = $super_meta->$metaclass_type;
# spent 2.14ms making 205 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 10µs/call # spent 2.14ms making 205 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 10µs/call # spent 2.13ms making 205 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 10µs/call # spent 1.98ms making 205 calls to Class::MOP::Class::instance_metaclass, avg 10µs/call # spent 1.69ms making 133 calls to Moose::Meta::Class::destructor_class, avg 13µs/call # spent 1.64ms making 133 calls to Moose::Meta::Class::error_class, avg 12µs/call # spent 1.62ms making 133 calls to Moose::Meta::Class::constructor_class, avg 12µs/call # spent 676µs making 72 calls to Class::MOP::Class::constructor_class, avg 9µs/call # spent 598µs making 72 calls to Class::MOP::Class::destructor_class, avg 8µs/call
366
367 # for instance, Moose::Meta::Class has a destructor_class, but
368 # Class::MOP::Class doesn't - this shouldn't be an error
369 return unless defined $super_specific_meta;
370
371 # if metaclass is defined in superclass but not here, it's fixable
372 # this is a really odd case
373 return 1 unless defined $specific_meta;
374
375129172.9ms return 1 if $specific_meta->_can_be_made_compatible_with($super_specific_meta);
# spent 72.9ms making 1291 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 56µs/call
376}
377
378sub _fix_class_metaclass_incompatibility {
379 my $self = shift;
380 my ( $super_meta ) = @_;
381
382 if ($self->_class_metaclass_can_be_made_compatible($super_meta)) {
383 ($self->is_pristine)
384 || confess "Can't fix metaclass incompatibility for "
385 . $self->name
386 . " because it is not pristine.";
387
388 my $super_meta_name = $super_meta->_real_ref_name;
389
390 $self->_make_compatible_with($super_meta_name);
391 }
392}
393
394sub _fix_single_metaclass_incompatibility {
395 my $self = shift;
396 my ( $metaclass_type, $super_meta ) = @_;
397
398 if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) {
399 ($self->is_pristine)
400 || confess "Can't fix metaclass incompatibility for "
401 . $self->name
402 . " because it is not pristine.";
403
404 my $new_metaclass = $self->$metaclass_type
405 ? $self->$metaclass_type->_get_compatible_metaclass($super_meta->$metaclass_type)
406 : $super_meta->$metaclass_type;
407 $self->{$metaclass_type} = $new_metaclass;
408 }
409}
410
411
# spent 214ms (2.35+212) within Class::MOP::Class::_restore_metaobjects_from which was called 42 times, avg 5.11ms/call: # 42 times (2.35ms+212ms) by Class::MOP::Class::reinitialize at line 63, avg 5.11ms/call
sub _restore_metaobjects_from {
4121682.24ms my $self = shift;
413 my ($old_meta) = @_;
414
41542209ms $self->_restore_metamethods_from($old_meta);
# spent 209ms making 42 calls to Class::MOP::Mixin::HasMethods::_restore_metamethods_from, avg 4.96ms/call
416423.54ms $self->_restore_metaattributes_from($old_meta);
# spent 3.54ms making 42 calls to Class::MOP::Mixin::HasAttributes::_restore_metaattributes_from, avg 84µs/call
417}
418
419
# spent 3.05ms (1.46+1.59) within Class::MOP::Class::_remove_generated_metaobjects which was called 42 times, avg 73µs/call: # 42 times (1.46ms+1.59ms) by Class::MOP::Class::reinitialize at line 60, avg 73µs/call
sub _remove_generated_metaobjects {
420841.23ms my $self = shift;
421
422421.59ms for my $attr (map { $self->get_attribute($_) } $self->get_attribute_list) {
# spent 1.59ms making 42 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 38µs/call
423 $attr->remove_accessors;
424 }
425}
426
427## ANON classes
428
429{
430 # NOTE:
431 # this should be sufficient, if you have a
432 # use case where it is not, write a test and
433 # I will change it.
43426µs my $ANON_CLASS_SERIAL = 0;
435
436 # NOTE:
437 # we need a sufficiently annoying prefix
438 # this should suffice for now, this is
439 # used in a couple of places below, so
440 # need to put it up here for now.
44113µs my $ANON_CLASS_PREFIX = 'Class::MOP::Class::__ANON__::SERIAL::';
442
443
# spent 1.81ms (1.35+459µs) within Class::MOP::Class::is_anon_class which was called 42 times, avg 43µs/call: # 42 times (1.35ms+459µs) by Moose::Meta::Class::reinitialize at line 153 of Moose/Meta/Class.pm, avg 43µs/call
sub is_anon_class {
444841.85ms my $self = shift;
4453433µs2209µs
# spent 132µs (55+77) within Class::MOP::Class::BEGIN@445 which was called: # once (55µs+77µs) by Class::MOP::BEGIN@19 at line 445
no warnings 'uninitialized';
# spent 132µs making 1 call to Class::MOP::Class::BEGIN@445 # spent 77µs making 1 call to warnings::unimport
44685459µs $self->name =~ /^$ANON_CLASS_PREFIX/o;
# spent 238µs making 42 calls to Class::MOP::Package::name, avg 6µs/call # spent 178µs making 42 calls to Class::MOP::Class::CORE:match, avg 4µs/call # spent 42µs making 1 call to Class::MOP::Class::CORE:regcomp
447 }
448
449
# spent 1.17s (1.05ms+1.17) within Class::MOP::Class::create_anon_class which was called 22 times, avg 53.3ms/call: # 22 times (1.05ms+1.17s) by Moose::Meta::Class::create_anon_class at line 111 of Moose/Meta/Class.pm, avg 53.3ms/call
sub create_anon_class {
45088994µs my ($class, %options) = @_;
451 $options{weaken} = 1 unless exists $options{weaken};
452 my $package_name = $ANON_CLASS_PREFIX . ++$ANON_CLASS_SERIAL;
453221.17s return $class->create($package_name, %options);
# spent 1.17s making 22 calls to Moose::Meta::Class::create, avg 53.2ms/call
454 }
455
456 # NOTE:
457 # this will only get called for
458 # anon-classes, all other calls
459 # are assumed to occur during
460 # global destruction and so don't
461 # really need to be handled explicitly
462
# spent 2.80ms (2.04+762µs) within Class::MOP::Class::DESTROY which was called 42 times, avg 67µs/call: # 42 times (2.04ms+762µs) by Moose::Util::MetaRole::apply_metaroles at line 627 of Moose/Exporter.pm, avg 67µs/call
sub DESTROY {
4631682.74ms my $self = shift;
464
46542311µs return if in_global_destruction(); # it'll happen soon anyway and this just makes things more complicated
# spent 311µs making 42 calls to Devel::GlobalDestruction::in_global_destruction, avg 7µs/call
466
4673276µs2157µs
# spent 99µs (40+58) within Class::MOP::Class::BEGIN@467 which was called: # once (40µs+58µs) by Class::MOP::BEGIN@19 at line 467
no warnings 'uninitialized';
# spent 99µs making 1 call to Class::MOP::Class::BEGIN@467 # spent 58µs making 1 call to warnings::unimport
46842288µs my $name = $self->name;
# spent 288µs making 42 calls to Class::MOP::Package::name, avg 7µs/call
46943164µ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 42µs making 1 call to Class::MOP::Class::CORE:regcomp
470
471 # Moose does a weird thing where it replaces the metaclass for
472 # class when fixing metaclass incompatibility. In that case,
473 # we don't want to clean out the namespace now. We can detect
474 # that because Moose will explicitly update the singleton
475 # cache in Class::MOP.
476 my $current_meta = Class::MOP::get_metaclass_by_name($name);
477 return if $current_meta ne $self;
478
479 my ($serial_id) = ($name =~ /^$ANON_CLASS_PREFIX(\d+)/o);
480314.3ms2188µs
# spent 119µs (49+70) within Class::MOP::Class::BEGIN@480 which was called: # once (49µs+70µs) by Class::MOP::BEGIN@19 at line 480
no strict 'refs';
# spent 119µs making 1 call to Class::MOP::Class::BEGIN@480 # spent 70µs making 1 call to strict::unimport
481 @{$name . '::ISA'} = ();
482 %{$name . '::'} = ();
483 delete ${$ANON_CLASS_PREFIX}{$serial_id . '::'};
484
485 Class::MOP::remove_metaclass_by_name($name);
486 }
487
488}
489
490# creating classes with MOP ...
491
492
# spent 343ms (4.21+338) within Class::MOP::Class::create which was called 24 times, avg 14.3ms/call: # 22 times (3.87ms+327ms) by Moose::Meta::Class::create at line 85 of Moose/Meta/Class.pm, avg 15.0ms/call # 2 times (347µs+11.6ms) by Class::MOP::Class::_immutable_metaclass at line 1246, avg 5.98ms/call
sub create {
4934083.98ms my ( $class, @args ) = @_;
494
495 unshift @args, 'package' if @args % 2 == 1;
496
497 my (%options) = @args;
498 my $package_name = $options{package};
499
500 (ref $options{superclasses} eq 'ARRAY')
501 || confess "You must pass an ARRAY ref of superclasses"
502 if exists $options{superclasses};
503
504 (ref $options{attributes} eq 'ARRAY')
505 || confess "You must pass an ARRAY ref of attributes"
506 if exists $options{attributes};
507
508 (ref $options{methods} eq 'HASH')
509 || confess "You must pass a HASH ref of methods"
510 if exists $options{methods};
511
512 $options{meta_name} = 'meta'
513 unless exists $options{meta_name};
514
515 my (%initialize_options) = @args;
516 delete @initialize_options{qw(
517 package
518 superclasses
519 attributes
520 methods
521 meta_name
522 version
523 authority
524 )};
5252494.3ms my $meta = $class->initialize( $package_name => %initialize_options );
# spent 93.0ms making 22 calls to Moose::Meta::Class::initialize, avg 4.23ms/call # spent 1.25ms making 2 calls to Class::MOP::Class::initialize, avg 626µs/call
526
527243.00ms $meta->_instantiate_module( $options{version}, $options{authority} );
# spent 3.00ms making 24 calls to Class::MOP::Module::_instantiate_module, avg 125µs/call
528
5292467.6ms $meta->_add_meta_method($options{meta_name})
# spent 67.6ms making 24 calls to Class::MOP::Mixin::HasMethods::_add_meta_method, avg 2.82ms/call
530 if defined $options{meta_name};
531
53224173ms $meta->superclasses(@{$options{superclasses}})
# spent 169ms making 22 calls to Moose::Meta::Class::superclasses, avg 7.66ms/call # spent 4.91ms making 2 calls to Class::MOP::Class::superclasses, avg 2.45ms/call
533 if exists $options{superclasses};
534 # NOTE:
535 # process attributes first, so that they can
536 # install accessors, but locally defined methods
537 # can then overwrite them. It is maybe a little odd, but
538 # I think this should be the order of things.
539 if (exists $options{attributes}) {
540 foreach my $attr (@{$options{attributes}}) {
541 $meta->add_attribute($attr);
542 }
543 }
544 if (exists $options{methods}) {
545 foreach my $method_name (keys %{$options{methods}}) {
546 $meta->add_method($method_name, $options{methods}->{$method_name});
547 }
548 }
549 return $meta;
550}
551
552## Attribute readers
553
554# NOTE:
555# all these attribute readers will be bootstrapped
556# away in the Class::MOP bootstrap section
557
558164122.8mssub instance_metaclass { $_[0]->{'instance_metaclass'} }
5591021.44mssub immutable_trait { $_[0]->{'immutable_trait'} }
5602583.37mssub constructor_class { $_[0]->{'constructor_class'} }
561931.22mssub constructor_name { $_[0]->{'constructor_name'} }
5622292.72mssub destructor_class { $_[0]->{'destructor_class'} }
563
564# Instance Construction & Cloning
565
566
# spent 641ms (16.3+625) within Class::MOP::Class::new_object which was called 330 times, avg 1.94ms/call: # 192 times (9.42ms+244ms) by Moose::Meta::Method::_new at line 4 of (eval 76)[Class/MOP/Method/Generated.pm:53], avg 1.32ms/call # 110 times (5.54ms+344ms) by Moose::Meta::Class::new_object at line 256 of Moose/Meta/Class.pm, avg 3.18ms/call # 26 times (1.27ms+31.3ms) 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 (52µs+1.40ms) by Class::MOP::Object::_new at line 22 of Class/MOP/Object.pm
sub new_object {
56799023.5ms my $class = shift;
568
569 # NOTE:
570 # we need to protect the integrity of the
571 # Class::MOP::Class singletons here, so we
572 # delegate this to &construct_class_instance
573 # which will deal with the singletons
5746607.01ms return $class->_construct_class_instance(@_)
# spent 5.02ms making 330 calls to UNIVERSAL::isa, avg 15µs/call # spent 1.99ms making 330 calls to Class::MOP::Package::name, avg 6µs/call
575 if $class->name->isa('Class::MOP::Class');
576330618ms return $class->_construct_instance(@_);
# spent 618ms making 330 calls to Class::MOP::Class::_construct_instance, avg 1.87ms/call
577}
578
579
# spent 1.01s (153ms+855ms) within Class::MOP::Class::_construct_instance which was called 440 times, avg 2.29ms/call: # 330 times (83.2ms+535ms) by Class::MOP::Class::new_object at line 576, avg 1.87ms/call # 110 times (69.6ms+320ms) by Class::MOP::Class::_construct_class_instance at line 105, avg 3.54ms/call
sub _construct_instance {
5808774147ms my $class = shift;
581 my $params = @_ == 1 ? $_[0] : {@_};
58244024.4ms my $meta_instance = $class->get_meta_instance();
# spent 13.5ms making 267 calls to Class::MOP::Class::get_meta_instance, avg 51µs/call # spent 8.05ms making 129 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 62µs/call # spent 2.84ms making 44 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::get_meta_instance, avg 64µs/call
583 # FIXME:
584 # the code below is almost certainly incorrect
585 # but this is foreign inheritance, so we might
586 # have to kludge it in the end.
587 my $instance;
5884403.48ms if (my $instance_class = blessed($params->{__INSTANCE__})) {
# spent 3.48ms making 440 calls to Scalar::Util::blessed, avg 8µs/call
589 ($instance_class eq $class->name)
590 || confess "Objects passed as the __INSTANCE__ parameter must "
591 . "already be blessed into the correct class, but "
592 . "$params->{__INSTANCE__} is not a " . $class->name;
593 $instance = $params->{__INSTANCE__};
594 }
595 elsif (exists $params->{__INSTANCE__}) {
596 confess "The __INSTANCE__ parameter must be a blessed reference, not "
597 . $params->{__INSTANCE__};
598 }
599 else {
60044024.5ms $instance = $meta_instance->create_instance();
# spent 24.5ms making 440 calls to Class::MOP::Instance::create_instance, avg 56µs/call
601 }
602440146ms foreach my $attr ($class->get_all_attributes()) {
# spent 132ms making 267 calls to Class::MOP::Class::get_all_attributes, avg 494µs/call # spent 9.77ms making 129 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 76µs/call # spent 4.68ms making 44 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::get_all_attributes, avg 106µs/call
6034814640ms $attr->initialize_instance_slot($meta_instance, $instance, $params);
# spent 573ms making 4704 calls to Class::MOP::Attribute::initialize_instance_slot, avg 122µs/call # spent 67.0ms making 110 calls to Moose::Meta::Attribute::initialize_instance_slot, avg 609µs/call
604 }
60592215.8ms if (Class::MOP::metaclass_is_weak($class->name)) {
# spent 11.2ms making 440 calls to Class::MOP::metaclass_is_weak, avg 26µs/call # spent 2.61ms making 440 calls to Class::MOP::Package::name, avg 6µs/call # spent 1.95ms making 42 calls to Class::MOP::Instance::_set_mop_slot, avg 46µs/call
606 $meta_instance->_set_mop_slot($instance, $class);
607 }
608 return $instance;
609}
610
611
612
# spent 150ms (12.2+138) within Class::MOP::Class::get_meta_instance which was called 787 times, avg 191µs/call: # 267 times (3.69ms+9.85ms) by Class::MOP::Class::_construct_instance at line 582, avg 51µs/call # 154 times (3.04ms+68.9ms) by Class::MOP::Attribute::inline_get at line 411 of Class/MOP/Attribute.pm, avg 467µs/call # 128 times (1.74ms+7.60ms) by Class::MOP::Attribute::inline_set at line 419 of Class/MOP/Attribute.pm, avg 73µs/call # 93 times (1.42ms+17.9ms) by Moose::Meta::Attribute::inline_set at line 697 of Moose/Meta/Attribute.pm, avg 208µs/call # 73 times (1.16ms+18.5ms) by Class::MOP::Class::inline_create_instance at line 634, avg 269µs/call # 31 times (399µs+0s) by Class::MOP::Attribute::inline_has at line 428 of Class/MOP/Attribute.pm, avg 13µs/call # 24 times (538µs+14.5ms) by Class::MOP::Class:::around at line 74 of Class/MOP/Class/Immutable/Trait.pm, avg 627µs/call # 12 times (156µs+0s) by Class::MOP::Attribute::set_initial_value at line 253 of Class/MOP/Attribute.pm, avg 13µs/call # 3 times (36µs+0s) by Class::MOP::Attribute::get_raw_value at line 274 of Class/MOP/Attribute.pm, avg 12µs/call # once (24µs+759µ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 282 of Class/MOP/Attribute.pm
sub get_meta_instance {
613157414.3ms my $self = shift;
614137138ms $self->{'_meta_instance'} ||= $self->_create_meta_instance();
# spent 138ms making 137 calls to Class::MOP::Class::_create_meta_instance, avg 1.01ms/call
615}
616
617
# spent 138ms (10.0+128) within Class::MOP::Class::_create_meta_instance which was called 137 times, avg 1.01ms/call: # 137 times (10.0ms+128ms) by Class::MOP::Class::get_meta_instance at line 614, avg 1.01ms/call
sub _create_meta_instance {
6185488.64ms my $self = shift;
619
620411127ms my $instance = $self->instance_metaclass->new(
# spent 65.5ms making 137 calls to Class::MOP::Instance::new, avg 478µs/call # spent 52.8ms making 125 calls to Class::MOP::Class::get_all_attributes, avg 422µs/call # spent 7.19ms making 12 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 599µs/call # spent 1.34ms making 137 calls to Class::MOP::Class::instance_metaclass, avg 10µs/call
621 associated_metaclass => $self,
622 attributes => [ $self->get_all_attributes() ],
623 );
624
6251371.15ms $self->add_meta_instance_dependencies()
# spent 1.15ms making 137 calls to Class::MOP::Instance::is_dependent_on_superclasses, avg 8µs/call
626 if $instance->is_dependent_on_superclasses();
627
628 return $instance;
629}
630
631
# spent 23.6ms (2.88+20.7) within Class::MOP::Class::inline_create_instance which was called 73 times, avg 323µs/call: # 42 times (1.61ms+12.3ms) by Moose::Meta::Method::Constructor::_generate_instance at line 132 of Moose/Meta/Method/Constructor.pm, avg 330µs/call # 31 times (1.26ms+8.48ms) by Class::MOP::Method::Constructor::_generate_constructor_method_inline at line 112 of Class/MOP/Method/Constructor.pm, avg 314µs/call
sub inline_create_instance {
6321462.47ms my $self = shift;
633
63414620.7ms return $self->get_meta_instance->inline_create_instance(@_);
# spent 19.6ms making 73 calls to Class::MOP::Class::get_meta_instance, avg 269µs/call # spent 1.09ms making 73 calls to Class::MOP::Instance::inline_create_instance, avg 15µs/call
635}
636
637sub inline_rebless_instance {
638 my $self = shift;
639
640 return $self->get_meta_instance->inline_rebless_instance_structure(@_);
641}
642
643sub _inline_get_mop_slot {
644 my $self = shift;
645
646 return $self->get_meta_instance->_inline_get_mop_slot(@_);
647}
648
649sub _inline_set_mop_slot {
650 my $self = shift;
651
652 return $self->get_meta_instance->_inline_set_mop_slot(@_);
653}
654
655sub _inline_clear_mop_slot {
656 my $self = shift;
657
658 return $self->get_meta_instance->_inline_clear_mop_slot(@_);
659}
660
661
# spent 1.30ms (111µs+1.18) within Class::MOP::Class::clone_object which was called: # once (111µs+1.18ms) by Class::MOP::Attribute::clone at line 516 of Class/MOP.pm
sub clone_object {
6625135µs my $class = shift;
663 my $instance = shift;
664318µs (blessed($instance) && $instance->isa($class->name))
# spent 6µs making 1 call to Class::MOP::Package::name # spent 6µs making 1 call to Scalar::Util::blessed # spent 6µs making 1 call to UNIVERSAL::isa
665 || confess "You must pass an instance of the metaclass (" . (ref $class ? $class->name : $class) . "), not ($instance)";
666
667 # NOTE:
668 # we need to protect the integrity of the
669 # Class::MOP::Class singletons here, they
670 # should not be cloned.
67117µs return $instance if $instance->isa('Class::MOP::Class');
# spent 7µs making 1 call to UNIVERSAL::isa
67211.16ms $class->_clone_instance($instance, @_);
# spent 1.16ms making 1 call to Class::MOP::Class::_clone_instance
673}
674
675
# spent 1.16ms (371µs+787µs) within Class::MOP::Class::_clone_instance which was called: # once (371µs+787µs) by Class::MOP::Class::clone_object at line 672
sub _clone_instance {
67620310µs my ($class, $instance, %params) = @_;
67717µs (blessed($instance))
# spent 7µs making 1 call to Scalar::Util::blessed
678 || confess "You can only clone instances, ($instance) is not a blessed instance";
679162µs my $meta_instance = $class->get_meta_instance();
6801149µs my $clone = $meta_instance->clone_instance($instance);
# spent 149µs making 1 call to Class::MOP::Instance::clone_instance
681160µs foreach my $attr ($class->get_all_attributes()) {
68216510µs if ( defined( my $init_arg = $attr->init_arg ) ) {
# spent 378µs making 2 calls to Class::MOP::Attribute::set_value, avg 189µs/call # spent 132µs making 14 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 9µs/call
683 if (exists $params{$init_arg}) {
684 $attr->set_value($clone, $params{$init_arg});
685 }
686 }
687 }
688 return $clone;
689}
690
691sub _force_rebless_instance {
692 my ($self, $instance, %params) = @_;
693 my $old_metaclass = Class::MOP::class_of($instance);
694
695 $old_metaclass->rebless_instance_away($instance, $self, %params)
696 if $old_metaclass;
697
698 my $meta_instance = $self->get_meta_instance;
699
700 if (Class::MOP::metaclass_is_weak($old_metaclass->name)) {
701 $meta_instance->_clear_mop_slot($instance);
702 }
703
704 # rebless!
705 # we use $_[1] here because of t/306_rebless_overload.t regressions on 5.8.8
706 $meta_instance->rebless_instance_structure($_[1], $self);
707
708 $self->_fixup_attributes_after_rebless($instance, $old_metaclass, %params);
709
710 if (Class::MOP::metaclass_is_weak($self->name)) {
711 $meta_instance->_set_mop_slot($instance, $self);
712 }
713}
714
715sub rebless_instance {
716 my ($self, $instance, %params) = @_;
717 my $old_metaclass = Class::MOP::class_of($instance);
718
719 my $old_class = $old_metaclass ? $old_metaclass->name : blessed($instance);
720 $self->name->isa($old_class)
721 || confess "You may rebless only into a subclass of ($old_class), of which (". $self->name .") isn't.";
722
723 $self->_force_rebless_instance($_[1], %params);
724
725 return $instance;
726}
727
728sub rebless_instance_back {
729 my ( $self, $instance ) = @_;
730 my $old_metaclass = Class::MOP::class_of($instance);
731
732 my $old_class
733 = $old_metaclass ? $old_metaclass->name : blessed($instance);
734 $old_class->isa( $self->name )
735 || confess
736 "You may rebless only into a superclass of ($old_class), of which ("
737 . $self->name
738 . ") isn't.";
739
740 $self->_force_rebless_instance($_[1]);
741
742 return $instance;
743}
744
745sub rebless_instance_away {
746 # this intentionally does nothing, it is just a hook
747}
748
749sub _fixup_attributes_after_rebless {
750 my $self = shift;
751 my ($instance, $rebless_from, %params) = @_;
752 my $meta_instance = $self->get_meta_instance;
753
754 for my $attr ( $rebless_from->get_all_attributes ) {
755 next if $self->find_attribute_by_name( $attr->name );
756 $meta_instance->deinitialize_slot( $instance, $_ ) for $attr->slots;
757 }
758
759 foreach my $attr ( $self->get_all_attributes ) {
760 if ( $attr->has_value($instance) ) {
761 if ( defined( my $init_arg = $attr->init_arg ) ) {
762 $params{$init_arg} = $attr->get_value($instance)
763 unless exists $params{$init_arg};
764 }
765 else {
766 $attr->set_value($instance, $attr->get_value($instance));
767 }
768 }
769 }
770
771 foreach my $attr ($self->get_all_attributes) {
772 $attr->initialize_instance_slot($meta_instance, $instance, \%params);
773 }
774}
775
776
# spent 15.7ms (4.44+11.3) within Class::MOP::Class::_attach_attribute which was called 187 times, avg 84µs/call: # 187 times (4.44ms+11.3ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 28 of Class/MOP/Mixin/HasAttributes.pm, avg 84µs/call
sub _attach_attribute {
7773744.56ms my ($self, $attribute) = @_;
77818711.3ms $attribute->attach_to_class($self);
# spent 11.3ms making 187 calls to Class::MOP::Attribute::attach_to_class, avg 60µs/call
779}
780
781
# spent 1.60s (11.9ms+1.59) within Class::MOP::Class::_post_add_attribute which was called 187 times, avg 8.56ms/call: # 187 times (11.9ms+1.59s) by Class::MOP::Mixin::HasAttributes::add_attribute at line 45 of Class/MOP/Mixin/HasAttributes.pm, avg 8.56ms/call
sub _post_add_attribute {
78256111.2ms my ( $self, $attribute ) = @_;
783
7841879.66ms $self->invalidate_meta_instances;
# spent 9.66ms making 187 calls to Class::MOP::Class::invalidate_meta_instances, avg 52µs/call
785
786 # invalidate package flag here
787
# spent 1.56s (8.33ms+1.55) within Class::MOP::Class::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP/Class.pm:790] which was called 187 times, avg 8.33ms/call: # 187 times (8.33ms+1.55s) by Try::Tiny::try at line 76 of Try/Tiny.pm, avg 8.33ms/call
try {
7883748.37ms local $SIG{__DIE__};
7891871.55s $attribute->install_accessors;
# spent 424ms making 66 calls to Moose::Meta::Attribute::install_accessors, avg 6.43ms/call # spent 248ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::15::install_accessors # spent 214ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::19::install_accessors # spent 187ms making 2 calls to Class::MOP::Class::__ANON__::SERIAL::5::install_accessors, avg 93.6ms/call # spent 167ms making 115 calls to Class::MOP::Attribute::install_accessors, avg 1.45ms/call # spent 155ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::11::install_accessors # spent 154ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::8::install_accessors
790 }
791 catch {
792 $self->remove_attribute( $attribute->name );
793 die $_;
7943741.39s };
# spent 1.57s making 187 calls to Try::Tiny::try, avg 8.42ms/call, recursion: max depth 1, sum of overlapping time 188ms # spent 4.11ms making 187 calls to Try::Tiny::catch, avg 22µs/call
795}
796
797sub remove_attribute {
798 my $self = shift;
799
800 my $removed_attribute = $self->SUPER::remove_attribute(@_)
801 or return;
802
803 $self->invalidate_meta_instances;
804
805 $removed_attribute->remove_accessors;
806 $removed_attribute->detach_from_class;
807
808 return$removed_attribute;
809}
810
811
# spent 76.6ms (21.7+54.8) within Class::MOP::Class::find_attribute_by_name which was called 178 times, avg 430µs/call: # 93 times (6.42ms+16.7ms) by Class::MOP::Class::_immutable_metaclass at line 1223, avg 248µs/call # 84 times (15.1ms+37.4ms) by Moose::Util::MetaRole::_make_new_metaclass at line 117 of Moose/Util/MetaRole.pm, avg 625µs/call # once (242µs+691µs) by Moose::Meta::Class::_process_inherited_attribute at line 443 of Moose/Meta/Class.pm
sub find_attribute_by_name {
812139418.7ms my ( $self, $attr_name ) = @_;
813
81417811.4ms foreach my $class ( $self->linearized_isa ) {
# spent 11.2ms making 173 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 65µs/call # spent 214µs making 5 calls to Class::MOP::Class::linearized_isa, avg 43µs/call
815 # fetch the meta-class ...
81649819.6ms my $meta = Class::MOP::Class->initialize($class);
# spent 19.6ms making 498 calls to Class::MOP::Class::initialize, avg 39µs/call
81763423.8ms return $meta->get_attribute($attr_name)
# spent 18.8ms making 498 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 38µs/call # spent 4.93ms making 136 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 36µs/call
818 if $meta->has_attribute($attr_name);
819 }
820
821 return;
822}
823
824
# spent 284ms (121+163) within Class::MOP::Class::get_all_attributes which was called 608 times, avg 467µs/call: # 267 times (56.2ms+75.7ms) by Class::MOP::Class::_construct_instance at line 602, avg 494µs/call # 125 times (22.5ms+30.3ms) by Class::MOP::Class::_create_meta_instance at line 620, avg 422µs/call # 73 times (11.7ms+16.1ms) by Class::MOP::Method::Constructor::_attributes at line 77 of Class/MOP/Method/Constructor.pm, avg 381µs/call # 66 times (13.2ms+17.5ms) by Moose::Meta::Class::new_object at line 258 of Moose/Meta/Class.pm, avg 465µs/call # 34 times (4.69ms+6.66ms) 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 334µs/call # 25 times (8.56ms+10.1ms) by Moose::Meta::Attribute::new at line 64 of Moose/Meta/Attribute.pm, avg 747µs/call # 18 times (4.49ms+6.44ms) by Class::MOP::Class:::around at line 68 of Class/MOP/Class/Immutable/Trait.pm, avg 607µs/call
sub get_all_attributes {
8257196107ms my $self = shift;
8265980162ms my %attrs = map { %{ Class::MOP::Class->initialize($_)->_attribute_map } }
# spent 107ms making 2686 calls to Class::MOP::Class::initialize, avg 40µs/call, recursion: max depth 1, sum of overlapping time 887µs # spent 26.8ms making 590 calls to Class::MOP::Class::linearized_isa, avg 45µs/call # spent 26.7ms making 2686 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 10µs/call # spent 1.89ms making 15 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 126µs/call # spent 374µs making 3 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::linearized_isa, avg 125µs/call
827 reverse $self->linearized_isa;
828 return values %attrs;
829}
830
831# Inheritance
832
833sub superclasses {
834420455.1ms my $self = shift;
835
836886135ms my $isa = $self->get_or_add_package_symbol(
# spent 135ms making 886 calls to Class::MOP::Package::get_or_add_package_symbol, avg 153µs/call
837 { sigil => '@', type => 'ARRAY', name => 'ISA' } );
838
839 if (@_) {
840 my @supers = @_;
841 @{$isa} = @supers;
842
843 # NOTE:
844 # on 5.8 and below, we need to call
845 # a method to get Perl to detect
846 # a cycle in the class hierarchy
847110735µs my $class = $self->name;
# spent 735µs making 110 calls to Class::MOP::Package::name, avg 7µs/call
8481101.00ms $class->isa($class);
# spent 1.00ms making 110 calls to UNIVERSAL::isa, avg 9µs/call
849
850 # NOTE:
851 # we need to check the metaclass
852 # compatibility here so that we can
853 # be sure that the superclass is
854 # not potentially creating an issues
855 # we don't know about
856
857110551ms $self->_check_metaclass_compatibility();
# spent 551ms making 110 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 5.01ms/call
85811046.3ms $self->_superclasses_updated();
# spent 46.3ms making 110 calls to Class::MOP::Class::_superclasses_updated, avg 421µs/call
859 }
860
861 return @{$isa};
862}
863
864
# spent 46.3ms (8.08+38.3) within Class::MOP::Class::_superclasses_updated which was called 110 times, avg 421µs/call: # 110 times (8.08ms+38.3ms) by Class::MOP::Class::superclasses at line 858, avg 421µs/call
sub _superclasses_updated {
8654526.79ms my $self = shift;
8661101.28ms $self->update_meta_instance_dependencies();
# spent 1.28ms making 110 calls to Class::MOP::Class::update_meta_instance_dependencies, avg 12µs/call
867 # keep strong references to all our parents, so they don't disappear if
868 # they are anon classes and don't have any direct instances
8691224.20ms $self->_superclass_metas(
# spent 4.20ms making 122 calls to Class::MOP::class_of, avg 34µs/call
8702201.77ms map { Class::MOP::class_of($_) } $self->superclasses
# spent 1.77ms making 110 calls to Class::MOP::Class::_superclass_metas, avg 16µs/call # spent 314µs making 2 calls to Class::MOP::Class::superclasses, avg 157µs/call, recursion: max depth 1, sum of overlapping time 314µs # spent 30.7ms making 108 calls to Moose::Meta::Class::superclasses, avg 284µs/call, recursion: max depth 1, sum of overlapping time 30.7ms
871 );
872}
873
874
# spent 1.77ms within Class::MOP::Class::_superclass_metas which was called 110 times, avg 16µs/call: # 110 times (1.77ms+0s) by Class::MOP::Class::_superclasses_updated at line 870, avg 16µs/call
sub _superclass_metas {
8752202.09ms my $self = shift;
876 $self->{_superclass_metas} = [@_];
877}
878
879sub subclasses {
880 my $self = shift;
881 my $super_class = $self->name;
882
883 return @{ $super_class->mro::get_isarev() };
884}
885
886sub direct_subclasses {
887 my $self = shift;
888 my $super_class = $self->name;
889
890 return grep {
891 grep {
892 $_ eq $super_class
893 } Class::MOP::Class->initialize($_)->superclasses
894 } $self->subclasses;
895}
896
897
# spent 56.0ms (35.4+20.6) within Class::MOP::Class::linearized_isa which was called 1203 times, avg 47µs/call: # 590 times (17.1ms+9.71ms) by Class::MOP::Class::get_all_attributes at line 826, avg 45µs/call # 253 times (7.82ms+4.58ms) by Class::MOP::Class::find_next_method_by_name at line 1064, avg 49µs/call # 248 times (7.29ms+4.39ms) by Class::MOP::Class::find_method_by_name at line 1017, avg 47µs/call # 81 times (2.21ms+1.35ms) by Class::MOP::Class::find_all_methods_by_name at line 1048, avg 44µs/call # 18 times (607µs+339µs) by Class::MOP::Class:::around at line 50 of Class/MOP/Class/Immutable/Trait.pm, avg 53µs/call # 8 times (228µs+136µs) by Class::MOP::Class::get_all_methods at line 1028, avg 45µs/call # 5 times (141µs+73µs) by Class::MOP::Class::find_attribute_by_name at line 814, avg 43µs/call
sub linearized_isa {
898120360.1ms240620.6ms return @{ mro::get_linear_isa( (shift)->name ) };
# spent 14.3ms making 1203 calls to mro::get_linear_isa, avg 12µs/call # spent 6.32ms making 1203 calls to Class::MOP::Package::name, avg 5µs/call
899}
900
901
# spent 119ms (25.1+93.5) within Class::MOP::Class::class_precedence_list which was called 295 times, avg 402µs/call: # 159 times (11.6ms+-11.6ms) by Class::MOP::Class::class_precedence_list at line 927, avg 0s/call # 73 times (7.46ms+81.4ms) by Moose::Meta::Class::excludes_role at line 239 of Moose/Meta/Class.pm, avg 1.22ms/call # 44 times (4.11ms+25.6ms) by Moose::Meta::Class::does_role at line 219 of Moose/Meta/Class.pm, avg 675µs/call # 19 times (1.89ms+-1.89ms) by Class::MOP::Class:::around at line 43 of Class/MOP/Class/Immutable/Trait.pm, avg 0s/call
sub class_precedence_list {
902170730.4ms my $self = shift;
9032951.58ms my $name = $self->name;
# spent 1.58ms making 295 calls to Class::MOP::Package::name, avg 5µs/call
904
9052951.58ms unless (Class::MOP::IS_RUNNING_ON_5_10()) {
# spent 1.58ms making 295 calls to Class::MOP::__ANON__, avg 5µs/call
906 # NOTE:
907 # We need to check for circular inheritance here
908 # if we are are not on 5.10, cause 5.8 detects it
909 # late. This will do nothing if all is well, and
910 # blow up otherwise. Yes, it's an ugly hack, better
911 # suggestions are welcome.
912 # - SL
913 ($name || return)->isa('This is a test for circular inheritance')
914 }
915
916 # if our mro is c3, we can
917 # just grab the linear_isa
9182953.60ms if (mro::get_mro($name) eq 'c3') {
# spent 3.60ms making 295 calls to mro::get_mro, avg 12µs/call
919 return @{ mro::get_linear_isa($name) }
920 }
921 else {
922 # NOTE:
923 # we can't grab the linear_isa for dfs
924 # since it has all the duplicates
925 # already removed.
926 return (
92746422.9ms $name,
# spent 25.6ms making 73 calls to Class::MOP::Class::Immutable::Class::MOP::Class::class_precedence_list, avg 351µs/call, recursion: max depth 4, sum of overlapping time 12.7ms # spent 9.93ms making 232 calls to Class::MOP::Class::initialize, avg 43µs/call # spent 72.6ms making 159 calls to Class::MOP::Class::class_precedence_list, avg 456µs/call, recursion: max depth 2, sum of overlapping time 72.6ms
928 map {
92929571.8ms Class::MOP::Class->initialize($_)->class_precedence_list()
# spent 65.2ms making 264 calls to Moose::Meta::Class::superclasses, avg 247µs/call # spent 4.66ms making 19 calls to Class::MOP::Class::Immutable::Class::MOP::Class::superclasses, avg 245µs/call # spent 1.91ms making 12 calls to Class::MOP::Class::superclasses, avg 159µs/call
930 } $self->superclasses()
931 );
932 }
933}
934
935## Methods
936
937{
93814µs
# spent 224ms (14.3+210) within Class::MOP::Class::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP/Class.pm:967] which was called 116 times, avg 1.93ms/call: # 99 times (12.3ms+185ms) by Class::MOP::Class::add_around_method_modifier at line 993, avg 1.99ms/call # 11 times (1.44ms+19.4ms) by Class::MOP::Class::add_before_method_modifier at line 973, avg 1.89ms/call # 6 times (575µs+5.26ms) by Class::MOP::Class::add_after_method_modifier at line 983, avg 972µs/call
my $fetch_and_prepare_method = sub {
939100613.6ms my ($self, $method_name) = @_;
9401161.45ms my $wrapped_metaclass = $self->wrapped_method_metaclass;
# spent 1.45ms making 116 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 12µs/call
941 # fetch it locally
94211629.9ms my $method = $self->get_method($method_name);
# spent 29.9ms making 116 calls to Class::MOP::Mixin::HasMethods::get_method, avg 257µs/call
943 # if we dont have local ...
944 unless ($method) {
945 # try to find the next method
9469787.4ms $method = $self->find_next_method_by_name($method_name);
# spent 87.4ms making 97 calls to Class::MOP::Class::find_next_method_by_name, avg 901µs/call
947 # die if it does not exist
948 (defined $method)
949 || confess "The method '$method_name' was not found in the inheritance hierarchy for " . $self->name;
950 # and now make sure to wrap it
951 # even if it is already wrapped
952 # because we need a new sub ref
95319432.0ms $method = $wrapped_metaclass->wrap($method,
# spent 31.5ms making 97 calls to Class::MOP::Method::Wrapped::wrap, avg 324µs/call # spent 548µs making 97 calls to Class::MOP::Package::name, avg 6µs/call
954 package_name => $self->name,
955 name => $method_name,
956 );
957 }
958 else {
959 # now make sure we wrap it properly
960454.30ms $method = $wrapped_metaclass->wrap($method,
# spent 4.01ms making 13 calls to Class::MOP::Method::Wrapped::wrap, avg 308µs/call # spent 216µs making 19 calls to UNIVERSAL::isa, avg 11µs/call # spent 74µs making 13 calls to Class::MOP::Package::name, avg 6µs/call
961 package_name => $self->name,
962 name => $method_name,
963 ) unless $method->isa($wrapped_metaclass);
964 }
96511654.7ms $self->add_method($method_name => $method);
# spent 54.7ms making 116 calls to Class::MOP::Mixin::HasMethods::add_method, avg 471µs/call
966 return $method;
967114µs };
968
969
# spent 22.4ms (610µs+21.8) within Class::MOP::Class::add_before_method_modifier which was called 11 times, avg 2.04ms/call: # 11 times (610µs+21.8ms) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 221 of Moose/Meta/Role/Application/ToClass.pm, avg 2.04ms/call
sub add_before_method_modifier {
97044740µs my ($self, $method_name, $method_modifier) = @_;
971 (defined $method_name && length $method_name)
972 || confess "You must pass in a method name";
9731120.8ms my $method = $fetch_and_prepare_method->($self, $method_name);
# spent 20.8ms making 11 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:967], avg 1.89ms/call
97422996µs $method->add_before_modifier(
# spent 832µs making 11 calls to Class::MOP::Method::Wrapped::add_before_modifier, avg 76µs/call # spent 164µs making 11 calls to Sub::Name::subname, avg 15µs/call
975 subname(':before' => $method_modifier)
976 );
977 }
978
979
# spent 6.72ms (338µs+6.39) within Class::MOP::Class::add_after_method_modifier which was called 6 times, avg 1.12ms/call: # 6 times (338µs+6.39ms) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 221 of Moose/Meta/Role/Application/ToClass.pm, avg 1.12ms/call
sub add_after_method_modifier {
98024411µs my ($self, $method_name, $method_modifier) = @_;
981 (defined $method_name && length $method_name)
982 || confess "You must pass in a method name";
98365.83ms my $method = $fetch_and_prepare_method->($self, $method_name);
# spent 5.83ms making 6 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:967], avg 972µs/call
98412553µs $method->add_after_modifier(
# spent 458µs making 6 calls to Class::MOP::Method::Wrapped::add_after_modifier, avg 76µs/call # spent 95µs making 6 calls to Sub::Name::subname, avg 16µs/call
985 subname(':after' => $method_modifier)
986 );
987 }
988
989
# spent 218ms (5.28+213) within Class::MOP::Class::add_around_method_modifier which was called 99 times, avg 2.20ms/call: # 52 times (2.83ms+110ms) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 221 of Moose/Meta/Role/Application/ToClass.pm, avg 2.18ms/call # 46 times (2.40ms+101ms) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 2.24ms/call # once (51µs+1.83ms) by Moose::Util::add_method_modifier at line 244 of Moose/Util.pm
sub add_around_method_modifier {
9903966.62ms my ($self, $method_name, $method_modifier) = @_;
991 (defined $method_name && length $method_name)
992 || confess "You must pass in a method name";
99399197ms my $method = $fetch_and_prepare_method->($self, $method_name);
# spent 197ms making 99 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:967], avg 1.99ms/call
99419815.4ms $method->add_around_modifier(
# spent 13.9ms making 99 calls to Class::MOP::Method::Wrapped::add_around_modifier, avg 140µs/call # spent 1.50ms making 99 calls to Sub::Name::subname, avg 15µs/call
995 subname(':around' => $method_modifier)
996 );
997 }
998
999 # NOTE:
1000 # the methods above used to be named like this:
1001 # ${pkg}::${method}:(before|after|around)
1002 # but this proved problematic when using one modifier
1003 # to wrap multiple methods (something which is likely
1004 # to happen pretty regularly IMO). So instead of naming
1005 # it like this, I have chosen to just name them purely
1006 # with their modifier names, like so:
1007 # :(before|after|around)
1008 # The fact is that in a stack trace, it will be fairly
1009 # evident from the context what method they are attached
1010 # to, and so don't need the fully qualified name.
1011}
1012
1013
# spent 237ms (27.9+209) within Class::MOP::Class::find_method_by_name which was called 248 times, avg 957µs/call: # 91 times (6.45ms+32.1ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 25 of Class/MOP/Mixin/HasMethods.pm, avg 424µs/call # 56 times (8.83ms+81.4ms) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 1.61ms/call # 42 times (5.96ms+43.5ms) by Moose::Meta::Method::Destructor::is_needed at line 62 of Moose/Meta/Method/Destructor.pm, avg 1.18ms/call # 42 times (5.56ms+42.6ms) by Moose::Meta::Method::Constructor::_generate_BUILDARGS at line 146 of Moose/Meta/Method/Constructor.pm, avg 1.15ms/call # 10 times (670µs+7.15ms) by Moose::Meta::Role::Application::ToClass::check_required_methods at line 64 of Moose/Meta/Role/Application/ToClass.pm, avg 782µs/call # 7 times (482µs+2.61ms) by Moose::BEGIN@38 at line 14 of Moose/Meta/Attribute/Native.pm, avg 442µs/call
sub find_method_by_name {
1014207825.0ms my ($self, $method_name) = @_;
1015 (defined $method_name && length $method_name)
1016 || confess "You must define a method name to find";
101724811.7ms foreach my $class ($self->linearized_isa) {
# spent 11.7ms making 248 calls to Class::MOP::Class::linearized_isa, avg 47µs/call
10181222198ms my $method = Class::MOP::Class->initialize($class)->get_method($method_name);
# spent 171ms making 611 calls to Class::MOP::Mixin::HasMethods::get_method, avg 279µs/call # spent 27.1ms making 611 calls to Class::MOP::Class::initialize, avg 44µs/call
1019 return $method if defined $method;
1020 }
1021 return;
1022}
1023
1024
# spent 27.4ms (1.49+26.0) within Class::MOP::Class::get_all_methods which was called 8 times, avg 3.43ms/call: # 8 times (1.49ms+26.0ms) by Class::MOP::MiniTrait::apply at line 18 of Class/MOP/MiniTrait.pm, avg 3.43ms/call
sub get_all_methods {
1025591.73ms my $self = shift;
1026
1027 my %methods;
10288364µs for my $class ( reverse $self->linearized_isa ) {
# spent 364µs making 8 calls to Class::MOP::Class::linearized_isa, avg 45µs/call
10299354µs my $meta = Class::MOP::Class->initialize($class);
# spent 354µs making 9 calls to Class::MOP::Class::initialize, avg 39µs/call
1030
10316525.2ms $methods{ $_->name } = $_ for $meta->_get_local_methods;
# spent 25.0ms making 9 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 2.77ms/call # spent 287µs making 56 calls to Class::MOP::Method::name, avg 5µs/call
1032 }
1033
1034 return values %methods;
1035}
1036
1037sub get_all_method_names {
1038 my $self = shift;
1039 my %uniq;
1040 return grep { !$uniq{$_}++ } map { Class::MOP::Class->initialize($_)->get_method_list } $self->linearized_isa;
1041}
1042
1043
# spent 84.9ms (11.4+73.6) within Class::MOP::Class::find_all_methods_by_name which was called 81 times, avg 1.05ms/call: # 42 times (6.22ms+42.0ms) by Moose::Meta::Method::Constructor::_generate_BUILDALL at line 184 of Moose/Meta/Method/Constructor.pm, avg 1.15ms/call # 39 times (5.17ms+31.5ms) by Moose::Meta::Method::Destructor::_initialize_body at line 81 of Moose/Meta/Method/Destructor.pm, avg 941µs/call
sub find_all_methods_by_name {
10449119.95ms my ($self, $method_name) = @_;
1045 (defined $method_name && length $method_name)
1046 || confess "You must define a method name to find";
1047 my @methods;
1048813.56ms foreach my $class ($self->linearized_isa) {
# spent 3.56ms making 81 calls to Class::MOP::Class::linearized_isa, avg 44µs/call
1049 # fetch the meta-class ...
105025310.5ms my $meta = Class::MOP::Class->initialize($class);
# spent 10.5ms making 253 calls to Class::MOP::Class::initialize, avg 42µs/call
105125459.5ms push @methods => {
# spent 58.9ms making 253 calls to Class::MOP::Mixin::HasMethods::has_method, avg 233µs/call # spent 563µs making 1 call to Class::MOP::Mixin::HasMethods::get_method
1052 name => $method_name,
1053 class => $class,
1054 code => $meta->get_method($method_name)
1055 } if $meta->has_method($method_name);
1056 }
1057 return @methods;
1058}
1059
1060
# spent 189ms (27.4+161) within Class::MOP::Class::find_next_method_by_name which was called 253 times, avg 745µs/call: # 111 times (11.4ms+66.1ms) by Class::MOP::Method::Inlined::can_be_inlined at line 40 of Class/MOP/Method/Inlined.pm, avg 699µs/call # 97 times (12.0ms+75.4ms) by Class::MOP::Class::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP/Class.pm:967] at line 946, avg 901µs/call # 45 times (4.01ms+19.7ms) by Moose::Meta::Method::Overridden::new at line 23 of Moose/Meta/Method/Overridden.pm, avg 526µs/call
sub find_next_method_by_name {
1061221824.6ms my ($self, $method_name) = @_;
1062 (defined $method_name && length $method_name)
1063 || confess "You must define a method name to find";
106425312.4ms my @cpl = $self->linearized_isa;
# spent 12.4ms making 253 calls to Class::MOP::Class::linearized_isa, avg 49µs/call
1065 shift @cpl; # discard ourselves
1066 foreach my $class (@cpl) {
1067948149ms my $method = Class::MOP::Class->initialize($class)->get_method($method_name);
# spent 128ms making 474 calls to Class::MOP::Mixin::HasMethods::get_method, avg 270µs/call # spent 20.6ms making 474 calls to Class::MOP::Class::initialize, avg 43µs/call
1068 return $method if defined $method;
1069 }
1070 return;
1071}
1072
1073
# spent 1.28ms within Class::MOP::Class::update_meta_instance_dependencies which was called 110 times, avg 12µs/call: # 110 times (1.28ms+0s) by Class::MOP::Class::_superclasses_updated at line 866, avg 12µs/call
sub update_meta_instance_dependencies {
10742201.84ms my $self = shift;
1075
1076 if ( $self->{meta_instance_dependencies} ) {
1077 return $self->add_meta_instance_dependencies;
1078 }
1079}
1080
1081sub add_meta_instance_dependencies {
1082 my $self = shift;
1083
1084 $self->remove_meta_instance_dependencies;
1085
1086 my @attrs = $self->get_all_attributes();
1087
1088 my %seen;
1089 my @classes = grep { not $seen{ $_->name }++ }
1090 map { $_->associated_class } @attrs;
1091
1092 foreach my $class (@classes) {
1093 $class->add_dependent_meta_instance($self);
1094 }
1095
1096 $self->{meta_instance_dependencies} = \@classes;
1097}
1098
1099sub remove_meta_instance_dependencies {
1100 my $self = shift;
1101
1102 if ( my $classes = delete $self->{meta_instance_dependencies} ) {
1103 foreach my $class (@$classes) {
1104 $class->remove_dependent_meta_instance($self);
1105 }
1106
1107 return $classes;
1108 }
1109
1110 return;
1111
1112}
1113
1114sub add_dependent_meta_instance {
1115 my ( $self, $metaclass ) = @_;
1116 push @{ $self->{dependent_meta_instances} }, $metaclass;
1117}
1118
1119sub remove_dependent_meta_instance {
1120 my ( $self, $metaclass ) = @_;
1121 my $name = $metaclass->name;
1122 @$_ = grep { $_->name ne $name } @$_
1123 for $self->{dependent_meta_instances};
1124}
1125
1126
# spent 9.66ms (7.42+2.24) within Class::MOP::Class::invalidate_meta_instances which was called 187 times, avg 52µs/call: # 187 times (7.42ms+2.24ms) by Class::MOP::Class::_post_add_attribute at line 784, avg 52µs/call
sub invalidate_meta_instances {
11275617.17ms my $self = shift;
1128 $_->invalidate_meta_instance()
11291872.24ms for $self, @{ $self->{dependent_meta_instances} };
# spent 2.24ms making 187 calls to Class::MOP::Class::invalidate_meta_instance, avg 12µs/call
1130}
1131
1132
# spent 2.24ms within Class::MOP::Class::invalidate_meta_instance which was called 187 times, avg 12µs/call: # 187 times (2.24ms+0s) by Class::MOP::Class::invalidate_meta_instances at line 1129, avg 12µs/call
sub invalidate_meta_instance {
11333743.01ms my $self = shift;
1134 undef $self->{_meta_instance};
1135}
1136
1137# check if we can reinitialize
1138sub is_pristine {
1139 my $self = shift;
1140
1141 # if any local attr is defined
1142 return if $self->get_attribute_list;
1143
1144 # or any non-declared methods
1145 for my $method ( map { $self->get_method($_) } $self->get_method_list ) {
1146 return if $method->isa("Class::MOP::Method::Generated");
1147 # FIXME do we need to enforce this too? return unless $method->isa( $self->method_metaclass );
1148 }
1149
1150 return 1;
1151}
1152
1153## Class closing
1154
11551241.41ms
# spent 896µs within Class::MOP::Class::is_mutable which was called 124 times, avg 7µs/call: # 93 times (702µs+0s) by Class::MOP::Class::make_immutable at line 1179, avg 8µs/call # 22 times (137µ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 }
11563173.87ms
# spent 2.51ms within Class::MOP::Class::is_immutable which was called 317 times, avg 8µs/call: # 317 times (2.51ms+0s) by Class::MOP::Class::_real_ref_name at line 126, avg 8µs/call
sub is_immutable { 0 }
1157
1158sub immutable_options { %{ $_[0]{__immutable}{options} || {} } }
1159
1160
# spent 11.3ms (7.14+4.14) within Class::MOP::Class::_immutable_options which was called 93 times, avg 121µs/call: # 51 times (3.77ms+1.94ms) by Class::MOP::Class::make_immutable at line 1180, avg 112µs/call # 42 times (3.37ms+2.19ms) by Moose::Meta::Class::_immutable_options at line 461 of Moose/Meta/Class.pm, avg 132µs/call
sub _immutable_options {
11611866.01ms my ( $self, @args ) = @_;
1162
1163 return (
11643724.14ms inline_accessors => 1,
# spent 993µs making 93 calls to Class::MOP::Class::constructor_name, avg 11µs/call # spent 595µs making 42 calls to Moose::Meta::Class::immutable_trait, avg 14µs/call # spent 569µs making 42 calls to Moose::Meta::Class::destructor_class, avg 14µs/call # spent 557µs making 42 calls to Moose::Meta::Class::constructor_class, avg 13µs/call # spent 505µs making 51 calls to Class::MOP::Class::immutable_trait, avg 10µs/call # spent 491µs making 51 calls to Class::MOP::Class::constructor_class, avg 10µs/call # spent 425µs making 51 calls to Class::MOP::Class::destructor_class, avg 8µs/call
1165 inline_constructor => 1,
1166 inline_destructor => 0,
1167 debug => 0,
1168 immutable_trait => $self->immutable_trait,
1169 constructor_name => $self->constructor_name,
1170 constructor_class => $self->constructor_class,
1171 destructor_class => $self->destructor_class,
1172 @args,
1173 );
1174}
1175
1176
# spent 1.39s (7.61ms+1.38) within Class::MOP::Class::make_immutable which was called 93 times, avg 14.9ms/call: # 22 times (1.88ms+303ms) by MooseX::Types::BEGIN@2 at line 236 of Moose.pm, avg 13.9ms/call # 13 times (934µs+107ms) by MooseX::Types::Combine::BEGIN@12 at line 699 of Class/MOP.pm, avg 8.27ms/call # 9 times (759µs+125ms) by Moose::Meta::Attribute::BEGIN@20 at line 693 of Moose/Util/TypeConstraints.pm, avg 14.0ms/call # 4 times (275µs+2.58ms) by MooseX::Types::Combine::BEGIN@12 at line 724 of Class/MOP.pm, avg 713µs/call # 2 times (166µs+-166µs) by Class::MOP::Class::_immutable_metaclass at line 1253, avg 0s/call # once (120µs+129ms) by Markdent::Simple::Document::BEGIN@9 at line 48 of Markdent/Handler/HTMLStream/Document.pm # once (83µs+42.9ms) by MooseX::Role::Parameterized::Meta::Role::Parameterizable::BEGIN@7 at line 8 of MooseX/Role/Parameterized/Meta/Role/Parameterized.pm # once (81µs+38.9ms) by MooseX::Role::Parameterized::BEGIN@8 at line 130 of MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm # once (81µs+35.0ms) by MooseX::Types::BEGIN@2 at line 268 of Moose.pm # once (87µs+32.5ms) by MooseX::Role::Parameterized::Meta::Role::Parameterizable::BEGIN@8 at line 22 of MooseX/Role/Parameterized/Meta/Parameter.pm # once (82µs+24.6ms) by Markdent::Parser::BEGIN@10 at line 748 of Markdent/Dialect/Standard/BlockParser.pm # once (83µs+22.4ms) by Markdent::Simple::Document::BEGIN@10 at line 198 of Markdent/Parser.pm # once (85µs+21.2ms) by Markdent::Parser::BEGIN@11 at line 895 of Markdent/Dialect/Standard/SpanParser.pm # once (81µs+19.1ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@21 at line 47 of Markdent/Event/Image.pm # once (86µs+18.6ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@25 at line 43 of Markdent/Event/StartLink.pm # once (81µs+16.1ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@27 at line 35 of Markdent/Event/Text.pm # once (81µs+15.8ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@24 at line 29 of Markdent/Event/StartHTMLTag.pm # once (82µs+15.8ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@20 at line 29 of Markdent/Event/HTMLTag.pm # once (83µs+15.1ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@10 at line 15 of Markdent/Event/StartDocument.pm # once (90µs+14.9ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@15 at line 23 of Markdent/Event/EndHTMLTag.pm # once (90µs+14.7ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@18 at line 23 of Markdent/Event/HTMLComment.pm # once (81µs+14.7ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@17 at line 29 of Markdent/Event/EndStrong.pm # once (81µs+14.7ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@26 at line 29 of Markdent/Event/StartStrong.pm # once (82µs+14.7ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@23 at line 29 of Markdent/Event/StartEmphasis.pm # once (81µs+14.6ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@22 at line 29 of Markdent/Event/StartCode.pm # once (84µs+14.6ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@25 at line 23 of Markdent/Event/HTMLBlock.pm # once (82µs+14.1ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@14 at line 23 of Markdent/Event/StartHeader.pm # once (84µs+14.1ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@19 at line 23 of Markdent/Event/HTMLEntity.pm # once (81µs+14.1ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@14 at line 29 of Markdent/Event/EndEmphasis.pm # once (85µs+14.0ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@12 at line 23 of Markdent/Event/AutoLink.pm # once (82µs+13.9ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@13 at line 29 of Markdent/Event/EndCode.pm # once (83µs+13.8ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@15 at line 23 of Markdent/Event/EndHeader.pm # once (84µs+13.8ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@26 at line 23 of Markdent/Event/HTMLCommentBlock.pm # once (84µs+13.8ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@27 at line 23 of Markdent/Event/Preformatted.pm # once (83µs+13.1ms) by Markdent::Dialect::Standard::SpanParser::BEGIN@16 at line 17 of Markdent/Event/EndLink.pm # once (83µs+13.1ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@20 at line 15 of Markdent/Event/StartParagraph.pm # once (82µs+13.1ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@11 at line 15 of Markdent/Event/EndDocument.pm # once (82µs+13.0ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@13 at line 15 of Markdent/Event/EndBlockquote.pm # once (82µs+13.0ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@23 at line 15 of Markdent/Event/EndUnorderedList.pm # once (82µs+13.0ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@24 at line 15 of Markdent/Event/HorizontalRule.pm # once (81µs+13.0ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@22 at line 15 of Markdent/Event/StartUnorderedList.pm # once (82µs+13.0ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@17 at line 15 of Markdent/Event/EndListItem.pm # once (82µs+13.0ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@18 at line 15 of Markdent/Event/StartOrderedList.pm # once (83µs+13.0ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@21 at line 15 of Markdent/Event/EndParagraph.pm # once (82µs+13.0ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@19 at line 15 of Markdent/Event/EndOrderedList.pm # once (82µs+12.9ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@16 at line 15 of Markdent/Event/StartListItem.pm # once (81µs+12.9ms) by Markdent::Dialect::Standard::BlockParser::BEGIN@12 at line 15 of Markdent/Event/StartBlockquote.pm # once (80µs+10.8ms) by MooseX::Role::Parameterized::Meta::Trait::Parameterized::BEGIN@6 at line 6 of MooseX/Role/Parameterized/Parameters.pm
sub make_immutable {
11774657.45ms my ( $self, @args ) = @_;
1178
117993702µs if ( $self->is_mutable ) {
# spent 702µs making 93 calls to Class::MOP::Class::is_mutable, avg 8µs/call
11801861.12s $self->_initialize_immutable( $self->_immutable_options(@args) );
# spent 1.11s making 93 calls to Class::MOP::Class::_initialize_immutable, avg 11.9ms/call # spent 7.35ms making 42 calls to Moose::Meta::Class::_immutable_options, avg 175µs/call # spent 5.71ms making 51 calls to Class::MOP::Class::_immutable_options, avg 112µs/call
118193256ms $self->_rebless_as_immutable(@args);
# spent 257ms making 93 calls to Class::MOP::Class::_rebless_as_immutable, avg 2.77ms/call, recursion: max depth 1, sum of overlapping time 1.09ms
1182 return $self;
1183 }
1184 else {
1185 return;
1186 }
1187}
1188
1189sub make_mutable {
1190 my $self = shift;
1191
1192 if ( $self->is_immutable ) {
1193 my @args = $self->immutable_options;
1194 $self->_rebless_as_mutable();
1195 $self->_remove_inlined_code(@args);
1196 delete $self->{__immutable};
1197 return $self;
1198 }
1199 else {
1200 return;
1201 }
1202}
1203
1204
# spent 256ms (3.93+252) within Class::MOP::Class::_rebless_as_immutable which was called 93 times, avg 2.75ms/call: # 93 times (3.93ms+252ms) by Class::MOP::Class::make_immutable at line 1181, avg 2.75ms/call
sub _rebless_as_immutable {
12052793.75ms my ( $self, @args ) = @_;
1206
1207 $self->{__immutable}{original_class} = ref $self;
1208
120993252ms bless $self => $self->_immutable_metaclass(@args);
# spent 253ms making 93 calls to Class::MOP::Class::_immutable_metaclass, avg 2.72ms/call, recursion: max depth 1, sum of overlapping time 937µs
1210}
1211
1212
# spent 252ms (9.74+243) within Class::MOP::Class::_immutable_metaclass which was called 93 times, avg 2.71ms/call: # 93 times (9.74ms+243ms) by Class::MOP::Class::_rebless_as_immutable at line 1209, avg 2.71ms/call
sub _immutable_metaclass {
121375410.7ms my ( $self, %args ) = @_;
1214
1215 if ( my $class = $args{immutable_metaclass} ) {
1216 return $class;
1217 }
1218
1219931.13ms my $trait = $args{immutable_trait} = $self->immutable_trait
# spent 641µs making 42 calls to Moose::Meta::Class::immutable_trait, avg 15µs/call # spent 494µs making 51 calls to Class::MOP::Class::immutable_trait, avg 10µs/call
1220 || confess "no immutable trait specified for $self";
1221
1222937.66ms my $meta = $self->meta;
# spent 7.66ms making 93 calls to Class::MOP::Object::meta, avg 82µs/call
12239323.1ms my $meta_attr = $meta->find_attribute_by_name("immutable_trait");
# spent 23.1ms making 93 calls to Class::MOP::Class::find_attribute_by_name, avg 248µs/call
1224
1225 my $class_name;
1226
1227931.62ms if ( $meta_attr and $trait eq $meta_attr->default ) {
# spent 1.62ms making 93 calls to Class::MOP::Mixin::AttributeCore::default, avg 17µs/call
1228 # if the trait is the same as the default we try and pick a
1229 # predictable name for the immutable metaclass
1230 $class_name = 'Class::MOP::Class::Immutable::' . ref($self);
1231 }
1232 else {
1233 $class_name = join '::', 'Class::MOP::Class::Immutable::CustomTrait',
1234 $trait, 'ForMetaClass', ref($self);
1235 }
1236
1237931.71ms return $class_name
# spent 1.71ms making 93 calls to Class::MOP::is_class_loaded, avg 18µs/call
1238 if Class::MOP::is_class_loaded($class_name);
1239
1240 # If the metaclass is a subclass of CMOP::Class which has had
1241 # metaclass roles applied (via Moose), then we want to make sure
1242 # that we preserve that anonymous class (see Fey::ORM for an
1243 # example of where this matters).
12442129µs my $meta_name = $meta->_real_ref_name;
# spent 129µs making 2 calls to Class::MOP::Class::_real_ref_name, avg 64µs/call
1245
1246212.0ms my $immutable_meta = $meta_name->create(
# spent 12.0ms making 2 calls to Class::MOP::Class::create, avg 5.98ms/call
1247 $class_name,
1248 superclasses => [ ref $self ],
1249 );
1250
12512195ms Class::MOP::MiniTrait::apply( $immutable_meta, $trait );
# spent 195ms making 2 calls to Class::MOP::MiniTrait::apply, avg 97.3ms/call
1252
125320s $immutable_meta->make_immutable(
# spent 1.68ms making 2 calls to Class::MOP::Class::make_immutable, avg 838µs/call, recursion: max depth 1, sum of overlapping time 1.68ms
1254 inline_constructor => 0,
1255 inline_accessors => 0,
1256 );
1257
1258 return $class_name;
1259}
1260
1261sub _remove_inlined_code {
1262 my $self = shift;
1263
1264 $self->remove_method( $_->name ) for $self->_inlined_methods;
1265
1266 delete $self->{__immutable}{inlined_methods};
1267}
1268
1269sub _inlined_methods { @{ $_[0]{__immutable}{inlined_methods} || [] } }
1270
1271
# spent 2.26ms within Class::MOP::Class::_add_inlined_method which was called 112 times, avg 20µs/call: # 73 times (1.55ms+0s) by Class::MOP::Class::_inline_constructor at line 1340, avg 21µs/call # 39 times (708µs+0s) by Class::MOP::Class::_inline_destructor at line 1373, avg 18µs/call
sub _add_inlined_method {
12722242.45ms my ( $self, $method ) = @_;
1273
1274 push @{ $self->{__immutable}{inlined_methods} ||= [] }, $method;
1275}
1276
1277
# spent 1.11s (5.33ms+1.10) within Class::MOP::Class::_initialize_immutable which was called 93 times, avg 11.9ms/call: # 93 times (5.33ms+1.10s) by Class::MOP::Class::make_immutable at line 1180, avg 11.9ms/call
sub _initialize_immutable {
12782794.99ms my ( $self, %args ) = @_;
1279
1280 $self->{__immutable}{options} = \%args;
1281931.10s $self->_install_inlined_code(%args);
# spent 1.10s making 93 calls to Class::MOP::Class::_install_inlined_code, avg 11.9ms/call
1282}
1283
1284
# spent 1.10s (5.70ms+1.10) within Class::MOP::Class::_install_inlined_code which was called 93 times, avg 11.9ms/call: # 93 times (5.70ms+1.10s) by Class::MOP::Class::_initialize_immutable at line 1281, avg 11.9ms/call
sub _install_inlined_code {
12853725.72ms my ( $self, %args ) = @_;
1286
1287 # FIXME
128832187ms $self->_inline_accessors(%args) if $args{inline_accessors};
# spent 187ms making 32 calls to Class::MOP::Class::_inline_accessors, avg 5.86ms/call
128973712ms $self->_inline_constructor(%args) if $args{inline_constructor};
# spent 712ms making 73 calls to Class::MOP::Class::_inline_constructor, avg 9.75ms/call
129042199ms $self->_inline_destructor(%args) if $args{inline_destructor};
# spent 199ms making 42 calls to Class::MOP::Class::_inline_destructor, avg 4.73ms/call
1291}
1292
1293sub _rebless_as_mutable {
1294 my $self = shift;
1295
1296 bless $self, $self->_get_mutable_metaclass_name;
1297
1298 return $self;
1299}
1300
1301
# spent 187ms (3.15+184) within Class::MOP::Class::_inline_accessors which was called 32 times, avg 5.86ms/call: # 32 times (3.15ms+184ms) by Class::MOP::Class::_install_inlined_code at line 1288, avg 5.86ms/call
sub _inline_accessors {
13021322.68ms my $self = shift;
1303
1304321.15ms foreach my $attr_name ( $self->get_attribute_list ) {
# spent 1.15ms making 32 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 36µs/call
1305136183ms $self->get_attribute($attr_name)->install_accessors(1);
# spent 174ms making 67 calls to Class::MOP::Attribute::install_accessors, avg 2.59ms/call # spent 6.67ms making 1 call to Moose::Meta::Attribute::install_accessors # spent 2.71ms making 68 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 40µs/call
1306 }
1307}
1308
1309
# spent 712ms (10.9+701) within Class::MOP::Class::_inline_constructor which was called 73 times, avg 9.75ms/call: # 73 times (10.9ms+701ms) by Class::MOP::Class::_install_inlined_code at line 1289, avg 9.75ms/call
sub _inline_constructor {
131073010.7ms my ( $self, %args ) = @_;
1311
1312 my $name = $args{constructor_name};
1313 # A class may not even have a constructor, and that's okay.
1314 return unless defined $name;
1315
13167322.8ms if ( $self->has_method($name) && !$args{replace_constructor} ) {
# spent 22.8ms making 73 calls to Class::MOP::Mixin::HasMethods::has_method, avg 313µs/call
1317 my $class = $self->name;
1318 warn "Not inlining a constructor for $class since it defines"
1319 . " its own constructor.\n"
1320 . "If you are certain you don't need to inline your"
1321 . " constructor, specify inline_constructor => 0 in your"
1322 . " call to $class->meta->make_immutable\n";
1323 return;
1324 }
1325
1326 my $constructor_class = $args{constructor_class};
1327
1328739.60ms Class::MOP::load_class($constructor_class);
# spent 18.2ms making 73 calls to Class::MOP::load_class, avg 250µs/call, recursion: max depth 2, sum of overlapping time 8.64ms
1329
1330146555ms my $constructor = $constructor_class->new(
# spent 363ms making 42 calls to Moose::Meta::Method::Constructor::new, avg 8.65ms/call # spent 192ms making 31 calls to Class::MOP::Method::Constructor::new, avg 6.18ms/call # spent 498µs making 73 calls to Class::MOP::Package::name, avg 7µs/call
1331 options => \%args,
1332 metaclass => $self,
1333 is_inline => 1,
1334 package_name => $self->name,
1335 name => $name,
1336 );
1337
13387267.9ms if ( $args{replace_constructor} or $constructor->can_be_inlined ) {
# spent 67.9ms making 72 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 943µs/call
13397335.3ms $self->add_method( $name => $constructor );
# spent 35.3ms making 73 calls to Class::MOP::Mixin::HasMethods::add_method, avg 483µs/call
1340731.55ms $self->_add_inlined_method($constructor);
# spent 1.55ms making 73 calls to Class::MOP::Class::_add_inlined_method, avg 21µs/call
1341 }
1342}
1343
1344
# spent 199ms (6.82+192) within Class::MOP::Class::_inline_destructor which was called 42 times, avg 4.73ms/call: # 42 times (6.82ms+192ms) by Class::MOP::Class::_install_inlined_code at line 1290, avg 4.73ms/call
sub _inline_destructor {
13454086.40ms my ( $self, %args ) = @_;
1346
1347 ( exists $args{destructor_class} && defined $args{destructor_class} )
1348 || confess "The 'inline_destructor' option is present, but "
1349 . "no destructor class was specified";
1350
13514212.2ms if ( $self->has_method('DESTROY') && ! $args{replace_destructor} ) {
# spent 12.2ms making 42 calls to Class::MOP::Mixin::HasMethods::has_method, avg 292µs/call
1352 my $class = $self->name;
1353 warn "Not inlining a destructor for $class since it defines"
1354 . " its own destructor.\n";
1355 return;
1356 }
1357
1358 my $destructor_class = $args{destructor_class};
1359
1360429.59ms Class::MOP::load_class($destructor_class);
# spent 10.6ms making 42 calls to Class::MOP::load_class, avg 252µs/call, recursion: max depth 2, sum of overlapping time 972µs
1361
13624252.4ms return unless $destructor_class->is_needed($self);
# spent 52.4ms making 42 calls to Moose::Meta::Method::Destructor::is_needed, avg 1.25ms/call
1363
13647865.4ms my $destructor = $destructor_class->new(
# spent 65.1ms making 39 calls to Moose::Meta::Method::Destructor::new, avg 1.67ms/call # spent 234µs making 39 calls to Class::MOP::Package::name, avg 6µs/call
1365 options => \%args,
1366 metaclass => $self,
1367 package_name => $self->name,
1368 name => 'DESTROY'
1369 );
1370
13713932.5ms if ( $args{replace_destructor} or $destructor->can_be_inlined ) {
# spent 32.5ms making 39 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 834µs/call
13723917.9ms $self->add_method( 'DESTROY' => $destructor );
# spent 17.9ms making 39 calls to Class::MOP::Mixin::HasMethods::add_method, avg 459µs/call
137339708µs $self->_add_inlined_method($destructor);
# spent 708µs making 39 calls to Class::MOP::Class::_add_inlined_method, avg 18µs/call
1374 }
1375}
1376
1377123µs1;
1378
1379__END__
 
# spent 300µs within Class::MOP::Class::CORE:match which was called 84 times, avg 4µs/call: # 42 times (178µs+0s) by Class::MOP::Class::is_anon_class at line 446, avg 4µs/call # 42 times (121µs+0s) by Class::MOP::Class::DESTROY at line 469, avg 3µs/call
sub Class::MOP::Class::CORE:match; # opcode
# spent 85µs within Class::MOP::Class::CORE:regcomp which was called 2 times, avg 42µs/call: # once (42µs+0s) by Class::MOP::Class::is_anon_class at line 446 # once (42µs+0s) by Class::MOP::Class::DESTROY at line 469
sub Class::MOP::Class::CORE:regcomp; # opcode