← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:42:38 2010
Reported on Wed Nov 17 22:05:13 2010

Filename/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Class.pm
StatementsExecuted 59300 statements in 739ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
31252413105ms349msClass::MOP::Class::::initializeClass::MOP::Class::initialize (recurses: max depth 1, inclusive time 4.98ms)
4068562.9ms146msClass::MOP::Class::::get_all_attributesClass::MOP::Class::get_all_attributes
5311136.6ms72.8msClass::MOP::Class::::_single_metaclass_can_be_made_compatibleClass::MOP::Class::_single_metaclass_can_be_made_compatible
1382135.3ms262msClass::MOP::Class::::_construct_instanceClass::MOP::Class::_construct_instance
3782225.7ms249msClass::MOP::Class::::_inline_slot_initializerClass::MOP::Class::_inline_slot_initializer
8377225.0ms38.9msClass::MOP::Class::::linearized_isaClass::MOP::Class::linearized_isa
2731124.9ms45.1msClass::MOP::Class::::_single_metaclass_is_compatibleClass::MOP::Class::_single_metaclass_is_compatible
2136619.5ms136msClass::MOP::Class::::find_method_by_nameClass::MOP::Class::find_method_by_name
1342119.0ms240msClass::MOP::Class::::_check_metaclass_compatibilityClass::MOP::Class::_check_metaclass_compatibility (recurses: max depth 1, inclusive time 3.70ms)
2391117.7ms1.94sClass::MOP::Class::::_post_add_attributeClass::MOP::Class::_post_add_attribute
551115.8ms23.0msClass::MOP::Class::::CORE:sortClass::MOP::Class::CORE:sort (opcode)
1574315.3ms76.9msClass::MOP::Class::::find_next_method_by_nameClass::MOP::Class::find_next_method_by_name
3782215.1ms23.6msClass::MOP::Class::::_inline_default_valueClass::MOP::Class::_inline_default_value
2561114.4ms76.9msClass::MOP::Class::::_inline_init_attr_from_constructorClass::MOP::Class::_inline_init_attr_from_constructor
821114.3ms109msClass::MOP::Class::::_can_fix_metaclass_incompatibilityClass::MOP::Class::_can_fix_metaclass_incompatibility
81012512.7ms160msClass::MOP::Class::::get_meta_instanceClass::MOP::Class::get_meta_instance
1731112.3ms148msClass::MOP::Class::::_create_meta_instanceClass::MOP::Class::_create_meta_instance
981110.9ms218msClass::MOP::Class::::_construct_class_instanceClass::MOP::Class::_construct_class_instance (recurses: max depth 1, inclusive time 726µs)
2391110.8ms1.89sClass::MOP::Class::::__ANON__[:932]Class::MOP::Class::__ANON__[:932]
2672110.1ms43.1msClass::MOP::Class::::_inline_init_attr_from_defaultClass::MOP::Class::_inline_init_attr_from_default
2391110.0ms13.0msClass::MOP::Class::::invalidate_meta_instancesClass::MOP::Class::invalidate_meta_instances
55118.51ms317msClass::MOP::Class::::_inline_slot_initializersClass::MOP::Class::_inline_slot_initializers
75118.01ms195msClass::MOP::Class::::_immutable_metaclassClass::MOP::Class::_immutable_metaclass (recurses: max depth 1, inclusive time 939µs)
55117.93ms710msClass::MOP::Class::::_inline_constructorClass::MOP::Class::_inline_constructor
68317.56ms112msClass::MOP::Class::::__ANON__[:1108]Class::MOP::Class::__ANON__[:1108]
273117.30ms52.4msClass::MOP::Class::::_check_single_metaclass_compatibilityClass::MOP::Class::_check_single_metaclass_compatibility
7530286.24ms1.27sClass::MOP::Class::::make_immutableClass::MOP::Class::make_immutable (recurses: max depth 1, inclusive time 1.56ms)
239115.67ms20.9msClass::MOP::Class::::_attach_attributeClass::MOP::Class::_attach_attribute
77225.46ms18.6msClass::MOP::Class::::find_attribute_by_nameClass::MOP::Class::find_attribute_by_name
75225.36ms7.56msClass::MOP::Class::::_immutable_optionsClass::MOP::Class::_immutable_options
104665.22ms152msClass::MOP::Class::::new_objectClass::MOP::Class::new_object
1115.11ms5.79msClass::MOP::Class::::BEGIN@7Class::MOP::Class::BEGIN@7
48225.02ms27.4msClass::MOP::Class::::find_all_methods_by_nameClass::MOP::Class::find_all_methods_by_name
55114.81ms396msClass::MOP::Class::::_inline_new_objectClass::MOP::Class::_inline_new_object
68114.81ms119msClass::MOP::Class::::_fix_metaclass_incompatibilityClass::MOP::Class::_fix_metaclass_incompatibility (recurses: max depth 1, inclusive time 2.92ms)
1114.78ms36.5msClass::MOP::Class::::BEGIN@9Class::MOP::Class::BEGIN@9
75114.63ms1.06sClass::MOP::Class::::_install_inlined_codeClass::MOP::Class::_install_inlined_code
51334.57ms18.5msClass::MOP::Class::::class_precedence_listClass::MOP::Class::class_precedence_list (recurses: max depth 4, inclusive time 14.7ms)
1114.24ms5.08msClass::MOP::Class::::BEGIN@8Class::MOP::Class::BEGIN@8
75114.07ms1.06sClass::MOP::Class::::_initialize_immutableClass::MOP::Class::_initialize_immutable
64114.05ms4.05msClass::MOP::Class::::_newClass::MOP::Class::_new
24113.88ms98.2msClass::MOP::Class::::_inline_destructorClass::MOP::Class::_inline_destructor
131413.79ms7.06msClass::MOP::Class::::_real_ref_nameClass::MOP::Class::_real_ref_name
75113.36ms198msClass::MOP::Class::::_rebless_as_immutableClass::MOP::Class::_rebless_as_immutable (recurses: max depth 1, inclusive time 1.06ms)
32113.12ms244msClass::MOP::Class::::_inline_accessorsClass::MOP::Class::_inline_accessors
61223.04ms112msClass::MOP::Class::::add_around_method_modifierClass::MOP::Class::add_around_method_modifier
82113.02ms12.3msClass::MOP::Class::::_class_metaclass_can_be_made_compatibleClass::MOP::Class::_class_metaclass_can_be_made_compatible
239112.96ms2.96msClass::MOP::Class::::invalidate_meta_instanceClass::MOP::Class::invalidate_meta_instance
1112.89ms7.27msClass::MOP::Class::::BEGIN@10Class::MOP::Class::BEGIN@10
150322.73ms2.73msClass::MOP::Class::::_base_metaclassesClass::MOP::Class::_base_metaclasses
36112.66ms12.4msClass::MOP::Class::::_superclasses_updatedClass::MOP::Class::_superclasses_updated
55112.37ms3.59msClass::MOP::Class::::_inline_fallback_constructorClass::MOP::Class::_inline_fallback_constructor
39112.27ms5.89msClass::MOP::Class::::_class_metaclass_is_compatibleClass::MOP::Class::_class_metaclass_is_compatible
55112.10ms12.3msClass::MOP::Class::::_inline_create_instanceClass::MOP::Class::_inline_create_instance
55111.91ms3.80msClass::MOP::Class::::_inline_preserve_weak_metaclassesClass::MOP::Class::_inline_preserve_weak_metaclasses
55111.81ms14.1msClass::MOP::Class::::_inline_generate_instanceClass::MOP::Class::_inline_generate_instance
10221.69ms125msClass::MOP::Class::::createClass::MOP::Class::create
79211.67ms1.67msClass::MOP::Class::::_add_inlined_methodClass::MOP::Class::_add_inlined_method
8111.42ms16.3msClass::MOP::Class::::get_all_methodsClass::MOP::Class::get_all_methods
1111.16ms4.84msClass::MOP::Class::::BEGIN@16Class::MOP::Class::BEGIN@16
1111.10ms1.30msClass::MOP::Class::::BEGIN@11Class::MOP::Class::BEGIN@11
39111.10ms6.98msClass::MOP::Class::::_check_class_metaclass_compatibilityClass::MOP::Class::_check_class_metaclass_compatibility
10633750µs750µsClass::MOP::Class::::is_mutableClass::MOP::Class::is_mutable
9111708µs708µsClass::MOP::Class::::is_immutableClass::MOP::Class::is_immutable
3611604µs604µsClass::MOP::Class::::_superclass_metasClass::MOP::Class::_superclass_metas
3111577µs577µsClass::MOP::Class::::_inline_paramsClass::MOP::Class::_inline_params
3111505µs505µsClass::MOP::Class::::_generate_fallback_constructorClass::MOP::Class::_generate_fallback_constructor
3611442µs442µsClass::MOP::Class::::update_meta_instance_dependenciesClass::MOP::Class::update_meta_instance_dependencies
811387µs381msClass::MOP::Class::::create_anon_classClass::MOP::Class::create_anon_class
522303µs10.7msClass::MOP::Class::::add_before_method_modifierClass::MOP::Class::add_before_method_modifier
3111220µs220µsClass::MOP::Class::::_inline_extra_initClass::MOP::Class::_inline_extra_init
211217µs1.63msClass::MOP::Class::::add_after_method_modifierClass::MOP::Class::add_after_method_modifier
111151µs174µsClass::MOP::Class::::BEGIN@4Class::MOP::Class::BEGIN@4
11156µs132µsClass::MOP::Class::::BEGIN@433Class::MOP::Class::BEGIN@433
11142µs106µsClass::MOP::Class::::BEGIN@468Class::MOP::Class::BEGIN@468
11142µs248µsClass::MOP::Class::::BEGIN@17Class::MOP::Class::BEGIN@17
11142µs102µsClass::MOP::Class::::BEGIN@455Class::MOP::Class::BEGIN@455
11140µs21.9msClass::MOP::Class::::BEGIN@24Class::MOP::Class::BEGIN@24
11140µs110µsClass::MOP::Class::::BEGIN@5Class::MOP::Class::BEGIN@5
11139µs216µsClass::MOP::Class::::BEGIN@14Class::MOP::Class::BEGIN@14
11138µs198µsClass::MOP::Class::::BEGIN@13Class::MOP::Class::BEGIN@13
11138µs166µsClass::MOP::Class::::BEGIN@18Class::MOP::Class::BEGIN@18
11136µs164µsClass::MOP::Class::::BEGIN@15Class::MOP::Class::BEGIN@15
0000s0sClass::MOP::Class::::DESTROYClass::MOP::Class::DESTROY
0000s0sClass::MOP::Class::::__ANON__[:214]Class::MOP::Class::__ANON__[:214]
0000s0sClass::MOP::Class::::__ANON__[:936]Class::MOP::Class::__ANON__[:936]
0000s0sClass::MOP::Class::::_clone_instanceClass::MOP::Class::_clone_instance
0000s0sClass::MOP::Class::::_fix_class_metaclass_incompatibilityClass::MOP::Class::_fix_class_metaclass_incompatibility
0000s0sClass::MOP::Class::::_fix_single_metaclass_incompatibilityClass::MOP::Class::_fix_single_metaclass_incompatibility
0000s0sClass::MOP::Class::::_fixup_attributes_after_reblessClass::MOP::Class::_fixup_attributes_after_rebless
0000s0sClass::MOP::Class::::_force_rebless_instanceClass::MOP::Class::_force_rebless_instance
0000s0sClass::MOP::Class::::_inline_clear_mop_slotClass::MOP::Class::_inline_clear_mop_slot
0000s0sClass::MOP::Class::::_inline_get_mop_slotClass::MOP::Class::_inline_get_mop_slot
0000s0sClass::MOP::Class::::_inline_rebless_instanceClass::MOP::Class::_inline_rebless_instance
0000s0sClass::MOP::Class::::_inline_set_mop_slotClass::MOP::Class::_inline_set_mop_slot
0000s0sClass::MOP::Class::::_inlined_methodsClass::MOP::Class::_inlined_methods
0000s0sClass::MOP::Class::::_rebless_as_mutableClass::MOP::Class::_rebless_as_mutable
0000s0sClass::MOP::Class::::_remove_generated_metaobjectsClass::MOP::Class::_remove_generated_metaobjects
0000s0sClass::MOP::Class::::_remove_inlined_codeClass::MOP::Class::_remove_inlined_code
0000s0sClass::MOP::Class::::_restore_metaobjects_fromClass::MOP::Class::_restore_metaobjects_from
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::::clone_objectClass::MOP::Class::clone_object
0000s0sClass::MOP::Class::::direct_subclassesClass::MOP::Class::direct_subclasses
0000s0sClass::MOP::Class::::get_all_method_namesClass::MOP::Class::get_all_method_names
0000s0sClass::MOP::Class::::immutable_optionsClass::MOP::Class::immutable_options
0000s0sClass::MOP::Class::::is_anon_classClass::MOP::Class::is_anon_class
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::::reinitializeClass::MOP::Class::reinitialize
0000s0sClass::MOP::Class::::remove_attributeClass::MOP::Class::remove_attribute
0000s0sClass::MOP::Class::::remove_dependent_meta_instanceClass::MOP::Class::remove_dependent_meta_instance
0000s0sClass::MOP::Class::::remove_meta_instance_dependenciesClass::MOP::Class::remove_meta_instance_dependencies
0000s0sClass::MOP::Class::::subclassesClass::MOP::Class::subclasses
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1
2package Class::MOP::Class;
3
43182µs2196µs
# spent 174µs (151+23) within Class::MOP::Class::BEGIN@4 which was called: # once (151µs+23µs) by Class::MOP::BEGIN@19 at line 4
use strict;
# spent 174µs making 1 call to Class::MOP::Class::BEGIN@4 # spent 23µs making 1 call to strict::import
5397µs2180µs
# spent 110µs (40+70) within Class::MOP::Class::BEGIN@5 which was called: # once (40µs+70µs) by Class::MOP::BEGIN@19 at line 5
use warnings;
# spent 110µs making 1 call to Class::MOP::Class::BEGIN@5 # spent 70µs making 1 call to warnings::import
6
73428µs15.79ms
# spent 5.79ms (5.11+678µs) within Class::MOP::Class::BEGIN@7 which was called: # once (5.11ms+678µs) by Class::MOP::BEGIN@19 at line 7
use Class::MOP::Instance;
# spent 5.79ms making 1 call to Class::MOP::Class::BEGIN@7
83478µs15.08ms
# spent 5.08ms (4.24+845µs) within Class::MOP::Class::BEGIN@8 which was called: # once (4.24ms+845µs) by Class::MOP::BEGIN@19 at line 8
use Class::MOP::Method::Wrapped;
# spent 5.08ms making 1 call to Class::MOP::Class::BEGIN@8
93442µs136.5ms
# spent 36.5ms (4.78+31.8) within Class::MOP::Class::BEGIN@9 which was called: # once (4.78ms+31.8ms) by Class::MOP::BEGIN@19 at line 9
use Class::MOP::Method::Accessor;
# spent 36.5ms making 1 call to Class::MOP::Class::BEGIN@9
103471µs17.27ms
# spent 7.27ms (2.89+4.38) within Class::MOP::Class::BEGIN@10 which was called: # once (2.89ms+4.38ms) by Class::MOP::BEGIN@19 at line 10
use Class::MOP::Method::Constructor;
# spent 7.27ms making 1 call to Class::MOP::Class::BEGIN@10
113500µs11.30ms
# spent 1.30ms (1.10+199µs) within Class::MOP::Class::BEGIN@11 which was called: # once (1.10ms+199µs) by Class::MOP::BEGIN@19 at line 11
use Class::MOP::MiniTrait;
# spent 1.30ms making 1 call to Class::MOP::Class::BEGIN@11
12
133116µs2357µs
# spent 198µs (38+159) within Class::MOP::Class::BEGIN@13 which was called: # once (38µs+159µs) by Class::MOP::BEGIN@19 at line 13
use Carp 'confess';
# spent 198µs making 1 call to Class::MOP::Class::BEGIN@13 # spent 159µs making 1 call to Exporter::import
143100µs2394µs
# spent 216µs (39+178) within Class::MOP::Class::BEGIN@14 which was called: # once (39µs+178µs) by Class::MOP::BEGIN@19 at line 14
use Scalar::Util 'blessed', 'reftype', 'weaken';
# spent 216µs making 1 call to Class::MOP::Class::BEGIN@14 # spent 178µs making 1 call to Exporter::import
153101µs2293µs
# spent 164µs (36+128) within Class::MOP::Class::BEGIN@15 which was called: # once (36µs+128µs) by Class::MOP::BEGIN@19 at line 15
use Sub::Name 'subname';
# spent 164µs making 1 call to Class::MOP::Class::BEGIN@15 # spent 128µs making 1 call to Exporter::import
163607µs25.64ms
# spent 4.84ms (1.16+3.68) within Class::MOP::Class::BEGIN@16 which was called: # once (1.16ms+3.68ms) by Class::MOP::BEGIN@19 at line 16
use Devel::GlobalDestruction 'in_global_destruction';
# spent 4.84ms making 1 call to Class::MOP::Class::BEGIN@16 # spent 801µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
173114µs2453µs
# spent 248µs (42+205) within Class::MOP::Class::BEGIN@17 which was called: # once (42µs+205µs) by Class::MOP::BEGIN@19 at line 17
use Try::Tiny;
# spent 248µs making 1 call to Class::MOP::Class::BEGIN@17 # spent 205µs making 1 call to Exporter::import
183232µs2295µs
# spent 166µs (38+129) within Class::MOP::Class::BEGIN@18 which was called: # once (38µs+129µs) by Class::MOP::BEGIN@19 at line 18
use List::MoreUtils 'all';
# spent 166µs making 1 call to Class::MOP::Class::BEGIN@18 # spent 129µs making 1 call to Exporter::import
19
2015µsour $VERSION = '1.11';
21187µs$VERSION = eval $VERSION;
# spent 12µs executing statements in string eval
2214µsour $AUTHORITY = 'cpan:STEVAN';
23
24121.9ms
# spent 21.9ms (40µs+21.9) within Class::MOP::Class::BEGIN@24 which was called: # once (40µs+21.9ms) by Class::MOP::BEGIN@19 at line 26
use base 'Class::MOP::Module',
# spent 21.9ms making 1 call to base::import
25 'Class::MOP::Mixin::HasAttributes',
2635.68ms121.9ms 'Class::MOP::Mixin::HasMethods';
# spent 21.9ms making 1 call to Class::MOP::Class::BEGIN@24
27
28# Creation
29
30
# spent 349ms (105+244) within Class::MOP::Class::initialize which was called 3125 times, avg 112µs/call: # 1334 times (43.2ms+11.2ms) by Class::MOP::Class::get_all_attributes at line 968, avg 41µs/call # 449 times (16.5ms+20.4ms) by Class::MOP::Class::__ANON__::SERIAL::1::meta or Class::MOP::Class::__ANON__::SERIAL::2::meta or Class::MOP::Class::__ANON__::SERIAL::5::meta or Class::MOP::Mixin::meta or Class::MOP::Object::meta or Data::Stream::Bulk::Cat::meta or Data::Stream::Bulk::Filter::meta or Data::Stream::Bulk::Nil::meta or Data::Visitor::meta or KiokuDB::Collapser::Buffer::meta or KiokuDB::Collapser::meta or KiokuDB::Entry::Skip::meta or KiokuDB::Entry::meta or KiokuDB::Error::MissingObjects::meta or KiokuDB::Error::UnknownObjects::meta or KiokuDB::Linker::meta or KiokuDB::LiveObjects::Scope::meta or KiokuDB::LiveObjects::TXNScope::meta or KiokuDB::LiveObjects::meta or KiokuDB::Reference::meta or KiokuDB::Stream::Objects::meta or KiokuDB::Thunk::meta or KiokuDB::TypeMap::Entry::Alias::meta or KiokuDB::TypeMap::Entry::Compiled::meta or KiokuDB::TypeMap::Entry::MOP::meta or KiokuDB::TypeMap::Resolver::meta or KiokuDB::TypeMap::Shadow::meta or KiokuDB::TypeMap::meta or KiokuDB::meta or Moose::Meta::Role::Application::RoleSummation::meta or Moose::Meta::Role::Application::ToClass::meta or Moose::Meta::Role::Application::ToInstance::meta or Moose::Meta::Role::Application::ToRole::meta or Moose::Meta::Role::Application::meta or Moose::Meta::Role::Composite::meta or Moose::Meta::Role::Method::Required::meta or Moose::Meta::Role::meta or Moose::Meta::TypeCoercion::Union::meta or Moose::Meta::TypeCoercion::meta or Moose::Meta::TypeConstraint::Class::meta or Moose::Meta::TypeConstraint::DuckType::meta or Moose::Meta::TypeConstraint::Enum::meta or Moose::Meta::TypeConstraint::Parameterizable::meta or Moose::Meta::TypeConstraint::Parameterized::meta or Moose::Meta::TypeConstraint::Registry::meta or Moose::Meta::TypeConstraint::Role::meta or Moose::Meta::TypeConstraint::Union::meta or Moose::Meta::TypeConstraint::meta at line 44 of Class/MOP/Method/Meta.pm, avg 82µs/call # 436 times (14.4ms+4.17ms) by Class::MOP::Class::find_method_by_name at line 1159, avg 43µs/call # 249 times (8.26ms+2.57ms) by Class::MOP::Class::find_next_method_by_name at line 1208, avg 43µs/call # 98 times (3.16ms+869µs) by Class::MOP::Class::find_all_methods_by_name at line 1191, avg 41µs/call # 82 times (2.83ms+2.73ms) by Class::MOP::Class::_fix_metaclass_incompatibility at line 298, avg 68µs/call # 79 times (2.55ms+687µs) by Class::MOP::Class::find_attribute_by_name at line 958, avg 41µs/call # 73 times (2.26ms+664µs) by Moose::Meta::Attribute::_new or Moose::Meta::Method::_new at line 4 of generated method (unknown origin), avg 40µs/call # 64 times (1.78ms+553µs) by Class::MOP::Attribute::has_value at line 316 of Class/MOP/Attribute.pm, avg 36µs/call # 49 times (1.64ms+470µs) by Class::MOP::Class::class_precedence_list at line 1068, avg 43µs/call # 35 times (1.01ms+311µs) by Class::MOP::Attribute::get_raw_value at line 295 of Class/MOP/Attribute.pm, avg 38µs/call # 34 times (1.84ms+136ms) by Moose::Meta::Class::initialize at line 68 of Moose/Meta/Class.pm, avg 4.06ms/call # 33 times (1.30ms+23.1ms) by Class::MOP::Object::meta at line 18 of Class/MOP/Object.pm, avg 738µs/call # 26 times (841µs+7.68ms) by Class::MOP::Method::_new at line 54 of Class/MOP/Method.pm, avg 328µs/call # 19 times (1.05ms+7.93ms) by metaclass::import at line 45 of metaclass.pm, avg 472µs/call # 18 times (741µs+7.20ms) by Class::MOP::Mixin::meta at line 14 of Class/MOP/Mixin.pm, avg 441µs/call # 14 times (673µs+13.7ms) by Class::MOP::MiniTrait::apply at line 15 of Class/MOP/MiniTrait.pm, avg 1.03ms/call # 11 times (342µs+105µs) by Class::MOP::Attribute::set_initial_value at line 259 of Class/MOP/Attribute.pm, avg 41µs/call # 9 times (276µs+75µs) by Class::MOP::Class::get_all_methods at line 1170, avg 39µs/call # 7 times (319µs+2.64ms) by Moose::BEGIN@38 at line 11 of Moose/Meta/Attribute/Native.pm, avg 423µs/call # 2 times (87µs+865µs) by Class::MOP::Class::create at line 513, avg 476µs/call # 2 times (58µs+17µs) by Moose::Meta::Attribute::_weaken_value at line 695 of Moose/Meta/Attribute.pm, avg 38µs/call # once (41µs+13µs) by Moose::Object::new at line 26 of Moose/Object.pm # once (30µs+9µs) by Class::MOP::Attribute::_new at line 62 of Class/MOP/Attribute.pm
sub initialize {
3115625101ms 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
453223248ms return Class::MOP::get_metaclass_by_name($package_name)
# spent 219ms making 98 calls to Class::MOP::Class::_construct_class_instance, avg 2.23ms/call, recursion: max depth 1, sum of overlapping time 726µs # spent 30.3ms making 3125 calls to Class::MOP::get_metaclass_by_name, avg 10µs/call
46 || $class->_construct_class_instance(package => $package_name, @_);
47}
48
49sub reinitialize {
50 my ( $class, @args ) = @_;
51 unshift @args, "package" if @args % 2;
52 my %options = @args;
53 my $old_metaclass = blessed($options{package})
54 ? $options{package}
55 : Class::MOP::get_metaclass_by_name($options{package});
56 $options{weaken} = Class::MOP::metaclass_is_weak($old_metaclass->name)
57 if !exists $options{weaken}
58 && blessed($old_metaclass)
59 && $old_metaclass->isa('Class::MOP::Class');
60 $old_metaclass->_remove_generated_metaobjects
61 if $old_metaclass && $old_metaclass->isa('Class::MOP::Class');
62 my $new_metaclass = $class->SUPER::reinitialize(%options);
63 $new_metaclass->_restore_metaobjects_from($old_metaclass)
64 if $old_metaclass && $old_metaclass->isa('Class::MOP::Class');
65 return $new_metaclass;
66}
67
68# NOTE: (meta-circularity)
69# this is a special form of _construct_instance
70# (see below), which is used to construct class
71# meta-object instances for any Class::MOP::*
72# class. All other classes will use the more
73# normal &construct_instance.
74
# spent 218ms (10.9+207) within Class::MOP::Class::_construct_class_instance which was called 98 times, avg 2.23ms/call: # 98 times (10.9ms+207ms) by Class::MOP::Class::initialize at line 45, avg 2.23ms/call
sub _construct_class_instance {
7511769.08ms 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
8698793µs if (defined(my $meta = Class::MOP::get_metaclass_by_name($package_name))) {
# spent 793µs making 98 calls to Class::MOP::get_metaclass_by_name, avg 8µs/call
87 return $meta;
88 }
89
90 $class
918840µs = ref $class
# spent 840µs making 8 calls to Class::MOP::Class::_real_ref_name, avg 105µs/call
92 ? $class->_real_ref_name
93 : $class;
94
95 # now create the metaclass
96 my $meta;
9734832µs644.05ms if ($class eq 'Class::MOP::Class') {
# spent 4.05ms making 64 calls to Class::MOP::Class::_new, avg 63µs/call
98 $meta = $class->_new($options);
99 }
100 else {
101 # NOTE:
102 # it is safe to use meta here because
103 # class will always be a subclass of
104 # Class::MOP::Class, which defines meta
10568120ms $meta = $class->meta->_construct_instance($options)
# spent 117ms making 34 calls to Class::MOP::Class::_construct_instance, avg 3.44ms/call # spent 2.81ms making 34 calls to Class::MOP::Object::meta, avg 83µs/call
106 }
107
108 # and check the metaclass compatibility
1099877.6ms $meta->_check_metaclass_compatibility();
# spent 81.3ms making 98 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 829µs/call, recursion: max depth 1, sum of overlapping time 3.70ms
110
111981.33ms Class::MOP::store_metaclass_by_name($package_name, $meta);
# spent 1.33ms making 98 calls to Class::MOP::store_metaclass_by_name, avg 14µs/call
112
113 # NOTE:
114 # we need to weaken any anon classes
115 # so that they can call DESTROY properly
116 Class::MOP::weaken_metaclass($package_name) if $options->{weaken};
117
118 $meta;
119}
120
121
# spent 7.06ms (3.79+3.27) within Class::MOP::Class::_real_ref_name which was called 131 times, avg 54µs/call: # 82 times (2.33ms+1.84ms) by Class::MOP::Class::_class_metaclass_can_be_made_compatible at line 343, avg 51µs/call # 39 times (1.13ms+803µs) by Class::MOP::Class::_class_metaclass_is_compatible at line 253, avg 50µs/call # 8 times (270µs+570µs) by Class::MOP::Class::_construct_class_instance at line 91, avg 105µs/call # 2 times (61µs+64µs) by Class::MOP::Class::_immutable_metaclass at line 1385, avg 62µs/call
sub _real_ref_name {
1222623.59ms 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
1261713.27ms return $self->is_immutable
# spent 1.91ms making 38 calls to Class::MOP::Class::Immutable::Class::MOP::Class::is_immutable, avg 50µs/call # spent 708µs making 91 calls to Class::MOP::Class::is_immutable, avg 8µs/call # spent 546µs making 40 calls to Class::MOP::Class::Immutable::Trait::_get_mutable_metaclass_name, avg 14µs/call # spent 104µs making 2 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::is_immutable, avg 52µs/call
127 ? $self->_get_mutable_metaclass_name()
128 : ref $self;
129}
130
131
# spent 4.05ms within Class::MOP::Class::_new which was called 64 times, avg 63µs/call: # 64 times (4.05ms+0s) by Class::MOP::Class::_construct_class_instance at line 97, avg 63µs/call
sub _new {
1322564.29ms my $class = shift;
133
134 return Class::MOP::Class->initialize($class)->new_object(@_)
135 if $class ne __PACKAGE__;
136
137 my $options = @_ == 1 ? $_[0] : {@_};
138
139 return bless {
140 # inherited from Class::MOP::Package
141 'package' => $options->{package},
142
143 # NOTE:
144 # since the following attributes will
145 # actually be loaded from the symbol
146 # table, and actually bypass the instance
147 # entirely, we can just leave these things
148 # listed here for reference, because they
149 # should not actually have a value associated
150 # with the slot.
151 'namespace' => \undef,
152 'methods' => {},
153
154 # inherited from Class::MOP::Module
155 'version' => \undef,
156 'authority' => \undef,
157
158 # defined in Class::MOP::Class
159 'superclasses' => \undef,
160
161 'attributes' => {},
162 'attribute_metaclass' =>
163 ( $options->{'attribute_metaclass'} || 'Class::MOP::Attribute' ),
164 'method_metaclass' =>
165 ( $options->{'method_metaclass'} || 'Class::MOP::Method' ),
166 'wrapped_method_metaclass' => (
167 $options->{'wrapped_method_metaclass'}
168 || 'Class::MOP::Method::Wrapped'
169 ),
170 'instance_metaclass' =>
171 ( $options->{'instance_metaclass'} || 'Class::MOP::Instance' ),
172 'immutable_trait' => (
173 $options->{'immutable_trait'}
174 || 'Class::MOP::Class::Immutable::Trait'
175 ),
176 'constructor_name' => ( $options->{constructor_name} || 'new' ),
177 'constructor_class' => (
178 $options->{constructor_class} || 'Class::MOP::Method::Constructor'
179 ),
180 'destructor_class' => $options->{destructor_class},
181 }, $class;
182}
183
184## Metaclass compatibility
185{
186222µs my %base_metaclass = (
187 attribute_metaclass => 'Class::MOP::Attribute',
188 method_metaclass => 'Class::MOP::Method',
189 wrapped_method_metaclass => 'Class::MOP::Method::Wrapped',
190 instance_metaclass => 'Class::MOP::Instance',
191 constructor_class => 'Class::MOP::Method::Constructor',
192 destructor_class => 'Class::MOP::Method::Destructor',
193 );
194
1951503.37ms
# spent 2.73ms within Class::MOP::Class::_base_metaclasses which was called 150 times, avg 18µs/call: # 73 times (1.38ms+0s) by Moose::Meta::Class::_base_metaclasses at line 538 of Moose/Meta/Class.pm, avg 19µs/call # 43 times (827µs+0s) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 331, avg 19µs/call # 34 times (527µs+0s) by Class::MOP::Class::_check_metaclass_compatibility at line 206, avg 15µs/call
sub _base_metaclasses { %base_metaclass }
196}
197
198
# spent 240ms (19.0+221) within Class::MOP::Class::_check_metaclass_compatibility which was called 134 times, avg 1.79ms/call: # 98 times (4.95ms+72.6ms) by Class::MOP::Class::_construct_class_instance at line 109, avg 791µs/call # 36 times (14.1ms+148ms) by Class::MOP::Class::superclasses at line 998, avg 4.51ms/call
sub _check_metaclass_compatibility {
1995407.55ms my $self = shift;
200
20113421.1ms my @superclasses = $self->superclasses
# spent 11.2ms making 66 calls to Class::MOP::Class::superclasses, avg 169µs/call, recursion: max depth 1, sum of overlapping time 314µs # spent 16.4ms making 68 calls to Moose::Meta::Class::superclasses, avg 241µs/call, recursion: max depth 1, sum of overlapping time 6.16ms
202 or return;
203
20468119ms $self->_fix_metaclass_incompatibility(@superclasses);
# spent 122ms making 68 calls to Class::MOP::Class::_fix_metaclass_incompatibility, avg 1.79ms/call, recursion: max depth 1, sum of overlapping time 2.92ms
205
206688.13ms my %base_metaclass = $self->_base_metaclasses;
# spent 7.60ms making 34 calls to Moose::Meta::Class::_base_metaclasses, avg 224µs/call # spent 527µs making 34 calls to Class::MOP::Class::_base_metaclasses, avg 15µs/call
207
208 # this is always okay ...
209 return
210 if ref($self) eq 'Class::MOP::Class'
211 && all {
2124084.18ms2041.07ms my $meta = $self->$_;
# spent 196µs making 34 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 6µs/call # spent 178µs making 34 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call # spent 177µs making 34 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call # spent 175µs making 34 calls to Class::MOP::Class::destructor_class, avg 5µs/call # spent 174µs making 34 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call # spent 167µs making 34 calls to Class::MOP::Class::constructor_class, avg 5µs/call
21311.24ms !defined($meta) || $meta eq $base_metaclass{$_};
214 }
215345.09ms keys %base_metaclass;
# spent 5.09ms making 34 calls to List::MoreUtils::all, avg 150µs/call
216
217 for my $superclass (@superclasses) {
21839647µs396.98ms $self->_check_class_metaclass_compatibility($superclass);
# spent 6.98ms making 39 calls to Class::MOP::Class::_check_class_metaclass_compatibility, avg 179µs/call
219 }
220
221 for my $metaclass_type ( keys %base_metaclass ) {
2224765.76ms2382.38ms next unless defined $self->$metaclass_type;
# spent 512µs making 34 calls to Moose::Meta::Class::error_class, avg 15µs/call # spent 502µs making 34 calls to Moose::Meta::Class::constructor_class, avg 15µs/call # spent 489µs making 34 calls to Moose::Meta::Class::destructor_class, avg 14µs/call # spent 245µs making 34 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 7µs/call # spent 217µs making 34 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 6µs/call # spent 211µs making 34 calls to Class::MOP::Class::instance_metaclass, avg 6µs/call # spent 207µs making 34 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 6µs/call
223 for my $superclass (@superclasses) {
2242734.16ms27352.4ms $self->_check_single_metaclass_compatibility( $metaclass_type,
# spent 52.4ms making 273 calls to Class::MOP::Class::_check_single_metaclass_compatibility, avg 192µs/call
225 $superclass );
226 }
227 }
228}
229
230
# spent 6.98ms (1.10+5.89) within Class::MOP::Class::_check_class_metaclass_compatibility which was called 39 times, avg 179µs/call: # 39 times (1.10ms+5.89ms) by Class::MOP::Class::_check_metaclass_compatibility at line 218, avg 179µs/call
sub _check_class_metaclass_compatibility {
2311171.03ms my $self = shift;
232 my ( $superclass_name ) = @_;
233
234395.89ms if (!$self->_class_metaclass_is_compatible($superclass_name)) {
# spent 5.89ms making 39 calls to Class::MOP::Class::_class_metaclass_is_compatible, avg 151µs/call
235 my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name);
236
237 my $super_meta_type = $super_meta->_real_ref_name;
238
239 confess "The metaclass of " . $self->name . " ("
240 . (ref($self)) . ")" . " is not compatible with "
241 . "the metaclass of its superclass, "
242 . $superclass_name . " (" . ($super_meta_type) . ")";
243 }
244}
245
246
# spent 5.89ms (2.27+3.62) within Class::MOP::Class::_class_metaclass_is_compatible which was called 39 times, avg 151µs/call: # 39 times (2.27ms+3.62ms) by Class::MOP::Class::_check_class_metaclass_compatibility at line 234, avg 151µs/call
sub _class_metaclass_is_compatible {
2471951.97ms my $self = shift;
248 my ( $superclass_name ) = @_;
249
25039415µs my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name)
# spent 415µs making 39 calls to Class::MOP::get_metaclass_by_name, avg 11µs/call
251 || return 1;
252
253391.93ms my $super_meta_name = $super_meta->_real_ref_name;
# spent 1.93ms making 39 calls to Class::MOP::Class::_real_ref_name, avg 50µs/call
254
255391.28ms return $self->_is_compatible_with($super_meta_name);
# spent 1.28ms making 39 calls to Class::MOP::Object::_is_compatible_with, avg 33µs/call
256}
257
258
# spent 52.4ms (7.30+45.1) within Class::MOP::Class::_check_single_metaclass_compatibility which was called 273 times, avg 192µs/call: # 273 times (7.30ms+45.1ms) by Class::MOP::Class::_check_metaclass_compatibility at line 224, avg 192µs/call
sub _check_single_metaclass_compatibility {
2598196.82ms my $self = shift;
260 my ( $metaclass_type, $superclass_name ) = @_;
261
26227345.1ms if (!$self->_single_metaclass_is_compatible($metaclass_type, $superclass_name)) {
# spent 45.1ms making 273 calls to Class::MOP::Class::_single_metaclass_is_compatible, avg 165µs/call
263 my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name);
264 my $metaclass_type_name = $metaclass_type;
265 $metaclass_type_name =~ s/_(?:meta)?class$//;
266 $metaclass_type_name =~ s/_/ /g;
267 confess "The $metaclass_type_name metaclass for "
268 . $self->name . " (" . ($self->$metaclass_type)
269 . ")" . " is not compatible with the "
270 . "$metaclass_type_name metaclass of its "
271 . "superclass, $superclass_name ("
272 . ($super_meta->$metaclass_type) . ")";
273 }
274}
275
276
# spent 45.1ms (24.9+20.1) within Class::MOP::Class::_single_metaclass_is_compatible which was called 273 times, avg 165µs/call: # 273 times (24.9ms+20.1ms) by Class::MOP::Class::_check_single_metaclass_compatibility at line 262, avg 165µs/call
sub _single_metaclass_is_compatible {
277184628.0ms my $self = shift;
278 my ( $metaclass_type, $superclass_name ) = @_;
279
2802732.31ms my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name)
# spent 2.31ms making 273 calls to Class::MOP::get_metaclass_by_name, avg 8µs/call
281 || return 1;
282
283 # for instance, Moose::Meta::Class has a error_class attribute, but
284 # Class::MOP::Class doesn't - this shouldn't be an error
2852731.68ms return 1 unless $super_meta->can($metaclass_type);
# spent 1.68ms making 273 calls to UNIVERSAL::can, avg 6µs/call
286 # for instance, Moose::Meta::Class has a destructor_class, but
287 # Class::MOP::Class doesn't - this shouldn't be an error
2882601.95ms return 1 unless defined $super_meta->$metaclass_type;
# spent 332µs making 26 calls to Moose::Meta::Class::error_class, avg 13µs/call # spent 325µs making 26 calls to Moose::Meta::Class::constructor_class, avg 12µs/call # spent 319µs making 26 calls to Moose::Meta::Class::destructor_class, avg 12µs/call # spent 217µs making 39 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 6µs/call # spent 208µs making 39 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call # spent 208µs making 39 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call # spent 206µs making 39 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call # spent 69µs making 13 calls to Class::MOP::Class::destructor_class, avg 5µs/call # spent 69µs making 13 calls to Class::MOP::Class::constructor_class, avg 5µs/call
289 # if metaclass is defined in superclass but not here, it's not compatible
290 # this is a really odd case
2912471.85ms return 0 unless defined $self->$metaclass_type;
# spent 454µs making 39 calls to Moose::Meta::Class::constructor_class, avg 12µs/call # spent 314µs making 26 calls to Moose::Meta::Class::error_class, avg 12µs/call # spent 306µs making 26 calls to Moose::Meta::Class::destructor_class, avg 12µs/call # spent 198µs making 39 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 5µs/call # spent 197µs making 39 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call # spent 193µs making 39 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call # spent 193µs making 39 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call
292
29374112.3ms return $self->$metaclass_type->_is_compatible_with($super_meta->$metaclass_type);
# spent 8.68ms making 247 calls to Class::MOP::Object::_is_compatible_with, avg 35µs/call # spent 826µs making 65 calls to Moose::Meta::Class::constructor_class, avg 13µs/call # spent 633µs making 52 calls to Moose::Meta::Class::error_class, avg 12µs/call # spent 614µs making 52 calls to Moose::Meta::Class::destructor_class, avg 12µs/call # spent 424µs making 78 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call # spent 370µs making 78 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 5µs/call # spent 364µs making 78 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call # spent 358µs making 78 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call # spent 67µs making 13 calls to Class::MOP::Class::constructor_class, avg 5µs/call
294}
295
296
# spent 119ms (4.81+114) within Class::MOP::Class::_fix_metaclass_incompatibility which was called 68 times, avg 1.75ms/call: # 68 times (4.81ms+114ms) by Class::MOP::Class::_check_metaclass_compatibility at line 204, avg 1.75ms/call
sub _fix_metaclass_incompatibility {
2973402.16ms my $self = shift;
29882924µs825.55ms my @supers = map { Class::MOP::Class->initialize($_) } @_;
# spent 7.93ms making 82 calls to Class::MOP::Class::initialize, avg 97µs/call, recursion: max depth 1, sum of overlapping time 2.38ms
299
300 my $necessary = 0;
301 for my $super (@supers) {
302821.35ms82109ms $necessary = 1
# spent 109ms making 82 calls to Class::MOP::Class::_can_fix_metaclass_incompatibility, avg 1.33ms/call
303 if $self->_can_fix_metaclass_incompatibility($super);
304 }
305 return unless $necessary;
306
307 for my $super (@supers) {
308 if (!$self->_class_metaclass_is_compatible($super->name)) {
309 $self->_fix_class_metaclass_incompatibility($super);
310 }
311 }
312
313 my %base_metaclass = $self->_base_metaclasses;
314 for my $metaclass_type (keys %base_metaclass) {
315 for my $super (@supers) {
316 if (!$self->_single_metaclass_is_compatible($metaclass_type, $super->name)) {
317 $self->_fix_single_metaclass_incompatibility(
318 $metaclass_type, $super
319 );
320 }
321 }
322 }
323}
324
325
# spent 109ms (14.3+95.0) within Class::MOP::Class::_can_fix_metaclass_incompatibility which was called 82 times, avg 1.33ms/call: # 82 times (14.3ms+95.0ms) by Class::MOP::Class::_fix_metaclass_incompatibility at line 302, avg 1.33ms/call
sub _can_fix_metaclass_incompatibility {
3264925.42ms my $self = shift;
327 my ($super_meta) = @_;
328
3298212.3ms return 1 if $self->_class_metaclass_can_be_made_compatible($super_meta);
# spent 12.3ms making 82 calls to Class::MOP::Class::_class_metaclass_can_be_made_compatible, avg 150µs/call
330
331829.82ms my %base_metaclass = $self->_base_metaclasses;
# spent 9.00ms making 39 calls to Moose::Meta::Class::_base_metaclasses, avg 231µs/call # spent 827µs making 43 calls to Class::MOP::Class::_base_metaclasses, avg 19µs/call
332 for my $metaclass_type (keys %base_metaclass) {
3335317.34ms53172.8ms return 1 if $self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type);
# spent 72.8ms making 531 calls to Class::MOP::Class::_single_metaclass_can_be_made_compatible, avg 137µs/call
334 }
335
336 return;
337}
338
339
# spent 12.3ms (3.02+9.28) within Class::MOP::Class::_class_metaclass_can_be_made_compatible which was called 82 times, avg 150µs/call: # 82 times (3.02ms+9.28ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 329, avg 150µs/call
sub _class_metaclass_can_be_made_compatible {
3402462.87ms my $self = shift;
341 my ($super_meta) = @_;
342
3431649.28ms return $self->_can_be_made_compatible_with($super_meta->_real_ref_name);
# spent 5.12ms making 82 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 62µs/call # spent 4.16ms making 82 calls to Class::MOP::Class::_real_ref_name, avg 51µs/call
344}
345
346
# spent 72.8ms (36.6+36.2) within Class::MOP::Class::_single_metaclass_can_be_made_compatible which was called 531 times, avg 137µs/call: # 531 times (36.6ms+36.2ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 333, avg 137µs/call
sub _single_metaclass_can_be_made_compatible {
347408444.2ms my $self = shift;
348 my ($super_meta, $metaclass_type) = @_;
349
3505314.17ms my $specific_meta = $self->$metaclass_type;
# spent 589µs making 39 calls to Moose::Meta::Class::error_class, avg 15µs/call # spent 560µs making 39 calls to Moose::Meta::Class::constructor_class, avg 14µs/call # spent 555µs making 39 calls to Moose::Meta::Class::destructor_class, avg 14µs/call # spent 536µs making 82 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 7µs/call # spent 534µs making 82 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 7µs/call # spent 504µs making 82 calls to Class::MOP::Class::instance_metaclass, avg 6µs/call # spent 471µs making 82 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 6µs/call # spent 215µs making 43 calls to Class::MOP::Class::constructor_class, avg 5µs/call # spent 203µs making 43 calls to Class::MOP::Class::destructor_class, avg 5µs/call
351
3525313.43ms return unless $super_meta->can($metaclass_type);
# spent 3.43ms making 531 calls to UNIVERSAL::can, avg 6µs/call
3535183.26ms my $super_specific_meta = $super_meta->$metaclass_type;
# spent 474µs making 82 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 6µs/call # spent 439µs making 82 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call # spent 421µs making 82 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call # spent 410µs making 82 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call # spent 323µs making 26 calls to Moose::Meta::Class::destructor_class, avg 12µs/call # spent 322µs making 26 calls to Moose::Meta::Class::error_class, avg 12µs/call # spent 309µs making 26 calls to Moose::Meta::Class::constructor_class, avg 12µs/call # spent 280µs making 56 calls to Class::MOP::Class::constructor_class, avg 5µs/call # spent 278µs making 56 calls to Class::MOP::Class::destructor_class, avg 5µs/call
354
355 # for instance, Moose::Meta::Class has a destructor_class, but
356 # Class::MOP::Class doesn't - this shouldn't be an error
357 return unless defined $super_specific_meta;
358
359 # if metaclass is defined in superclass but not here, it's fixable
360 # this is a really odd case
361 return 1 unless defined $specific_meta;
362
36346225.4ms return 1 if $specific_meta->_can_be_made_compatible_with($super_specific_meta);
# spent 25.4ms making 462 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 55µs/call
364}
365
366sub _fix_class_metaclass_incompatibility {
367 my $self = shift;
368 my ( $super_meta ) = @_;
369
370 if ($self->_class_metaclass_can_be_made_compatible($super_meta)) {
371 ($self->is_pristine)
372 || confess "Can't fix metaclass incompatibility for "
373 . $self->name
374 . " because it is not pristine.";
375
376 my $super_meta_name = $super_meta->_real_ref_name;
377
378 $self->_make_compatible_with($super_meta_name);
379 }
380}
381
382sub _fix_single_metaclass_incompatibility {
383 my $self = shift;
384 my ( $metaclass_type, $super_meta ) = @_;
385
386 if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) {
387 ($self->is_pristine)
388 || confess "Can't fix metaclass incompatibility for "
389 . $self->name
390 . " because it is not pristine.";
391
392 my $new_metaclass = $self->$metaclass_type
393 ? $self->$metaclass_type->_get_compatible_metaclass($super_meta->$metaclass_type)
394 : $super_meta->$metaclass_type;
395 $self->{$metaclass_type} = $new_metaclass;
396 }
397}
398
399sub _restore_metaobjects_from {
400 my $self = shift;
401 my ($old_meta) = @_;
402
403 $self->_restore_metamethods_from($old_meta);
404 $self->_restore_metaattributes_from($old_meta);
405}
406
407sub _remove_generated_metaobjects {
408 my $self = shift;
409
410 for my $attr (map { $self->get_attribute($_) } $self->get_attribute_list) {
411 $attr->remove_accessors;
412 }
413}
414
415## ANON classes
416
417{
418 # NOTE:
419 # this should be sufficient, if you have a
420 # use case where it is not, write a test and
421 # I will change it.
42239µs my $ANON_CLASS_SERIAL = 0;
423
424 # NOTE:
425 # we need a sufficiently annoying prefix
426 # this should suffice for now, this is
427 # used in a couple of places below, so
428 # need to put it up here for now.
429 my $ANON_CLASS_PREFIX = 'Class::MOP::Class::__ANON__::SERIAL::';
430
431 sub is_anon_class {
432 my $self = shift;
4333460µs2207µs
# spent 132µs (56+75) within Class::MOP::Class::BEGIN@433 which was called: # once (56µs+75µs) by Class::MOP::BEGIN@19 at line 433
no warnings 'uninitialized';
# spent 132µs making 1 call to Class::MOP::Class::BEGIN@433 # spent 75µs making 1 call to warnings::unimport
434 $self->name =~ /^$ANON_CLASS_PREFIX/o;
435 }
436
437
# spent 381ms (387µs+381) within Class::MOP::Class::create_anon_class which was called 8 times, avg 47.7ms/call: # 8 times (387µs+381ms) by Moose::Meta::Class::create_anon_class at line 111 of Moose/Meta/Class.pm, avg 47.7ms/call
sub create_anon_class {
43832369µs my ($class, %options) = @_;
439 $options{weaken} = 1 unless exists $options{weaken};
440 my $package_name = $ANON_CLASS_PREFIX . ++$ANON_CLASS_SERIAL;
4418381ms return $class->create($package_name, %options);
# spent 381ms making 8 calls to Moose::Meta::Class::create, avg 47.6ms/call
442 }
443
444 # NOTE:
445 # this will only get called for
446 # anon-classes, all other calls
447 # are assumed to occur during
448 # global destruction and so don't
449 # really need to be handled explicitly
450 sub DESTROY {
451 my $self = shift;
452
453 return if in_global_destruction(); # it'll happen soon anyway and this just makes things more complicated
454
4553264µs2163µs
# spent 102µs (42+61) within Class::MOP::Class::BEGIN@455 which was called: # once (42µs+61µs) by Class::MOP::BEGIN@19 at line 455
no warnings 'uninitialized';
# spent 102µs making 1 call to Class::MOP::Class::BEGIN@455 # spent 61µs making 1 call to warnings::unimport
456 my $name = $self->name;
457 return unless $name =~ /^$ANON_CLASS_PREFIX/o;
458
459 # Moose does a weird thing where it replaces the metaclass for
460 # class when fixing metaclass incompatibility. In that case,
461 # we don't want to clean out the namespace now. We can detect
462 # that because Moose will explicitly update the singleton
463 # cache in Class::MOP.
464 my $current_meta = Class::MOP::get_metaclass_by_name($name);
465 return if $current_meta ne $self;
466
467 my ($serial_id) = ($name =~ /^$ANON_CLASS_PREFIX(\d+)/o);
468316.4ms2170µs
# spent 106µs (42+64) within Class::MOP::Class::BEGIN@468 which was called: # once (42µs+64µs) by Class::MOP::BEGIN@19 at line 468
no strict 'refs';
# spent 106µs making 1 call to Class::MOP::Class::BEGIN@468 # spent 64µs making 1 call to strict::unimport
469 @{$name . '::ISA'} = ();
470 %{$name . '::'} = ();
471 delete ${$ANON_CLASS_PREFIX}{$serial_id . '::'};
472
473 Class::MOP::remove_metaclass_by_name($name);
474 }
475
476}
477
478# creating classes with MOP ...
479
480
# spent 125ms (1.69+123) within Class::MOP::Class::create which was called 10 times, avg 12.5ms/call: # 8 times (1.35ms+113ms) by Moose::Meta::Class::create at line 85 of Moose/Meta/Class.pm, avg 14.3ms/call # 2 times (339µs+10.3ms) by Class::MOP::Class::_immutable_metaclass at line 1387, avg 5.33ms/call
sub create {
4811701.59ms my ( $class, @args ) = @_;
482
483 unshift @args, 'package' if @args % 2 == 1;
484
485 my (%options) = @args;
486 my $package_name = $options{package};
487
488 (ref $options{superclasses} eq 'ARRAY')
489 || confess "You must pass an ARRAY ref of superclasses"
490 if exists $options{superclasses};
491
492 (ref $options{attributes} eq 'ARRAY')
493 || confess "You must pass an ARRAY ref of attributes"
494 if exists $options{attributes};
495
496 (ref $options{methods} eq 'HASH')
497 || confess "You must pass a HASH ref of methods"
498 if exists $options{methods};
499
500 $options{meta_name} = 'meta'
501 unless exists $options{meta_name};
502
503 my (%initialize_options) = @args;
504 delete @initialize_options{qw(
505 package
506 superclasses
507 attributes
508 methods
509 meta_name
510 version
511 authority
512 )};
5131032.4ms my $meta = $class->initialize( $package_name => %initialize_options );
# spent 31.4ms making 8 calls to Moose::Meta::Class::initialize, avg 3.93ms/call # spent 953µs making 2 calls to Class::MOP::Class::initialize, avg 476µs/call
514
515101.19ms $meta->_instantiate_module( $options{version}, $options{authority} );
# spent 1.19ms making 10 calls to Class::MOP::Module::_instantiate_module, avg 119µs/call
516
5171026.9ms $meta->_add_meta_method($options{meta_name})
# spent 26.9ms making 10 calls to Class::MOP::Mixin::HasMethods::_add_meta_method, avg 2.69ms/call
518 if defined $options{meta_name};
519
5201062.7ms $meta->superclasses(@{$options{superclasses}})
# spent 58.4ms making 8 calls to Moose::Meta::Class::superclasses, avg 7.30ms/call # spent 4.32ms making 2 calls to Class::MOP::Class::superclasses, avg 2.16ms/call
521 if exists $options{superclasses};
522 # NOTE:
523 # process attributes first, so that they can
524 # install accessors, but locally defined methods
525 # can then overwrite them. It is maybe a little odd, but
526 # I think this should be the order of things.
527 if (exists $options{attributes}) {
528 foreach my $attr (@{$options{attributes}}) {
529 $meta->add_attribute($attr);
530 }
531 }
532 if (exists $options{methods}) {
533 foreach my $method_name (keys %{$options{methods}}) {
534 $meta->add_method($method_name, $options{methods}->{$method_name});
535 }
536 }
537 return $meta;
538}
539
540# Instance Construction & Cloning
541
542
# spent 152ms (5.22+147) within Class::MOP::Class::new_object which was called 104 times, avg 1.46ms/call: # 68 times (3.36ms+84.5ms) by Moose::Meta::Method::_new at line 4 of generated method (unknown origin), avg 1.29ms/call # 26 times (1.32ms+30.9ms) by Class::MOP::Method::_new at line 54 of Class/MOP/Method.pm, avg 1.24ms/call # 6 times (309µs+23.5ms) by Moose::Meta::Class::new_object at line 256 of Moose/Meta/Class.pm, avg 3.96ms/call # 2 times (112µs+2.75ms) by Moose::Meta::TypeCoercion::new at line 34 of Moose/Meta/TypeCoercion.pm, avg 1.43ms/call # once (65µs+4.05ms) by Class::MOP::Attribute::_new at line 62 of Class/MOP/Attribute.pm # once (61µs+1.38ms) by Class::MOP::Object::_new at line 22 of Class/MOP/Object.pm
sub new_object {
5433127.46ms my $class = shift;
544
545 # NOTE:
546 # we need to protect the integrity of the
547 # Class::MOP::Class singletons here, so we
548 # delegate this to &construct_class_instance
549 # which will deal with the singletons
5502082.18ms return $class->_construct_class_instance(@_)
# spent 1.58ms making 104 calls to UNIVERSAL::isa, avg 15µs/call # spent 605µs making 104 calls to Class::MOP::Package::name, avg 6µs/call
551 if $class->name->isa('Class::MOP::Class');
552104145ms return $class->_construct_instance(@_);
# spent 145ms making 104 calls to Class::MOP::Class::_construct_instance, avg 1.39ms/call
553}
554
555
# spent 262ms (35.3+226) within Class::MOP::Class::_construct_instance which was called 138 times, avg 1.90ms/call: # 104 times (22.0ms+123ms) by Class::MOP::Class::new_object at line 552, avg 1.39ms/call # 34 times (13.3ms+104ms) by Class::MOP::Class::_construct_class_instance at line 105, avg 3.44ms/call
sub _construct_instance {
556110415.0ms my $class = shift;
557 my $params = @_ == 1 ? $_[0] : {@_};
55813814.0ms my $meta_instance = $class->get_meta_instance();
# spent 10.7ms making 83 calls to Class::MOP::Class::get_meta_instance, avg 128µs/call # spent 3.35ms making 55 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 61µs/call
559 # FIXME:
560 # the code below is almost certainly incorrect
561 # but this is foreign inheritance, so we might
562 # have to kludge it in the end.
563 my $instance;
5641381.80ms138992µs if (my $instance_class = blessed($params->{__INSTANCE__})) {
# spent 992µs making 138 calls to Scalar::Util::blessed, avg 7µs/call
565 ($instance_class eq $class->name)
566 || confess "Objects passed as the __INSTANCE__ parameter must "
567 . "already be blessed into the correct class, but "
568 . "$params->{__INSTANCE__} is not a " . $class->name;
569 $instance = $params->{__INSTANCE__};
570 }
571 elsif (exists $params->{__INSTANCE__}) {
572 confess "The __INSTANCE__ parameter must be a blessed reference, not "
573 . $params->{__INSTANCE__};
574 }
575 else {
57613811.0ms $instance = $meta_instance->create_instance();
# spent 11.0ms making 138 calls to Class::MOP::Instance::create_instance, avg 80µs/call
577 }
57813844.1ms foreach my $attr ($class->get_all_attributes()) {
# spent 39.4ms making 83 calls to Class::MOP::Class::get_all_attributes, avg 474µs/call # spent 4.73ms making 55 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 86µs/call
579127817.4ms1278152ms $attr->initialize_instance_slot($meta_instance, $instance, $params);
# spent 144ms making 1264 calls to Class::MOP::Attribute::initialize_instance_slot, avg 114µs/call # spent 7.71ms making 14 calls to Moose::Meta::Attribute::initialize_instance_slot, avg 551µs/call
580 }
5812764.40ms if (Class::MOP::metaclass_is_weak($class->name)) {
# spent 3.52ms making 138 calls to Class::MOP::metaclass_is_weak, avg 26µs/call # spent 877µs making 138 calls to Class::MOP::Package::name, avg 6µs/call
582 $meta_instance->_set_mop_slot($instance, $class);
583 }
584 return $instance;
585}
586
587
# spent 396ms (4.81+391) within Class::MOP::Class::_inline_new_object which was called 55 times, avg 7.20ms/call: # 55 times (4.81ms+391ms) by Class::MOP::Method::Constructor::_generate_constructor_method_inline at line 112 of Class/MOP/Method/Constructor.pm, avg 7.20ms/call
sub _inline_new_object {
5881104.36ms my $self = shift;
589
590 return (
591330391ms 'my $class = shift;',
# spent 317ms making 55 calls to Class::MOP::Class::_inline_slot_initializers, avg 5.77ms/call # spent 36.0ms making 24 calls to Moose::Meta::Class::_inline_extra_init, avg 1.50ms/call # spent 15.5ms making 24 calls to Moose::Meta::Class::_inline_params, avg 645µs/call # spent 14.1ms making 55 calls to Class::MOP::Class::_inline_generate_instance, avg 256µs/call # spent 3.80ms making 55 calls to Class::MOP::Class::_inline_preserve_weak_metaclasses, avg 69µs/call # spent 3.59ms making 55 calls to Class::MOP::Class::_inline_fallback_constructor, avg 65µs/call # spent 577µs making 31 calls to Class::MOP::Class::_inline_params, avg 19µs/call # spent 220µs making 31 calls to Class::MOP::Class::_inline_extra_init, avg 7µs/call
592 '$class = Scalar::Util::blessed($class) || $class;',
593 $self->_inline_fallback_constructor('$class'),
594 $self->_inline_params('$params', '$class'),
595 $self->_inline_generate_instance('$instance', '$class'),
596 $self->_inline_slot_initializers,
597 $self->_inline_preserve_weak_metaclasses,
598 $self->_inline_extra_init,
599 'return $instance',
600 );
601}
602
603
# spent 3.59ms (2.37+1.22) within Class::MOP::Class::_inline_fallback_constructor which was called 55 times, avg 65µs/call: # 55 times (2.37ms+1.22ms) by Class::MOP::Class::_inline_new_object at line 591, avg 65µs/call
sub _inline_fallback_constructor {
6041652.52ms my $self = shift;
605 my ($class) = @_;
606 return (
6071101.22ms 'return ' . $self->_generate_fallback_constructor($class),
# spent 505µs making 31 calls to Class::MOP::Class::_generate_fallback_constructor, avg 16µs/call # spent 418µs making 24 calls to Moose::Meta::Class::_generate_fallback_constructor, avg 17µs/call # spent 297µs making 55 calls to Class::MOP::Package::name, avg 5µs/call
608 'if ' . $class . ' ne \'' . $self->name . '\';',
609 );
610}
611
612
# spent 505µs within Class::MOP::Class::_generate_fallback_constructor which was called 31 times, avg 16µs/call: # 31 times (505µs+0s) by Class::MOP::Class::_inline_fallback_constructor at line 607, avg 16µs/call
sub _generate_fallback_constructor {
61393654µs my $self = shift;
614 my ($class) = @_;
615 return 'Class::MOP::Class->initialize(' . $class . ')->new_object(@_)',
616}
617
618
# spent 577µs within Class::MOP::Class::_inline_params which was called 31 times, avg 19µs/call: # 31 times (577µs+0s) by Class::MOP::Class::_inline_new_object at line 591, avg 19µs/call
sub _inline_params {
61993664µs my $self = shift;
620 my ($params, $class) = @_;
621 return (
622 'my ' . $params . ' = @_ == 1 ? $_[0] : {@_};',
623 );
624}
625
626
# spent 14.1ms (1.81+12.3) within Class::MOP::Class::_inline_generate_instance which was called 55 times, avg 256µs/call: # 55 times (1.81ms+12.3ms) by Class::MOP::Class::_inline_new_object at line 591, avg 256µs/call
sub _inline_generate_instance {
6271651.59ms my $self = shift;
628 my ($inst, $class) = @_;
629 return (
6305512.3ms 'my ' . $inst . ' = ' . $self->_inline_create_instance($class) . ';',
# spent 12.3ms making 55 calls to Class::MOP::Class::_inline_create_instance, avg 223µs/call
631 );
632}
633
634
# spent 12.3ms (2.10+10.2) within Class::MOP::Class::_inline_create_instance which was called 55 times, avg 223µs/call: # 55 times (2.10ms+10.2ms) by Class::MOP::Class::_inline_generate_instance at line 630, avg 223µs/call
sub _inline_create_instance {
6351102.02ms my $self = shift;
636
63711010.2ms return $self->get_meta_instance->inline_create_instance(@_);
# spent 9.36ms making 55 calls to Class::MOP::Class::get_meta_instance, avg 170µs/call # spent 829µs making 55 calls to Class::MOP::Instance::inline_create_instance, avg 15µs/call
638}
639
640
# spent 317ms (8.51+309) within Class::MOP::Class::_inline_slot_initializers which was called 55 times, avg 5.77ms/call: # 55 times (8.51ms+309ms) by Class::MOP::Class::_inline_new_object at line 591, avg 5.77ms/call
sub _inline_slot_initializers {
641102226.0ms my $self = shift;
642
643 my $idx = 0;
644
6452092275ms return map { $self->_inline_slot_initializer($_, $idx++) }
# spent 138ms making 267 calls to Class::MOP::Class::_inline_slot_initializer, avg 517µs/call # spent 130ms making 111 calls to Moose::Meta::Class::_inline_slot_initializer, avg 1.17ms/call # spent 7.19ms making 1714 calls to Class::MOP::Mixin::AttributeCore::name, avg 4µs/call
6463784.50ms11040.9ms sort { $a->name cmp $b->name } $self->get_all_attributes;
# spent 23.0ms making 55 calls to Class::MOP::Class::CORE:sort, avg 418µs/call # spent 17.9ms making 55 calls to Class::MOP::Class::get_all_attributes, avg 325µs/call
647}
648
649
# spent 249ms (25.7+224) within Class::MOP::Class::_inline_slot_initializer which was called 378 times, avg 660µs/call: # 267 times (16.7ms+121ms) by Class::MOP::Class::_inline_slot_initializers at line 645, avg 517µs/call # 111 times (8.95ms+102ms) by Moose::Meta::Class::_inline_slot_initializer at line 344 of Moose/Meta/Class.pm, avg 1.00ms/call
sub _inline_slot_initializer {
65011349.40ms my $self = shift;
651 my ($attr, $idx) = @_;
652
653108417.4ms39510.8ms if (defined(my $init_arg = $attr->init_arg)) {
# spent 4.91ms making 11 calls to Class::MOP::Class::_inline_init_attr_from_default, avg 447µs/call # spent 3.88ms making 6 calls to Moose::Meta::Class::_inline_init_attr_from_default, avg 647µs/call # spent 1.97ms making 378 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 5µs/call
654361140ms my @source = (
# spent 76.9ms making 256 calls to Class::MOP::Class::_inline_init_attr_from_constructor, avg 300µs/call # spent 62.8ms making 105 calls to Moose::Meta::Class::_inline_init_attr_from_constructor, avg 598µs/call
655 'if (exists $params->{\'' . $init_arg . '\'}) {',
656 $self->_inline_init_attr_from_constructor($attr, $idx),
657 '}',
658 );
65936173.3ms if (my @default = $self->_inline_init_attr_from_default($attr, $idx)) {
# spent 38.2ms making 256 calls to Class::MOP::Class::_inline_init_attr_from_default, avg 149µs/call # spent 35.1ms making 105 calls to Moose::Meta::Class::_inline_init_attr_from_default, avg 335µs/call
660 push @source, (
661 'else {',
662 @default,
663 '}',
664 );
665 }
666 return @source;
667 }
668 elsif (my @default = $self->_inline_init_attr_from_default($attr, $idx)) {
669 return (
670 '{',
671 @default,
672 '}',
673 );
674 }
675 else {
676 return ();
677 }
678}
679
680
# spent 76.9ms (14.4+62.5) within Class::MOP::Class::_inline_init_attr_from_constructor which was called 256 times, avg 300µs/call: # 256 times (14.4ms+62.5ms) by Class::MOP::Class::_inline_slot_initializer at line 654, avg 300µs/call
sub _inline_init_attr_from_constructor {
681128014.6ms my $self = shift;
682 my ($attr, $idx) = @_;
683
68451259.8ms my @initial_value = $attr->_inline_set_value(
# spent 54.4ms making 254 calls to Class::MOP::Attribute::_inline_set_value, avg 214µs/call # spent 4.30ms making 2 calls to Moose::Meta::Attribute::_inline_set_value, avg 2.15ms/call # spent 1.16ms making 256 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 5µs/call
685 '$instance', '$params->{\'' . $attr->init_arg . '\'}',
686 );
687
6882562.66ms push @initial_value, (
# spent 2.66ms making 256 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 10µs/call
689 '$attrs->[' . $idx . ']->set_initial_value(',
690 '$instance,',
691 $attr->_inline_instance_get('$instance'),
692 ');',
693 ) if $attr->has_initializer;
694
695 return @initial_value;
696}
697
698
# spent 43.1ms (10.1+33.0) within Class::MOP::Class::_inline_init_attr_from_default which was called 267 times, avg 161µs/call: # 256 times (9.45ms+28.7ms) by Class::MOP::Class::_inline_slot_initializer at line 659, avg 149µs/call # 11 times (646µs+4.27ms) by Class::MOP::Class::_inline_slot_initializer at line 653, avg 447µs/call
sub _inline_init_attr_from_default {
69913359.33ms my $self = shift;
700 my ($attr, $idx) = @_;
701
70226716.0ms my $default = $self->_inline_default_value($attr, $idx);
# spent 16.0ms making 267 calls to Class::MOP::Class::_inline_default_value, avg 60µs/call
703 return unless $default;
704
7058916.1ms my @initial_value = $attr->_inline_set_value('$instance', $default);
# spent 16.1ms making 89 calls to Class::MOP::Attribute::_inline_set_value, avg 181µs/call
706
70789885µs push @initial_value, (
# spent 885µs making 89 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 10µs/call
708 '$attrs->[' . $idx . ']->set_initial_value(',
709 '$instance,',
710 $attr->_inline_instance_get('$instance'),
711 ');',
712 ) if $attr->has_initializer;
713
714 return @initial_value;
715}
716
717
# spent 23.6ms (15.1+8.52) within Class::MOP::Class::_inline_default_value which was called 378 times, avg 62µs/call: # 267 times (10.2ms+5.79ms) by Class::MOP::Class::_inline_init_attr_from_default at line 702, avg 60µs/call # 111 times (4.91ms+2.73ms) by Moose::Meta::Class::_inline_init_attr_from_default at line 396 of Moose/Meta/Class.pm, avg 69µs/call
sub _inline_default_value {
718113410.7ms my $self = shift;
719 my ($attr, $index) = @_;
720
7212793.08ms7738.52ms if ($attr->has_default) {
# spent 3.63ms making 378 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 10µs/call # spent 2.51ms making 255 calls to Class::MOP::Mixin::AttributeCore::has_builder, avg 10µs/call # spent 2.28ms making 123 calls to Class::MOP::Mixin::AttributeCore::is_default_a_coderef, avg 19µs/call # spent 99µs making 17 calls to Class::MOP::Mixin::AttributeCore::builder, avg 6µs/call
722 # NOTE:
723 # default values can either be CODE refs
724 # in which case we need to call them. Or
725 # they can be scalars (strings/numbers)
726 # in which case we can just deal with them
727 # in the code we eval.
728 if ($attr->is_default_a_coderef) {
729 return '$defaults->[' . $index . ']->($instance)';
730 }
731 else {
732 return '$defaults->[' . $index . ']';
733 }
734 }
735 elsif ($attr->has_builder) {
736 return '$instance->' . $attr->builder;
737 }
738 else {
739 return;
740 }
741}
742
743
# spent 3.80ms (1.91+1.89) within Class::MOP::Class::_inline_preserve_weak_metaclasses which was called 55 times, avg 69µs/call: # 55 times (1.91ms+1.89ms) by Class::MOP::Class::_inline_new_object at line 591, avg 69µs/call
sub _inline_preserve_weak_metaclasses {
7441101.76ms my $self = shift;
74555603µs1101.89ms if (Class::MOP::metaclass_is_weak($self->name)) {
# spent 1.46ms making 55 calls to Class::MOP::metaclass_is_weak, avg 26µs/call # spent 432µs making 55 calls to Class::MOP::Package::name, avg 8µs/call
746 return (
747 $self->_inline_set_mop_slot(
748 '$instance', 'Class::MOP::class_of($class)'
749 ) . ';'
750 );
751 }
752 else {
753 return ();
754 }
755}
756
75731292µs
# spent 220µs within Class::MOP::Class::_inline_extra_init which was called 31 times, avg 7µs/call: # 31 times (220µs+0s) by Class::MOP::Class::_inline_new_object at line 591, avg 7µs/call
sub _inline_extra_init { }
758
759
760
# spent 160ms (12.7+148) within Class::MOP::Class::get_meta_instance which was called 810 times, avg 198µs/call: # 341 times (4.75ms+30.2ms) by Class::MOP::Attribute::_inline_instance_set at line 285 of Class/MOP/Attribute.pm, avg 103µs/call # 196 times (3.91ms+86.0ms) by Class::MOP::Attribute::_inline_instance_get at line 308 of Class/MOP/Attribute.pm, avg 459µs/call # 83 times (1.17ms+9.49ms) by Class::MOP::Class::_construct_instance at line 558, avg 128µs/call # 62 times (840µs+0s) by Class::MOP::Attribute::_inline_instance_has at line 329 of Class/MOP/Attribute.pm, avg 14µs/call # 55 times (880µs+8.48ms) by Class::MOP::Class::_inline_create_instance at line 637, avg 170µs/call # 29 times (422µs+578µs) by Class::MOP::Attribute::_inline_instance_clear at line 350 of Class/MOP/Attribute.pm, avg 34µs/call # 21 times (403µs+12.1ms) by Class::MOP::Class:::around at line 74 of Class/MOP/Class/Immutable/Trait.pm, avg 595µs/call # 9 times (116µs+0s) by Class::MOP::Attribute::set_initial_value at line 259 of Class/MOP/Attribute.pm, avg 13µs/call # 9 times (107µs+0s) by Moose::Meta::Attribute::_inline_weaken_value at line 676 of Moose/Meta/Attribute.pm, avg 12µs/call # 3 times (37µs+0s) by Class::MOP::Attribute::get_raw_value at line 295 of Class/MOP/Attribute.pm, avg 12µs/call # once (25µs+755µs) by Moose::Exporter::BEGIN@11 at line 684 of Class/MOP.pm # once (14µs+0s) by Class::MOP::Attribute::has_value at line 316 of Class/MOP/Attribute.pm
sub get_meta_instance {
761162015.0ms my $self = shift;
762173148ms $self->{'_meta_instance'} ||= $self->_create_meta_instance();
# spent 148ms making 173 calls to Class::MOP::Class::_create_meta_instance, avg 853µs/call
763}
764
765
# spent 148ms (12.3+135) within Class::MOP::Class::_create_meta_instance which was called 173 times, avg 853µs/call: # 173 times (12.3ms+135ms) by Class::MOP::Class::get_meta_instance at line 762, avg 853µs/call
sub _create_meta_instance {
76669212.4ms my $self = shift;
767
768519134ms my $instance = $self->instance_metaclass->new(
# spent 77.1ms making 173 calls to Class::MOP::Instance::new, avg 446µs/call # spent 50.1ms making 161 calls to Class::MOP::Class::get_all_attributes, avg 311µs/call # spent 5.74ms making 12 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 478µs/call # spent 916µs making 173 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call
769 associated_metaclass => $self,
770 attributes => [ $self->get_all_attributes() ],
771 );
772
7731731.47ms $self->add_meta_instance_dependencies()
# spent 1.47ms making 173 calls to Class::MOP::Instance::is_dependent_on_superclasses, avg 9µs/call
774 if $instance->is_dependent_on_superclasses();
775
776 return $instance;
777}
778
779sub _inline_rebless_instance {
780 my $self = shift;
781
782 return $self->get_meta_instance->inline_rebless_instance_structure(@_);
783}
784
785sub _inline_get_mop_slot {
786 my $self = shift;
787
788 return $self->get_meta_instance->_inline_get_mop_slot(@_);
789}
790
791sub _inline_set_mop_slot {
792 my $self = shift;
793
794 return $self->get_meta_instance->_inline_set_mop_slot(@_);
795}
796
797sub _inline_clear_mop_slot {
798 my $self = shift;
799
800 return $self->get_meta_instance->_inline_clear_mop_slot(@_);
801}
802
803sub clone_object {
804 my $class = shift;
805 my $instance = shift;
806 (blessed($instance) && $instance->isa($class->name))
807 || confess "You must pass an instance of the metaclass (" . (ref $class ? $class->name : $class) . "), not ($instance)";
808
809 # NOTE:
810 # we need to protect the integrity of the
811 # Class::MOP::Class singletons here, they
812 # should not be cloned.
813 return $instance if $instance->isa('Class::MOP::Class');
814 $class->_clone_instance($instance, @_);
815}
816
817sub _clone_instance {
818 my ($class, $instance, %params) = @_;
819 (blessed($instance))
820 || confess "You can only clone instances, ($instance) is not a blessed instance";
821 my $meta_instance = $class->get_meta_instance();
822 my $clone = $meta_instance->clone_instance($instance);
823 foreach my $attr ($class->get_all_attributes()) {
824 if ( defined( my $init_arg = $attr->init_arg ) ) {
825 if (exists $params{$init_arg}) {
826 $attr->set_value($clone, $params{$init_arg});
827 }
828 }
829 }
830 return $clone;
831}
832
833sub _force_rebless_instance {
834 my ($self, $instance, %params) = @_;
835 my $old_metaclass = Class::MOP::class_of($instance);
836
837 $old_metaclass->rebless_instance_away($instance, $self, %params)
838 if $old_metaclass;
839
840 my $meta_instance = $self->get_meta_instance;
841
842 if (Class::MOP::metaclass_is_weak($old_metaclass->name)) {
843 $meta_instance->_clear_mop_slot($instance);
844 }
845
846 # rebless!
847 # we use $_[1] here because of t/306_rebless_overload.t regressions on 5.8.8
848 $meta_instance->rebless_instance_structure($_[1], $self);
849
850 $self->_fixup_attributes_after_rebless($instance, $old_metaclass, %params);
851
852 if (Class::MOP::metaclass_is_weak($self->name)) {
853 $meta_instance->_set_mop_slot($instance, $self);
854 }
855}
856
857sub rebless_instance {
858 my ($self, $instance, %params) = @_;
859 my $old_metaclass = Class::MOP::class_of($instance);
860
861 my $old_class = $old_metaclass ? $old_metaclass->name : blessed($instance);
862 $self->name->isa($old_class)
863 || confess "You may rebless only into a subclass of ($old_class), of which (". $self->name .") isn't.";
864
865 $self->_force_rebless_instance($_[1], %params);
866
867 return $instance;
868}
869
870sub rebless_instance_back {
871 my ( $self, $instance ) = @_;
872 my $old_metaclass = Class::MOP::class_of($instance);
873
874 my $old_class
875 = $old_metaclass ? $old_metaclass->name : blessed($instance);
876 $old_class->isa( $self->name )
877 || confess
878 "You may rebless only into a superclass of ($old_class), of which ("
879 . $self->name
880 . ") isn't.";
881
882 $self->_force_rebless_instance($_[1]);
883
884 return $instance;
885}
886
887sub rebless_instance_away {
888 # this intentionally does nothing, it is just a hook
889}
890
891sub _fixup_attributes_after_rebless {
892 my $self = shift;
893 my ($instance, $rebless_from, %params) = @_;
894 my $meta_instance = $self->get_meta_instance;
895
896 for my $attr ( $rebless_from->get_all_attributes ) {
897 next if $self->find_attribute_by_name( $attr->name );
898 $meta_instance->deinitialize_slot( $instance, $_ ) for $attr->slots;
899 }
900
901 foreach my $attr ( $self->get_all_attributes ) {
902 if ( $attr->has_value($instance) ) {
903 if ( defined( my $init_arg = $attr->init_arg ) ) {
904 $params{$init_arg} = $attr->get_value($instance)
905 unless exists $params{$init_arg};
906 }
907 else {
908 $attr->set_value($instance, $attr->get_value($instance));
909 }
910 }
911 }
912
913 foreach my $attr ($self->get_all_attributes) {
914 $attr->initialize_instance_slot($meta_instance, $instance, \%params);
915 }
916}
917
918
# spent 20.9ms (5.67+15.2) within Class::MOP::Class::_attach_attribute which was called 239 times, avg 87µs/call: # 239 times (5.67ms+15.2ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 25 of Class/MOP/Mixin/HasAttributes.pm, avg 87µs/call
sub _attach_attribute {
9194785.80ms my ($self, $attribute) = @_;
92023915.2ms $attribute->attach_to_class($self);
# spent 15.2ms making 239 calls to Class::MOP::Attribute::attach_to_class, avg 64µs/call
921}
922
923
# spent 1.94s (17.7ms+1.93) within Class::MOP::Class::_post_add_attribute which was called 239 times, avg 8.14ms/call: # 239 times (17.7ms+1.93s) by Class::MOP::Mixin::HasAttributes::add_attribute at line 42 of Class/MOP/Mixin/HasAttributes.pm, avg 8.14ms/call
sub _post_add_attribute {
92471714.1ms my ( $self, $attribute ) = @_;
925
92623913.0ms $self->invalidate_meta_instances;
# spent 13.0ms making 239 calls to Class::MOP::Class::invalidate_meta_instances, avg 54µs/call
927
928 # invalidate package flag here
929
# spent 1.89s (10.8ms+1.87) within Class::MOP::Class::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Class.pm:932] which was called 239 times, avg 7.89ms/call: # 239 times (10.8ms+1.87s) by Try::Tiny::try at line 76 of Try/Tiny.pm, avg 7.89ms/call
try {
93047810.8ms local $SIG{__DIE__};
9312391.87s $attribute->install_accessors;
# spent 992ms making 122 calls to Moose::Meta::Attribute::install_accessors, avg 8.13ms/call # spent 483ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::5::install_accessors # spent 236ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::2::install_accessors # spent 163ms making 115 calls to Class::MOP::Attribute::install_accessors, avg 1.42ms/call
932 }
933 catch {
934 $self->remove_attribute( $attribute->name );
935 die $_;
9364781.87s };
# spent 1.91s making 239 calls to Try::Tiny::try, avg 7.98ms/call, recursion: max depth 1, sum of overlapping time 48.7ms # spent 5.33ms making 239 calls to Try::Tiny::catch, avg 22µs/call
937}
938
939sub remove_attribute {
940 my $self = shift;
941
942 my $removed_attribute = $self->SUPER::remove_attribute(@_)
943 or return;
944
945 $self->invalidate_meta_instances;
946
947 $removed_attribute->remove_accessors;
948 $removed_attribute->detach_from_class;
949
950 return$removed_attribute;
951}
952
953
# spent 18.6ms (5.46+13.1) within Class::MOP::Class::find_attribute_by_name which was called 77 times, avg 242µs/call: # 75 times (5.22ms+12.7ms) by Class::MOP::Class::_immutable_metaclass at line 1364, avg 238µs/call # 2 times (244µs+476µs) by Moose::Meta::Class::_process_inherited_attribute at line 627 of Moose/Meta/Class.pm, avg 360µs/call
sub find_attribute_by_name {
9541541.30ms my ( $self, $attr_name ) = @_;
955
956774.83ms foreach my $class ( $self->linearized_isa ) {
# spent 4.57ms making 71 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 64µs/call # spent 265µs making 6 calls to Class::MOP::Class::linearized_isa, avg 44µs/call
957 # fetch the meta-class ...
9581583.67ms793.24ms my $meta = Class::MOP::Class->initialize($class);
# spent 3.24ms making 79 calls to Class::MOP::Class::initialize, avg 41µs/call
9591565.06ms return $meta->get_attribute($attr_name)
# spent 2.77ms making 79 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 35µs/call # spent 2.29ms making 77 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 30µs/call
960 if $meta->has_attribute($attr_name);
961 }
962
963 return;
964}
965
966
# spent 146ms (62.9+83.5) within Class::MOP::Class::get_all_attributes which was called 406 times, avg 361µs/call: # 161 times (21.5ms+28.6ms) by Class::MOP::Class::_create_meta_instance at line 768, avg 311µs/call # 83 times (16.9ms+22.4ms) by Class::MOP::Class::_construct_instance at line 578, avg 474µs/call # 55 times (7.88ms+10.0ms) by Class::MOP::Class::_inline_slot_initializers at line 646, avg 325µs/call # 55 times (7.68ms+10.2ms) by Class::MOP::Method::Constructor::_attributes at line 79 of Class/MOP/Method/Constructor.pm, avg 325µs/call # 24 times (2.86ms+3.69ms) by Moose::Meta::Class::_inline_triggers at line 432 of Moose/Meta/Class.pm, avg 273µs/call # 16 times (2.53ms+4.43ms) by Class::MOP::Class:::around at line 68 of Class/MOP/Class/Immutable/Trait.pm, avg 435µs/call # 6 times (1.92ms+2.12ms) by Moose::Meta::Attribute::new at line 69 of Moose/Meta/Attribute.pm, avg 672µs/call # 6 times (1.60ms+1.98ms) by Moose::Meta::Class::new_object at line 258 of Moose/Meta/Class.pm, avg 597µs/call
sub get_all_attributes {
967121822.2ms my $self = shift;
968266846.2ms307482.3ms my %attrs = map { %{ Class::MOP::Class->initialize($_)->_attribute_map } }
# spent 55.6ms making 1334 calls to Class::MOP::Class::initialize, avg 42µs/call, recursion: max depth 1, sum of overlapping time 1.21ms # spent 18.3ms making 390 calls to Class::MOP::Class::linearized_isa, avg 47µs/call # spent 7.78ms making 1334 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 6µs/call # spent 1.81ms making 16 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 113µs/call
969 reverse $self->linearized_isa;
970 return values %attrs;
971}
972
973# Inheritance
974
975sub superclasses {
97611288.99ms my $self = shift;
977
97828227.3ms my $isa = $self->get_or_add_package_symbol('@ISA');
# spent 27.3ms making 282 calls to Class::MOP::Package::get_or_add_package_symbol, avg 97µs/call
979
9802165.61ms if (@_) {
981 my @supers = @_;
982 @{$isa} = @supers;
983
984 # NOTE:
985 # on 5.8 and below, we need to call
986 # a method to get Perl to detect
987 # a cycle in the class hierarchy
98836236µs my $class = $self->name;
# spent 236µs making 36 calls to Class::MOP::Package::name, avg 7µs/call
98936284µs $class->isa($class);
# spent 284µs making 36 calls to UNIVERSAL::isa, avg 8µs/call
990
991 # NOTE:
992 # we need to check the metaclass
993 # compatibility here so that we can
994 # be sure that the superclass is
995 # not potentially creating an issues
996 # we don't know about
997
99836162ms $self->_check_metaclass_compatibility();
# spent 162ms making 36 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 4.51ms/call
9993612.4ms $self->_superclasses_updated();
# spent 12.4ms making 36 calls to Class::MOP::Class::_superclasses_updated, avg 343µs/call
1000 }
1001
1002 return @{$isa};
1003}
1004
1005
# spent 12.4ms (2.66+9.70) within Class::MOP::Class::_superclasses_updated which was called 36 times, avg 343µs/call: # 36 times (2.66ms+9.70ms) by Class::MOP::Class::superclasses at line 999, avg 343µs/call
sub _superclasses_updated {
10061081.68ms my $self = shift;
100736442µs $self->update_meta_instance_dependencies();
# spent 442µs making 36 calls to Class::MOP::Class::update_meta_instance_dependencies, avg 12µs/call
1008 # keep strong references to all our parents, so they don't disappear if
1009 # they are anon classes and don't have any direct instances
1010411.44ms $self->_superclass_metas(
# spent 1.44ms making 41 calls to Class::MOP::class_of, avg 35µs/call
101141518µs72604µs map { Class::MOP::class_of($_) } $self->superclasses
# spent 604µs making 36 calls to Class::MOP::Class::_superclass_metas, avg 17µs/call # spent 193µs making 2 calls to Class::MOP::Class::superclasses, avg 96µs/call, recursion: max depth 1, sum of overlapping time 193µs # spent 7.01ms making 34 calls to Moose::Meta::Class::superclasses, avg 206µs/call, recursion: max depth 1, sum of overlapping time 7.01ms
1012 );
1013}
1014
1015
# spent 604µs within Class::MOP::Class::_superclass_metas which was called 36 times, avg 17µs/call: # 36 times (604µs+0s) by Class::MOP::Class::_superclasses_updated at line 1011, avg 17µs/call
sub _superclass_metas {
101672696µs my $self = shift;
1017 $self->{_superclass_metas} = [@_];
1018}
1019
1020sub subclasses {
1021 my $self = shift;
1022 my $super_class = $self->name;
1023
1024 return @{ $super_class->mro::get_isarev() };
1025}
1026
1027sub direct_subclasses {
1028 my $self = shift;
1029 my $super_class = $self->name;
1030
1031 return grep {
1032 grep {
1033 $_ eq $super_class
1034 } Class::MOP::Class->initialize($_)->superclasses
1035 } $self->subclasses;
1036}
1037
1038
# spent 38.9ms (25.0+13.9) within Class::MOP::Class::linearized_isa which was called 837 times, avg 46µs/call: # 390 times (11.7ms+6.64ms) by Class::MOP::Class::get_all_attributes at line 968, avg 47µs/call # 213 times (6.23ms+3.39ms) by Class::MOP::Class::find_method_by_name at line 1158, avg 45µs/call # 155 times (4.80ms+2.72ms) by Class::MOP::Class::find_next_method_by_name at line 1205, avg 49µs/call # 48 times (1.30ms+697µs) by Class::MOP::Class::find_all_methods_by_name at line 1189, avg 42µs/call # 17 times (567µs+269µs) by Class::MOP::Class:::around at line 50 of Class/MOP/Class/Immutable/Trait.pm, avg 49µs/call # 8 times (229µs+143µs) by Class::MOP::Class::get_all_methods at line 1169, avg 46µs/call # 6 times (178µs+87µs) by Class::MOP::Class::find_attribute_by_name at line 956, avg 44µs/call
sub linearized_isa {
103983741.4ms167413.9ms return @{ mro::get_linear_isa( (shift)->name ) };
# spent 9.57ms making 837 calls to mro::get_linear_isa, avg 11µs/call # spent 4.37ms making 837 calls to Class::MOP::Package::name, avg 5µs/call
1040}
1041
1042
# spent 18.5ms (4.57+13.9) within Class::MOP::Class::class_precedence_list which was called 51 times, avg 363µs/call: # 21 times (2.22ms+16.3ms) by Moose::Meta::Class::excludes_role at line 239 of Moose/Meta/Class.pm, avg 882µs/call # 18 times (1.31ms+-1.31ms) by Class::MOP::Class::class_precedence_list at line 1068, avg 0s/call # 12 times (1.04ms+-1.04ms) by Class::MOP::Class:::around at line 43 of Class/MOP/Class/Immutable/Trait.pm, avg 0s/call
sub class_precedence_list {
10432043.02ms my $self = shift;
104451279µs my $name = $self->name;
# spent 279µs making 51 calls to Class::MOP::Package::name, avg 5µs/call
1045
104651242µs unless (Class::MOP::IS_RUNNING_ON_5_10()) {
# spent 242µs making 51 calls to Class::MOP::__ANON__, avg 5µs/call
1047 # NOTE:
1048 # We need to check for circular inheritance here
1049 # if we are are not on 5.10, cause 5.8 detects it
1050 # late. This will do nothing if all is well, and
1051 # blow up otherwise. Yes, it's an ugly hack, better
1052 # suggestions are welcome.
1053 # - SL
1054 ($name || return)->isa('This is a test for circular inheritance')
1055 }
1056
1057 # if our mro is c3, we can
1058 # just grab the linear_isa
1059511.25ms51558µs if (mro::get_mro($name) eq 'c3') {
# spent 558µs making 51 calls to mro::get_mro, avg 11µs/call
1060 return @{ mro::get_linear_isa($name) }
1061 }
1062 else {
1063 # NOTE:
1064 # we can't grab the linear_isa for dfs
1065 # since it has all the duplicates
1066 # already removed.
1067 return (
1068988.11ms $name,
# spent 10.7ms making 30 calls to Class::MOP::Class::Immutable::Class::MOP::Class::class_precedence_list, avg 357µs/call, recursion: max depth 3, sum of overlapping time 5.51ms # spent 2.11ms making 49 calls to Class::MOP::Class::initialize, avg 43µs/call # spent 818µs making 1 call to Class::MOP::Class::Immutable::Moose::Meta::Class::class_precedence_list # spent 5.22ms making 18 calls to Class::MOP::Class::class_precedence_list, avg 290µs/call, recursion: max depth 2, sum of overlapping time 5.22ms
1069 map {
1070491.05ms518.76ms Class::MOP::Class->initialize($_)->class_precedence_list()
# spent 6.34ms making 34 calls to Moose::Meta::Class::superclasses, avg 186µs/call # spent 1.65ms making 11 calls to Class::MOP::Class::Immutable::Class::MOP::Class::superclasses, avg 150µs/call # spent 448µs making 5 calls to Class::MOP::Class::superclasses, avg 90µs/call # spent 322µs making 1 call to Class::MOP::Class::Immutable::Moose::Meta::Class::superclasses
1071 } $self->superclasses()
1072 );
1073 }
1074}
1075
1076## Methods
1077
1078{
107914µs
# spent 112ms (7.56+104) within Class::MOP::Class::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Class.pm:1108] which was called 68 times, avg 1.64ms/call: # 61 times (6.73ms+93.7ms) by Class::MOP::Class::add_around_method_modifier at line 1134, avg 1.65ms/call # 5 times (637µs+9.22ms) by Class::MOP::Class::add_before_method_modifier at line 1114, avg 1.97ms/call # 2 times (195µs+1.05ms) by Class::MOP::Class::add_after_method_modifier at line 1124, avg 621µs/call
my $fetch_and_prepare_method = sub {
10804084.73ms my ($self, $method_name) = @_;
108168424µs my $wrapped_metaclass = $self->wrapped_method_metaclass;
# spent 424µs making 68 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 6µs/call
1082 # fetch it locally
10836810.2ms my $method = $self->get_method($method_name);
# spent 10.2ms making 68 calls to Class::MOP::Mixin::HasMethods::get_method, avg 151µs/call
1084 # if we dont have local ...
10851903.18ms unless ($method) {
1086 # try to find the next method
10876143.3ms $method = $self->find_next_method_by_name($method_name);
# spent 43.3ms making 61 calls to Class::MOP::Class::find_next_method_by_name, avg 710µs/call
1088 # die if it does not exist
1089 (defined $method)
1090 || confess "The method '$method_name' was not found in the inheritance hierarchy for " . $self->name;
1091 # and now make sure to wrap it
1092 # even if it is already wrapped
1093 # because we need a new sub ref
109412220.6ms $method = $wrapped_metaclass->wrap($method,
# spent 20.2ms making 61 calls to Class::MOP::Method::Wrapped::wrap, avg 332µs/call # spent 360µs making 61 calls to Class::MOP::Package::name, avg 6µs/call
1095 package_name => $self->name,
1096 name => $method_name,
1097 );
1098 }
1099 else {
1100 # now make sure we wrap it properly
1101171.56ms $method = $wrapped_metaclass->wrap($method,
# spent 1.46ms making 5 calls to Class::MOP::Method::Wrapped::wrap, avg 291µs/call # spent 79µs making 7 calls to UNIVERSAL::isa, avg 11µs/call # spent 24µs making 5 calls to Class::MOP::Package::name, avg 5µs/call
1102 package_name => $self->name,
1103 name => $method_name,
1104 ) unless $method->isa($wrapped_metaclass);
1105 }
11066827.9ms $self->add_method($method_name => $method);
# spent 27.9ms making 68 calls to Class::MOP::Mixin::HasMethods::add_method, avg 410µs/call
1107 return $method;
1108114µs };
1109
1110
# spent 10.7ms (303µs+10.4) within Class::MOP::Class::add_before_method_modifier which was called 5 times, avg 2.13ms/call: # 4 times (249µs+8.97ms) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 221 of Moose/Meta/Role/Application/ToClass.pm, avg 2.30ms/call # once (54µs+1.40ms) by Moose::Util::add_method_modifier at line 244 of Moose/Util.pm
sub add_before_method_modifier {
111120353µs my ($self, $method_name, $method_modifier) = @_;
1112 (defined $method_name && length $method_name)
1113 || confess "You must pass in a method name";
111459.86ms my $method = $fetch_and_prepare_method->($self, $method_name);
# spent 9.86ms making 5 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:1108], avg 1.97ms/call
111510502µs $method->add_before_modifier(
# spent 438µs making 5 calls to Class::MOP::Method::Wrapped::add_before_modifier, avg 88µs/call # spent 64µs making 5 calls to Sub::Name::subname, avg 13µs/call
1116 subname(':before' => $method_modifier)
1117 );
1118 }
1119
1120
# spent 1.63ms (217µs+1.42) within Class::MOP::Class::add_after_method_modifier which was called 2 times, avg 816µs/call: # 2 times (217µs+1.42ms) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 221 of Moose/Meta/Role/Application/ToClass.pm, avg 816µs/call
sub add_after_method_modifier {
11218238µs my ($self, $method_name, $method_modifier) = @_;
1122 (defined $method_name && length $method_name)
1123 || confess "You must pass in a method name";
112421.24ms my $method = $fetch_and_prepare_method->($self, $method_name);
# spent 1.24ms making 2 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:1108], avg 621µs/call
11254174µs $method->add_after_modifier(
# spent 146µs making 2 calls to Class::MOP::Method::Wrapped::add_after_modifier, avg 73µs/call # spent 29µs making 2 calls to Sub::Name::subname, avg 14µs/call
1126 subname(':after' => $method_modifier)
1127 );
1128 }
1129
1130
# spent 112ms (3.04+109) within Class::MOP::Class::add_around_method_modifier which was called 61 times, avg 1.84ms/call: # 46 times (2.25ms+81.6ms) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 1.82ms/call # 15 times (792µs+27.9ms) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 221 of Moose/Meta/Role/Application/ToClass.pm, avg 1.91ms/call
sub add_around_method_modifier {
11312443.84ms my ($self, $method_name, $method_modifier) = @_;
1132 (defined $method_name && length $method_name)
1133 || confess "You must pass in a method name";
113461100ms my $method = $fetch_and_prepare_method->($self, $method_name);
# spent 100ms making 61 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:1108], avg 1.65ms/call
11351229.00ms $method->add_around_modifier(
# spent 8.24ms making 61 calls to Class::MOP::Method::Wrapped::add_around_modifier, avg 135µs/call # spent 753µs making 61 calls to Sub::Name::subname, avg 12µs/call
1136 subname(':around' => $method_modifier)
1137 );
1138 }
1139
1140 # NOTE:
1141 # the methods above used to be named like this:
1142 # ${pkg}::${method}:(before|after|around)
1143 # but this proved problematic when using one modifier
1144 # to wrap multiple methods (something which is likely
1145 # to happen pretty regularly IMO). So instead of naming
1146 # it like this, I have chosen to just name them purely
1147 # with their modifier names, like so:
1148 # :(before|after|around)
1149 # The fact is that in a stack trace, it will be fairly
1150 # evident from the context what method they are attached
1151 # to, and so don't need the fully qualified name.
1152}
1153
1154
# spent 136ms (19.5+117) within Class::MOP::Class::find_method_by_name which was called 213 times, avg 639µs/call: # 57 times (3.93ms+15.1ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 23 of Class/MOP/Mixin/HasMethods.pm, avg 334µs/call # 56 times (8.10ms+56.4ms) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 1.15ms/call # 45 times (2.56ms+23.7ms) by Moose::Meta::Role::Application::ToClass::check_required_methods at line 64 of Moose/Meta/Role/Application/ToClass.pm, avg 584µs/call # 24 times (2.24ms+10.0ms) by Moose::Meta::Class::_inline_BUILDARGS at line 303 of Moose/Meta/Class.pm, avg 510µs/call # 24 times (2.20ms+9.86ms) by Moose::Meta::Method::Destructor::is_needed at line 62 of Moose/Meta/Method/Destructor.pm, avg 503µs/call # 7 times (448µs+1.62ms) by Moose::BEGIN@38 at line 14 of Moose/Meta/Attribute/Native.pm, avg 295µs/call
sub find_method_by_name {
11557115.16ms my ($self, $method_name) = @_;
1156 (defined $method_name && length $method_name)
1157 || confess "You must define a method name to find";
11582139.62ms foreach my $class ($self->linearized_isa) {
# spent 9.62ms making 213 calls to Class::MOP::Class::linearized_isa, avg 45µs/call
115987213.0ms872107ms my $method = Class::MOP::Class->initialize($class)->get_method($method_name);
# spent 88.5ms making 436 calls to Class::MOP::Mixin::HasMethods::get_method, avg 203µs/call # spent 18.6ms making 436 calls to Class::MOP::Class::initialize, avg 43µs/call
1160 return $method if defined $method;
1161 }
1162 return;
1163}
1164
1165
# spent 16.3ms (1.42+14.9) within Class::MOP::Class::get_all_methods which was called 8 times, avg 2.04ms/call: # 8 times (1.42ms+14.9ms) by Class::MOP::MiniTrait::apply at line 18 of Class/MOP/MiniTrait.pm, avg 2.04ms/call
sub get_all_methods {
116632308µs my $self = shift;
1167
1168 my %methods;
11698372µs for my $class ( reverse $self->linearized_isa ) {
# spent 372µs making 8 calls to Class::MOP::Class::linearized_isa, avg 46µs/call
1170271.33ms9350µs my $meta = Class::MOP::Class->initialize($class);
# spent 350µs making 9 calls to Class::MOP::Class::initialize, avg 39µs/call
1171
11726514.2ms $methods{ $_->name } = $_ for $meta->_get_local_methods;
# spent 13.9ms making 9 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 1.55ms/call # spent 266µs making 56 calls to Class::MOP::Method::name, avg 5µs/call
1173 }
1174
1175 return values %methods;
1176}
1177
1178sub get_all_method_names {
1179 my $self = shift;
1180 my %uniq;
1181 return grep { !$uniq{$_}++ } map { Class::MOP::Class->initialize($_)->get_method_list } $self->linearized_isa;
1182}
1183
1184
# spent 27.4ms (5.02+22.4) within Class::MOP::Class::find_all_methods_by_name which was called 48 times, avg 571µs/call: # 24 times (2.54ms+11.6ms) by Moose::Meta::Class::_inline_BUILDALL at line 456 of Moose/Meta/Class.pm, avg 590µs/call # 24 times (2.48ms+10.8ms) by Moose::Meta::Method::Destructor::_generate_DEMOLISHALL at line 118 of Moose/Meta/Method/Destructor.pm, avg 552µs/call
sub find_all_methods_by_name {
11852401.72ms my ($self, $method_name) = @_;
1186 (defined $method_name && length $method_name)
1187 || confess "You must define a method name to find";
1188 my @methods;
1189482.00ms foreach my $class ($self->linearized_isa) {
# spent 2.00ms making 48 calls to Class::MOP::Class::linearized_isa, avg 42µs/call
1190 # fetch the meta-class ...
11911962.79ms984.03ms my $meta = Class::MOP::Class->initialize($class);
# spent 4.03ms making 98 calls to Class::MOP::Class::initialize, avg 41µs/call
119210216.4ms push @methods => {
# spent 14.6ms making 98 calls to Class::MOP::Mixin::HasMethods::has_method, avg 149µs/call # spent 1.74ms making 4 calls to Class::MOP::Mixin::HasMethods::get_method, avg 435µs/call
1193 name => $method_name,
1194 class => $class,
1195 code => $meta->get_method($method_name)
1196 } if $meta->has_method($method_name);
1197 }
1198 return @methods;
1199}
1200
1201
# spent 76.9ms (15.3+61.6) within Class::MOP::Class::find_next_method_by_name which was called 157 times, avg 490µs/call: # 79 times (6.09ms+20.9ms) by Class::MOP::Method::Inlined::can_be_inlined at line 38 of Class/MOP/Method/Inlined.pm, avg 342µs/call # 61 times (7.77ms+35.5ms) by Class::MOP::Class::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Class.pm:1108] at line 1087, avg 710µs/call # 15 times (1.28ms+4.78ms) by Moose::Meta::Method::Overridden::new at line 23 of Moose/Meta/Method/Overridden.pm, avg 404µs/call # 2 times (128µs+399µs) by Class::MOP::Method::Inlined::_uninlined_body at line 18 of Class/MOP/Method/Inlined.pm, avg 264µs/call
sub find_next_method_by_name {
12027885.42ms my ($self, $method_name) = @_;
1203 (defined $method_name && length $method_name)
1204 || confess "You must define a method name to find";
12051577.69ms my @cpl = $self->linearized_isa;
# spent 7.52ms making 155 calls to Class::MOP::Class::linearized_isa, avg 49µs/call # spent 169µs making 2 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::linearized_isa, avg 85µs/call
1206 shift @cpl; # discard ourselves
1207 foreach my $class (@cpl) {
12084988.42ms49853.9ms my $method = Class::MOP::Class->initialize($class)->get_method($method_name);
# spent 43.1ms making 249 calls to Class::MOP::Mixin::HasMethods::get_method, avg 173µs/call # spent 10.8ms making 249 calls to Class::MOP::Class::initialize, avg 43µs/call
1209 return $method if defined $method;
1210 }
1211 return;
1212}
1213
1214
# spent 442µs within Class::MOP::Class::update_meta_instance_dependencies which was called 36 times, avg 12µs/call: # 36 times (442µs+0s) by Class::MOP::Class::_superclasses_updated at line 1007, avg 12µs/call
sub update_meta_instance_dependencies {
121572624µs my $self = shift;
1216
1217 if ( $self->{meta_instance_dependencies} ) {
1218 return $self->add_meta_instance_dependencies;
1219 }
1220}
1221
1222sub add_meta_instance_dependencies {
1223 my $self = shift;
1224
1225 $self->remove_meta_instance_dependencies;
1226
1227 my @attrs = $self->get_all_attributes();
1228
1229 my %seen;
1230 my @classes = grep { not $seen{ $_->name }++ }
1231 map { $_->associated_class } @attrs;
1232
1233 foreach my $class (@classes) {
1234 $class->add_dependent_meta_instance($self);
1235 }
1236
1237 $self->{meta_instance_dependencies} = \@classes;
1238}
1239
1240sub remove_meta_instance_dependencies {
1241 my $self = shift;
1242
1243 if ( my $classes = delete $self->{meta_instance_dependencies} ) {
1244 foreach my $class (@$classes) {
1245 $class->remove_dependent_meta_instance($self);
1246 }
1247
1248 return $classes;
1249 }
1250
1251 return;
1252
1253}
1254
1255sub add_dependent_meta_instance {
1256 my ( $self, $metaclass ) = @_;
1257 push @{ $self->{dependent_meta_instances} }, $metaclass;
1258}
1259
1260sub remove_dependent_meta_instance {
1261 my ( $self, $metaclass ) = @_;
1262 my $name = $metaclass->name;
1263 @$_ = grep { $_->name ne $name } @$_
1264 for $self->{dependent_meta_instances};
1265}
1266
1267
# spent 13.0ms (10.0+2.96) within Class::MOP::Class::invalidate_meta_instances which was called 239 times, avg 54µs/call: # 239 times (10.0ms+2.96ms) by Class::MOP::Class::_post_add_attribute at line 926, avg 54µs/call
sub invalidate_meta_instances {
12687179.57ms my $self = shift;
1269 $_->invalidate_meta_instance()
12702392.96ms for $self, @{ $self->{dependent_meta_instances} };
# spent 2.96ms making 239 calls to Class::MOP::Class::invalidate_meta_instance, avg 12µs/call
1271}
1272
1273
# spent 2.96ms within Class::MOP::Class::invalidate_meta_instance which was called 239 times, avg 12µs/call: # 239 times (2.96ms+0s) by Class::MOP::Class::invalidate_meta_instances at line 1270, avg 12µs/call
sub invalidate_meta_instance {
12744784.01ms my $self = shift;
1275 undef $self->{_meta_instance};
1276}
1277
1278# check if we can reinitialize
1279sub is_pristine {
1280 my $self = shift;
1281
1282 # if any local attr is defined
1283 return if $self->get_attribute_list;
1284
1285 # or any non-declared methods
1286 for my $method ( map { $self->get_method($_) } $self->get_method_list ) {
1287 return if $method->isa("Class::MOP::Method::Generated");
1288 # FIXME do we need to enforce this too? return unless $method->isa( $self->method_metaclass );
1289 }
1290
1291 return 1;
1292}
1293
1294## Class closing
1295
12961061.22ms
# spent 750µs within Class::MOP::Class::is_mutable which was called 106 times, avg 7µs/call: # 75 times (548µs+0s) by Class::MOP::Class::make_immutable at line 1320, avg 7µs/call # 22 times (141µs+0s) by KiokuDB::BEGIN@4 at line 231 of Moose.pm, avg 6µs/call # 9 times (61µs+0s) by Moose::Meta::Attribute::BEGIN@20 at line 688 of Moose/Util/TypeConstraints.pm, avg 7µs/call
sub is_mutable { 1 }
1297911.05ms
# spent 708µs within Class::MOP::Class::is_immutable which was called 91 times, avg 8µs/call: # 91 times (708µs+0s) by Class::MOP::Class::_real_ref_name at line 126, avg 8µs/call
sub is_immutable { 0 }
1298
1299sub immutable_options { %{ $_[0]{__immutable}{options} || {} } }
1300
1301
# spent 7.56ms (5.36+2.20) within Class::MOP::Class::_immutable_options which was called 75 times, avg 101µs/call: # 51 times (3.33ms+987µs) by Class::MOP::Class::make_immutable at line 1321, avg 85µs/call # 24 times (2.02ms+1.21ms) by Moose::Meta::Class::_immutable_options at line 645 of Moose/Meta/Class.pm, avg 135µs/call
sub _immutable_options {
13021506.35ms my ( $self, @args ) = @_;
1303
1304 return (
13053002.20ms inline_accessors => 1,
# spent 417µs making 75 calls to Class::MOP::Class::constructor_name, avg 6µs/call # spent 368µs making 24 calls to Moose::Meta::Class::immutable_trait, avg 15µs/call # spent 345µs making 24 calls to Moose::Meta::Class::constructor_class, avg 14µs/call # spent 336µs making 24 calls to Moose::Meta::Class::destructor_class, avg 14µs/call # spent 288µs making 51 calls to Class::MOP::Class::immutable_trait, avg 6µs/call # spent 224µs making 51 calls to Class::MOP::Class::constructor_class, avg 4µs/call # spent 224µs making 51 calls to Class::MOP::Class::destructor_class, avg 4µs/call
1306 inline_constructor => 1,
1307 inline_destructor => 0,
1308 debug => 0,
1309 immutable_trait => $self->immutable_trait,
1310 constructor_name => $self->constructor_name,
1311 constructor_class => $self->constructor_class,
1312 destructor_class => $self->destructor_class,
1313 @args,
1314 );
1315}
1316
1317
# spent 1.27s (6.24ms+1.27) within Class::MOP::Class::make_immutable which was called 75 times, avg 17.0ms/call: # 22 times (1.98ms+403ms) by KiokuDB::BEGIN@4 at line 236 of Moose.pm, avg 18.4ms/call # 13 times (953µs+85.3ms) by Moose::Exporter::BEGIN@11 at line 699 of Class/MOP.pm, avg 6.63ms/call # 9 times (754µs+171ms) by Moose::Meta::Attribute::BEGIN@20 at line 693 of Moose/Util/TypeConstraints.pm, avg 19.1ms/call # 4 times (267µs+2.33ms) by Moose::Exporter::BEGIN@11 at line 724 of Class/MOP.pm, avg 650µs/call # 2 times (163µs+-163µs) by Class::MOP::Class::_immutable_metaclass at line 1394, avg 0s/call # once (121µs+119ms) by KiokuDB::Collapser::BEGIN@12 at line 304 of KiokuDB/Entry.pm # once (79µs+46.7ms) by KiokuDB::BEGIN@4 at line 268 of Moose.pm # once (85µs+44.2ms) by main::BEGIN@0 at line 655 of KiokuDB.pm # once (86µs+31.8ms) by KiokuDB::Collapser::BEGIN@15 at line 231 of KiokuDB/Collapser/Buffer.pm # once (85µs+27.8ms) by KiokuDB::BEGIN@13 at line 531 of KiokuDB/LiveObjects.pm # once (84µs+25.8ms) by KiokuDB::BEGIN@11 at line 396 of KiokuDB/Collapser.pm # once (86µs+22.7ms) by KiokuDB::BEGIN@14 at line 171 of KiokuDB/TypeMap.pm # once (84µs+21.8ms) by KiokuDB::BEGIN@12 at line 381 of KiokuDB/Linker.pm # once (86µs+20.6ms) by KiokuDB::TypeMap::Resolver::BEGIN@9 at line 484 of KiokuDB/TypeMap/Entry/MOP.pm # once (81µs+20.6ms) by KiokuDB::BEGIN@17 at line 79 of KiokuDB/Stream/Objects.pm # once (85µs+20.5ms) by KiokuDB::TypeMap::Entry::Std::BEGIN@6 at line 26 of KiokuDB/TypeMap/Entry/Compiled.pm # once (82µs+17.2ms) by KiokuDB::LiveObjects::BEGIN@14 at line 55 of KiokuDB/LiveObjects/TXNScope.pm # once (83µs+16.9ms) by KiokuDB::TypeMap::Entry::MOP::BEGIN@9 at line 51 of KiokuDB/Thunk.pm # once (85µs+16.6ms) by KiokuDB::LiveObjects::BEGIN@13 at line 60 of KiokuDB/LiveObjects/Scope.pm # once (85µs+16.4ms) by KiokuDB::BEGIN@16 at line 117 of KiokuDB/TypeMap/Resolver.pm # once (83µs+16.1ms) by KiokuDB::Collapser::BEGIN@14 at line 39 of KiokuDB/Reference.pm # once (82µs+14.8ms) by KiokuDB::Collapser::BEGIN@13 at line 27 of KiokuDB/Entry/Skip.pm # once (84µs+14.6ms) by KiokuDB::Collapser::BEGIN@16 at line 25 of KiokuDB/Error/UnknownObjects.pm # once (81µs+14.4ms) by KiokuDB::Linker::BEGIN@18 at line 37 of KiokuDB/Error/MissingObjects.pm # once (100µs+14.2ms) by KiokuDB::Collapser::BEGIN@18 at line 443 of Data/Visitor.pm # once (80µs+13.9ms) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 38 of Data/Stream/Bulk/Filter.pm # once (80µs+13.3ms) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 35 of Data/Stream/Bulk/Nil.pm # once (83µs+12.3ms) by KiokuDB::BEGIN@15 at line 28 of KiokuDB/TypeMap/Shadow.pm # once (84µs+12.2ms) by KiokuDB::TypeMap::BEGIN@10 at line 14 of KiokuDB/TypeMap/Entry/Alias.pm # once (80µs+12.1ms) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 51 of Data/Stream/Bulk/Cat.pm
sub make_immutable {
13181501.33ms my ( $self, @args ) = @_;
1319
13202254.57ms75548µs if ( $self->is_mutable ) {
# spent 548µs making 75 calls to Class::MOP::Class::is_mutable, avg 7µs/call
13211501.07s $self->_initialize_immutable( $self->_immutable_options(@args) );
# spent 1.06s making 75 calls to Class::MOP::Class::_initialize_immutable, avg 14.1ms/call # spent 4.32ms making 51 calls to Class::MOP::Class::_immutable_options, avg 85µs/call # spent 4.24ms making 24 calls to Moose::Meta::Class::_immutable_options, avg 177µs/call
132275198ms $self->_rebless_as_immutable(@args);
# spent 199ms making 75 calls to Class::MOP::Class::_rebless_as_immutable, avg 2.66ms/call, recursion: max depth 1, sum of overlapping time 1.06ms
1323 return $self;
1324 }
1325 else {
1326 return;
1327 }
1328}
1329
1330sub make_mutable {
1331 my $self = shift;
1332
1333 if ( $self->is_immutable ) {
1334 my @args = $self->immutable_options;
1335 $self->_rebless_as_mutable();
1336 $self->_remove_inlined_code(@args);
1337 delete $self->{__immutable};
1338 return $self;
1339 }
1340 else {
1341 return;
1342 }
1343}
1344
1345
# spent 198ms (3.36+195) within Class::MOP::Class::_rebless_as_immutable which was called 75 times, avg 2.64ms/call: # 75 times (3.36ms+195ms) by Class::MOP::Class::make_immutable at line 1322, avg 2.64ms/call
sub _rebless_as_immutable {
13462253.23ms my ( $self, @args ) = @_;
1347
1348 $self->{__immutable}{original_class} = ref $self;
1349
135075195ms bless $self => $self->_immutable_metaclass(@args);
# spent 196ms making 75 calls to Class::MOP::Class::_immutable_metaclass, avg 2.61ms/call, recursion: max depth 1, sum of overlapping time 939µs
1351}
1352
1353
# spent 195ms (8.01+187) within Class::MOP::Class::_immutable_metaclass which was called 75 times, avg 2.60ms/call: # 75 times (8.01ms+187ms) by Class::MOP::Class::_rebless_as_immutable at line 1350, avg 2.60ms/call
sub _immutable_metaclass {
13546109.14ms my ( $self, %args ) = @_;
1355
1356 if ( my $class = $args{immutable_metaclass} ) {
1357 return $class;
1358 }
1359
136075659µs my $trait = $args{immutable_trait} = $self->immutable_trait
# spent 373µs making 24 calls to Moose::Meta::Class::immutable_trait, avg 16µs/call # spent 287µs making 51 calls to Class::MOP::Class::immutable_trait, avg 6µs/call
1361 || confess "no immutable trait specified for $self";
1362
1363756.29ms my $meta = $self->meta;
# spent 6.29ms making 75 calls to Class::MOP::Object::meta, avg 84µs/call
13647517.9ms my $meta_attr = $meta->find_attribute_by_name("immutable_trait");
# spent 17.9ms making 75 calls to Class::MOP::Class::find_attribute_by_name, avg 238µs/call
1365
1366 my $class_name;
1367
1368751.29ms if ( $meta_attr and $trait eq $meta_attr->default ) {
# spent 1.29ms making 75 calls to Class::MOP::Mixin::AttributeCore::default, avg 17µs/call
1369 # if the trait is the same as the default we try and pick a
1370 # predictable name for the immutable metaclass
1371 $class_name = 'Class::MOP::Class::Immutable::' . ref($self);
1372 }
1373 else {
1374 $class_name = join '::', 'Class::MOP::Class::Immutable::CustomTrait',
1375 $trait, 'ForMetaClass', ref($self);
1376 }
1377
1378751.29ms return $class_name
# spent 1.29ms making 75 calls to Class::MOP::is_class_loaded, avg 17µs/call
1379 if Class::MOP::is_class_loaded($class_name);
1380
1381 # If the metaclass is a subclass of CMOP::Class which has had
1382 # metaclass roles applied (via Moose), then we want to make sure
1383 # that we preserve that anonymous class (see Fey::ORM for an
1384 # example of where this matters).
13852124µs my $meta_name = $meta->_real_ref_name;
# spent 124µs making 2 calls to Class::MOP::Class::_real_ref_name, avg 62µs/call
1386
1387210.7ms my $immutable_meta = $meta_name->create(
# spent 10.7ms making 2 calls to Class::MOP::Class::create, avg 5.33ms/call
1388 $class_name,
1389 superclasses => [ ref $self ],
1390 );
1391
13922148ms Class::MOP::MiniTrait::apply( $immutable_meta, $trait );
# spent 148ms making 2 calls to Class::MOP::MiniTrait::apply, avg 74.0ms/call
1393
139420s $immutable_meta->make_immutable(
# spent 1.56ms making 2 calls to Class::MOP::Class::make_immutable, avg 779µs/call, recursion: max depth 1, sum of overlapping time 1.56ms
1395 inline_constructor => 0,
1396 inline_accessors => 0,
1397 );
1398
1399 return $class_name;
1400}
1401
1402sub _remove_inlined_code {
1403 my $self = shift;
1404
1405 $self->remove_method( $_->name ) for $self->_inlined_methods;
1406
1407 delete $self->{__immutable}{inlined_methods};
1408}
1409
1410sub _inlined_methods { @{ $_[0]{__immutable}{inlined_methods} || [] } }
1411
1412
# spent 1.67ms within Class::MOP::Class::_add_inlined_method which was called 79 times, avg 21µs/call: # 55 times (1.24ms+0s) by Class::MOP::Class::_inline_constructor at line 1481, avg 23µs/call # 24 times (429µs+0s) by Class::MOP::Class::_inline_destructor at line 1514, avg 18µs/call
sub _add_inlined_method {
14131581.80ms my ( $self, $method ) = @_;
1414
1415 push @{ $self->{__immutable}{inlined_methods} ||= [] }, $method;
1416}
1417
1418
# spent 1.06s (4.07ms+1.06) within Class::MOP::Class::_initialize_immutable which was called 75 times, avg 14.1ms/call: # 75 times (4.07ms+1.06s) by Class::MOP::Class::make_immutable at line 1321, avg 14.1ms/call
sub _initialize_immutable {
14192254.08ms my ( $self, %args ) = @_;
1420
1421 $self->{__immutable}{options} = \%args;
1422751.06s $self->_install_inlined_code(%args);
# spent 1.06s making 75 calls to Class::MOP::Class::_install_inlined_code, avg 14.1ms/call
1423}
1424
1425
# spent 1.06s (4.63ms+1.05) within Class::MOP::Class::_install_inlined_code which was called 75 times, avg 14.1ms/call: # 75 times (4.63ms+1.05s) by Class::MOP::Class::_initialize_immutable at line 1422, avg 14.1ms/call
sub _install_inlined_code {
14263004.59ms my ( $self, %args ) = @_;
1427
1428 # FIXME
142932244ms $self->_inline_accessors(%args) if $args{inline_accessors};
# spent 244ms making 32 calls to Class::MOP::Class::_inline_accessors, avg 7.63ms/call
143055710ms $self->_inline_constructor(%args) if $args{inline_constructor};
# spent 710ms making 55 calls to Class::MOP::Class::_inline_constructor, avg 12.9ms/call
14312498.2ms $self->_inline_destructor(%args) if $args{inline_destructor};
# spent 98.2ms making 24 calls to Class::MOP::Class::_inline_destructor, avg 4.09ms/call
1432}
1433
1434sub _rebless_as_mutable {
1435 my $self = shift;
1436
1437 bless $self, $self->_get_mutable_metaclass_name;
1438
1439 return $self;
1440}
1441
1442
# spent 244ms (3.12+241) within Class::MOP::Class::_inline_accessors which was called 32 times, avg 7.63ms/call: # 32 times (3.12ms+241ms) by Class::MOP::Class::_install_inlined_code at line 1429, avg 7.63ms/call
sub _inline_accessors {
144364938µs my $self = shift;
1444
1445321.02ms foreach my $attr_name ( $self->get_attribute_list ) {
# spent 1.02ms making 32 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 32µs/call
1446691.81ms138240ms $self->get_attribute($attr_name)->install_accessors(1);
# spent 231ms making 68 calls to Class::MOP::Attribute::install_accessors, avg 3.40ms/call # spent 6.36ms making 1 call to Moose::Meta::Attribute::install_accessors # spent 2.42ms making 69 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 35µs/call
1447 }
1448}
1449
1450
# spent 710ms (7.93+702) within Class::MOP::Class::_inline_constructor which was called 55 times, avg 12.9ms/call: # 55 times (7.93ms+702ms) by Class::MOP::Class::_install_inlined_code at line 1430, avg 12.9ms/call
sub _inline_constructor {
14514406.15ms my ( $self, %args ) = @_;
1452
1453 my $name = $args{constructor_name};
1454 # A class may not even have a constructor, and that's okay.
1455 return unless defined $name;
1456
14575510.4ms if ( $self->has_method($name) && !$args{replace_constructor} ) {
# spent 10.4ms making 55 calls to Class::MOP::Mixin::HasMethods::has_method, avg 188µs/call
1458 my $class = $self->name;
1459 warn "Not inlining a constructor for $class since it defines"
1460 . " its own constructor.\n"
1461 . "If you are certain you don't need to inline your"
1462 . " constructor, specify inline_constructor => 0 in your"
1463 . " call to $class->meta->make_immutable\n";
1464 return;
1465 }
1466
1467 my $constructor_class = $args{constructor_class};
1468
14695512.4ms Class::MOP::load_class($constructor_class);
# spent 13.4ms making 55 calls to Class::MOP::load_class, avg 243µs/call, recursion: max depth 1, sum of overlapping time 961µs
1470
1471110621ms my $constructor = $constructor_class->new(
# spent 317ms making 24 calls to Moose::Meta::Method::Constructor::new, avg 13.2ms/call # spent 304ms making 31 calls to Class::MOP::Method::Constructor::new, avg 9.81ms/call # spent 338µs making 55 calls to Class::MOP::Package::name, avg 6µs/call
1472 options => \%args,
1473 metaclass => $self,
1474 is_inline => 1,
1475 package_name => $self->name,
1476 name => $name,
1477 );
1478
14791101.51ms5532.4ms if ( $args{replace_constructor} or $constructor->can_be_inlined ) {
# spent 32.4ms making 55 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 589µs/call
14805523.6ms $self->add_method( $name => $constructor );
# spent 23.6ms making 55 calls to Class::MOP::Mixin::HasMethods::add_method, avg 430µs/call
1481551.24ms $self->_add_inlined_method($constructor);
# spent 1.24ms making 55 calls to Class::MOP::Class::_add_inlined_method, avg 23µs/call
1482 }
1483}
1484
1485
# spent 98.2ms (3.88+94.3) within Class::MOP::Class::_inline_destructor which was called 24 times, avg 4.09ms/call: # 24 times (3.88ms+94.3ms) by Class::MOP::Class::_install_inlined_code at line 1431, avg 4.09ms/call
sub _inline_destructor {
14861923.02ms my ( $self, %args ) = @_;
1487
1488 ( exists $args{destructor_class} && defined $args{destructor_class} )
1489 || confess "The 'inline_destructor' option is present, but "
1490 . "no destructor class was specified";
1491
1492243.63ms if ( $self->has_method('DESTROY') && ! $args{replace_destructor} ) {
# spent 3.63ms making 24 calls to Class::MOP::Mixin::HasMethods::has_method, avg 151µs/call
1493 my $class = $self->name;
1494 warn "Not inlining a destructor for $class since it defines"
1495 . " its own destructor.\n";
1496 return;
1497 }
1498
1499 my $destructor_class = $args{destructor_class};
1500
1501244.89ms Class::MOP::load_class($destructor_class);
# spent 5.94ms making 24 calls to Class::MOP::load_class, avg 248µs/call, recursion: max depth 1, sum of overlapping time 1.05ms
1502
15032413.7ms return unless $destructor_class->is_needed($self);
# spent 13.7ms making 24 calls to Moose::Meta::Method::Destructor::is_needed, avg 570µs/call
1504
15054850.3ms my $destructor = $destructor_class->new(
# spent 50.2ms making 24 calls to Moose::Meta::Method::Destructor::new, avg 2.09ms/call # spent 141µs making 24 calls to Class::MOP::Package::name, avg 6µs/call
1506 options => \%args,
1507 metaclass => $self,
1508 package_name => $self->name,
1509 name => 'DESTROY'
1510 );
1511
151248606µs2410.5ms if ( $args{replace_destructor} or $destructor->can_be_inlined ) {
# spent 10.5ms making 24 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 436µs/call
1513249.83ms $self->add_method( 'DESTROY' => $destructor );
# spent 9.83ms making 24 calls to Class::MOP::Mixin::HasMethods::add_method, avg 409µs/call
151424429µs $self->_add_inlined_method($destructor);
# spent 429µs making 24 calls to Class::MOP::Class::_add_inlined_method, avg 18µs/call
1515 }
1516}
1517
1518123µs1;
1519
1520__END__
 
# spent 23.0ms (15.8+7.19) within Class::MOP::Class::CORE:sort which was called 55 times, avg 418µs/call: # 55 times (15.8ms+7.19ms) by Class::MOP::Class::_inline_slot_initializers at line 646, avg 418µs/call
sub Class::MOP::Class::CORE:sort; # opcode