Profile of Class/MOP/Class.pm

← Index
NYTProf Performance Profile «line view»
For script/ponapi
Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:10 2016

Filename | /usr/local/lib/perl/5.18.2/Class/MOP/Class.pm
Statements | Executed 6235905 statements in 7.68s

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1235442 | 24 | 14 | 8.55s | 10.7s | Class::MOP::Class::::initializeClass::MOP::Class::initialize (recurses: max depth 2, inclusive time 670µs)
516 | 9 | 4 | 16.6ms | 27.8ms | Class::MOP::Class::::get_all_attributesClass::MOP::Class::get_all_attributes
317 | 2 | 1 | 14.5ms | 88.4ms | Class::MOP::Class::::_construct_instanceClass::MOP::Class::_construct_instance
642 | 1 | 1 | 13.7ms | 18.1ms | Class::MOP::Class::::_single_metaclass_can_be_made_compatibleClass::MOP::Class::_single_metaclass_can_be_made_compatible
116 | 2 | 1 | 12.6ms | 13.6ms | Class::MOP::Class::::CORE:sortClass::MOP::Class::CORE:sort (opcode)
271 | 1 | 1 | 9.34ms | 24.5ms | Class::MOP::Class::::_inline_init_attr_from_constructorClass::MOP::Class::_inline_init_attr_from_constructor
82 | 2 | 2 | 6.19ms | 6.52ms | Class::MOP::Class::::_immutable_optionsClass::MOP::Class::_immutable_options
107 | 1 | 1 | 6.18ms | 28.6ms | Class::MOP::Class::::_can_fix_metaclass_incompatibilityClass::MOP::Class::_can_fix_metaclass_incompatibility
240 | 1 | 1 | 6.09ms | 537ms | Class::MOP::Class::::_post_add_attributeClass::MOP::Class::_post_add_attribute
58 | 1 | 1 | 4.99ms | 5.25ms | Class::MOP::Class::::_inline_preserve_weak_metaclassesClass::MOP::Class::_inline_preserve_weak_metaclasses
360 | 1 | 1 | 3.89ms | 5.94ms | Class::MOP::Class::::_single_metaclass_is_compatibleClass::MOP::Class::_single_metaclass_is_compatible
468 | 2 | 2 | 3.89ms | 81.1ms | Class::MOP::Class::::_inline_slot_initializerClass::MOP::Class::_inline_slot_initializer
969 | 4 | 2 | 3.84ms | 5.88ms | Class::MOP::Class::::linearized_isaClass::MOP::Class::linearized_isa
159 | 2 | 1 | 3.02ms | 52.4ms | Class::MOP::Class::::_check_metaclass_compatibilityClass::MOP::Class::_check_metaclass_compatibility (recurses: max depth 1, inclusive time 205µs)
207 | 6 | 6 | 2.83ms | 30.6ms | Class::MOP::Class::::find_method_by_nameClass::MOP::Class::find_method_by_name
200 | 4 | 3 | 2.05ms | 11.6ms | Class::MOP::Class::::find_next_method_by_nameClass::MOP::Class::find_next_method_by_name
278 | 7 | 7 | 1.98ms | 71.6ms | Class::MOP::Class::::new_objectClass::MOP::Class::new_object
453 | 2 | 2 | 1.90ms | 2.79ms | Class::MOP::Class::::_inline_default_valueClass::MOP::Class::_inline_default_value
105 | 1 | 1 | 1.73ms | 42.6ms | Class::MOP::Class::::_construct_class_instanceClass::MOP::Class::_construct_class_instance (recurses: max depth 1, inclusive time 249µs)
160 | 1 | 1 | 1.65ms | 22.7ms | Class::MOP::Class::::_create_meta_instanceClass::MOP::Class::_create_meta_instance
58 | 1 | 1 | 1.57ms | 220ms | Class::MOP::Class::::_inline_constructorClass::MOP::Class::_inline_constructor
848 | 10 | 5 | 1.32ms | 24.1ms | Class::MOP::Class::::get_meta_instanceClass::MOP::Class::get_meta_instance
82 | 1 | 1 | 1.30ms | 31.5ms | Class::MOP::Class::::_immutable_metaclassClass::MOP::Class::_immutable_metaclass (recurses: max depth 1, inclusive time 130µs)
58 | 1 | 1 | 1.28ms | 91.3ms | Class::MOP::Class::::_inline_slot_initializersClass::MOP::Class::_inline_slot_initializers
58 | 2 | 2 | 1.28ms | 14.1ms | Class::MOP::Class::::_eval_environmentClass::MOP::Class::_eval_environment
241 | 2 | 1 | 1.25ms | 1.55ms | Class::MOP::Class::::invalidate_meta_instancesClass::MOP::Class::invalidate_meta_instances
1 | 1 | 1 | 1.15ms | 1.26ms | Class::MOP::Class::::BEGIN@7Class::MOP::Class::BEGIN@7
82 | 34 | 32 | 1.12ms | 342ms | Class::MOP::Class::::make_immutableClass::MOP::Class::make_immutable (recurses: max depth 1, inclusive time 233µs)
282 | 2 | 1 | 1.09ms | 7.81ms | Class::MOP::Class::::_inline_init_attr_from_defaultClass::MOP::Class::_inline_init_attr_from_default
56 | 2 | 2 | 1.05ms | 9.86ms | Class::MOP::Class::::find_all_methods_by_nameClass::MOP::Class::find_all_methods_by_name
1 | 1 | 1 | 994µs | 2.63ms | Class::MOP::Class::::BEGIN@9Class::MOP::Class::BEGIN@9
470 | 4 | 1 | 989µs | 3.91ms | Class::MOP::Class::::_method_lookup_orderClass::MOP::Class::_method_lookup_order
28 | 1 | 1 | 984µs | 32.5ms | Class::MOP::Class::::_inline_destructorClass::MOP::Class::_inline_destructor
1 | 1 | 1 | 947µs | 1.08ms | Class::MOP::Class::::BEGIN@8Class::MOP::Class::BEGIN@8
66 | 2 | 1 | 903µs | 12.2ms | Class::MOP::Class::::__ANON__[:1082]Class::MOP::Class::__ANON__[:1082]
360 | 1 | 1 | 890µs | 6.84ms | Class::MOP::Class::::_check_single_metaclass_compatibilityClass::MOP::Class::_check_single_metaclass_compatibility
88 | 1 | 1 | 825µs | 29.9ms | Class::MOP::Class::::_fix_metaclass_incompatibilityClass::MOP::Class::_fix_metaclass_incompatibility (recurses: max depth 1, inclusive time 128µs)
58 | 1 | 1 | 807µs | 114ms | Class::MOP::Class::::_inline_new_objectClass::MOP::Class::_inline_new_object
83 | 2 | 2 | 785µs | 2.84ms | Class::MOP::Class::::find_attribute_by_nameClass::MOP::Class::find_attribute_by_name
82 | 1 | 1 | 778µs | 302ms | Class::MOP::Class::::_install_inlined_codeClass::MOP::Class::_install_inlined_code
82 | 1 | 1 | 771µs | 303ms | Class::MOP::Class::::_initialize_immutableClass::MOP::Class::_initialize_immutable
50 | 3 | 3 | 732µs | 3.03ms | Class::MOP::Class::::class_precedence_listClass::MOP::Class::class_precedence_list (recurses: max depth 4, inclusive time 1.67ms)
178 | 4 | 1 | 677µs | 1.90ms | Class::MOP::Class::::_real_ref_nameClass::MOP::Class::_real_ref_name
240 | 1 | 1 | 646µs | 2.62ms | Class::MOP::Class::::_attach_attributeClass::MOP::Class::_attach_attribute
54 | 1 | 1 | 574µs | 2.16ms | Class::MOP::Class::::_superclasses_updatedClass::MOP::Class::_superclasses_updated
66 | 1 | 1 | 563µs | 563µs | Class::MOP::Class::::_newClass::MOP::Class::_new
107 | 1 | 1 | 554µs | 2.61ms | Class::MOP::Class::::_class_metaclass_can_be_made_compatibleClass::MOP::Class::_class_metaclass_can_be_made_compatible
1 | 1 | 1 | 520µs | 1.13ms | Class::MOP::Class::::BEGIN@10Class::MOP::Class::BEGIN@10
82 | 1 | 1 | 498µs | 31.9ms | Class::MOP::Class::::_rebless_as_immutableClass::MOP::Class::_rebless_as_immutable (recurses: max depth 1, inclusive time 145µs)
132 | 2 | 2 | 453µs | 95.2ms | Class::MOP::Class::::create_anon_classClass::MOP::Class::create_anon_class
60 | 1 | 1 | 427µs | 1.13ms | Class::MOP::Class::::_class_metaclass_is_compatibleClass::MOP::Class::_class_metaclass_is_compatible
62 | 2 | 2 | 408µs | 12.8ms | Class::MOP::Class::::add_around_method_modifierClass::MOP::Class::add_around_method_modifier
33 | 1 | 1 | 401µs | 48.8ms | Class::MOP::Class::::_inline_accessorsClass::MOP::Class::_inline_accessors
195 | 3 | 2 | 400µs | 400µs | Class::MOP::Class::::_base_metaclassesClass::MOP::Class::_base_metaclasses
58 | 1 | 1 | 398µs | 546µs | Class::MOP::Class::::_inline_fallback_constructorClass::MOP::Class::_inline_fallback_constructor
241 | 1 | 1 | 295µs | 295µs | Class::MOP::Class::::invalidate_meta_instanceClass::MOP::Class::invalidate_meta_instance
58 | 1 | 1 | 273µs | 1.71ms | Class::MOP::Class::::_inline_create_instanceClass::MOP::Class::_inline_create_instance
7 | 1 | 1 | 270µs | 2.47ms | Class::MOP::Class::::get_all_methodsClass::MOP::Class::get_all_methods
86 | 2 | 1 | 250µs | 250µs | Class::MOP::Class::::_add_inlined_methodClass::MOP::Class::_add_inlined_method
58 | 1 | 1 | 250µs | 1.96ms | Class::MOP::Class::::_inline_generate_instanceClass::MOP::Class::_inline_generate_instance
12 | 2 | 2 | 248µs | 23.3ms | Class::MOP::Class::::createClass::MOP::Class::create
60 | 1 | 1 | 221µs | 1.35ms | Class::MOP::Class::::_check_class_metaclass_compatibilityClass::MOP::Class::_check_class_metaclass_compatibility
1 | 1 | 1 | 211µs | 260µs | Class::MOP::Class::::BEGIN@11Class::MOP::Class::BEGIN@11
54 | 1 | 1 | 123µs | 123µs | Class::MOP::Class::::_superclass_metasClass::MOP::Class::_superclass_metas
54 | 1 | 1 | 94µs | 94µs | Class::MOP::Class::::update_meta_instance_dependenciesClass::MOP::Class::update_meta_instance_dependencies
115 | 4 | 3 | 71µs | 71µs | Class::MOP::Class::::is_mutableClass::MOP::Class::is_mutable
91 | 1 | 1 | 63µs | 63µs | Class::MOP::Class::::is_immutableClass::MOP::Class::is_immutable
30 | 1 | 1 | 56µs | 56µs | Class::MOP::Class::::_inline_paramsClass::MOP::Class::_inline_params
30 | 1 | 1 | 48µs | 48µs | Class::MOP::Class::::_generate_fallback_constructorClass::MOP::Class::_generate_fallback_constructor
1 | 1 | 1 | 44µs | 279µs | Class::MOP::Class::::remove_attributeClass::MOP::Class::remove_attribute
4 | 1 | 1 | 32µs | 923µs | Class::MOP::Class::::add_before_method_modifierClass::MOP::Class::add_before_method_modifier
30 | 1 | 1 | 18µs | 18µs | Class::MOP::Class::::_inline_extra_initClass::MOP::Class::_inline_extra_init
1 | 1 | 1 | 17µs | 52µs | Class::MOP::Class::::BEGIN@18Class::MOP::Class::BEGIN@18
1 | 1 | 1 | 16µs | 20µs | Class::MOP::Class::::BEGIN@5Class::MOP::Class::BEGIN@5
1 | 1 | 1 | 8µs | 17µs | Class::MOP::Class::::BEGIN@4Class::MOP::Class::BEGIN@4
1 | 1 | 1 | 6µs | 27µs | Class::MOP::Class::::BEGIN@13Class::MOP::Class::BEGIN@13
1 | 1 | 1 | 6µs | 15µs | Class::MOP::Class::::BEGIN@14Class::MOP::Class::BEGIN@14
1 | 1 | 1 | 6µs | 22µs | Class::MOP::Class::::BEGIN@16Class::MOP::Class::BEGIN@16
1 | 1 | 1 | 6µs | 2.83ms | Class::MOP::Class::::BEGIN@20Class::MOP::Class::BEGIN@20
1 | 1 | 1 | 5µs | 27µs | Class::MOP::Class::::BEGIN@17Class::MOP::Class::BEGIN@17
1 | 1 | 1 | 5µs | 22µs | Class::MOP::Class::::BEGIN@15Class::MOP::Class::BEGIN@15
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::__ANON__[:210]Class::MOP::Class::__ANON__[:210]
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::__ANON__[:900]Class::MOP::Class::__ANON__[:900]
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::__ANON__[:904]Class::MOP::Class::__ANON__[:904]
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::_anon_cache_keyClass::MOP::Class::_anon_cache_key
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::_anon_package_prefixClass::MOP::Class::_anon_package_prefix
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::_clone_instanceClass::MOP::Class::_clone_instance
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::_fix_class_metaclass_incompatibilityClass::MOP::Class::_fix_class_metaclass_incompatibility
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::_fix_single_metaclass_incompatibilityClass::MOP::Class::_fix_single_metaclass_incompatibility
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::_fixup_attributes_after_reblessClass::MOP::Class::_fixup_attributes_after_rebless
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::_force_rebless_instanceClass::MOP::Class::_force_rebless_instance
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::_inline_clear_mop_slotClass::MOP::Class::_inline_clear_mop_slot
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::_inline_get_mop_slotClass::MOP::Class::_inline_get_mop_slot
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::_inline_rebless_instanceClass::MOP::Class::_inline_rebless_instance
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::_inline_set_mop_slotClass::MOP::Class::_inline_set_mop_slot
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::_inlined_methodsClass::MOP::Class::_inlined_methods
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::_rebless_as_mutableClass::MOP::Class::_rebless_as_mutable
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::_remove_generated_metaobjectsClass::MOP::Class::_remove_generated_metaobjects
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::_remove_inlined_codeClass::MOP::Class::_remove_inlined_code
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::_restore_metaobjects_fromClass::MOP::Class::_restore_metaobjects_from
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::add_after_method_modifierClass::MOP::Class::add_after_method_modifier
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::add_dependent_meta_instanceClass::MOP::Class::add_dependent_meta_instance
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::add_meta_instance_dependenciesClass::MOP::Class::add_meta_instance_dependencies
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::clone_objectClass::MOP::Class::clone_object
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::direct_subclassesClass::MOP::Class::direct_subclasses
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::get_all_method_namesClass::MOP::Class::get_all_method_names
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::immutable_optionsClass::MOP::Class::immutable_options
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::is_anon_classClass::MOP::Class::is_anon_class
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::is_pristineClass::MOP::Class::is_pristine
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::make_mutableClass::MOP::Class::make_mutable
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::rebless_instanceClass::MOP::Class::rebless_instance
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::rebless_instance_awayClass::MOP::Class::rebless_instance_away
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::rebless_instance_backClass::MOP::Class::rebless_instance_back
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::reinitializeClass::MOP::Class::reinitialize
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::remove_dependent_meta_instanceClass::MOP::Class::remove_dependent_meta_instance
0 | 0 | 0 | 0s | 0s | Class::MOP::Class::::remove_meta_instance_dependenciesClass::MOP::Class::remove_meta_instance_dependencies
0 | 0 | 0 | 0s | 0s | Class::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 |  |  |  |  | package Class::MOP::Class;
2 | 1 | 600ns |  |  | our $VERSION = '2.1604';
3 |  |  |  |  |
4 | 2 | 28µs | 2 | 27µs | # spent 17µs (8+9) within Class::MOP::Class::BEGIN@4 which was called: # once (8µs+9µs) by Class::MOP::BEGIN@18 at line 4 use strict; # spent 17µs making 1 call to Class::MOP::Class::BEGIN@4 # spent 9µs making 1 call to strict::import
5 | 2 | 19µs | 2 | 23µs | # spent 20µs (16+4) within Class::MOP::Class::BEGIN@5 which was called: # once (16µs+4µs) by Class::MOP::BEGIN@18 at line 5 use warnings; # spent 20µs making 1 call to Class::MOP::Class::BEGIN@5 # spent 4µs making 1 call to warnings::import
6 |  |  |  |  |
7 | 2 | 94µs | 1 | 1.26ms | # spent 1.26ms (1.15+107µs) within Class::MOP::Class::BEGIN@7 which was called: # once (1.15ms+107µs) by Class::MOP::BEGIN@18 at line 7 use Class::MOP::Instance; # spent 1.26ms making 1 call to Class::MOP::Class::BEGIN@7
8 | 2 | 125µs | 1 | 1.08ms | # spent 1.08ms (947µs+135µs) within Class::MOP::Class::BEGIN@8 which was called: # once (947µs+135µs) by Class::MOP::BEGIN@18 at line 8 use Class::MOP::Method::Wrapped; # spent 1.08ms making 1 call to Class::MOP::Class::BEGIN@8
9 | 2 | 88µs | 1 | 2.63ms | # spent 2.63ms (994µs+1.64) within Class::MOP::Class::BEGIN@9 which was called: # once (994µs+1.64ms) by Class::MOP::BEGIN@18 at line 9 use Class::MOP::Method::Accessor; # spent 2.63ms making 1 call to Class::MOP::Class::BEGIN@9
10 | 2 | 88µs | 1 | 1.13ms | # spent 1.13ms (520µs+605µs) within Class::MOP::Class::BEGIN@10 which was called: # once (520µs+605µs) by Class::MOP::BEGIN@18 at line 10 use Class::MOP::Method::Constructor; # spent 1.13ms making 1 call to Class::MOP::Class::BEGIN@10
11 | 2 | 78µs | 1 | 260µs | # spent 260µs (211+50) within Class::MOP::Class::BEGIN@11 which was called: # once (211µs+50µs) by Class::MOP::BEGIN@18 at line 11 use Class::MOP::MiniTrait; # spent 260µs making 1 call to Class::MOP::Class::BEGIN@11
12 |  |  |  |  |
13 | 2 | 21µs | 2 | 48µs | # spent 27µs (6+21) within Class::MOP::Class::BEGIN@13 which was called: # once (6µs+21µs) by Class::MOP::BEGIN@18 at line 13 use Carp 'confess'; # spent 27µs making 1 call to Class::MOP::Class::BEGIN@13 # spent 21µs making 1 call to Exporter::import
14 | 2 | 19µs | 2 | 24µs | # spent 15µs (6+9) within Class::MOP::Class::BEGIN@14 which was called: # once (6µs+9µs) by Class::MOP::BEGIN@18 at line 14 use Module::Runtime 'use_package_optimistically'; # spent 15µs making 1 call to Class::MOP::Class::BEGIN@14 # spent 9µs making 1 call to Module::Runtime::import
15 | 2 | 19µs | 2 | 39µs | # spent 22µs (5+17) within Class::MOP::Class::BEGIN@15 which was called: # once (5µs+17µs) by Class::MOP::BEGIN@18 at line 15 use Scalar::Util 'blessed'; # spent 22µs making 1 call to Class::MOP::Class::BEGIN@15 # spent 17µs making 1 call to Exporter::import
16 | 2 | 18µs | 2 | 38µs | # spent 22µs (6+16) within Class::MOP::Class::BEGIN@16 which was called: # once (6µs+16µs) by Class::MOP::BEGIN@18 at line 16 use Sub::Name 'subname'; # spent 22µs making 1 call to Class::MOP::Class::BEGIN@16 # spent 16µs making 1 call to Exporter::import
17 | 2 | 23µs | 2 | 48µs | # spent 27µs (5+21) within Class::MOP::Class::BEGIN@17 which was called: # once (5µs+21µs) by Class::MOP::BEGIN@18 at line 17 use Try::Tiny; # spent 27µs making 1 call to Class::MOP::Class::BEGIN@17 # spent 21µs making 1 call to Exporter::import
18 | 3 | 46µs | 3 | 71µs | # spent 52µs (17+34) within Class::MOP::Class::BEGIN@18 which was called: # once (17µs+34µs) by Class::MOP::BEGIN@18 at line 18 use List::Util 1.33 'all'; # spent 52µs making 1 call to Class::MOP::Class::BEGIN@18 # spent 11µs making 1 call to UNIVERSAL::VERSION # spent 8µs making 1 call to List::Util::import
19 |  |  |  |  |
20 | 1 | 4µs | 1 | 2.82ms | # spent 2.83ms (6µs+2.82) within Class::MOP::Class::BEGIN@20 which was called: # once (6µs+2.82ms) by Class::MOP::BEGIN@18 at line 23 use parent 'Class::MOP::Module', # spent 2.82ms making 1 call to parent::import
21 |  |  |  |  | 'Class::MOP::Mixin::HasAttributes',
22 |  |  |  |  | 'Class::MOP::Mixin::HasMethods',
23 | 1 | 4.64ms | 1 | 2.83ms | 'Class::MOP::Mixin::HasOverloads'; # spent 2.83ms making 1 call to Class::MOP::Class::BEGIN@20
24 |  |  |  |  |
25 |  |  |  |  | # Creation
26 |  |  |  |  |
27 |  |  |  |  | # spent 10.7s (8.55+2.13) within Class::MOP::Class::initialize which was called 1235442 times, avg 9µs/call: # 1230964 times (8.54s+2.09s) by Moose::Object::does at line 120 of Moose/Object.pm, avg 9µs/call # 2210 times (5.46ms+1.20ms) by Class::MOP::Class::get_all_attributes at line 936, avg 3µs/call # 566 times (1.54ms+397µs) by Class::MOP::Class::find_method_by_name at line 1133, avg 3µs/call # 495 times (1.77ms+7.59ms) by Class::MOP::Mixin::meta or Class::MOP::Object::meta or Moose::Meta::Class::__ANON__::SERIAL::1::meta or Moose::Meta::Class::__ANON__::SERIAL::7::meta or Moose::Meta::Role::Application::RoleSummation::meta or Moose::Meta::Role::Application::ToClass::meta or Moose::Meta::Role::Application::ToInstance::meta or Moose::Meta::Role::Application::ToRole::meta or Moose::Meta::Role::Application::meta or Moose::Meta::Role::Composite::meta or Moose::Meta::Role::Method::Required::meta or Moose::Meta::Role::meta or Moose::Meta::TypeCoercion::Union::meta or Moose::Meta::TypeCoercion::meta or Moose::Meta::TypeConstraint::Class::meta or Moose::Meta::TypeConstraint::DuckType::meta or Moose::Meta::TypeConstraint::Enum::meta or Moose::Meta::TypeConstraint::Parameterizable::meta or Moose::Meta::TypeConstraint::Parameterized::meta or Moose::Meta::TypeConstraint::Registry::meta or Moose::Meta::TypeConstraint::Role::meta or Moose::Meta::TypeConstraint::Union::meta or Moose::Meta::TypeConstraint::meta or PONAPI::Builder::Document::meta or PONAPI::Builder::Errors::meta or PONAPI::Builder::Links::meta or PONAPI::Builder::Relationship::meta or PONAPI::Builder::Resource::Identifier::meta or PONAPI::Builder::Resource::Null::meta or PONAPI::Builder::Resource::meta or PONAPI::DAO::Request::Create::meta or PONAPI::DAO::Request::CreateRelationships::meta or PONAPI::DAO::Request::Delete::meta or PONAPI::DAO::Request::DeleteRelationships::meta or PONAPI::DAO::Request::Retrieve::meta or PONAPI::DAO::Request::RetrieveAll::meta or PONAPI::DAO::Request::RetrieveByRelationship::meta or PONAPI::DAO::Request::RetrieveRelationships::meta or PONAPI::DAO::Request::Update::meta or PONAPI::DAO::Request::UpdateRelationships::meta or PONAPI::DAO::Request::meta or PONAPI::DAO::meta or PONAPI::Exception::meta or PONAPI::Server::ConfigReader::meta or Test::PONAPI::Repository::MockDB::Loader::meta or Test::PONAPI::Repository::MockDB::Table::Articles::meta or Test::PONAPI::Repository::MockDB::Table::Comments::meta or Test::PONAPI::Repository::MockDB::Table::People::meta or Test::PONAPI::Repository::MockDB::Table::Relationships::meta or Test::PONAPI::Repository::MockDB::Table::meta or Test::PONAPI::Repository::MockDB::meta at line 42 of Class/MOP/Method/Meta.pm, avg 19µs/call # 275 times (807µs+216µs) by Class::MOP::Class::find_next_method_by_name at line 1181, avg 4µs/call # 196 times (497µs+119µs) by Class::MOP::Class::find_all_methods_by_name at line 1164, avg 3µs/call # 146 times (497µs+511µs) by Class::MOP::Method::Accessor::_new at line 51 of Class/MOP/Method/Accessor.pm, avg 7µs/call # 107 times (320µs+-86µs) by Class::MOP::Class::_fix_metaclass_incompatibility at line 291, avg 2µs/call # 105 times (278µs+81µs) by Moose::Meta::Attribute::_new or Moose::Meta::Method::_new at line 7 of (eval 45)[Eval/Closure.pm:144], avg 3µs/call # 83 times (217µs+45µs) by Class::MOP::Class::find_attribute_by_name at line 926, avg 3µs/call # 59 times (203µs+3.93ms) by Class::MOP::Mixin::meta at line 12 of Class/MOP/Mixin.pm, avg 70µs/call # 52 times (189µs+52µs) by Class::MOP::Class::class_precedence_list at line 1036, avg 5µs/call # 40 times (99µs+21µs) by Class::MOP::Attribute::has_value at line 332 of Class/MOP/Attribute.pm, avg 3µs/call # 39 times (265µs+23.2ms) by Moose::Meta::Class::initialize at line 64 of Moose/Meta/Class.pm, avg 601µs/call # 24 times (65µs+521µs) by Class::MOP::Method::_new at line 59 of Class/MOP/Method.pm, avg 24µs/call # 23 times (57µs+13µs) by Class::MOP::Attribute::get_raw_value at line 311 of Class/MOP/Attribute.pm, avg 3µs/call # 19 times (120µs+1.19ms) by metaclass::import at line 38 of metaclass.pm, avg 69µs/call # 15 times (39µs+9µs) by Class::MOP::Class::get_all_methods at line 1144, avg 3µs/call # 12 times (69µs+5.74ms) by Class::MOP::MiniTrait::apply at line 14 of Class/MOP/MiniTrait.pm, avg 484µs/call # 7 times (33µs+326µs) by Moose::BEGIN@43 at line 12 of Moose/Meta/Attribute/Native.pm, avg 51µs/call # 2 times (12µs+140µs) by Class::MOP::Package::create at line 67 of Class/MOP/Package.pm, avg 76µs/call # once (3µs+700ns) by Class::MOP::Attribute::_new at line 69 of Class/MOP/Attribute.pm # once (3µs+600ns) by Class::MOP::Attribute::set_initial_value at line 275 of Class/MOP/Attribute.pm # once (3µs+700ns) by Moose::Meta::Attribute::_weaken_value at line 796 of Moose/Meta/Attribute.pm sub initialize {
28 | 1235442 | 397ms |  |  | my $class = shift;
29 |  |  |  |  |
30 | 1235442 | 190ms |  |  | my $package_name;
31 |  |  |  |  |
32 | 1235442 | 752ms |  |  | if ( @_ % 2 ) {
33 |  |  |  |  | $package_name = shift;
34 |  |  |  |  | } else {
35 |  |  |  |  | my %options = @_;
36 |  |  |  |  | $package_name = $options{package};
37 |  |  |  |  | }
38 |  |  |  |  |
39 | 1235442 | 474ms |  |  | ($package_name && !ref($package_name))
40 |  |  |  |  | || ($class||__PACKAGE__)->_throw_exception( InitializeTakesUnBlessedPackageName => package_name => $package_name );
41 | 1235442 | 5.73s | 1235547 | 2.13s | return Class::MOP::get_metaclass_by_name($package_name) # spent 2.09s making 1235442 calls to Class::MOP::get_metaclass_by_name, avg 2µs/call # spent 42.8ms making 105 calls to Class::MOP::Class::_construct_class_instance, avg 408µs/call, recursion: max depth 1, sum of overlapping time 249µs
42 |  |  |  |  | || $class->_construct_class_instance(package => $package_name, @_);
43 |  |  |  |  | }
44 |  |  |  |  |
45 |  |  |  |  | sub reinitialize {
46 |  |  |  |  | my ( $class, @args ) = @_;
47 |  |  |  |  | unshift @args, "package" if @args % 2;
48 |  |  |  |  | my %options = @args;
49 |  |  |  |  | my $old_metaclass = blessed($options{package})
50 |  |  |  |  | ? $options{package}
51 |  |  |  |  | : Class::MOP::get_metaclass_by_name($options{package});
52 |  |  |  |  | $options{weaken} = Class::MOP::metaclass_is_weak($old_metaclass->name)
53 |  |  |  |  | if !exists $options{weaken}
54 |  |  |  |  | && blessed($old_metaclass)
55 |  |  |  |  | && $old_metaclass->isa('Class::MOP::Class');
56 |  |  |  |  | $old_metaclass->_remove_generated_metaobjects
57 |  |  |  |  | if $old_metaclass && $old_metaclass->isa('Class::MOP::Class');
58 |  |  |  |  | my $new_metaclass = $class->SUPER::reinitialize(%options);
59 |  |  |  |  | $new_metaclass->_restore_metaobjects_from($old_metaclass)
60 |  |  |  |  | if $old_metaclass && $old_metaclass->isa('Class::MOP::Class');
61 |  |  |  |  | return $new_metaclass;
62 |  |  |  |  | }
63 |  |  |  |  |
64 |  |  |  |  | # NOTE: (meta-circularity)
65 |  |  |  |  | # this is a special form of _construct_instance
66 |  |  |  |  | # (see below), which is used to construct class
67 |  |  |  |  | # meta-object instances for any Class::MOP::*
68 |  |  |  |  | # class. All other classes will use the more
69 |  |  |  |  | # normal &construct_instance.
70 |  |  |  |  | # spent 42.6ms (1.73+40.9) within Class::MOP::Class::_construct_class_instance which was called 105 times, avg 406µs/call: # 105 times (1.73ms+40.9ms) by Class::MOP::Class::initialize at line 41, avg 406µs/call sub _construct_class_instance {
71 | 105 | 42µs |  |  | my $class = shift;
72 | 105 | 205µs |  |  | my $options = @_ == 1 ? $_[0] : {@_};
73 | 105 | 52µs |  |  | my $package_name = $options->{package};
74 | 105 | 41µs |  |  | (defined $package_name && $package_name)
75 |  |  |  |  | || $class->_throw_exception("ConstructClassInstanceTakesPackageName");
76 |  |  |  |  | # NOTE:
77 |  |  |  |  | # return the metaclass if we have it cached,
78 |  |  |  |  | # and it is still defined (it has not been
79 |  |  |  |  | # reaped by DESTROY yet, which can happen
80 |  |  |  |  | # annoyingly enough during global destruction)
81 |  |  |  |  |
82 | 105 | 88µs | 105 | 62µs | if (defined(my $meta = Class::MOP::get_metaclass_by_name($package_name))) { # spent 62µs making 105 calls to Class::MOP::get_metaclass_by_name, avg 593ns/call
83 |  |  |  |  | return $meta;
84 |  |  |  |  | }
85 |  |  |  |  |
86 |  |  |  |  | $class
87 | 105 | 50µs | 9 | 175µs | = ref $class # spent 175µs making 9 calls to Class::MOP::Class::_real_ref_name, avg 19µs/call
88 |  |  |  |  | ? $class->_real_ref_name
89 |  |  |  |  | : $class;
90 |  |  |  |  |
91 |  |  |  |  | # now create the metaclass
92 | 105 | 12µs |  |  | my $meta;
93 | 105 | 133µs | 66 | 563µs | if ($class eq 'Class::MOP::Class') { # spent 563µs making 66 calls to Class::MOP::Class::_new, avg 9µs/call
94 |  |  |  |  | $meta = $class->_new($options);
95 |  |  |  |  | }
96 |  |  |  |  | else {
97 |  |  |  |  | # NOTE:
98 |  |  |  |  | # it is safe to use meta here because
99 |  |  |  |  | # class will always be a subclass of
100 |  |  |  |  | # Class::MOP::Class, which defines meta
101 | 39 | 139µs | 78 | 19.9ms | $meta = $class->meta->_construct_instance($options) # spent 19.5ms making 39 calls to Class::MOP::Class::_construct_instance, avg 499µs/call # spent 418µs making 39 calls to Class::MOP::Object::meta, avg 11µs/call
102 |  |  |  |  | }
103 |  |  |  |  |
104 |  |  |  |  | # and check the metaclass compatibility
105 | 105 | 203µs | 105 | 20.0ms | $meta->_check_metaclass_compatibility(); # spent 20.2ms making 105 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 193µs/call, recursion: max depth 1, sum of overlapping time 205µs
106 |  |  |  |  |
107 | 105 | 146µs | 105 | 200µs | Class::MOP::store_metaclass_by_name($package_name, $meta); # spent 200µs making 105 calls to Class::MOP::store_metaclass_by_name, avg 2µs/call
108 |  |  |  |  |
109 |  |  |  |  | # NOTE:
110 |  |  |  |  | # we need to weaken any anon classes
111 |  |  |  |  | # so that they can call DESTROY properly
112 | 105 | 49µs |  |  | Class::MOP::weaken_metaclass($package_name) if $options->{weaken};
113 |  |  |  |  |
114 | 105 | 248µs |  |  | $meta;
115 |  |  |  |  | }
116 |  |  |  |  |
117 |  |  |  |  | # spent 1.90ms (677µs+1.23) within Class::MOP::Class::_real_ref_name which was called 178 times, avg 11µs/call: # 107 times (451µs+765µs) by Class::MOP::Class::_class_metaclass_can_be_made_compatible at line 336, avg 11µs/call # 60 times (173µs+313µs) by Class::MOP::Class::_class_metaclass_is_compatible at line 250, avg 8µs/call # 9 times (43µs+132µs) by Class::MOP::Class::_construct_class_instance at line 87, avg 19µs/call # 2 times (10µs+15µs) by Class::MOP::Class::_immutable_metaclass at line 1364, avg 13µs/call sub _real_ref_name {
118 | 178 | 34µs |  |  | my $self = shift;
119 |  |  |  |  |
120 |  |  |  |  | # NOTE: we need to deal with the possibility of class immutability here,
121 |  |  |  |  | # and then get the name of the class appropriately
122 | 178 | 608µs | 265 | 1.23ms | return $self->is_immutable # spent 654µs making 59 calls to Class::MOP::Class::Immutable::Class::MOP::Class::is_immutable, avg 11µs/call # spent 358µs making 28 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::is_immutable, avg 13µs/call # spent 152µs making 87 calls to Class::MOP::Class::Immutable::Trait::_get_mutable_metaclass_name, avg 2µs/call # spent 63µs making 91 calls to Class::MOP::Class::is_immutable, avg 690ns/call
123 |  |  |  |  | ? $self->_get_mutable_metaclass_name()
124 |  |  |  |  | : ref $self;
125 |  |  |  |  | }
126 |  |  |  |  |
127 |  |  |  |  | # spent 563µs within Class::MOP::Class::_new which was called 66 times, avg 9µs/call: # 66 times (563µs+0s) by Class::MOP::Class::_construct_class_instance at line 93, avg 9µs/call sub _new {
128 | 66 | 17µs |  |  | my $class = shift;
129 |  |  |  |  |
130 | 66 | 14µs |  |  | return Class::MOP::Class->initialize($class)->new_object(@_)
131 |  |  |  |  | if $class ne __PACKAGE__;
132 |  |  |  |  |
133 | 66 | 22µs |  |  | my $options = @_ == 1 ? $_[0] : {@_};
134 |  |  |  |  |
135 | 66 | 578µs |  |  | return bless {
136 |  |  |  |  | # inherited from Class::MOP::Package
137 |  |  |  |  | 'package' => $options->{package},
138 |  |  |  |  |
139 |  |  |  |  | # NOTE:
140 |  |  |  |  | # since the following attributes will
141 |  |  |  |  | # actually be loaded from the symbol
142 |  |  |  |  | # table, and actually bypass the instance
143 |  |  |  |  | # entirely, we can just leave these things
144 |  |  |  |  | # listed here for reference, because they
145 |  |  |  |  | # should not actually have a value associated
146 |  |  |  |  | # with the slot.
147 |  |  |  |  | 'namespace' => \undef,
148 |  |  |  |  | 'methods' => {},
149 |  |  |  |  |
150 |  |  |  |  | # inherited from Class::MOP::Module
151 |  |  |  |  | 'version' => \undef,
152 |  |  |  |  | 'authority' => \undef,
153 |  |  |  |  |
154 |  |  |  |  | # defined in Class::MOP::Class
155 |  |  |  |  | 'superclasses' => \undef,
156 |  |  |  |  |
157 |  |  |  |  | 'attributes' => {},
158 |  |  |  |  | 'attribute_metaclass' =>
159 |  |  |  |  | ( $options->{'attribute_metaclass'} || 'Class::MOP::Attribute' ),
160 |  |  |  |  | 'method_metaclass' =>
161 |  |  |  |  | ( $options->{'method_metaclass'} || 'Class::MOP::Method' ),
162 |  |  |  |  | 'wrapped_method_metaclass' => (
163 |  |  |  |  | $options->{'wrapped_method_metaclass'}
164 |  |  |  |  | || 'Class::MOP::Method::Wrapped'
165 |  |  |  |  | ),
166 |  |  |  |  | 'instance_metaclass' =>
167 |  |  |  |  | ( $options->{'instance_metaclass'} || 'Class::MOP::Instance' ),
168 |  |  |  |  | 'immutable_trait' => (
169 |  |  |  |  | $options->{'immutable_trait'}
170 |  |  |  |  | || 'Class::MOP::Class::Immutable::Trait'
171 |  |  |  |  | ),
172 |  |  |  |  | 'constructor_name' => ( $options->{constructor_name} || 'new' ),
173 |  |  |  |  | 'constructor_class' => (
174 |  |  |  |  | $options->{constructor_class} || 'Class::MOP::Method::Constructor'
175 |  |  |  |  | ),
176 |  |  |  |  | 'destructor_class' => $options->{destructor_class},
177 |  |  |  |  | }, $class;
178 |  |  |  |  | }
179 |  |  |  |  |
180 |  |  |  |  | ## Metaclass compatibility
181 |  |  |  |  | {
182 | 2 | 4µs |  |  | my %base_metaclass = (
183 |  |  |  |  | attribute_metaclass => 'Class::MOP::Attribute',
184 |  |  |  |  | method_metaclass => 'Class::MOP::Method',
185 |  |  |  |  | wrapped_method_metaclass => 'Class::MOP::Method::Wrapped',
186 |  |  |  |  | instance_metaclass => 'Class::MOP::Instance',
187 |  |  |  |  | constructor_class => 'Class::MOP::Method::Constructor',
188 |  |  |  |  | destructor_class => 'Class::MOP::Method::Destructor',
189 |  |  |  |  | );
190 |  |  |  |  |
191 | 195 | 609µs |  |  | # spent 400µs within Class::MOP::Class::_base_metaclasses which was called 195 times, avg 2µs/call: # 112 times (242µs+0s) by Moose::Meta::Class::_base_metaclasses at line 628 of Moose/Meta/Class.pm, avg 2µs/call # 47 times (106µs+0s) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 324, avg 2µs/call # 36 times (52µs+0s) by Class::MOP::Class::_check_metaclass_compatibility at line 202, avg 1µs/call sub _base_metaclasses { %base_metaclass }
192 |  |  |  |  | }
193 |  |  |  |  |
194 |  |  |  |  | # spent 52.4ms (3.02+49.3) within Class::MOP::Class::_check_metaclass_compatibility which was called 159 times, avg 329µs/call: # 105 times (755µs+19.3ms) by Class::MOP::Class::_construct_class_instance at line 105, avg 191µs/call # 54 times (2.26ms+30.1ms) by Class::MOP::Class::superclasses at line 966, avg 599µs/call sub _check_metaclass_compatibility {
195 | 159 | 31µs |  |  | my $self = shift;
196 |  |  |  |  |
197 | 159 | 424µs | 159 | 3.09ms | my @superclasses = $self->superclasses # spent 1.94ms making 68 calls to Class::MOP::Class::superclasses, avg 28µs/call, recursion: max depth 1, sum of overlapping time 28µs # spent 3.36ms making 91 calls to Moose::Meta::Class::superclasses, avg 37µs/call, recursion: max depth 2, sum of overlapping time 2.18ms
198 |  |  |  |  | or return;
199 |  |  |  |  |
200 | 88 | 130µs | 88 | 29.9ms | $self->_fix_metaclass_incompatibility(@superclasses); # spent 30.1ms making 88 calls to Class::MOP::Class::_fix_metaclass_incompatibility, avg 342µs/call, recursion: max depth 1, sum of overlapping time 128µs
201 |  |  |  |  |
202 | 88 | 213µs | 88 | 1.11ms | my %base_metaclass = $self->_base_metaclasses; # spent 1.05ms making 52 calls to Moose::Meta::Class::_base_metaclasses, avg 20µs/call # spent 52µs making 36 calls to Class::MOP::Class::_base_metaclasses, avg 1µs/call
203 |  |  |  |  |
204 |  |  |  |  | # this is always okay ...
205 |  |  |  |  | return
206 |  |  |  |  | if ref($self) eq 'Class::MOP::Class'
207 |  |  |  |  | && all {
208 | 216 | 4.54ms | 216 | 78µs | my $meta = $self->$_; # spent 14µs making 36 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 386ns/call # spent 13µs making 36 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 372ns/call # spent 13µs making 36 calls to Class::MOP::Class::constructor_class, avg 364ns/call # spent 13µs making 36 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 358ns/call # spent 12µs making 36 calls to Class::MOP::Class::destructor_class, avg 344ns/call # spent 12µs making 36 calls to Class::MOP::Class::instance_metaclass, avg 333ns/call
209 | 216 | 212µs |  |  | !defined($meta) || $meta eq $base_metaclass{$_};
210 |  |  |  |  | }
211 | 88 | 200µs | 36 | 4.68ms | keys %base_metaclass; # spent 4.68ms making 36 calls to List::Util::all, avg 130µs/call
212 |  |  |  |  |
213 | 52 | 35µs |  |  | for my $superclass (@superclasses) {
214 | 60 | 115µs | 60 | 1.35ms | $self->_check_class_metaclass_compatibility($superclass); # spent 1.35ms making 60 calls to Class::MOP::Class::_check_class_metaclass_compatibility, avg 22µs/call
215 |  |  |  |  | }
216 |  |  |  |  |
217 | 52 | 190µs |  |  | for my $metaclass_type ( keys %base_metaclass ) {
218 | 312 | 601µs | 312 | 200µs | next unless defined $self->$metaclass_type; # spent 54µs making 52 calls to Moose::Meta::Class::destructor_class, avg 1µs/call # spent 53µs making 52 calls to Moose::Meta::Class::constructor_class, avg 1µs/call # spent 26µs making 52 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 500ns/call # spent 23µs making 52 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 438ns/call # spent 23µs making 52 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 435ns/call # spent 22µs making 52 calls to Class::MOP::Class::instance_metaclass, avg 419ns/call
219 | 312 | 146µs |  |  | for my $superclass (@superclasses) {
220 | 360 | 420µs | 360 | 6.84ms | $self->_check_single_metaclass_compatibility( $metaclass_type, # spent 6.84ms making 360 calls to Class::MOP::Class::_check_single_metaclass_compatibility, avg 19µs/call
221 |  |  |  |  | $superclass );
222 |  |  |  |  | }
223 |  |  |  |  | }
224 |  |  |  |  | }
225 |  |  |  |  |
226 |  |  |  |  | # spent 1.35ms (221µs+1.13) within Class::MOP::Class::_check_class_metaclass_compatibility which was called 60 times, avg 22µs/call: # 60 times (221µs+1.13ms) by Class::MOP::Class::_check_metaclass_compatibility at line 214, avg 22µs/call sub _check_class_metaclass_compatibility {
227 | 60 | 19µs |  |  | my $self = shift;
228 | 60 | 23µs |  |  | my ( $superclass_name ) = @_;
229 |  |  |  |  |
230 | 60 | 168µs | 60 | 1.13ms | if (!$self->_class_metaclass_is_compatible($superclass_name)) { # spent 1.13ms making 60 calls to Class::MOP::Class::_class_metaclass_is_compatible, avg 19µs/call
231 |  |  |  |  | my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name);
232 |  |  |  |  |
233 |  |  |  |  | my $super_meta_type = $super_meta->_real_ref_name;
234 |  |  |  |  |
235 |  |  |  |  | $self->_throw_exception( IncompatibleMetaclassOfSuperclass => class_name => $self->name,
236 |  |  |  |  | class_meta_type => ref( $self ),
237 |  |  |  |  | superclass_name => $superclass_name,
238 |  |  |  |  | superclass_meta_type => $super_meta_type
239 |  |  |  |  | );
240 |  |  |  |  | }
241 |  |  |  |  | }
242 |  |  |  |  |
243 |  |  |  |  | # spent 1.13ms (427µs+700µs) within Class::MOP::Class::_class_metaclass_is_compatible which was called 60 times, avg 19µs/call: # 60 times (427µs+700µs) by Class::MOP::Class::_check_class_metaclass_compatibility at line 230, avg 19µs/call sub _class_metaclass_is_compatible {
244 | 60 | 15µs |  |  | my $self = shift;
245 | 60 | 16µs |  |  | my ( $superclass_name ) = @_;
246 |  |  |  |  |
247 | 60 | 63µs | 60 | 42µs | my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name) # spent 42µs making 60 calls to Class::MOP::get_metaclass_by_name, avg 692ns/call
248 |  |  |  |  | || return 1;
249 |  |  |  |  |
250 | 60 | 59µs | 60 | 486µs | my $super_meta_name = $super_meta->_real_ref_name; # spent 486µs making 60 calls to Class::MOP::Class::_real_ref_name, avg 8µs/call
251 |  |  |  |  |
252 | 60 | 151µs | 60 | 172µs | return $self->_is_compatible_with($super_meta_name); # spent 172µs making 60 calls to Class::MOP::Object::_is_compatible_with, avg 3µs/call
253 |  |  |  |  | }
254 |  |  |  |  |
255 |  |  |  |  | # spent 6.84ms (890µs+5.94) within Class::MOP::Class::_check_single_metaclass_compatibility which was called 360 times, avg 19µs/call: # 360 times (890µs+5.94ms) by Class::MOP::Class::_check_metaclass_compatibility at line 220, avg 19µs/call sub _check_single_metaclass_compatibility {
256 | 360 | 61µs |  |  | my $self = shift;
257 | 360 | 105µs |  |  | my ( $metaclass_type, $superclass_name ) = @_;
258 |  |  |  |  |
259 | 360 | 689µs | 360 | 5.94ms | if (!$self->_single_metaclass_is_compatible($metaclass_type, $superclass_name)) { # spent 5.94ms making 360 calls to Class::MOP::Class::_single_metaclass_is_compatible, avg 17µs/call
260 |  |  |  |  | my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name);
261 |  |  |  |  |
262 |  |  |  |  | $self->_throw_exception( MetaclassTypeIncompatible => class_name => $self->name,
263 |  |  |  |  | superclass_name => $superclass_name,
264 |  |  |  |  | metaclass_type => $metaclass_type
265 |  |  |  |  | );
266 |  |  |  |  | }
267 |  |  |  |  | }
268 |  |  |  |  |
269 |  |  |  |  | # spent 5.94ms (3.89+2.05) within Class::MOP::Class::_single_metaclass_is_compatible which was called 360 times, avg 17µs/call: # 360 times (3.89ms+2.05ms) by Class::MOP::Class::_check_single_metaclass_compatibility at line 259, avg 17µs/call sub _single_metaclass_is_compatible {
270 | 360 | 37µs |  |  | my $self = shift;
271 | 360 | 67µs |  |  | my ( $metaclass_type, $superclass_name ) = @_;
272 |  |  |  |  |
273 | 360 | 195µs | 360 | 200µs | my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name) # spent 200µs making 360 calls to Class::MOP::get_metaclass_by_name, avg 556ns/call
274 |  |  |  |  | || return 1;
275 |  |  |  |  |
276 |  |  |  |  | # for instance, Moose::Meta::Class has a error_class attribute, but
277 |  |  |  |  | # Class::MOP::Class doesn't - this shouldn't be an error
278 | 360 | 704µs | 360 | 197µs | return 1 unless $super_meta->can($metaclass_type); # spent 197µs making 360 calls to UNIVERSAL::can, avg 548ns/call
279 |  |  |  |  | # for instance, Moose::Meta::Class has a destructor_class, but
280 |  |  |  |  | # Class::MOP::Class doesn't - this shouldn't be an error
281 | 360 | 611µs | 360 | 173µs | return 1 unless defined $super_meta->$metaclass_type; # spent 34µs making 42 calls to Moose::Meta::Class::constructor_class, avg 802ns/call # spent 33µs making 60 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 557ns/call # spent 33µs making 42 calls to Moose::Meta::Class::destructor_class, avg 788ns/call # spent 22µs making 60 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 367ns/call # spent 19µs making 60 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 313ns/call # spent 19µs making 60 calls to Class::MOP::Class::instance_metaclass, avg 312ns/call # spent 6µs making 18 calls to Class::MOP::Class::constructor_class, avg 361ns/call # spent 6µs making 18 calls to Class::MOP::Class::destructor_class, avg 361ns/call
282 |  |  |  |  | # if metaclass is defined in superclass but not here, it's not compatible
283 |  |  |  |  | # this is a really odd case
284 | 342 | 502µs | 342 | 155µs | return 0 unless defined $self->$metaclass_type; # spent 55µs making 60 calls to Moose::Meta::Class::constructor_class, avg 913ns/call # spent 30µs making 42 calls to Moose::Meta::Class::destructor_class, avg 702ns/call # spent 18µs making 60 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 303ns/call # spent 18µs making 60 calls to Class::MOP::Class::instance_metaclass, avg 295ns/call # spent 18µs making 60 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 295ns/call # spent 17µs making 60 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 290ns/call
285 |  |  |  |  |
286 | 342 | 1.62ms | 1026 | 1.33ms | return $self->$metaclass_type->_is_compatible_with($super_meta->$metaclass_type); # spent 1.06ms making 342 calls to Class::MOP::Object::_is_compatible_with, avg 3µs/call # spent 70µs making 102 calls to Moose::Meta::Class::constructor_class, avg 686ns/call # spent 60µs making 84 calls to Moose::Meta::Class::destructor_class, avg 713ns/call # spent 35µs making 120 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 291ns/call # spent 33µs making 120 calls to Class::MOP::Class::instance_metaclass, avg 276ns/call # spent 33µs making 120 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 273ns/call # spent 32µs making 120 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 268ns/call # spent 6µs making 18 calls to Class::MOP::Class::constructor_class, avg 339ns/call
287 |  |  |  |  | }
288 |  |  |  |  |
289 |  |  |  |  | # spent 29.9ms (825µs+29.1) within Class::MOP::Class::_fix_metaclass_incompatibility which was called 88 times, avg 340µs/call: # 88 times (825µs+29.1ms) by Class::MOP::Class::_check_metaclass_compatibility at line 200, avg 340µs/call sub _fix_metaclass_incompatibility {
290 | 88 | 21µs |  |  | my $self = shift;
291 | 195 | 265µs | 107 | 235µs | my @supers = map { Class::MOP::Class->initialize($_) } @_; # spent 652µs making 107 calls to Class::MOP::Class::initialize, avg 6µs/call, recursion: max depth 2, sum of overlapping time 417µs
292 |  |  |  |  |
293 | 88 | 29µs |  |  | my $necessary = 0;
294 | 88 | 54µs |  |  | for my $super (@supers) {
295 | 107 | 169µs | 107 | 28.6ms | $necessary = 1 # spent 28.6ms making 107 calls to Class::MOP::Class::_can_fix_metaclass_incompatibility, avg 267µs/call
296 |  |  |  |  | if $self->_can_fix_metaclass_incompatibility($super);
297 |  |  |  |  | }
298 | 88 | 173µs |  |  | return unless $necessary;
299 |  |  |  |  |
300 |  |  |  |  | for my $super (@supers) {
301 |  |  |  |  | if (!$self->_class_metaclass_is_compatible($super->name)) {
302 |  |  |  |  | $self->_fix_class_metaclass_incompatibility($super);
303 |  |  |  |  | }
304 |  |  |  |  | }
305 |  |  |  |  |
306 |  |  |  |  | my %base_metaclass = $self->_base_metaclasses;
307 |  |  |  |  | for my $metaclass_type (keys %base_metaclass) {
308 |  |  |  |  | for my $super (@supers) {
309 |  |  |  |  | if (!$self->_single_metaclass_is_compatible($metaclass_type, $super->name)) {
310 |  |  |  |  | $self->_fix_single_metaclass_incompatibility(
311 |  |  |  |  | $metaclass_type, $super
312 |  |  |  |  | );
313 |  |  |  |  | }
314 |  |  |  |  | }
315 |  |  |  |  | }
316 |  |  |  |  | }
317 |  |  |  |  |
318 |  |  |  |  | # spent 28.6ms (6.18+22.4) within Class::MOP::Class::_can_fix_metaclass_incompatibility which was called 107 times, avg 267µs/call: # 107 times (6.18ms+22.4ms) by Class::MOP::Class::_fix_metaclass_incompatibility at line 295, avg 267µs/call sub _can_fix_metaclass_incompatibility {
319 | 107 | 29µs |  |  | my $self = shift;
320 | 107 | 28µs |  |  | my ($super_meta) = @_;
321 |  |  |  |  |
322 | 107 | 135µs | 107 | 2.61ms | return 1 if $self->_class_metaclass_can_be_made_compatible($super_meta); # spent 2.61ms making 107 calls to Class::MOP::Class::_class_metaclass_can_be_made_compatible, avg 24µs/call
323 |  |  |  |  |
324 | 107 | 274µs | 107 | 1.72ms | my %base_metaclass = $self->_base_metaclasses; # spent 1.62ms making 60 calls to Moose::Meta::Class::_base_metaclasses, avg 27µs/call # spent 106µs making 47 calls to Class::MOP::Class::_base_metaclasses, avg 2µs/call
325 | 107 | 119µs |  |  | for my $metaclass_type (keys %base_metaclass) {
326 | 642 | 666µs | 642 | 18.1ms | return 1 if $self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type); # spent 18.1ms making 642 calls to Class::MOP::Class::_single_metaclass_can_be_made_compatible, avg 28µs/call
327 |  |  |  |  | }
328 |  |  |  |  |
329 | 107 | 237µs |  |  | return;
330 |  |  |  |  | }
331 |  |  |  |  |
332 |  |  |  |  | # spent 2.61ms (554µs+2.05) within Class::MOP::Class::_class_metaclass_can_be_made_compatible which was called 107 times, avg 24µs/call: # 107 times (554µs+2.05ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 322, avg 24µs/call sub _class_metaclass_can_be_made_compatible {
333 | 107 | 21µs |  |  | my $self = shift;
334 | 107 | 21µs |  |  | my ($super_meta) = @_;
335 |  |  |  |  |
336 | 107 | 452µs | 214 | 2.05ms | return $self->_can_be_made_compatible_with($super_meta->_real_ref_name); # spent 1.22ms making 107 calls to Class::MOP::Class::_real_ref_name, avg 11µs/call # spent 837µs making 107 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 8µs/call
337 |  |  |  |  | }
338 |  |  |  |  |
339 |  |  |  |  | # spent 18.1ms (13.7+4.40) within Class::MOP::Class::_single_metaclass_can_be_made_compatible which was called 642 times, avg 28µs/call: # 642 times (13.7ms+4.40ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 326, avg 28µs/call sub _single_metaclass_can_be_made_compatible {
340 | 642 | 100µs |  |  | my $self = shift;
341 | 642 | 130µs |  |  | my ($super_meta, $metaclass_type) = @_;
342 |  |  |  |  |
343 | 642 | 1.62ms | 642 | 497µs | my $specific_meta = $self->$metaclass_type; # spent 117µs making 60 calls to Moose::Meta::Class::constructor_class, avg 2µs/call # spent 110µs making 60 calls to Moose::Meta::Class::destructor_class, avg 2µs/call # spent 68µs making 107 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 636ns/call # spent 56µs making 107 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 521ns/call # spent 56µs making 107 calls to Class::MOP::Class::instance_metaclass, avg 519ns/call # spent 53µs making 107 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 494ns/call # spent 19µs making 47 calls to Class::MOP::Class::destructor_class, avg 413ns/call # spent 18µs making 47 calls to Class::MOP::Class::constructor_class, avg 391ns/call
344 |  |  |  |  |
345 | 642 | 1.34ms | 642 | 398µs | return unless $super_meta->can($metaclass_type); # spent 398µs making 642 calls to UNIVERSAL::can, avg 619ns/call
346 | 642 | 1.21ms | 642 | 294µs | my $super_specific_meta = $super_meta->$metaclass_type; # spent 41µs making 42 calls to Moose::Meta::Class::constructor_class, avg 976ns/call # spent 41µs making 107 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 379ns/call # spent 39µs making 107 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 366ns/call # spent 38µs making 107 calls to Class::MOP::Class::instance_metaclass, avg 358ns/call # spent 37µs making 42 calls to Moose::Meta::Class::destructor_class, avg 886ns/call # spent 36µs making 107 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 336ns/call # spent 34µs making 65 calls to Class::MOP::Class::constructor_class, avg 523ns/call # spent 27µs making 65 calls to Class::MOP::Class::destructor_class, avg 420ns/call
347 |  |  |  |  |
348 |  |  |  |  | # for instance, Moose::Meta::Class has a destructor_class, but
349 |  |  |  |  | # Class::MOP::Class doesn't - this shouldn't be an error
350 | 642 | 172µs |  |  | return unless defined $super_specific_meta;
351 |  |  |  |  |
352 |  |  |  |  | # if metaclass is defined in superclass but not here, it's fixable
353 |  |  |  |  | # this is a really odd case
354 | 577 | 39µs |  |  | return 1 unless defined $specific_meta;
355 |  |  |  |  |
356 | 577 | 1.41ms | 577 | 3.21ms | return 1 if $specific_meta->_can_be_made_compatible_with($super_specific_meta); # spent 3.21ms making 577 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 6µs/call
357 |  |  |  |  | }
358 |  |  |  |  |
359 |  |  |  |  | sub _fix_class_metaclass_incompatibility {
360 |  |  |  |  | my $self = shift;
361 |  |  |  |  | my ( $super_meta ) = @_;
362 |  |  |  |  |
363 |  |  |  |  | if ($self->_class_metaclass_can_be_made_compatible($super_meta)) {
364 |  |  |  |  | ($self->is_pristine)
365 |  |  |  |  | || $self->_throw_exception( CannotFixMetaclassCompatibility => class_name => $self->name,
366 |  |  |  |  | superclass => $super_meta
367 |  |  |  |  | );
368 |  |  |  |  |
369 |  |  |  |  | my $super_meta_name = $super_meta->_real_ref_name;
370 |  |  |  |  |
371 |  |  |  |  | $self->_make_compatible_with($super_meta_name);
372 |  |  |  |  | }
373 |  |  |  |  | }
374 |  |  |  |  |
375 |  |  |  |  | sub _fix_single_metaclass_incompatibility {
376 |  |  |  |  | my $self = shift;
377 |  |  |  |  | my ( $metaclass_type, $super_meta ) = @_;
378 |  |  |  |  |
379 |  |  |  |  | if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) {
380 |  |  |  |  | ($self->is_pristine)
381 |  |  |  |  | || $self->_throw_exception( CannotFixMetaclassCompatibility => class_name => $self->name,
382 |  |  |  |  | superclass => $super_meta,
383 |  |  |  |  | metaclass_type => $metaclass_type
384 |  |  |  |  | );
385 |  |  |  |  |
386 |  |  |  |  | my $new_metaclass = $self->$metaclass_type
387 |  |  |  |  | ? $self->$metaclass_type->_get_compatible_metaclass($super_meta->$metaclass_type)
388 |  |  |  |  | : $super_meta->$metaclass_type;
389 |  |  |  |  | $self->{$metaclass_type} = $new_metaclass;
390 |  |  |  |  | }
391 |  |  |  |  | }
392 |  |  |  |  |
393 |  |  |  |  | sub _restore_metaobjects_from {
394 |  |  |  |  | my $self = shift;
395 |  |  |  |  | my ($old_meta) = @_;
396 |  |  |  |  |
397 |  |  |  |  | $self->_restore_metamethods_from($old_meta);
398 |  |  |  |  | $self->_restore_metaattributes_from($old_meta);
399 |  |  |  |  | }
400 |  |  |  |  |
401 |  |  |  |  | sub _remove_generated_metaobjects {
402 |  |  |  |  | my $self = shift;
403 |  |  |  |  |
404 |  |  |  |  | for my $attr (map { $self->get_attribute($_) } $self->get_attribute_list) {
405 |  |  |  |  | $attr->remove_accessors;
406 |  |  |  |  | }
407 |  |  |  |  | }
408 |  |  |  |  |
409 |  |  |  |  | # creating classes with MOP ...
410 |  |  |  |  |
411 |  |  |  |  | # spent 23.3ms (248µs+23.1) within Class::MOP::Class::create which was called 12 times, avg 1.94ms/call: # 10 times (204µs+21.5ms) by Moose::Meta::Class::create at line 87 of Moose/Meta/Class.pm, avg 2.17ms/call # 2 times (44µs+1.58ms) by Class::MOP::Class::_immutable_metaclass at line 1366, avg 815µs/call sub create {
412 | 12 | 5µs |  |  | my $class = shift;
413 | 12 | 9µs |  |  | my @args = @_;
414 |  |  |  |  |
415 | 12 | 11µs |  |  | unshift @args, 'package' if @args % 2 == 1;
416 | 12 | 15µs |  |  | my %options = @args;
417 |  |  |  |  |
418 | 12 | 13µs |  |  | (ref $options{superclasses} eq 'ARRAY')
419 |  |  |  |  | || __PACKAGE__->_throw_exception( CreateMOPClassTakesArrayRefOfSuperclasses => class => $class,
420 |  |  |  |  | params => \%options
421 |  |  |  |  | )
422 |  |  |  |  | if exists $options{superclasses};
423 |  |  |  |  |
424 | 12 | 7µs |  |  | (ref $options{attributes} eq 'ARRAY')
425 |  |  |  |  | || __PACKAGE__->_throw_exception( CreateMOPClassTakesArrayRefOfAttributes => class => $class,
426 |  |  |  |  | params => \%options
427 |  |  |  |  | )
428 |  |  |  |  | if exists $options{attributes};
429 |  |  |  |  |
430 | 12 | 6µs |  |  | (ref $options{methods} eq 'HASH')
431 |  |  |  |  | || __PACKAGE__->_throw_exception( CreateMOPClassTakesHashRefOfMethods => class => $class,
432 |  |  |  |  | params => \%options
433 |  |  |  |  | )
434 |  |  |  |  | if exists $options{methods};
435 |  |  |  |  |
436 | 12 | 10µs |  |  | my $package = delete $options{package};
437 | 12 | 6µs |  |  | my $superclasses = delete $options{superclasses};
438 | 12 | 5µs |  |  | my $attributes = delete $options{attributes};
439 | 12 | 7µs |  |  | my $methods = delete $options{methods};
440 | 12 | 7µs |  |  | my $meta_name = exists $options{meta_name}
441 |  |  |  |  | ? delete $options{meta_name}
442 |  |  |  |  | : 'meta';
443 |  |  |  |  |
444 | 12 | 34µs | 12 | 9.71ms | my $meta = $class->SUPER::create($package => %options); # spent 9.71ms making 12 calls to Class::MOP::Module::create, avg 809µs/call
445 |  |  |  |  |
446 | 12 | 26µs | 12 | 4.30ms | $meta->_add_meta_method($meta_name) # spent 4.30ms making 12 calls to Class::MOP::Mixin::HasMethods::_add_meta_method, avg 359µs/call
447 |  |  |  |  | if defined $meta_name;
448 |  |  |  |  |
449 | 12 | 21µs | 12 | 566µs | $meta->superclasses(@{$superclasses}) # spent 566µs making 2 calls to Class::MOP::Class::superclasses, avg 283µs/call # spent 8.51ms making 10 calls to Moose::Meta::Class::superclasses, avg 851µs/call, recursion: max depth 1, sum of overlapping time 8.51ms
450 |  |  |  |  | if defined $superclasses;
451 |  |  |  |  | # NOTE:
452 |  |  |  |  | # process attributes first, so that they can
453 |  |  |  |  | # install accessors, but locally defined methods
454 |  |  |  |  | # can then overwrite them. It is maybe a little odd, but
455 |  |  |  |  | # I think this should be the order of things.
456 | 12 | 5µs |  |  | if (defined $attributes) {
457 |  |  |  |  | foreach my $attr (@{$attributes}) {
458 |  |  |  |  | $meta->add_attribute($attr);
459 |  |  |  |  | }
460 |  |  |  |  | }
461 | 12 | 3µs |  |  | if (defined $methods) {
462 |  |  |  |  | foreach my $method_name (keys %{$methods}) {
463 |  |  |  |  | $meta->add_method($method_name, $methods->{$method_name});
464 |  |  |  |  | }
465 |  |  |  |  | }
466 | 12 | 38µs |  |  | return $meta;
467 |  |  |  |  | }
468 |  |  |  |  |
469 |  |  |  |  | # XXX: something more intelligent here?
470 |  |  |  |  | sub _anon_package_prefix { 'Class::MOP::Class::__ANON__::SERIAL::' }
471 |  |  |  |  |
472 | 132 | 444µs | 132 | 94.8ms | # spent 95.2ms (453µs+94.8) within Class::MOP::Class::create_anon_class which was called 132 times, avg 721µs/call: # 100 times (333µs+75.2ms) by Moose::Meta::Attribute::Native::Trait::_native_accessor_class_for at line 136 of Moose/Meta/Attribute/Native/Trait.pm, avg 755µs/call # 32 times (120µs+19.6ms) by Moose::Meta::Attribute::interpolate_class at line 158 of Moose/Meta/Attribute.pm, avg 617µs/call sub create_anon_class { shift->create_anon(@_) } # spent 94.8ms making 132 calls to Class::MOP::Package::create_anon, avg 718µs/call
473 |  |  |  |  | sub is_anon_class { shift->is_anon(@_) }
474 |  |  |  |  |
475 |  |  |  |  | sub _anon_cache_key {
476 |  |  |  |  | my $class = shift;
477 |  |  |  |  | my %options = @_;
478 |  |  |  |  | # Makes something like Super::Class|Super::Class::2
479 |  |  |  |  | return join '=' => (
480 |  |  |  |  | join( '|', sort @{ $options{superclasses} || [] } ),
481 |  |  |  |  | );
482 |  |  |  |  | }
483 |  |  |  |  |
484 |  |  |  |  | # Instance Construction & Cloning
485 |  |  |  |  |
486 |  |  |  |  | # spent 71.6ms (1.98+69.7) within Class::MOP::Class::new_object which was called 278 times, avg 258µs/call: # 146 times (949µs+31.9ms) by Class::MOP::Method::Accessor::_new at line 51 of Class/MOP/Method/Accessor.pm, avg 225µs/call # 73 times (579µs+10.9ms) by Moose::Meta::Method::_new at line 7 of (eval 45)[Eval/Closure.pm:144], avg 157µs/call # 32 times (235µs+22.6ms) by Moose::Meta::Class::new_object at line 274 of Moose/Meta/Class.pm, avg 713µs/call # 24 times (174µs+3.40ms) by Class::MOP::Method::_new at line 59 of Class/MOP/Method.pm, avg 149µs/call # once (14µs+458µs) by Class::MOP::Attribute::_new at line 69 of Class/MOP/Attribute.pm # once (10µs+249µs) by Moose::Meta::TypeCoercion::new at line 35 of Moose/Meta/TypeCoercion.pm # once (13µs+237µs) by Class::MOP::Object::_new at line 23 of Class/MOP/Object.pm sub new_object {
487 | 278 | 76µs |  |  | my $class = shift;
488 |  |  |  |  |
489 |  |  |  |  | # NOTE:
490 |  |  |  |  | # we need to protect the integrity of the
491 |  |  |  |  | # Class::MOP::Class singletons here, so we
492 |  |  |  |  | # delegate this to &construct_class_instance
493 |  |  |  |  | # which will deal with the singletons
494 | 278 | 1.85ms | 556 | 774µs | return $class->_construct_class_instance(@_) # spent 628µs making 278 calls to UNIVERSAL::isa, avg 2µs/call # spent 146µs making 278 calls to Class::MOP::Package::name, avg 525ns/call
495 |  |  |  |  | if $class->name->isa('Class::MOP::Class');
496 | 278 | 818µs | 278 | 68.9ms | return $class->_construct_instance(@_); # spent 68.9ms making 278 calls to Class::MOP::Class::_construct_instance, avg 248µs/call
497 |  |  |  |  | }
498 |  |  |  |  |
499 |  |  |  |  | # spent 88.4ms (14.5+73.9) within Class::MOP::Class::_construct_instance which was called 317 times, avg 279µs/call: # 278 times (8.89ms+60.0ms) by Class::MOP::Class::new_object at line 496, avg 248µs/call # 39 times (5.59ms+13.9ms) by Class::MOP::Class::_construct_class_instance at line 101, avg 499µs/call sub _construct_instance {
500 | 317 | 65µs |  |  | my $class = shift;
501 | 317 | 133µs |  |  | my $params = @_ == 1 ? $_[0] : {@_};
502 | 317 | 421µs | 317 | 3.97ms | my $meta_instance = $class->get_meta_instance(); # spent 2.85ms making 203 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 14µs/call # spent 1.12ms making 114 calls to Class::MOP::Class::get_meta_instance, avg 10µs/call
503 |  |  |  |  | # FIXME:
504 |  |  |  |  | # the code below is almost certainly incorrect
505 |  |  |  |  | # but this is foreign inheritance, so we might
506 |  |  |  |  | # have to kludge it in the end.
507 | 317 | 44µs |  |  | my $instance;
508 | 317 | 1.46ms | 317 | 345µs | if (my $instance_class = blessed($params->{__INSTANCE__})) { # spent 345µs making 317 calls to Scalar::Util::blessed, avg 1µs/call
509 |  |  |  |  | ($instance_class eq $class->name)
510 |  |  |  |  | || $class->_throw_exception( InstanceBlessedIntoWrongClass => class_name => $class->name,
511 |  |  |  |  | params => $params,
512 |  |  |  |  | instance => $params->{__INSTANCE__}
513 |  |  |  |  | );
514 |  |  |  |  | $instance = $params->{__INSTANCE__};
515 |  |  |  |  | }
516 |  |  |  |  | elsif (exists $params->{__INSTANCE__}) {
517 |  |  |  |  | $class->_throw_exception( InstanceMustBeABlessedReference => class_name => $class->name,
518 |  |  |  |  | params => $params,
519 |  |  |  |  | instance => $params->{__INSTANCE__}
520 |  |  |  |  | );
521 |  |  |  |  | }
522 |  |  |  |  | else {
523 | 317 | 523µs | 317 | 1.74ms | $instance = $meta_instance->create_instance(); # spent 1.74ms making 317 calls to Class::MOP::Instance::create_instance, avg 5µs/call
524 |  |  |  |  | }
525 | 317 | 698µs | 317 | 13.5ms | foreach my $attr ($class->get_all_attributes()) { # spent 10.8ms making 114 calls to Class::MOP::Class::get_all_attributes, avg 95µs/call # spent 2.76ms making 203 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 14µs/call
526 | 3462 | 3.46ms | 3462 | 53.0ms | $attr->initialize_instance_slot($meta_instance, $instance, $params); # spent 52.6ms making 3429 calls to Class::MOP::Attribute::initialize_instance_slot, avg 15µs/call # spent 439µs making 33 calls to Moose::Meta::Attribute::initialize_instance_slot, avg 13µs/call
527 |  |  |  |  | }
528 | 317 | 1.01ms | 634 | 1.25ms | if (Class::MOP::metaclass_is_weak($class->name)) { # spent 1.10ms making 317 calls to Class::MOP::metaclass_is_weak, avg 3µs/call # spent 148µs making 317 calls to Class::MOP::Package::name, avg 465ns/call
529 |  |  |  |  | $meta_instance->_set_mop_slot($instance, $class);
530 |  |  |  |  | }
531 | 317 | 649µs |  |  | return $instance;
532 |  |  |  |  | }
533 |  |  |  |  |
534 |  |  |  |  | # spent 114ms (807µs+113) within Class::MOP::Class::_inline_new_object which was called 58 times, avg 1.96ms/call: # 58 times (807µs+113ms) by Class::MOP::Method::Constructor::_generate_constructor_method_inline at line 98 of Class/MOP/Method/Constructor.pm, avg 1.96ms/call sub _inline_new_object {
535 | 58 | 13µs |  |  | my $self = shift;
536 |  |  |  |  |
537 |  |  |  |  | return (
538 | 58 | 592µs | 348 | 113ms | 'my $class = shift;', # spent 91.3ms making 58 calls to Class::MOP::Class::_inline_slot_initializers, avg 1.57ms/call # spent 10.9ms making 28 calls to Moose::Meta::Class::_inline_extra_init, avg 389µs/call # spent 5.25ms making 58 calls to Class::MOP::Class::_inline_preserve_weak_metaclasses, avg 90µs/call # spent 2.96ms making 28 calls to Moose::Meta::Class::_inline_params, avg 106µs/call # spent 1.96ms making 58 calls to Class::MOP::Class::_inline_generate_instance, avg 34µs/call # spent 546µs making 58 calls to Class::MOP::Class::_inline_fallback_constructor, avg 9µs/call # spent 56µs making 30 calls to Class::MOP::Class::_inline_params, avg 2µs/call # spent 18µs making 30 calls to Class::MOP::Class::_inline_extra_init, avg 617ns/call
539 |  |  |  |  | '$class = Scalar::Util::blessed($class) || $class;',
540 |  |  |  |  | $self->_inline_fallback_constructor('$class'),
541 |  |  |  |  | $self->_inline_params('$params', '$class'),
542 |  |  |  |  | $self->_inline_generate_instance('$instance', '$class'),
543 |  |  |  |  | $self->_inline_slot_initializers,
544 |  |  |  |  | $self->_inline_preserve_weak_metaclasses,
545 |  |  |  |  | $self->_inline_extra_init,
546 |  |  |  |  | 'return $instance',
547 |  |  |  |  | );
548 |  |  |  |  | }
549 |  |  |  |  |
550 |  |  |  |  | # spent 546µs (398+149) within Class::MOP::Class::_inline_fallback_constructor which was called 58 times, avg 9µs/call: # 58 times (398µs+149µs) by Class::MOP::Class::_inline_new_object at line 538, avg 9µs/call sub _inline_fallback_constructor {
551 | 58 | 16µs |  |  | my $self = shift;
552 | 58 | 25µs |  |  | my ($class) = @_;
553 |  |  |  |  | return (
554 | 58 | 367µs | 116 | 148µs | 'return ' . $self->_generate_fallback_constructor($class), # spent 74µs making 28 calls to Moose::Meta::Class::_generate_fallback_constructor, avg 3µs/call # spent 48µs making 30 calls to Class::MOP::Class::_generate_fallback_constructor, avg 2µs/call # spent 26µs making 58 calls to Class::MOP::Package::name, avg 452ns/call
555 |  |  |  |  | 'if ' . $class . ' ne \'' . $self->name . '\';',
556 |  |  |  |  | );
557 |  |  |  |  | }
558 |  |  |  |  |
559 |  |  |  |  | # spent 48µs within Class::MOP::Class::_generate_fallback_constructor which was called 30 times, avg 2µs/call: # 30 times (48µs+0s) by Class::MOP::Class::_inline_fallback_constructor at line 554, avg 2µs/call sub _generate_fallback_constructor {
560 | 30 | 4µs |  |  | my $self = shift;
561 | 30 | 7µs |  |  | my ($class) = @_;
562 | 30 | 63µs |  |  | return 'Class::MOP::Class->initialize(' . $class . ')->new_object(@_)',
563 |  |  |  |  | }
564 |  |  |  |  |
565 |  |  |  |  | # spent 56µs within Class::MOP::Class::_inline_params which was called 30 times, avg 2µs/call: # 30 times (56µs+0s) by Class::MOP::Class::_inline_new_object at line 538, avg 2µs/call sub _inline_params {
566 | 30 | 7µs |  |  | my $self = shift;
567 | 30 | 10µs |  |  | my ($params, $class) = @_;
568 |  |  |  |  | return (
569 | 30 | 63µs |  |  | 'my ' . $params . ' = @_ == 1 ? $_[0] : {@_};',
570 |  |  |  |  | );
571 |  |  |  |  | }
572 |  |  |  |  |
573 |  |  |  |  | # spent 1.96ms (250µs+1.71) within Class::MOP::Class::_inline_generate_instance which was called 58 times, avg 34µs/call: # 58 times (250µs+1.71ms) by Class::MOP::Class::_inline_new_object at line 538, avg 34µs/call sub _inline_generate_instance {
574 | 58 | 14µs |  |  | my $self = shift;
575 | 58 | 25µs |  |  | my ($inst, $class) = @_;
576 |  |  |  |  | return (
577 | 58 | 202µs | 58 | 1.71ms | 'my ' . $inst . ' = ' . $self->_inline_create_instance($class) . ';', # spent 1.71ms making 58 calls to Class::MOP::Class::_inline_create_instance, avg 29µs/call
578 |  |  |  |  | );
579 |  |  |  |  | }
580 |  |  |  |  |
581 |  |  |  |  | # spent 1.71ms (273µs+1.43) within Class::MOP::Class::_inline_create_instance which was called 58 times, avg 29µs/call: # 58 times (273µs+1.43ms) by Class::MOP::Class::_inline_generate_instance at line 577, avg 29µs/call sub _inline_create_instance {
582 | 58 | 10µs |  |  | my $self = shift;
583 |  |  |  |  |
584 | 58 | 224µs | 116 | 1.43ms | return $self->get_meta_instance->inline_create_instance(@_); # spent 1.31ms making 58 calls to Class::MOP::Class::get_meta_instance, avg 23µs/call # spent 118µs making 58 calls to Class::MOP::Instance::inline_create_instance, avg 2µs/call
585 |  |  |  |  | }
586 |  |  |  |  |
587 |  |  |  |  | # spent 91.3ms (1.28+90.0) within Class::MOP::Class::_inline_slot_initializers which was called 58 times, avg 1.57ms/call: # 58 times (1.28ms+90.0ms) by Class::MOP::Class::_inline_new_object at line 538, avg 1.57ms/call sub _inline_slot_initializers {
588 | 58 | 16µs |  |  | my $self = shift;
589 |  |  |  |  |
590 | 58 | 14µs |  |  | my $idx = 0;
591 |  |  |  |  |
592 | 1581 | 3.68ms | 2694 | 85.2ms | return map { $self->_inline_slot_initializer($_, $idx++) } # spent 50.2ms making 186 calls to Moose::Meta::Class::_inline_slot_initializer, avg 270µs/call # spent 34.5ms making 282 calls to Class::MOP::Class::_inline_slot_initializer, avg 122µs/call # spent 536µs making 2226 calls to Class::MOP::Mixin::AttributeCore::name, avg 241ns/call
593 | 58 | 446µs | 116 | 5.37ms | sort { $a->name cmp $b->name } $self->get_all_attributes; # spent 3.22ms making 58 calls to Class::MOP::Class::CORE:sort, avg 55µs/call # spent 2.15ms making 58 calls to Class::MOP::Class::get_all_attributes, avg 37µs/call
594 |  |  |  |  | }
595 |  |  |  |  |
596 |  |  |  |  | # spent 81.1ms (3.89+77.2) within Class::MOP::Class::_inline_slot_initializer which was called 468 times, avg 173µs/call: # 282 times (2.10ms+32.4ms) by Class::MOP::Class::_inline_slot_initializers at line 592, avg 122µs/call # 186 times (1.79ms+44.8ms) by Moose::Meta::Class::_inline_slot_initializer at line 365 of Moose/Meta/Class.pm, avg 250µs/call sub _inline_slot_initializer {
597 | 468 | 74µs |  |  | my $self = shift;
598 | 468 | 101µs |  |  | my ($attr, $idx) = @_;
599 |  |  |  |  |
600 | 468 | 1.06ms | 496 | 1.63ms | if (defined(my $init_arg = $attr->init_arg)) { # spent 918µs making 17 calls to Moose::Meta::Class::_inline_init_attr_from_default, avg 54µs/call # spent 537µs making 11 calls to Class::MOP::Class::_inline_init_attr_from_default, avg 49µs/call # spent 174µs making 468 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 372ns/call
601 | 440 | 656µs | 440 | 59.2ms | my @source = ( # spent 34.7ms making 169 calls to Moose::Meta::Class::_inline_init_attr_from_constructor, avg 205µs/call # spent 24.5ms making 271 calls to Class::MOP::Class::_inline_init_attr_from_constructor, avg 90µs/call
602 |  |  |  |  | 'if (exists $params->{\'' . $init_arg . '\'}) {',
603 |  |  |  |  | $self->_inline_init_attr_from_constructor($attr, $idx),
604 |  |  |  |  | '}',
605 |  |  |  |  | );
606 | 440 | 586µs | 440 | 16.4ms | if (my @default = $self->_inline_init_attr_from_default($attr, $idx)) { # spent 9.09ms making 169 calls to Moose::Meta::Class::_inline_init_attr_from_default, avg 54µs/call # spent 7.27ms making 271 calls to Class::MOP::Class::_inline_init_attr_from_default, avg 27µs/call
607 |  |  |  |  | push @source, (
608 |  |  |  |  | 'else {',
609 |  |  |  |  | @default,
610 |  |  |  |  | '}',
611 |  |  |  |  | );
612 |  |  |  |  | }
613 | 440 | 1.18ms |  |  | return @source;
614 |  |  |  |  | }
615 |  |  |  |  | elsif (my @default = $self->_inline_init_attr_from_default($attr, $idx)) {
616 |  |  |  |  | return (
617 |  |  |  |  | '{',
618 |  |  |  |  | @default,
619 |  |  |  |  | '}',
620 |  |  |  |  | );
621 |  |  |  |  | }
622 |  |  |  |  | else {
623 | 13 | 24µs |  |  | return ();
624 |  |  |  |  | }
625 |  |  |  |  | }
626 |  |  |  |  |
627 |  |  |  |  | # spent 24.5ms (9.34+15.1) within Class::MOP::Class::_inline_init_attr_from_constructor which was called 271 times, avg 90µs/call: # 271 times (9.34ms+15.1ms) by Class::MOP::Class::_inline_slot_initializer at line 601, avg 90µs/call sub _inline_init_attr_from_constructor {
628 | 271 | 34µs |  |  | my $self = shift;
629 | 271 | 39µs |  |  | my ($attr, $idx) = @_;
630 |  |  |  |  |
631 | 271 | 725µs | 542 | 14.9ms | my @initial_value = $attr->_inline_set_value( # spent 14.3ms making 269 calls to Class::MOP::Attribute::_inline_set_value, avg 53µs/call # spent 552µs making 2 calls to Moose::Meta::Attribute::_inline_set_value, avg 276µs/call # spent 60µs making 271 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 220ns/call
632 |  |  |  |  | '$instance', '$params->{\'' . $attr->init_arg . '\'}',
633 |  |  |  |  | );
634 |  |  |  |  |
635 | 271 | 219µs | 271 | 251µs | push @initial_value, ( # spent 251µs making 271 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 928ns/call
636 |  |  |  |  | '$attrs->[' . $idx . ']->set_initial_value(',
637 |  |  |  |  | '$instance,',
638 |  |  |  |  | $attr->_inline_instance_get('$instance'),
639 |  |  |  |  | ');',
640 |  |  |  |  | ) if $attr->has_initializer;
641 |  |  |  |  |
642 | 271 | 494µs |  |  | return @initial_value;
643 |  |  |  |  | }
644 |  |  |  |  |
645 |  |  |  |  | # spent 7.81ms (1.09+6.71) within Class::MOP::Class::_inline_init_attr_from_default which was called 282 times, avg 28µs/call: # 271 times (1.03ms+6.24ms) by Class::MOP::Class::_inline_slot_initializer at line 606, avg 27µs/call # 11 times (63µs+475µs) by Class::MOP::Class::_inline_slot_initializer at line 600, avg 49µs/call sub _inline_init_attr_from_default {
646 | 282 | 47µs |  |  | my $self = shift;
647 | 282 | 48µs |  |  | my ($attr, $idx) = @_;
648 |  |  |  |  |
649 | 282 | 179µs | 282 | 1.61ms | my $default = $self->_inline_default_value($attr, $idx); # spent 1.61ms making 282 calls to Class::MOP::Class::_inline_default_value, avg 6µs/call
650 | 282 | 248µs |  |  | return unless $default;
651 |  |  |  |  |
652 | 99 | 118µs | 99 | 5.03ms | my @initial_value = $attr->_inline_set_value('$instance', $default); # spent 5.03ms making 99 calls to Class::MOP::Attribute::_inline_set_value, avg 51µs/call
653 |  |  |  |  |
654 | 99 | 75µs | 99 | 78µs | push @initial_value, ( # spent 78µs making 99 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 792ns/call
655 |  |  |  |  | '$attrs->[' . $idx . ']->set_initial_value(',
656 |  |  |  |  | '$instance,',
657 |  |  |  |  | $attr->_inline_instance_get('$instance'),
658 |  |  |  |  | ');',
659 |  |  |  |  | ) if $attr->has_initializer;
660 |  |  |  |  |
661 | 99 | 185µs |  |  | return @initial_value;
662 |  |  |  |  | }
663 |  |  |  |  |
664 |  |  |  |  | # spent 2.79ms (1.90+889µs) within Class::MOP::Class::_inline_default_value which was called 453 times, avg 6µs/call: # 282 times (1.08ms+526µs) by Class::MOP::Class::_inline_init_attr_from_default at line 649, avg 6µs/call # 171 times (819µs+363µs) by Moose::Meta::Class::_inline_init_attr_from_default at line 422 of Moose/Meta/Class.pm, avg 7µs/call sub _inline_default_value {
665 | 453 | 55µs |  |  | my $self = shift;
666 | 453 | 72µs |  |  | my ($attr, $index) = @_;
667 |  |  |  |  |
668 | 453 | 886µs | 907 | 889µs | if ($attr->has_default) { # spent 343µs making 453 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 757ns/call # spent 330µs making 168 calls to Class::MOP::Mixin::AttributeCore::is_default_a_coderef, avg 2µs/call # spent 215µs making 285 calls to Class::MOP::Mixin::AttributeCore::has_builder, avg 755ns/call # spent 600ns making 1 call to Class::MOP::Mixin::AttributeCore::builder
669 |  |  |  |  | # NOTE:
670 |  |  |  |  | # default values can either be CODE refs
671 |  |  |  |  | # in which case we need to call them. Or
672 |  |  |  |  | # they can be scalars (strings/numbers)
673 |  |  |  |  | # in which case we can just deal with them
674 |  |  |  |  | # in the code we eval.
675 |  |  |  |  | if ($attr->is_default_a_coderef) {
676 |  |  |  |  | return '$defaults->[' . $index . ']->($instance)';
677 |  |  |  |  | }
678 |  |  |  |  | else {
679 | 30 | 55µs |  |  | return '$defaults->[' . $index . ']';
680 |  |  |  |  | }
681 |  |  |  |  | }
682 |  |  |  |  | elsif ($attr->has_builder) {
683 |  |  |  |  | return '$instance->' . $attr->builder;
684 |  |  |  |  | }
685 |  |  |  |  | else {
686 | 284 | 410µs |  |  | return;
687 |  |  |  |  | }
688 |  |  |  |  | }
689 |  |  |  |  |
690 |  |  |  |  | # spent 5.25ms (4.99+259µs) within Class::MOP::Class::_inline_preserve_weak_metaclasses which was called 58 times, avg 90µs/call: # 58 times (4.99ms+259µs) by Class::MOP::Class::_inline_new_object at line 538, avg 90µs/call sub _inline_preserve_weak_metaclasses {
691 | 58 | 17µs |  |  | my $self = shift;
692 | 58 | 220µs | 116 | 259µs | if (Class::MOP::metaclass_is_weak($self->name)) { # spent 229µs making 58 calls to Class::MOP::metaclass_is_weak, avg 4µs/call # spent 30µs making 58 calls to Class::MOP::Package::name, avg 519ns/call
693 |  |  |  |  | return (
694 |  |  |  |  | $self->_inline_set_mop_slot(
695 |  |  |  |  | '$instance', 'Class::MOP::class_of($class)'
696 |  |  |  |  | ) . ';'
697 |  |  |  |  | );
698 |  |  |  |  | }
699 |  |  |  |  | else {
700 | 58 | 113µs |  |  | return ();
701 |  |  |  |  | }
702 |  |  |  |  | }
703 |  |  |  |  |
704 | 30 | 37µs |  |  | # spent 18µs within Class::MOP::Class::_inline_extra_init which was called 30 times, avg 617ns/call: # 30 times (18µs+0s) by Class::MOP::Class::_inline_new_object at line 538, avg 617ns/call sub _inline_extra_init { }
705 |  |  |  |  |
706 |  |  |  |  | # spent 14.1ms (1.28+12.9) within Class::MOP::Class::_eval_environment which was called 58 times, avg 244µs/call: # 30 times (702µs+7.66ms) by Class::MOP::Method::Constructor::_eval_environment at line 86 of Class/MOP/Method/Constructor.pm, avg 279µs/call # 28 times (576µs+5.21ms) by Moose::Meta::Class::_eval_environment at line 542 of Moose/Meta/Class.pm, avg 207µs/call sub _eval_environment {
707 | 58 | 19µs |  |  | my $self = shift;
708 |  |  |  |  |
709 | 1199 | 10.6ms | 2398 | 13.0ms | my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes; # spent 10.4ms making 58 calls to Class::MOP::Class::CORE:sort, avg 179µs/call # spent 2.04ms making 58 calls to Class::MOP::Class::get_all_attributes, avg 35µs/call # spent 531µs making 2282 calls to Class::MOP::Mixin::AttributeCore::name, avg 233ns/call
710 |  |  |  |  |
711 | 526 | 503µs | 468 | 416µs | my $defaults = [map { $_->default } @attrs]; # spent 416µs making 468 calls to Class::MOP::Mixin::AttributeCore::default, avg 889ns/call
712 |  |  |  |  |
713 |  |  |  |  | return {
714 | 58 | 189µs |  |  | '$defaults' => \$defaults,
715 |  |  |  |  | };
716 |  |  |  |  | }
717 |  |  |  |  |
718 |  |  |  |  |
719 |  |  |  |  | # spent 24.1ms (1.32+22.7) within Class::MOP::Class::get_meta_instance which was called 848 times, avg 28µs/call: # 315 times (327µs+934µs) by Class::MOP::Attribute::_inline_instance_set at line 301 of Class/MOP/Attribute.pm, avg 4µs/call # 236 times (525µs+18.2ms) by Class::MOP::Attribute::_inline_instance_get at line 324 of Class/MOP/Attribute.pm, avg 80µs/call # 114 times (228µs+897µs) by Class::MOP::Class::_construct_instance at line 502, avg 10µs/call # 87 times (99µs+0s) by Class::MOP::Attribute::_inline_instance_has at line 345 of Class/MOP/Attribute.pm, avg 1µs/call # 58 times (86µs+1.23ms) by Class::MOP::Class::_inline_create_instance at line 584, avg 23µs/call # 24 times (44µs+1.34ms) by Class::MOP::Class:::around at line 77 of Class/MOP/Class/Immutable/Trait.pm, avg 57µs/call # 8 times (6µs+0s) by Moose::Meta::Attribute::_inline_weaken_value at line 737 of Moose/Meta/Attribute.pm, avg 762ns/call # 3 times (2µs+0s) by Class::MOP::Attribute::has_value at line 332 of Class/MOP/Attribute.pm, avg 833ns/call # 2 times (2µs+0s) by Class::MOP::Attribute::get_raw_value at line 311 of Class/MOP/Attribute.pm, avg 950ns/call # once (3µs+104µs) by Moose::Exporter::BEGIN@8 at line 733 of Class/MOP.pm sub get_meta_instance {
720 | 848 | 165µs |  |  | my $self = shift;
721 | 848 | 4.75ms | 160 | 22.7ms | $self->{'_meta_instance'} ||= $self->_create_meta_instance(); # spent 22.7ms making 160 calls to Class::MOP::Class::_create_meta_instance, avg 142µs/call
722 |  |  |  |  | }
723 |  |  |  |  |
724 |  |  |  |  | # spent 22.7ms (1.65+21.1) within Class::MOP::Class::_create_meta_instance which was called 160 times, avg 142µs/call: # 160 times (1.65ms+21.1ms) by Class::MOP::Class::get_meta_instance at line 721, avg 142µs/call sub _create_meta_instance {
725 | 160 | 39µs |  |  | my $self = shift;
726 |  |  |  |  |
727 | 160 | 914µs | 480 | 20.9ms | my $instance = $self->instance_metaclass->new( # spent 14.7ms making 160 calls to Class::MOP::Instance::new, avg 92µs/call # spent 5.55ms making 148 calls to Class::MOP::Class::get_all_attributes, avg 38µs/call # spent 669µs making 12 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 56µs/call # spent 56µs making 160 calls to Class::MOP::Class::instance_metaclass, avg 351ns/call
728 |  |  |  |  | associated_metaclass => $self,
729 |  |  |  |  | attributes => [ $self->get_all_attributes() ],
730 |  |  |  |  | );
731 |  |  |  |  |
732 | 160 | 272µs | 160 | 154µs | $self->add_meta_instance_dependencies() # spent 154µs making 160 calls to Class::MOP::Instance::is_dependent_on_superclasses, avg 966ns/call
733 |  |  |  |  | if $instance->is_dependent_on_superclasses();
734 |  |  |  |  |
735 | 160 | 266µs |  |  | return $instance;
736 |  |  |  |  | }
737 |  |  |  |  |
738 |  |  |  |  | # TODO: this is actually not being used!
739 |  |  |  |  | sub _inline_rebless_instance {
740 |  |  |  |  | my $self = shift;
741 |  |  |  |  |
742 |  |  |  |  | return $self->get_meta_instance->inline_rebless_instance_structure(@_);
743 |  |  |  |  | }
744 |  |  |  |  |
745 |  |  |  |  | sub _inline_get_mop_slot {
746 |  |  |  |  | my $self = shift;
747 |  |  |  |  |
748 |  |  |  |  | return $self->get_meta_instance->_inline_get_mop_slot(@_);
749 |  |  |  |  | }
750 |  |  |  |  |
751 |  |  |  |  | sub _inline_set_mop_slot {
752 |  |  |  |  | my $self = shift;
753 |  |  |  |  |
754 |  |  |  |  | return $self->get_meta_instance->_inline_set_mop_slot(@_);
755 |  |  |  |  | }
756 |  |  |  |  |
757 |  |  |  |  | sub _inline_clear_mop_slot {
758 |  |  |  |  | my $self = shift;
759 |  |  |  |  |
760 |  |  |  |  | return $self->get_meta_instance->_inline_clear_mop_slot(@_);
761 |  |  |  |  | }
762 |  |  |  |  |
763 |  |  |  |  | sub clone_object {
764 |  |  |  |  | my $class = shift;
765 |  |  |  |  | my $instance = shift;
766 |  |  |  |  | (blessed($instance) && $instance->isa($class->name))
767 |  |  |  |  | || $class->_throw_exception( CloneObjectExpectsAnInstanceOfMetaclass => class_name => $class->name,
768 |  |  |  |  | instance => $instance,
769 |  |  |  |  | );
770 |  |  |  |  | # NOTE:
771 |  |  |  |  | # we need to protect the integrity of the
772 |  |  |  |  | # Class::MOP::Class singletons here, they
773 |  |  |  |  | # should not be cloned.
774 |  |  |  |  | return $instance if $instance->isa('Class::MOP::Class');
775 |  |  |  |  | $class->_clone_instance($instance, @_);
776 |  |  |  |  | }
777 |  |  |  |  |
778 |  |  |  |  | sub _clone_instance {
779 |  |  |  |  | my ($class, $instance, %params) = @_;
780 |  |  |  |  | (blessed($instance))
781 |  |  |  |  | || $class->_throw_exception( OnlyInstancesCanBeCloned => class_name => $class->name,
782 |  |  |  |  | instance => $instance,
783 |  |  |  |  | params => \%params
784 |  |  |  |  | );
785 |  |  |  |  | my $meta_instance = $class->get_meta_instance();
786 |  |  |  |  | my $clone = $meta_instance->clone_instance($instance);
787 |  |  |  |  | foreach my $attr ($class->get_all_attributes()) {
788 |  |  |  |  | if ( defined( my $init_arg = $attr->init_arg ) ) {
789 |  |  |  |  | if (exists $params{$init_arg}) {
790 |  |  |  |  | $attr->set_value($clone, $params{$init_arg});
791 |  |  |  |  | }
792 |  |  |  |  | }
793 |  |  |  |  | }
794 |  |  |  |  | return $clone;
795 |  |  |  |  | }
796 |  |  |  |  |
797 |  |  |  |  | sub _force_rebless_instance {
798 |  |  |  |  | my ($self, $instance, %params) = @_;
799 |  |  |  |  | my $old_metaclass = Class::MOP::class_of($instance);
800 |  |  |  |  |
801 |  |  |  |  | $old_metaclass->rebless_instance_away($instance, $self, %params)
802 |  |  |  |  | if $old_metaclass;
803 |  |  |  |  |
804 |  |  |  |  | my $meta_instance = $self->get_meta_instance;
805 |  |  |  |  |
806 |  |  |  |  | if (Class::MOP::metaclass_is_weak($old_metaclass->name)) {
807 |  |  |  |  | $meta_instance->_clear_mop_slot($instance);
808 |  |  |  |  | }
809 |  |  |  |  |
810 |  |  |  |  | # rebless!
811 |  |  |  |  | # we use $_[1] here because of t/cmop/rebless_overload.t regressions
812 |  |  |  |  | # on 5.8.8
813 |  |  |  |  | $meta_instance->rebless_instance_structure($_[1], $self);
814 |  |  |  |  |
815 |  |  |  |  | $self->_fixup_attributes_after_rebless($instance, $old_metaclass, %params);
816 |  |  |  |  |
817 |  |  |  |  | if (Class::MOP::metaclass_is_weak($self->name)) {
818 |  |  |  |  | $meta_instance->_set_mop_slot($instance, $self);
819 |  |  |  |  | }
820 |  |  |  |  | }
821 |  |  |  |  |
822 |  |  |  |  | sub rebless_instance {
823 |  |  |  |  | my ($self, $instance, %params) = @_;
824 |  |  |  |  | my $old_metaclass = Class::MOP::class_of($instance);
825 |  |  |  |  |
826 |  |  |  |  | my $old_class = $old_metaclass ? $old_metaclass->name : blessed($instance);
827 |  |  |  |  | $self->name->isa($old_class)
828 |  |  |  |  | || $self->_throw_exception( CanReblessOnlyIntoASubclass => class_name => $self->name,
829 |  |  |  |  | instance => $instance,
830 |  |  |  |  | instance_class => blessed( $instance ),
831 |  |  |  |  | params => \%params,
832 |  |  |  |  | );
833 |  |  |  |  |
834 |  |  |  |  | $self->_force_rebless_instance($_[1], %params);
835 |  |  |  |  |
836 |  |  |  |  | return $instance;
837 |  |  |  |  | }
838 |  |  |  |  |
839 |  |  |  |  | sub rebless_instance_back {
840 |  |  |  |  | my ( $self, $instance ) = @_;
841 |  |  |  |  | my $old_metaclass = Class::MOP::class_of($instance);
842 |  |  |  |  | my $old_class
843 |  |  |  |  | = $old_metaclass ? $old_metaclass->name : blessed($instance);
844 |  |  |  |  | $old_class->isa( $self->name )
845 |  |  |  |  | || $self->_throw_exception( CanReblessOnlyIntoASuperclass => class_name => $self->name,
846 |  |  |  |  | instance => $instance,
847 |  |  |  |  | instance_class => blessed( $instance ),
848 |  |  |  |  | );
849 |  |  |  |  |
850 |  |  |  |  | $self->_force_rebless_instance($_[1]);
851 |  |  |  |  |
852 |  |  |  |  | return $instance;
853 |  |  |  |  | }
854 |  |  |  |  |
855 |  |  |  |  | sub rebless_instance_away {
856 |  |  |  |  | # this intentionally does nothing, it is just a hook
857 |  |  |  |  | }
858 |  |  |  |  |
859 |  |  |  |  | sub _fixup_attributes_after_rebless {
860 |  |  |  |  | my $self = shift;
861 |  |  |  |  | my ($instance, $rebless_from, %params) = @_;
862 |  |  |  |  | my $meta_instance = $self->get_meta_instance;
863 |  |  |  |  |
864 |  |  |  |  | for my $attr ( $rebless_from->get_all_attributes ) {
865 |  |  |  |  | next if $self->find_attribute_by_name( $attr->name );
866 |  |  |  |  | $meta_instance->deinitialize_slot( $instance, $_ ) for $attr->slots;
867 |  |  |  |  | }
868 |  |  |  |  |
869 |  |  |  |  | foreach my $attr ( $self->get_all_attributes ) {
870 |  |  |  |  | if ( $attr->has_value($instance) ) {
871 |  |  |  |  | if ( defined( my $init_arg = $attr->init_arg ) ) {
872 |  |  |  |  | $params{$init_arg} = $attr->get_value($instance)
873 |  |  |  |  | unless exists $params{$init_arg};
874 |  |  |  |  | }
875 |  |  |  |  | else {
876 |  |  |  |  | $attr->set_value($instance, $attr->get_value($instance));
877 |  |  |  |  | }
878 |  |  |  |  | }
879 |  |  |  |  | }
880 |  |  |  |  |
881 |  |  |  |  | foreach my $attr ($self->get_all_attributes) {
882 |  |  |  |  | $attr->initialize_instance_slot($meta_instance, $instance, \%params);
883 |  |  |  |  | }
884 |  |  |  |  | }
885 |  |  |  |  |
886 |  |  |  |  | # spent 2.62ms (646µs+1.97) within Class::MOP::Class::_attach_attribute which was called 240 times, avg 11µs/call: # 240 times (646µs+1.97ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 22 of Class/MOP/Mixin/HasAttributes.pm, avg 11µs/call sub _attach_attribute {
887 | 240 | 65µs |  |  | my ($self, $attribute) = @_;
888 | 240 | 613µs | 240 | 1.97ms | $attribute->attach_to_class($self); # spent 1.97ms making 240 calls to Class::MOP::Attribute::attach_to_class, avg 8µs/call
889 |  |  |  |  | }
890 |  |  |  |  |
891 |  |  |  |  | # spent 537ms (6.09+531) within Class::MOP::Class::_post_add_attribute which was called 240 times, avg 2.24ms/call: # 240 times (6.09ms+531ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 39 of Class/MOP/Mixin/HasAttributes.pm, avg 2.24ms/call sub _post_add_attribute {
892 | 240 | 62µs |  |  | my ( $self, $attribute ) = @_;
893 |  |  |  |  |
894 | 240 | 285µs | 240 | 1.54ms | $self->invalidate_meta_instances; # spent 1.54ms making 240 calls to Class::MOP::Class::invalidate_meta_instances, avg 6µs/call
895 |  |  |  |  |
896 |  |  |  |  | # invalidate package flag here
897 |  |  |  |  | try {
898 | 240 | 382µs |  |  | local $SIG{__DIE__};
899 | 240 | 780µs | 240 | 524ms | $attribute->install_accessors; # spent 218ms making 21 calls to Moose::Meta::Class::__ANON__::SERIAL::1::install_accessors, avg 10.4ms/call # spent 154ms making 78 calls to Moose::Meta::Attribute::install_accessors, avg 1.97ms/call # spent 117ms making 11 calls to Moose::Meta::Class::__ANON__::SERIAL::7::install_accessors, avg 10.6ms/call # spent 35.4ms making 130 calls to Class::MOP::Attribute::install_accessors, avg 273µs/call
900 |  |  |  |  | }
901 |  |  |  |  | catch {
902 |  |  |  |  | $self->remove_attribute( $attribute->name );
903 |  |  |  |  | die $_;
904 | 240 | 1.56ms | 480 | 530ms | }; # spent 529ms making 240 calls to Try::Tiny::try, avg 2.20ms/call # spent 658µs making 240 calls to Try::Tiny::catch, avg 3µs/call
905 |  |  |  |  | }
906 |  |  |  |  |
907 |  |  |  |  | # spent 279µs (44+235) within Class::MOP::Class::remove_attribute which was called: # once (44µs+235µs) by Class::MOP::Mixin::HasAttributes::add_attribute at line 26 of Class/MOP/Mixin/HasAttributes.pm sub remove_attribute {
908 | 1 | 400ns |  |  | my $self = shift;
909 |  |  |  |  |
910 | 1 | 7µs | 1 | 10µs | my $removed_attribute = $self->SUPER::remove_attribute(@_) # spent 10µs making 1 call to Class::MOP::Mixin::HasAttributes::remove_attribute
911 |  |  |  |  | or return;
912 |  |  |  |  |
913 | 1 | 2µs | 1 | 11µs | $self->invalidate_meta_instances; # spent 11µs making 1 call to Class::MOP::Class::invalidate_meta_instances
914 |  |  |  |  |
915 | 1 | 2µs | 1 | 212µs | $removed_attribute->remove_accessors; # spent 212µs making 1 call to Moose::Meta::Attribute::remove_accessors
916 | 1 | 4µs | 1 | 2µs | $removed_attribute->detach_from_class; # spent 2µs making 1 call to Class::MOP::Attribute::detach_from_class
917 |  |  |  |  |
918 | 1 | 21µs |  |  | return$removed_attribute;
919 |  |  |  |  | }
920 |  |  |  |  |
921 |  |  |  |  | # spent 2.84ms (785µs+2.06) within Class::MOP::Class::find_attribute_by_name which was called 83 times, avg 34µs/call: # 82 times (765µs+2.03ms) by Class::MOP::Class::_immutable_metaclass at line 1343, avg 34µs/call # once (20µs+26µs) by Moose::Meta::Class::_process_inherited_attribute at line 718 of Moose/Meta/Class.pm sub find_attribute_by_name {
922 | 83 | 35µs |  |  | my ( $self, $attr_name ) = @_;
923 |  |  |  |  |
924 | 83 | 117µs | 83 | 1.11ms | foreach my $class ( $self->linearized_isa ) { # spent 1.08ms making 78 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 14µs/call # spent 28µs making 5 calls to Class::MOP::Class::linearized_isa, avg 6µs/call
925 |  |  |  |  | # fetch the meta-class ...
926 | 83 | 101µs | 83 | 262µs | my $meta = Class::MOP::Class->initialize($class); # spent 262µs making 83 calls to Class::MOP::Class::initialize, avg 3µs/call
927 | 83 | 366µs | 166 | 686µs | return $meta->get_attribute($attr_name) # spent 383µs making 83 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 5µs/call # spent 303µs making 83 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 4µs/call
928 |  |  |  |  | if $meta->has_attribute($attr_name);
929 |  |  |  |  | }
930 |  |  |  |  |
931 |  |  |  |  | return;
932 |  |  |  |  | }
933 |  |  |  |  |
934 |  |  |  |  | # spent 27.8ms (16.6+11.2) within Class::MOP::Class::get_all_attributes which was called 516 times, avg 54µs/call: # 148 times (2.85ms+2.70ms) by Class::MOP::Class::_create_meta_instance at line 727, avg 38µs/call # 114 times (7.70ms+3.09ms) by Class::MOP::Class::_construct_instance at line 525, avg 95µs/call # 58 times (1.15ms+1.00ms) by Class::MOP::Class::_inline_slot_initializers at line 593, avg 37µs/call # 58 times (1.01ms+1.04ms) by Class::MOP::Class::_eval_environment at line 709, avg 35µs/call # 33 times (1.51ms+1.13ms) by Moose::Meta::Attribute::new at line 58 of Moose/Meta/Attribute.pm, avg 80µs/call # 32 times (1.12ms+878µs) by Moose::Meta::Class::_call_all_triggers at line 286 of Moose/Meta/Class.pm, avg 62µs/call # 28 times (465µs+438µs) by Moose::Meta::Class::_inline_triggers at line 459 of Moose/Meta/Class.pm, avg 32µs/call # 28 times (396µs+390µs) by Moose::Meta::Class::_eval_environment at line 497 of Moose/Meta/Class.pm, avg 28µs/call # 17 times (397µs+530µs) by Class::MOP::Class:::around at line 71 of Class/MOP/Class/Immutable/Trait.pm, avg 55µs/call sub get_all_attributes {
935 | 516 | 100µs |  |  | my $self = shift;
936 | 4936 | 14.6ms | 4936 | 11.1ms | my %attrs = map { %{ Class::MOP::Class->initialize($_)->_attribute_map } } # spent 6.73ms making 2210 calls to Class::MOP::Class::initialize, avg 3µs/call, recursion: max depth 1, sum of overlapping time 79µs # spent 3.08ms making 499 calls to Class::MOP::Class::linearized_isa, avg 6µs/call # spent 1.10ms making 2210 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 497ns/call # spent 282µs making 17 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 17µs/call
937 |  |  |  |  | reverse $self->linearized_isa;
938 | 516 | 1.60ms |  |  | return values %attrs;
939 |  |  |  |  | }
940 |  |  |  |  |
941 |  |  |  |  | # Inheritance
942 |  |  |  |  |
943 |  |  |  |  | sub superclasses {
944 | 345 | 81µs |  |  | my $self = shift;
945 |  |  |  |  |
946 | 345 | 436µs | 345 | 4.88ms | my $isa = $self->get_or_add_package_symbol('@ISA'); # spent 4.88ms making 345 calls to Class::MOP::Package::get_or_add_package_symbol, avg 14µs/call
947 |  |  |  |  |
948 | 345 | 91µs |  |  | if (@_) {
949 | 54 | 44µs |  |  | my @supers = @_;
950 | 54 | 550µs |  |  | @{$isa} = @supers;
951 |  |  |  |  |
952 |  |  |  |  | # NOTE:
953 |  |  |  |  | # on 5.8 and below, we need to call
954 |  |  |  |  | # a method to get Perl to detect
955 |  |  |  |  | # a cycle in the class hierarchy
956 | 54 | 184µs | 54 | 40µs | my $class = $self->name; # spent 40µs making 54 calls to Class::MOP::Package::name, avg 744ns/call
957 | 54 | 404µs | 54 | 50µs | $class->isa($class); # spent 50µs making 54 calls to UNIVERSAL::isa, avg 930ns/call
958 |  |  |  |  |
959 |  |  |  |  | # NOTE:
960 |  |  |  |  | # we need to check the metaclass
961 |  |  |  |  | # compatibility here so that we can
962 |  |  |  |  | # be sure that the superclass is
963 |  |  |  |  | # not potentially creating an issues
964 |  |  |  |  | # we don't know about
965 |  |  |  |  |
966 | 54 | 72µs | 54 | 32.3ms | $self->_check_metaclass_compatibility(); # spent 32.3ms making 54 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 599µs/call
967 | 54 | 90µs | 54 | 2.16ms | $self->_superclasses_updated(); # spent 2.16ms making 54 calls to Class::MOP::Class::_superclasses_updated, avg 40µs/call
968 |  |  |  |  | }
969 |  |  |  |  |
970 | 345 | 730µs |  |  | return @{$isa};
971 |  |  |  |  | }
972 |  |  |  |  |
973 |  |  |  |  | # spent 2.16ms (574µs+1.58) within Class::MOP::Class::_superclasses_updated which was called 54 times, avg 40µs/call: # 54 times (574µs+1.58ms) by Class::MOP::Class::superclasses at line 967, avg 40µs/call sub _superclasses_updated {
974 | 54 | 18µs |  |  | my $self = shift;
975 | 54 | 84µs | 54 | 94µs | $self->update_meta_instance_dependencies(); # spent 94µs making 54 calls to Class::MOP::Class::update_meta_instance_dependencies, avg 2µs/call
976 |  |  |  |  | # keep strong references to all our parents, so they don't disappear if
977 |  |  |  |  | # they are anon classes and don't have any direct instances
978 | 62 | 61µs | 62 | 198µs | $self->_superclass_metas( # spent 198µs making 62 calls to Class::MOP::class_of, avg 3µs/call
979 | 54 | 248µs | 108 | 123µs | map { Class::MOP::class_of($_) } $self->superclasses # spent 123µs making 54 calls to Class::MOP::Class::_superclass_metas, avg 2µs/call # spent 20µs making 2 calls to Class::MOP::Class::superclasses, avg 10µs/call, recursion: max depth 1, sum of overlapping time 20µs # spent 1.15ms making 52 calls to Moose::Meta::Class::superclasses, avg 22µs/call, recursion: max depth 2, sum of overlapping time 1.15ms
980 |  |  |  |  | );
981 |  |  |  |  | }
982 |  |  |  |  |
983 |  |  |  |  | # spent 123µs within Class::MOP::Class::_superclass_metas which was called 54 times, avg 2µs/call: # 54 times (123µs+0s) by Class::MOP::Class::_superclasses_updated at line 979, avg 2µs/call sub _superclass_metas {
984 | 54 | 14µs |  |  | my $self = shift;
985 | 54 | 157µs |  |  | $self->{_superclass_metas} = [@_];
986 |  |  |  |  | }
987 |  |  |  |  |
988 |  |  |  |  | sub subclasses {
989 |  |  |  |  | my $self = shift;
990 |  |  |  |  | my $super_class = $self->name;
991 |  |  |  |  |
992 |  |  |  |  | return @{ $super_class->mro::get_isarev() };
993 |  |  |  |  | }
994 |  |  |  |  |
995 |  |  |  |  | sub direct_subclasses {
996 |  |  |  |  | my $self = shift;
997 |  |  |  |  | my $super_class = $self->name;
998 |  |  |  |  |
999 |  |  |  |  | return grep {
1000 |  |  |  |  | grep {
1001 |  |  |  |  | $_ eq $super_class
1002 |  |  |  |  | } Class::MOP::Class->initialize($_)->superclasses
1003 |  |  |  |  | } $self->subclasses;
1004 |  |  |  |  | }
1005 |  |  |  |  |
1006 |  |  |  |  | # spent 5.88ms (3.84+2.04) within Class::MOP::Class::linearized_isa which was called 969 times, avg 6µs/call: # 499 times (2.02ms+1.07ms) by Class::MOP::Class::get_all_attributes at line 936, avg 6µs/call # 442 times (1.66ms+888µs) by Class::MOP::Class::_method_lookup_order at line 1045, avg 6µs/call # 23 times (143µs+76µs) by Class::MOP::Class:::around at line 53 of Class/MOP/Class/Immutable/Trait.pm, avg 10µs/call # 5 times (20µs+8µs) by Class::MOP::Class::find_attribute_by_name at line 924, avg 6µs/call sub linearized_isa {
1007 | 969 | 6.61ms | 1938 | 2.04ms | return @{ mro::get_linear_isa( (shift)->name ) }; # spent 1.65ms making 969 calls to mro::get_linear_isa, avg 2µs/call # spent 390µs making 969 calls to Class::MOP::Package::name, avg 402ns/call
1008 |  |  |  |  | }
1009 |  |  |  |  |
1010 |  |  |  |  | # spent 3.03ms (732µs+2.30) within Class::MOP::Class::class_precedence_list which was called 50 times, avg 61µs/call: # 28 times (507µs+2.53ms) by Moose::Meta::Class::excludes_role at line 257 of Moose/Meta/Class.pm, avg 108µs/call # 13 times (159µs+-159µs) by Class::MOP::Class:::around at line 46 of Class/MOP/Class/Immutable/Trait.pm, avg 0s/call # 9 times (66µs+-66µs) by Class::MOP::Class::class_precedence_list at line 1036, avg 0s/call sub class_precedence_list {
1011 | 50 | 14µs |  |  | my $self = shift;
1012 | 50 | 138µs | 50 | 28µs | my $name = $self->name; # spent 28µs making 50 calls to Class::MOP::Package::name, avg 556ns/call
1013 |  |  |  |  |
1014 | 50 | 111µs | 50 | 32µs | unless (Class::MOP::IS_RUNNING_ON_5_10()) { # spent 32µs making 50 calls to Class::MOP::__ANON__, avg 640ns/call
1015 |  |  |  |  | # NOTE:
1016 |  |  |  |  | # We need to check for circular inheritance here
1017 |  |  |  |  | # if we are not on 5.10, cause 5.8 detects it late.
1018 |  |  |  |  | # This will do nothing if all is well, and blow up
1019 |  |  |  |  | # otherwise. Yes, it's an ugly hack, better
1020 |  |  |  |  | # suggestions are welcome.
1021 |  |  |  |  | # - SL
1022 |  |  |  |  | ($name || return)->isa('This is a test for circular inheritance')
1023 |  |  |  |  | }
1024 |  |  |  |  |
1025 |  |  |  |  | # if our mro is c3, we can
1026 |  |  |  |  | # just grab the linear_isa
1027 | 50 | 187µs | 50 | 87µs | if (mro::get_mro($name) eq 'c3') { # spent 87µs making 50 calls to mro::get_mro, avg 2µs/call
1028 |  |  |  |  | return @{ mro::get_linear_isa($name) }
1029 |  |  |  |  | }
1030 |  |  |  |  | else {
1031 |  |  |  |  | # NOTE:
1032 |  |  |  |  | # we can't grab the linear_isa for dfs
1033 |  |  |  |  | # since it has all the duplicates
1034 |  |  |  |  | # already removed.
1035 |  |  |  |  | return (
1036 | 52 | 134µs | 104 | 1.43ms | $name, # spent 1.71ms making 33 calls to Class::MOP::Class::Immutable::Class::MOP::Class::class_precedence_list, avg 52µs/call, recursion: max depth 3, sum of overlapping time 834µs # spent 308µs making 10 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::class_precedence_list, avg 31µs/call # spent 241µs making 52 calls to Class::MOP::Class::initialize, avg 5µs/call # spent 262µs making 9 calls to Class::MOP::Class::class_precedence_list, avg 29µs/call, recursion: max depth 2, sum of overlapping time 262µs
1037 |  |  |  |  | map {
1038 | 50 | 201µs | 50 | 708µs | Class::MOP::Class->initialize($_)->class_precedence_list() # spent 993µs making 37 calls to Moose::Meta::Class::superclasses, avg 27µs/call, recursion: max depth 1, sum of overlapping time 587µs # spent 251µs making 12 calls to Class::MOP::Class::Immutable::Class::MOP::Class::superclasses, avg 21µs/call # spent 51µs making 1 call to Class::MOP::Class::Immutable::Moose::Meta::Class::superclasses
1039 |  |  |  |  | } $self->superclasses()
1040 |  |  |  |  | );
1041 |  |  |  |  | }
1042 |  |  |  |  | }
1043 |  |  |  |  |
1044 |  |  |  |  | # spent 3.91ms (989µs+2.92) within Class::MOP::Class::_method_lookup_order which was called 470 times, avg 8µs/call: # 207 times (470µs+1.27ms) by Class::MOP::Class::find_method_by_name at line 1132, avg 8µs/call # 200 times (401µs+1.32ms) by Class::MOP::Class::find_next_method_by_name at line 1178, avg 9µs/call # 56 times (99µs+273µs) by Class::MOP::Class::find_all_methods_by_name at line 1162, avg 7µs/call # 7 times (19µs+59µs) by Class::MOP::Class::get_all_methods at line 1143, avg 11µs/call sub _method_lookup_order {
1045 | 470 | 1.06ms | 470 | 2.92ms | return (shift->linearized_isa, 'UNIVERSAL'); # spent 2.55ms making 442 calls to Class::MOP::Class::linearized_isa, avg 6µs/call # spent 366µs making 28 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::linearized_isa, avg 13µs/call
1046 |  |  |  |  | }
1047 |  |  |  |  |
1048 |  |  |  |  | ## Methods
1049 |  |  |  |  |
1050 |  |  |  |  | {
1051 | 1 | 200ns |  |  | # spent 12.2ms (903µs+11.3) within Class::MOP::Class::__ANON__[/usr/local/lib/perl/5.18.2/Class/MOP/Class.pm:1082] which was called 66 times, avg 185µs/call: # 62 times (832µs+10.5ms) by Class::MOP::Class::add_around_method_modifier at line 1108, avg 183µs/call # 4 times (71µs+772µs) by Class::MOP::Class::add_before_method_modifier at line 1088, avg 211µs/call my $fetch_and_prepare_method = sub {
1052 | 66 | 17µs |  |  | my ($self, $method_name) = @_;
1053 | 66 | 173µs | 66 | 34µs | my $wrapped_metaclass = $self->wrapped_method_metaclass; # spent 34µs making 66 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 518ns/call
1054 |  |  |  |  | # fetch it locally
1055 | 66 | 50µs | 66 | 1.01ms | my $method = $self->get_method($method_name); # spent 1.01ms making 66 calls to Class::MOP::Mixin::HasMethods::get_method, avg 15µs/call
1056 |  |  |  |  | # if we don't have local ...
1057 | 66 | 32µs | 5 | 3µs | unless ($method) { # spent 3µs making 5 calls to Class::MOP::Method::__ANON__[Class/MOP/Method.pm:16], avg 520ns/call
1058 |  |  |  |  | # try to find the next method
1059 | 61 | 77µs | 61 | 4.35ms | $method = $self->find_next_method_by_name($method_name); # spent 4.35ms making 61 calls to Class::MOP::Class::find_next_method_by_name, avg 71µs/call
1060 |  |  |  |  | # die if it does not exist
1061 | 61 | 10µs |  |  | (defined $method)
1062 |  |  |  |  | || $self->_throw_exception( MethodNameNotFoundInInheritanceHierarchy => class_name => $self->name,
1063 |  |  |  |  | method_name => $method_name
1064 |  |  |  |  | );
1065 |  |  |  |  | # and now make sure to wrap it
1066 |  |  |  |  | # even if it is already wrapped
1067 |  |  |  |  | # because we need a new sub ref
1068 | 61 | 221µs | 122 | 2.47ms | $method = $wrapped_metaclass->wrap($method, # spent 2.44ms making 61 calls to Class::MOP::Method::Wrapped::wrap, avg 40µs/call # spent 33µs making 61 calls to Class::MOP::Package::name, avg 548ns/call
1069 |  |  |  |  | package_name => $self->name,
1070 |  |  |  |  | name => $method_name,
1071 |  |  |  |  | );
1072 |  |  |  |  | }
1073 |  |  |  |  | else {
1074 |  |  |  |  | # now make sure we wrap it properly
1075 | 5 | 34µs | 15 | 199µs | $method = $wrapped_metaclass->wrap($method, # spent 191µs making 5 calls to Class::MOP::Method::Wrapped::wrap, avg 38µs/call # spent 6µs making 5 calls to UNIVERSAL::isa, avg 1µs/call # spent 2µs making 5 calls to Class::MOP::Package::name, avg 460ns/call
1076 |  |  |  |  | package_name => $self->name,
1077 |  |  |  |  | name => $method_name,
1078 |  |  |  |  | ) unless $method->isa($wrapped_metaclass);
1079 |  |  |  |  | }
1080 | 66 | 62µs | 66 | 3.24ms | $self->add_method($method_name => $method); # spent 3.24ms making 66 calls to Class::MOP::Mixin::HasMethods::add_method, avg 49µs/call
1081 | 66 | 128µs |  |  | return $method;
1082 | 1 | 3µs |  |  | };
1083 |  |  |  |  |
1084 |  |  |  |  | # spent 923µs (32+891) within Class::MOP::Class::add_before_method_modifier which was called 4 times, avg 231µs/call: # 4 times (32µs+891µs) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 207 of Moose/Meta/Role/Application/ToClass.pm, avg 231µs/call sub add_before_method_modifier {
1085 | 4 | 1µs |  |  | my ($self, $method_name, $method_modifier) = @_;
1086 | 4 | 2µs |  |  | (defined $method_name && length $method_name)
1087 |  |  |  |  | || $self->_throw_exception( MethodModifierNeedsMethodName => class_name => $self->name );
1088 | 4 | 5µs | 4 | 844µs | my $method = $fetch_and_prepare_method->($self, $method_name); # spent 844µs making 4 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:1082], avg 211µs/call
1089 | 4 | 25µs | 8 | 48µs | $method->add_before_modifier( # spent 41µs making 4 calls to Class::MOP::Method::Wrapped::add_before_modifier, avg 10µs/call # spent 6µs making 4 calls to Sub::Name::subname, avg 2µs/call
1090 |  |  |  |  | subname(':before' => $method_modifier)
1091 |  |  |  |  | );
1092 |  |  |  |  | }
1093 |  |  |  |  |
1094 |  |  |  |  | sub add_after_method_modifier {
1095 |  |  |  |  | my ($self, $method_name, $method_modifier) = @_;
1096 |  |  |  |  | (defined $method_name && length $method_name)
1097 |  |  |  |  | || $self->_throw_exception( MethodModifierNeedsMethodName => class_name => $self->name );
1098 |  |  |  |  | my $method = $fetch_and_prepare_method->($self, $method_name);
1099 |  |  |  |  | $method->add_after_modifier(
1100 |  |  |  |  | subname(':after' => $method_modifier)
1101 |  |  |  |  | );
1102 |  |  |  |  | }
1103 |  |  |  |  |
1104 |  |  |  |  | # spent 12.8ms (408µs+12.4) within Class::MOP::Class::add_around_method_modifier which was called 62 times, avg 206µs/call: # 43 times (264µs+8.87ms) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 212µs/call # 19 times (144µs+3.48ms) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 207 of Moose/Meta/Role/Application/ToClass.pm, avg 191µs/call sub add_around_method_modifier {
1105 | 62 | 26µs |  |  | my ($self, $method_name, $method_modifier) = @_;
1106 | 62 | 20µs |  |  | (defined $method_name && length $method_name)
1107 |  |  |  |  | || $self->_throw_exception( MethodModifierNeedsMethodName => class_name => $self->name );
1108 | 62 | 65µs | 62 | 11.4ms | my $method = $fetch_and_prepare_method->($self, $method_name); # spent 11.4ms making 62 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:1082], avg 183µs/call
1109 | 62 | 347µs | 124 | 982µs | $method->add_around_modifier( # spent 888µs making 62 calls to Class::MOP::Method::Wrapped::add_around_modifier, avg 14µs/call # spent 95µs making 62 calls to Sub::Name::subname, avg 2µs/call
1110 |  |  |  |  | subname(':around' => $method_modifier)
1111 |  |  |  |  | );
1112 |  |  |  |  | }
1113 |  |  |  |  |
1114 |  |  |  |  | # NOTE:
1115 |  |  |  |  | # the methods above used to be named like this:
1116 |  |  |  |  | # ${pkg}::${method}:(before|after|around)
1117 |  |  |  |  | # but this proved problematic when using one modifier
1118 |  |  |  |  | # to wrap multiple methods (something which is likely
1119 |  |  |  |  | # to happen pretty regularly IMO). So instead of naming
1120 |  |  |  |  | # it like this, I have chosen to just name them purely
1121 |  |  |  |  | # with their modifier names, like so:
1122 |  |  |  |  | # :(before|after|around)
1123 |  |  |  |  | # The fact is that in a stack trace, it will be fairly
1124 |  |  |  |  | # evident from the context what method they are attached
1125 |  |  |  |  | # to, and so don't need the fully qualified name.
1126 |  |  |  |  | }
1127 |  |  |  |  |
1128 |  |  |  |  | # spent 30.6ms (2.83+27.7) within Class::MOP::Class::find_method_by_name which was called 207 times, avg 148µs/call: # 62 times (781µs+3.24ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 19 of Class/MOP/Mixin/HasMethods.pm, avg 65µs/call # 56 times (1.01ms+13.3ms) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 256µs/call # 28 times (393µs+6.81ms) by Moose::Meta::Method::Destructor::is_needed at line 66 of Moose/Meta/Method/Destructor.pm, avg 257µs/call # 28 times (376µs+1.95ms) by Moose::Meta::Class::_inline_BUILDARGS at line 325 of Moose/Meta/Class.pm, avg 83µs/call # 26 times (206µs+2.10ms) by Moose::Meta::Role::Application::ToClass::check_required_methods at line 69 of Moose/Meta/Role/Application/ToClass.pm, avg 89µs/call # 7 times (66µs+318µs) by Moose::BEGIN@43 at line 16 of Moose/Meta/Attribute/Native.pm, avg 55µs/call sub find_method_by_name {
1129 | 207 | 82µs |  |  | my ($self, $method_name) = @_;
1130 | 207 | 106µs |  |  | (defined $method_name && length $method_name)
1131 |  |  |  |  | || $self->_throw_exception( MethodNameNotGiven => class_name => $self->name );
1132 | 207 | 310µs | 207 | 1.74ms | foreach my $class ($self->_method_lookup_order) { # spent 1.74ms making 207 calls to Class::MOP::Class::_method_lookup_order, avg 8µs/call
1133 | 566 | 941µs | 1132 | 26.0ms | my $method = Class::MOP::Class->initialize($class)->get_method($method_name); # spent 24.0ms making 566 calls to Class::MOP::Mixin::HasMethods::get_method, avg 42µs/call # spent 1.94ms making 566 calls to Class::MOP::Class::initialize, avg 3µs/call
1134 | 566 | 490µs |  |  | return $method if defined $method;
1135 |  |  |  |  | }
1136 | 80 | 5.10ms |  |  | return;
1137 |  |  |  |  | }
1138 |  |  |  |  |
1139 |  |  |  |  | # spent 2.47ms (270µs+2.20) within Class::MOP::Class::get_all_methods which was called 7 times, avg 354µs/call: # 7 times (270µs+2.20ms) by Class::MOP::MiniTrait::apply at line 17 of Class/MOP/MiniTrait.pm, avg 354µs/call sub get_all_methods {
1140 | 7 | 4µs |  |  | my $self = shift;
1141 |  |  |  |  |
1142 | 7 | 2µs |  |  | my %methods;
1143 | 7 | 16µs | 7 | 78µs | for my $class ( reverse $self->_method_lookup_order ) { # spent 78µs making 7 calls to Class::MOP::Class::_method_lookup_order, avg 11µs/call
1144 | 15 | 14µs | 15 | 48µs | my $meta = Class::MOP::Class->initialize($class); # spent 48µs making 15 calls to Class::MOP::Class::initialize, avg 3µs/call
1145 |  |  |  |  |
1146 | 15 | 215µs | 101 | 2.08ms | $methods{ $_->name } = $_ for $meta->_get_local_methods; # spent 2.05ms making 15 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 137µs/call # spent 31µs making 86 calls to Class::MOP::Method::name, avg 362ns/call
1147 |  |  |  |  | }
1148 |  |  |  |  |
1149 | 7 | 27µs |  |  | return values %methods;
1150 |  |  |  |  | }
1151 |  |  |  |  |
1152 |  |  |  |  | sub get_all_method_names {
1153 |  |  |  |  | my $self = shift;
1154 |  |  |  |  | map { $_->name } $self->get_all_methods;
1155 |  |  |  |  | }
1156 |  |  |  |  |
1157 |  |  |  |  | # spent 9.86ms (1.05+8.80) within Class::MOP::Class::find_all_methods_by_name which was called 56 times, avg 176µs/call: # 28 times (597µs+6.83ms) by Moose::Meta::Class::_inline_BUILDALL at line 483 of Moose/Meta/Class.pm, avg 265µs/call # 28 times (456µs+1.97ms) by Moose::Meta::Method::Destructor::_generate_DEMOLISHALL at line 116 of Moose/Meta/Method/Destructor.pm, avg 87µs/call sub find_all_methods_by_name {
1158 | 56 | 26µs |  |  | my ($self, $method_name) = @_;
1159 | 56 | 30µs |  |  | (defined $method_name && length $method_name)
1160 |  |  |  |  | || $self->_throw_exception( MethodNameNotGiven => class_name => $self->name );
1161 | 56 | 9µs |  |  | my @methods;
1162 | 56 | 95µs | 56 | 372µs | foreach my $class ($self->_method_lookup_order) { # spent 372µs making 56 calls to Class::MOP::Class::_method_lookup_order, avg 7µs/call
1163 |  |  |  |  | # fetch the meta-class ...
1164 | 196 | 184µs | 196 | 616µs | my $meta = Class::MOP::Class->initialize($class); # spent 616µs making 196 calls to Class::MOP::Class::initialize, avg 3µs/call
1165 | 196 | 290µs | 208 | 7.81ms | push @methods => { # spent 7.51ms making 196 calls to Class::MOP::Mixin::HasMethods::has_method, avg 38µs/call # spent 306µs making 12 calls to Class::MOP::Mixin::HasMethods::get_method, avg 26µs/call
1166 |  |  |  |  | name => $method_name,
1167 |  |  |  |  | class => $class,
1168 |  |  |  |  | code => $meta->get_method($method_name)
1169 |  |  |  |  | } if $meta->has_method($method_name);
1170 |  |  |  |  | }
1171 | 56 | 110µs |  |  | return @methods;
1172 |  |  |  |  | }
1173 |  |  |  |  |
1174 |  |  |  |  | # spent 11.6ms (2.05+9.53) within Class::MOP::Class::find_next_method_by_name which was called 200 times, avg 58µs/call: # 86 times (883µs+3.81ms) by Class::MOP::Method::Inlined::can_be_inlined at line 34 of Class/MOP/Method/Inlined.pm, avg 55µs/call # 61 times (715µs+3.64ms) by Class::MOP::Class::__ANON__[/usr/local/lib/perl/5.18.2/Class/MOP/Class.pm:1082] at line 1059, avg 71µs/call # 28 times (204µs+895µs) by Class::MOP::Method::Inlined::_uninlined_body at line 14 of Class/MOP/Method/Inlined.pm, avg 39µs/call # 25 times (252µs+1.19ms) by Moose::Meta::Method::Overridden::new at line 22 of Moose/Meta/Method/Overridden.pm, avg 57µs/call sub find_next_method_by_name {
1175 | 200 | 79µs |  |  | my ($self, $method_name) = @_;
1176 | 200 | 82µs |  |  | (defined $method_name && length $method_name)
1177 |  |  |  |  | || $self->_throw_exception( MethodNameNotGiven => class_name => $self->name );
1178 | 200 | 364µs | 200 | 1.72ms | my @cpl = ($self->_method_lookup_order); # spent 1.72ms making 200 calls to Class::MOP::Class::_method_lookup_order, avg 9µs/call
1179 | 200 | 50µs |  |  | shift @cpl; # discard ourselves
1180 | 200 | 89µs |  |  | foreach my $class (@cpl) {
1181 | 275 | 484µs | 550 | 7.81ms | my $method = Class::MOP::Class->initialize($class)->get_method($method_name); # spent 6.79ms making 275 calls to Class::MOP::Mixin::HasMethods::get_method, avg 25µs/call # spent 1.02ms making 275 calls to Class::MOP::Class::initialize, avg 4µs/call
1182 | 275 | 469µs |  |  | return $method if defined $method;
1183 |  |  |  |  | }
1184 | 2 | 4µs |  |  | return;
1185 |  |  |  |  | }
1186 |  |  |  |  |
1187 |  |  |  |  | # spent 94µs within Class::MOP::Class::update_meta_instance_dependencies which was called 54 times, avg 2µs/call: # 54 times (94µs+0s) by Class::MOP::Class::_superclasses_updated at line 975, avg 2µs/call sub update_meta_instance_dependencies {
1188 | 54 | 16µs |  |  | my $self = shift;
1189 |  |  |  |  |
1190 | 54 | 117µs |  |  | if ( $self->{meta_instance_dependencies} ) {
1191 |  |  |  |  | return $self->add_meta_instance_dependencies;
1192 |  |  |  |  | }
1193 |  |  |  |  | }
1194 |  |  |  |  |
1195 |  |  |  |  | sub add_meta_instance_dependencies {
1196 |  |  |  |  | my $self = shift;
1197 |  |  |  |  |
1198 |  |  |  |  | $self->remove_meta_instance_dependencies;
1199 |  |  |  |  |
1200 |  |  |  |  | my @attrs = $self->get_all_attributes();
1201 |  |  |  |  |
1202 |  |  |  |  | my %seen;
1203 |  |  |  |  | my @classes = grep { not $seen{ $_->name }++ }
1204 |  |  |  |  | map { $_->associated_class } @attrs;
1205 |  |  |  |  |
1206 |  |  |  |  | foreach my $class (@classes) {
1207 |  |  |  |  | $class->add_dependent_meta_instance($self);
1208 |  |  |  |  | }
1209 |  |  |  |  |
1210 |  |  |  |  | $self->{meta_instance_dependencies} = \@classes;
1211 |  |  |  |  | }
1212 |  |  |  |  |
1213 |  |  |  |  | sub remove_meta_instance_dependencies {
1214 |  |  |  |  | my $self = shift;
1215 |  |  |  |  |
1216 |  |  |  |  | if ( my $classes = delete $self->{meta_instance_dependencies} ) {
1217 |  |  |  |  | foreach my $class (@$classes) {
1218 |  |  |  |  | $class->remove_dependent_meta_instance($self);
1219 |  |  |  |  | }
1220 |  |  |  |  |
1221 |  |  |  |  | return $classes;
1222 |  |  |  |  | }
1223 |  |  |  |  |
1224 |  |  |  |  | return;
1225 |  |  |  |  |
1226 |  |  |  |  | }
1227 |  |  |  |  |
1228 |  |  |  |  | sub add_dependent_meta_instance {
1229 |  |  |  |  | my ( $self, $metaclass ) = @_;
1230 |  |  |  |  | push @{ $self->{dependent_meta_instances} }, $metaclass;
1231 |  |  |  |  | }
1232 |  |  |  |  |
1233 |  |  |  |  | sub remove_dependent_meta_instance {
1234 |  |  |  |  | my ( $self, $metaclass ) = @_;
1235 |  |  |  |  | my $name = $metaclass->name;
1236 |  |  |  |  | @$_ = grep { $_->name ne $name } @$_
1237 |  |  |  |  | for $self->{dependent_meta_instances};
1238 |  |  |  |  | }
1239 |  |  |  |  |
1240 |  |  |  |  | # spent 1.55ms (1.25+295µs) within Class::MOP::Class::invalidate_meta_instances which was called 241 times, avg 6µs/call: # 240 times (1.24ms+293µs) by Class::MOP::Class::_post_add_attribute at line 894, avg 6µs/call # once (9µs+2µs) by Class::MOP::Class::remove_attribute at line 913 sub invalidate_meta_instances {
1241 | 241 | 57µs |  |  | my $self = shift;
1242 |  |  |  |  | $_->invalidate_meta_instance()
1243 | 241 | 1.09ms | 241 | 295µs | for $self, @{ $self->{dependent_meta_instances} }; # spent 295µs making 241 calls to Class::MOP::Class::invalidate_meta_instance, avg 1µs/call
1244 |  |  |  |  | }
1245 |  |  |  |  |
1246 |  |  |  |  | # spent 295µs within Class::MOP::Class::invalidate_meta_instance which was called 241 times, avg 1µs/call: # 241 times (295µs+0s) by Class::MOP::Class::invalidate_meta_instances at line 1243, avg 1µs/call sub invalidate_meta_instance {
1247 | 241 | 41µs |  |  | my $self = shift;
1248 | 241 | 505µs |  |  | undef $self->{_meta_instance};
1249 |  |  |  |  | }
1250 |  |  |  |  |
1251 |  |  |  |  | # check if we can reinitialize
1252 |  |  |  |  | sub is_pristine {
1253 |  |  |  |  | my $self = shift;
1254 |  |  |  |  |
1255 |  |  |  |  | # if any local attr is defined
1256 |  |  |  |  | return if $self->get_attribute_list;
1257 |  |  |  |  |
1258 |  |  |  |  | # or any non-declared methods
1259 |  |  |  |  | for my $method ( map { $self->get_method($_) } $self->get_method_list ) {
1260 |  |  |  |  | return if $method->isa("Class::MOP::Method::Generated");
1261 |  |  |  |  | # FIXME do we need to enforce this too? return unless $method->isa( $self->method_metaclass );
1262 |  |  |  |  | }
1263 |  |  |  |  |
1264 |  |  |  |  | return 1;
1265 |  |  |  |  | }
1266 |  |  |  |  |
1267 |  |  |  |  | ## Class closing
1268 |  |  |  |  |
1269 | 115 | 179µs |  |  | # spent 71µs within Class::MOP::Class::is_mutable which was called 115 times, avg 618ns/call: # 82 times (57µs+0s) by Class::MOP::Class::make_immutable at line 1293, avg 698ns/call # 21 times (9µs+0s) by PONAPI::Server::ConfigReader::BEGIN@4 at line 238 of Moose.pm, avg 414ns/call # 9 times (4µs+0s) by Moose::Meta::Attribute::BEGIN@16 at line 712 of Moose/Util/TypeConstraints.pm, avg 422ns/call # 3 times (1µs+0s) by PONAPI::Server::ConfigReader::BEGIN@4 at line 274 of Moose.pm, avg 467ns/call sub is_mutable { 1 }
1270 | 91 | 138µs |  |  | # spent 63µs within Class::MOP::Class::is_immutable which was called 91 times, avg 690ns/call: # 91 times (63µs+0s) by Class::MOP::Class::_real_ref_name at line 122, avg 690ns/call sub is_immutable { 0 }
1271 |  |  |  |  |
1272 |  |  |  |  | sub immutable_options { %{ $_[0]{__immutable}{options} || {} } }
1273 |  |  |  |  |
1274 |  |  |  |  | # spent 6.52ms (6.19+340µs) within Class::MOP::Class::_immutable_options which was called 82 times, avg 80µs/call: # 54 times (505µs+109µs) by Class::MOP::Class::make_immutable at line 1297, avg 11µs/call # 28 times (5.68ms+230µs) by Moose::Meta::Class::_immutable_options at line 757 of Moose/Meta/Class.pm, avg 211µs/call sub _immutable_options {
1275 | 82 | 66µs |  |  | my ( $self, @args ) = @_;
1276 |  |  |  |  |
1277 |  |  |  |  | return (
1278 | 82 | 6.24ms | 328 | 340µs | inline_accessors => 1, # spent 74µs making 28 calls to Moose::Meta::Class::immutable_trait, avg 3µs/call # spent 71µs making 28 calls to Moose::Meta::Class::constructor_class, avg 3µs/call # spent 58µs making 28 calls to Moose::Meta::Class::destructor_class, avg 2µs/call # spent 55µs making 82 calls to Class::MOP::Class::constructor_name, avg 673ns/call # spent 33µs making 54 calls to Class::MOP::Class::immutable_trait, avg 609ns/call # spent 25µs making 54 calls to Class::MOP::Class::destructor_class, avg 470ns/call # spent 24µs making 54 calls to Class::MOP::Class::constructor_class, avg 443ns/call
1279 |  |  |  |  | inline_constructor => 1,
1280 |  |  |  |  | inline_destructor => 0,
1281 |  |  |  |  | debug => 0,
1282 |  |  |  |  | immutable_trait => $self->immutable_trait,
1283 |  |  |  |  | constructor_name => $self->constructor_name,
1284 |  |  |  |  | constructor_class => $self->constructor_class,
1285 |  |  |  |  | destructor_class => $self->destructor_class,
1286 |  |  |  |  | @args,
1287 |  |  |  |  | );
1288 |  |  |  |  | }
1289 |  |  |  |  |
1290 |  |  |  |  | # spent 342ms (1.12+341) within Class::MOP::Class::make_immutable which was called 82 times, avg 4.18ms/call: # 21 times (272µs+79.9ms) by PONAPI::Server::ConfigReader::BEGIN@4 at line 243 of Moose.pm, avg 3.82ms/call # 14 times (125µs+14.4ms) by Moose::Exporter::BEGIN@8 at line 748 of Class/MOP.pm, avg 1.03ms/call # 9 times (126µs+41.0ms) by Moose::Meta::Attribute::BEGIN@16 at line 717 of Moose/Util/TypeConstraints.pm, avg 4.57ms/call # 5 times (41µs+314µs) by Moose::Exporter::BEGIN@8 at line 775 of Class/MOP.pm, avg 71µs/call # 3 times (31µs+10.6ms) by PONAPI::Server::ConfigReader::BEGIN@4 at line 279 of Moose.pm, avg 3.56ms/call # 2 times (30µs+-30µs) by Class::MOP::Class::_immutable_metaclass at line 1373, avg 0s/call # once (21µs+17.0ms) by PONAPI::Builder::Relationship::BEGIN@6 at line 23 of lib/PONAPI/Builder/Resource/Identifier.pm # once (17µs+11.0ms) by PONAPI::DAO::BEGIN@13 at line 34 of lib/PONAPI/DAO/Request/UpdateRelationships.pm # once (18µs+10.6ms) by PONAPI::DAO::BEGIN@11 at line 45 of lib/PONAPI/DAO/Request/CreateRelationships.pm # once (18µs+10.2ms) by PONAPI::DAO::BEGIN@9 at line 35 of lib/PONAPI/DAO/Request/RetrieveByRelationship.pm # once (19µs+10.2ms) by PONAPI::DAO::BEGIN@6 at line 29 of lib/PONAPI/DAO/Request/Retrieve.pm # once (18µs+10.0ms) by PONAPI::DAO::BEGIN@10 at line 37 of lib/PONAPI/DAO/Request/Create.pm # once (17µs+10.0ms) by Test::PONAPI::Repository::MockDB::Table::Articles::BEGIN@5 at line 20 of lib/Test/PONAPI/Repository/MockDB/Table/Relationships.pm # once (17µs+9.93ms) by PONAPI::DAO::BEGIN@15 at line 46 of lib/PONAPI/DAO/Request/DeleteRelationships.pm # once (16µs+9.71ms) by PONAPI::DAO::BEGIN@14 at line 27 of lib/PONAPI/DAO/Request/Delete.pm # once (15µs+9.45ms) by Test::PONAPI::Repository::MockDB::BEGIN@14 at line 35 of lib/Test/PONAPI/Repository/MockDB/Table/Comments.pm # once (21µs+9.08ms) by PONAPI::Builder::Document::BEGIN@6 at line 130 of lib/PONAPI/Builder/Resource.pm # once (20µs+8.73ms) by PONAPI::Builder::Resource::BEGIN@6 at line 95 of lib/PONAPI/Builder/Relationship.pm # once (20µs+8.50ms) by Test::PONAPI::Repository::MockDB::BEGIN@13 at line 35 of lib/Test/PONAPI/Repository/MockDB/Table/People.pm # once (18µs+7.45ms) by PONAPI::DAO::Request::Role::UpdateLike::BEGIN@7 at line 150 of lib/PONAPI/Exception.pm # once (17µs+6.27ms) by PONAPI::DAO::BEGIN@7 at line 26 of lib/PONAPI/DAO/Request/RetrieveAll.pm # once (18µs+6.26ms) by PONAPI::DAO::BEGIN@8 at line 33 of lib/PONAPI/DAO/Request/RetrieveRelationships.pm # once (17µs+6.06ms) by PONAPI::DAO::BEGIN@12 at line 31 of lib/PONAPI/DAO/Request/Update.pm # once (16µs+4.76ms) by PONAPI::DAO::Request::BEGIN@7 at line 204 of lib/PONAPI/Builder/Document.pm # once (16µs+4.24ms) by Test::PONAPI::Repository::MockDB::BEGIN@12 at line 70 of lib/Test/PONAPI/Repository/MockDB/Table/Articles.pm # once (18µs+4.11ms) by Module::Runtime::require_module at line 166 of lib/Test/PONAPI/Repository/MockDB/Table.pm # once (16µs+4.09ms) by Module::Runtime::require_module at line 161 of lib/PONAPI/DAO/Request.pm # once (17µs+3.11ms) by PONAPI::Server::ConfigReader::BEGIN@10 at line 70 of lib/PONAPI/DAO.pm # once (16µs+2.57ms) by Test::PONAPI::Repository::MockDB::BEGIN@10 at line 97 of lib/Test/PONAPI/Repository/MockDB/Loader.pm # once (16µs+2.49ms) by Module::Runtime::require_module at line 797 of lib/Test/PONAPI/Repository/MockDB.pm # once (18µs+2.46ms) by PONAPI::Builder::Role::HasLinksBuilder::BEGIN@6 at line 51 of lib/PONAPI/Builder/Links.pm # once (15µs+2.36ms) by PONAPI::Server::BEGIN@17 at line 112 of lib/PONAPI/Server/ConfigReader.pm # once (19µs+2.28ms) by PONAPI::Builder::Document::BEGIN@8 at line 32 of lib/PONAPI/Builder/Errors.pm # once (16µs+2.12ms) by PONAPI::Builder::Document::BEGIN@7 at line 10 of lib/PONAPI/Builder/Resource/Null.pm sub make_immutable {
1291 | 82 | 63µs |  |  | my ( $self, @args ) = @_;
1292 |  |  |  |  |
1293 | 82 | 95µs | 82 | 57µs | return $self unless $self->is_mutable; # spent 57µs making 82 calls to Class::MOP::Class::is_mutable, avg 698ns/call
1294 |  |  |  |  |
1295 | 82 | 128µs |  |  | my ($file, $line) = (caller)[1..2];
1296 |  |  |  |  |
1297 | 82 | 357µs | 164 | 309ms | $self->_initialize_immutable( # spent 303ms making 82 calls to Class::MOP::Class::_initialize_immutable, avg 3.69ms/call # spent 6.05ms making 28 calls to Moose::Meta::Class::_immutable_options, avg 216µs/call # spent 614µs making 54 calls to Class::MOP::Class::_immutable_options, avg 11µs/call
1298 |  |  |  |  | file => $file,
1299 |  |  |  |  | line => $line,
1300 |  |  |  |  | $self->_immutable_options(@args),
1301 |  |  |  |  | );
1302 | 82 | 135µs | 82 | 31.9ms | $self->_rebless_as_immutable(@args); # spent 32.1ms making 82 calls to Class::MOP::Class::_rebless_as_immutable, avg 391µs/call, recursion: max depth 1, sum of overlapping time 145µs
1303 |  |  |  |  |
1304 | 82 | 5.32ms |  |  | return $self;
1305 |  |  |  |  | }
1306 |  |  |  |  |
1307 |  |  |  |  | sub make_mutable {
1308 |  |  |  |  | my $self = shift;
1309 |  |  |  |  |
1310 |  |  |  |  | if ( $self->is_immutable ) {
1311 |  |  |  |  | my @args = $self->immutable_options;
1312 |  |  |  |  | $self->_rebless_as_mutable();
1313 |  |  |  |  | $self->_remove_inlined_code(@args);
1314 |  |  |  |  | delete $self->{__immutable};
1315 |  |  |  |  | return $self;
1316 |  |  |  |  | }
1317 |  |  |  |  | else {
1318 |  |  |  |  | return;
1319 |  |  |  |  | }
1320 |  |  |  |  | }
1321 |  |  |  |  |
1322 |  |  |  |  | # spent 31.9ms (498µs+31.4) within Class::MOP::Class::_rebless_as_immutable which was called 82 times, avg 390µs/call: # 82 times (498µs+31.4ms) by Class::MOP::Class::make_immutable at line 1302, avg 390µs/call sub _rebless_as_immutable {
1323 | 82 | 66µs |  |  | my ( $self, @args ) = @_;
1324 |  |  |  |  |
1325 | 82 | 82µs |  |  | $self->{__immutable}{original_class} = ref $self;
1326 |  |  |  |  |
1327 | 82 | 303µs | 82 | 31.5ms | bless $self => $self->_immutable_metaclass(@args); # spent 31.6ms making 82 calls to Class::MOP::Class::_immutable_metaclass, avg 385µs/call, recursion: max depth 1, sum of overlapping time 130µs
1328 |  |  |  |  | }
1329 |  |  |  |  |
1330 |  |  |  |  | # spent 31.5ms (1.30+30.2) within Class::MOP::Class::_immutable_metaclass which was called 82 times, avg 384µs/call: # 82 times (1.30ms+30.2ms) by Class::MOP::Class::_rebless_as_immutable at line 1327, avg 384µs/call sub _immutable_metaclass {
1331 | 82 | 66µs |  |  | my ( $self, %args ) = @_;
1332 |  |  |  |  |
1333 | 82 | 44µs |  |  | if ( my $class = $args{immutable_metaclass} ) {
1334 |  |  |  |  | return $class;
1335 |  |  |  |  | }
1336 |  |  |  |  |
1337 | 82 | 231µs | 82 | 91µs | my $trait = $args{immutable_trait} = $self->immutable_trait # spent 65µs making 28 calls to Moose::Meta::Class::immutable_trait, avg 2µs/call # spent 26µs making 54 calls to Class::MOP::Class::immutable_trait, avg 491ns/call
1338 |  |  |  |  | || $self->_throw_exception( NoImmutableTraitSpecifiedForClass => class_name => $self->name,
1339 |  |  |  |  | params => \%args
1340 |  |  |  |  | );
1341 |  |  |  |  |
1342 | 82 | 138µs | 82 | 798µs | my $meta = $self->meta; # spent 798µs making 82 calls to Class::MOP::Object::meta, avg 10µs/call
1343 | 82 | 161µs | 82 | 2.80ms | my $meta_attr = $meta->find_attribute_by_name("immutable_trait"); # spent 2.80ms making 82 calls to Class::MOP::Class::find_attribute_by_name, avg 34µs/call
1344 |  |  |  |  |
1345 | 82 | 16µs |  |  | my $class_name;
1346 |  |  |  |  |
1347 | 82 | 159µs | 82 | 139µs | if ( $meta_attr and $trait eq $meta_attr->default ) { # spent 139µs making 82 calls to Class::MOP::Mixin::AttributeCore::default, avg 2µs/call
1348 |  |  |  |  | # if the trait is the same as the default we try and pick a
1349 |  |  |  |  | # predictable name for the immutable metaclass
1350 |  |  |  |  | $class_name = 'Class::MOP::Class::Immutable::' . ref($self);
1351 |  |  |  |  | }
1352 |  |  |  |  | else {
1353 |  |  |  |  | $class_name = join '::', 'Class::MOP::Class::Immutable::CustomTrait',
1354 |  |  |  |  | $trait, 'ForMetaClass', ref($self);
1355 |  |  |  |  | }
1356 |  |  |  |  |
1357 | 82 | 306µs | 82 | 145µs | return $class_name # spent 145µs making 82 calls to Class::MOP::does_metaclass_exist, avg 2µs/call
1358 |  |  |  |  | if Class::MOP::does_metaclass_exist($class_name);
1359 |  |  |  |  |
1360 |  |  |  |  | # If the metaclass is a subclass of CMOP::Class which has had
1361 |  |  |  |  | # metaclass roles applied (via Moose), then we want to make sure
1362 |  |  |  |  | # that we preserve that anonymous class (see Fey::ORM for an
1363 |  |  |  |  | # example of where this matters).
1364 | 2 | 4µs | 2 | 26µs | my $meta_name = $meta->_real_ref_name; # spent 26µs making 2 calls to Class::MOP::Class::_real_ref_name, avg 13µs/call
1365 |  |  |  |  |
1366 | 2 | 6µs | 2 | 1.63ms | my $immutable_meta = $meta_name->create( # spent 1.63ms making 2 calls to Class::MOP::Class::create, avg 815µs/call
1367 |  |  |  |  | $class_name,
1368 |  |  |  |  | superclasses => [ ref $self ],
1369 |  |  |  |  | );
1370 |  |  |  |  |
1371 | 2 | 5µs | 2 | 24.4ms | Class::MOP::MiniTrait::apply( $immutable_meta, $trait ); # spent 24.4ms making 2 calls to Class::MOP::MiniTrait::apply, avg 12.2ms/call
1372 |  |  |  |  |
1373 | 2 | 5µs | 2 | 0s | $immutable_meta->make_immutable( # spent 233µs making 2 calls to Class::MOP::Class::make_immutable, avg 117µs/call, recursion: max depth 1, sum of overlapping time 233µs
1374 |  |  |  |  | inline_constructor => 0,
1375 |  |  |  |  | inline_accessors => 0,
1376 |  |  |  |  | );
1377 |  |  |  |  |
1378 | 2 | 7µs |  |  | return $class_name;
1379 |  |  |  |  | }
1380 |  |  |  |  |
1381 |  |  |  |  | sub _remove_inlined_code {
1382 |  |  |  |  | my $self = shift;
1383 |  |  |  |  |
1384 |  |  |  |  | $self->remove_method( $_->name ) for $self->_inlined_methods;
1385 |  |  |  |  |
1386 |  |  |  |  | delete $self->{__immutable}{inlined_methods};
1387 |  |  |  |  | }
1388 |  |  |  |  |
1389 |  |  |  |  | sub _inlined_methods { @{ $_[0]{__immutable}{inlined_methods} || [] } }
1390 |  |  |  |  |
1391 |  |  |  |  | # spent 250µs within Class::MOP::Class::_add_inlined_method which was called 86 times, avg 3µs/call: # 58 times (200µs+0s) by Class::MOP::Class::_inline_constructor at line 1468, avg 3µs/call # 28 times (49µs+0s) by Class::MOP::Class::_inline_destructor at line 1510, avg 2µs/call sub _add_inlined_method {
1392 | 86 | 29µs |  |  | my ( $self, $method ) = @_;
1393 |  |  |  |  |
1394 | 86 | 269µs |  |  | push @{ $self->{__immutable}{inlined_methods} ||= [] }, $method;
1395 |  |  |  |  | }
1396 |  |  |  |  |
1397 |  |  |  |  | # spent 303ms (771µs+302) within Class::MOP::Class::_initialize_immutable which was called 82 times, avg 3.69ms/call: # 82 times (771µs+302ms) by Class::MOP::Class::make_immutable at line 1297, avg 3.69ms/call sub _initialize_immutable {
1398 | 82 | 306µs |  |  | my ( $self, %args ) = @_;
1399 |  |  |  |  |
1400 | 82 | 108µs |  |  | $self->{__immutable}{options} = \%args;
1401 | 82 | 323µs | 82 | 302ms | $self->_install_inlined_code(%args); # spent 302ms making 82 calls to Class::MOP::Class::_install_inlined_code, avg 3.68ms/call
1402 |  |  |  |  | }
1403 |  |  |  |  |
1404 |  |  |  |  | # spent 302ms (778µs+301) within Class::MOP::Class::_install_inlined_code which was called 82 times, avg 3.68ms/call: # 82 times (778µs+301ms) by Class::MOP::Class::_initialize_immutable at line 1401, avg 3.68ms/call sub _install_inlined_code {
1405 | 82 | 150µs |  |  | my ( $self, %args ) = @_;
1406 |  |  |  |  |
1407 |  |  |  |  | # FIXME
1408 | 82 | 107µs | 33 | 48.8ms | $self->_inline_accessors(%args) if $args{inline_accessors}; # spent 48.8ms making 33 calls to Class::MOP::Class::_inline_accessors, avg 1.48ms/call
1409 | 82 | 177µs | 58 | 220ms | $self->_inline_constructor(%args) if $args{inline_constructor}; # spent 220ms making 58 calls to Class::MOP::Class::_inline_constructor, avg 3.79ms/call
1410 | 82 | 346µs | 28 | 32.5ms | $self->_inline_destructor(%args) if $args{inline_destructor}; # spent 32.5ms making 28 calls to Class::MOP::Class::_inline_destructor, avg 1.16ms/call
1411 |  |  |  |  | }
1412 |  |  |  |  |
1413 |  |  |  |  | sub _rebless_as_mutable {
1414 |  |  |  |  | my $self = shift;
1415 |  |  |  |  |
1416 |  |  |  |  | bless $self, $self->_get_mutable_metaclass_name;
1417 |  |  |  |  |
1418 |  |  |  |  | return $self;
1419 |  |  |  |  | }
1420 |  |  |  |  |
1421 |  |  |  |  | # spent 48.8ms (401µs+48.4) within Class::MOP::Class::_inline_accessors which was called 33 times, avg 1.48ms/call: # 33 times (401µs+48.4ms) by Class::MOP::Class::_install_inlined_code at line 1408, avg 1.48ms/call sub _inline_accessors {
1422 | 33 | 9µs |  |  | my $self = shift;
1423 |  |  |  |  |
1424 | 33 | 121µs | 33 | 142µs | foreach my $attr_name ( $self->get_attribute_list ) { # spent 142µs making 33 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 4µs/call
1425 | 76 | 159µs | 152 | 48.3ms | $self->get_attribute($attr_name)->install_accessors(1); # spent 47.0ms making 75 calls to Class::MOP::Attribute::install_accessors, avg 627µs/call # spent 982µs making 1 call to Moose::Meta::Attribute::install_accessors # spent 251µs making 76 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 3µs/call
1426 |  |  |  |  | }
1427 |  |  |  |  | }
1428 |  |  |  |  |
1429 |  |  |  |  | # spent 220ms (1.57+218) within Class::MOP::Class::_inline_constructor which was called 58 times, avg 3.79ms/call: # 58 times (1.57ms+218ms) by Class::MOP::Class::_install_inlined_code at line 1409, avg 3.79ms/call sub _inline_constructor {
1430 | 58 | 145µs |  |  | my ( $self, %args ) = @_;
1431 |  |  |  |  |
1432 | 58 | 27µs |  |  | my $name = $args{constructor_name};
1433 |  |  |  |  | # A class may not even have a constructor, and that's okay.
1434 | 58 | 15µs |  |  | return unless defined $name;
1435 |  |  |  |  |
1436 | 58 | 85µs | 58 | 1.62ms | if ( $self->has_method($name) && !$args{replace_constructor} ) { # spent 1.62ms making 58 calls to Class::MOP::Mixin::HasMethods::has_method, avg 28µs/call
1437 |  |  |  |  | my $class = $self->name;
1438 |  |  |  |  | warn "Not inlining a constructor for $class since it defines"
1439 |  |  |  |  | . " its own constructor.\n"
1440 |  |  |  |  | . "If you are certain you don't need to inline your"
1441 |  |  |  |  | . " constructor, specify inline_constructor => 0 in your"
1442 |  |  |  |  | . " call to $class->meta->make_immutable\n";
1443 |  |  |  |  | return;
1444 |  |  |  |  | }
1445 |  |  |  |  |
1446 | 58 | 32µs |  |  | my $constructor_class = $args{constructor_class};
1447 |  |  |  |  |
1448 |  |  |  |  | {
1449 | 116 | 31µs |  |  | local $@;
1450 | 58 | 109µs | 58 | 7.59ms | use_package_optimistically($constructor_class); # spent 8.10ms making 58 calls to Module::Runtime::use_package_optimistically, avg 140µs/call, recursion: max depth 1, sum of overlapping time 511µs
1451 |  |  |  |  | }
1452 |  |  |  |  |
1453 | 58 | 524µs | 174 | 197ms | my $constructor = $constructor_class->new( # spent 125ms making 28 calls to Moose::Meta::Method::Constructor::new, avg 4.48ms/call # spent 71.9ms making 30 calls to Class::MOP::Method::Constructor::new, avg 2.40ms/call # spent 59µs making 116 calls to Class::MOP::Package::name, avg 506ns/call
1454 |  |  |  |  | options => \%args,
1455 |  |  |  |  | metaclass => $self,
1456 |  |  |  |  | is_inline => 1,
1457 |  |  |  |  | package_name => $self->name,
1458 |  |  |  |  | name => $name,
1459 |  |  |  |  | definition_context => {
1460 |  |  |  |  | description => "constructor " . $self->name . "::" . $name,
1461 |  |  |  |  | file => $args{file},
1462 |  |  |  |  | line => $args{line},
1463 |  |  |  |  | },
1464 |  |  |  |  | );
1465 |  |  |  |  |
1466 | 58 | 315µs | 58 | 7.25ms | if ( $args{replace_constructor} or $constructor->can_be_inlined ) { # spent 7.25ms making 58 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 125µs/call
1467 | 58 | 83µs | 58 | 3.81ms | $self->add_method( $name => $constructor ); # spent 3.81ms making 58 calls to Class::MOP::Mixin::HasMethods::add_method, avg 66µs/call
1468 | 58 | 116µs | 58 | 200µs | $self->_add_inlined_method($constructor); # spent 200µs making 58 calls to Class::MOP::Class::_add_inlined_method, avg 3µs/call
1469 |  |  |  |  | }
1470 |  |  |  |  | }
1471 |  |  |  |  |
1472 |  |  |  |  | # spent 32.5ms (984µs+31.5) within Class::MOP::Class::_inline_destructor which was called 28 times, avg 1.16ms/call: # 28 times (984µs+31.5ms) by Class::MOP::Class::_install_inlined_code at line 1410, avg 1.16ms/call sub _inline_destructor {
1473 | 28 | 104µs |  |  | my ( $self, %args ) = @_;
1474 |  |  |  |  |
1475 | 28 | 31µs |  |  | ( exists $args{destructor_class} && defined $args{destructor_class} )
1476 |  |  |  |  | || $self->_throw_exception( NoDestructorClassSpecified => class_name => $self->name,
1477 |  |  |  |  | params => \%args,
1478 |  |  |  |  | );
1479 |  |  |  |  |
1480 | 28 | 35µs | 28 | 521µs | if ( $self->has_method('DESTROY') && ! $args{replace_destructor} ) { # spent 521µs making 28 calls to Class::MOP::Mixin::HasMethods::has_method, avg 19µs/call
1481 |  |  |  |  | my $class = $self->name;
1482 |  |  |  |  | warn "Not inlining a destructor for $class since it defines"
1483 |  |  |  |  | . " its own destructor.\n";
1484 |  |  |  |  | return;
1485 |  |  |  |  | }
1486 |  |  |  |  |
1487 | 28 | 18µs |  |  | my $destructor_class = $args{destructor_class};
1488 |  |  |  |  |
1489 |  |  |  |  | {
1490 | 56 | 16µs |  |  | local $@;
1491 | 28 | 65µs | 28 | 1.02ms | use_package_optimistically($destructor_class); # spent 1.48ms making 28 calls to Module::Runtime::use_package_optimistically, avg 53µs/call, recursion: max depth 1, sum of overlapping time 466µs
1492 |  |  |  |  | }
1493 |  |  |  |  |
1494 | 28 | 115µs | 56 | 7.53ms | return unless $destructor_class->is_needed($self); # spent 7.51ms making 28 calls to Moose::Meta::Method::Destructor::is_needed, avg 268µs/call # spent 16µs making 28 calls to Class::MOP::Method::__ANON__[Class/MOP/Method.pm:16], avg 579ns/call
1495 |  |  |  |  |
1496 | 28 | 277µs | 84 | 18.7ms | my $destructor = $destructor_class->new( # spent 18.7ms making 28 calls to Moose::Meta::Method::Destructor::new, avg 668µs/call # spent 19µs making 56 calls to Class::MOP::Package::name, avg 343ns/call
1497 |  |  |  |  | options => \%args,
1498 |  |  |  |  | metaclass => $self,
1499 |  |  |  |  | package_name => $self->name,
1500 |  |  |  |  | name => 'DESTROY',
1501 |  |  |  |  | definition_context => {
1502 |  |  |  |  | description => "destructor " . $self->name . "::DESTROY",
1503 |  |  |  |  | file => $args{file},
1504 |  |  |  |  | line => $args{line},
1505 |  |  |  |  | },
1506 |  |  |  |  | );
1507 |  |  |  |  |
1508 | 28 | 108µs | 28 | 1.67ms | if ( $args{replace_destructor} or $destructor->can_be_inlined ) { # spent 1.67ms making 28 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 60µs/call
1509 | 28 | 34µs | 28 | 1.55ms | $self->add_method( 'DESTROY' => $destructor ); # spent 1.55ms making 28 calls to Class::MOP::Mixin::HasMethods::add_method, avg 55µs/call
1510 | 28 | 36µs | 28 | 49µs | $self->_add_inlined_method($destructor); # spent 49µs making 28 calls to Class::MOP::Class::_add_inlined_method, avg 2µs/call
1511 |  |  |  |  | }
1512 |  |  |  |  | }
1513 |  |  |  |  |
1514 | 1 | 5µs |  |  | 1;
1515 |  |  |  |  |
1516 |  |  |  |  | # ABSTRACT: Class Meta Object
1517 |  |  |  |  |
1518 |  |  |  |  | __END__
|  |  |  |  | # spent 13.6ms (12.6+1.07) within Class::MOP::Class::CORE:sort which was called 116 times, avg 117µs/call: # 58 times (9.88ms+531µs) by Class::MOP::Class::_eval_environment at line 709, avg 179µs/call # 58 times (2.68ms+536µs) by Class::MOP::Class::_inline_slot_initializers at line 593, avg 55µs/call sub Class::MOP::Class::CORE:sort; # opcode