← Index
NYTProf Performance Profile   « line view »
For examples/Atom-timer.pl
  Run on Mon Aug 12 14:45:28 2013
Reported on Mon Aug 12 14:46:14 2013

Filename/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Class/MOP/Class.pm
StatementsExecuted 42682 statements in 78.7ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
2135251514.3ms40.7msClass::MOP::Class::::initializeClass::MOP::Class::initialize (recurses: max depth 1, inclusive time 395µs)
109217.43ms36.9msClass::MOP::Class::::_construct_instanceClass::MOP::Class::_construct_instance
62217.22ms8.23msClass::MOP::Class::::CORE:sortClass::MOP::Class::CORE:sort (opcode)
308225.16ms32.1msClass::MOP::Class::::_inline_slot_initializerClass::MOP::Class::_inline_slot_initializer
275114.92ms14.3msClass::MOP::Class::::_inline_init_attr_from_constructorClass::MOP::Class::_inline_init_attr_from_constructor
196944.04ms12.1msClass::MOP::Class::::get_all_attributesClass::MOP::Class::get_all_attributes
151113.75ms3.88msClass::MOP::Class::::invalidate_meta_instancesClass::MOP::Class::invalidate_meta_instances
410113.08ms5.65msClass::MOP::Class::::_single_metaclass_can_be_made_compatibleClass::MOP::Class::_single_metaclass_can_be_made_compatible
31112.86ms45.2msClass::MOP::Class::::_inline_new_objectClass::MOP::Class::_inline_new_object
31222.82ms6.60msClass::MOP::Class::::_eval_environmentClass::MOP::Class::_eval_environment
108771.58ms22.8msClass::MOP::Class::::find_method_by_nameClass::MOP::Class::find_method_by_name
430421.45ms2.19msClass::MOP::Class::::linearized_isaClass::MOP::Class::linearized_isa
65111.30ms8.77msClass::MOP::Class::::_can_fix_metaclass_incompatibilityClass::MOP::Class::_can_fix_metaclass_incompatibility
94211.29ms22.9msClass::MOP::Class::::_check_metaclass_compatibilityClass::MOP::Class::_check_metaclass_compatibility (recurses: max depth 1, inclusive time 55µs)
140111.29ms2.01msClass::MOP::Class::::_single_metaclass_is_compatibleClass::MOP::Class::_single_metaclass_is_compatible
1111.29ms1.40msClass::MOP::Class::::BEGIN@13Class::MOP::Class::BEGIN@13
151111.27ms299msClass::MOP::Class::::_post_add_attributeClass::MOP::Class::_post_add_attribute
1111.18ms3.22msClass::MOP::Class::::BEGIN@15Class::MOP::Class::BEGIN@15
112331.18ms6.63msClass::MOP::Class::::find_next_method_by_nameClass::MOP::Class::find_next_method_by_name
286211.14ms4.67msClass::MOP::Class::::_inline_init_attr_from_defaultClass::MOP::Class::_inline_init_attr_from_default
289221.08ms1.61msClass::MOP::Class::::_inline_default_valueClass::MOP::Class::_inline_default_value
79111.06ms25.1msClass::MOP::Class::::_construct_class_instanceClass::MOP::Class::_construct_class_instance (recurses: max depth 1, inclusive time 98µs)
111957µs1.10msClass::MOP::Class::::BEGIN@14Class::MOP::Class::BEGIN@14
6831899µs14.6msClass::MOP::Class::::__ANON__[:1072]Class::MOP::Class::__ANON__[:1072]
3111700µs40.1msClass::MOP::Class::::_inline_slot_initializersClass::MOP::Class::_inline_slot_initializers
111672µs1.56msClass::MOP::Class::::BEGIN@16Class::MOP::Class::BEGIN@16
5411671µs28.9msClass::MOP::Class::::_immutable_metaclassClass::MOP::Class::_immutable_metaclass (recurses: max depth 1, inclusive time 108µs)
545115663µs9.08msClass::MOP::Class::::get_meta_instanceClass::MOP::Class::get_meta_instance
3111629µs76.0msClass::MOP::Class::::_inline_constructorClass::MOP::Class::_inline_constructor
7511618µs8.42msClass::MOP::Class::::_create_meta_instanceClass::MOP::Class::_create_meta_instance
5475615µs154msClass::MOP::Class::::make_immutableClass::MOP::Class::make_immutable (recurses: max depth 1, inclusive time 209µs)
5422530µs635µsClass::MOP::Class::::_immutable_optionsClass::MOP::Class::_immutable_options
9666526µs29.3msClass::MOP::Class::::new_objectClass::MOP::Class::new_object
6611507µs507µsClass::MOP::Class::::_newClass::MOP::Class::_new
23041486µs1.68msClass::MOP::Class::::_method_lookup_orderClass::MOP::Class::_method_lookup_order
5411420µs123msClass::MOP::Class::::_initialize_immutableClass::MOP::Class::_initialize_immutable
4811418µs9.54msClass::MOP::Class::::_fix_metaclass_incompatibilityClass::MOP::Class::_fix_metaclass_incompatibility
5411403µs1.27msClass::MOP::Class::::find_attribute_by_nameClass::MOP::Class::find_attribute_by_name
6522401µs15.4msClass::MOP::Class::::add_around_method_modifierClass::MOP::Class::add_around_method_modifier
3311384µs45.8msClass::MOP::Class::::_inline_accessorsClass::MOP::Class::_inline_accessors
5411362µs123msClass::MOP::Class::::_install_inlined_codeClass::MOP::Class::_install_inlined_code
15111346µs1.37msClass::MOP::Class::::_attach_attributeClass::MOP::Class::_attach_attribute
9741329µs744µsClass::MOP::Class::::_real_ref_nameClass::MOP::Class::_real_ref_name
14011316µs2.32msClass::MOP::Class::::_check_single_metaclass_compatibilityClass::MOP::Class::_check_single_metaclass_compatibility
2333302µs1.17msClass::MOP::Class::::class_precedence_listClass::MOP::Class::class_precedence_list (recurses: max depth 4, inclusive time 1.09ms)
811282µs2.61msClass::MOP::Class::::get_all_methodsClass::MOP::Class::get_all_methods
111280µs344µsClass::MOP::Class::::BEGIN@17Class::MOP::Class::BEGIN@17
5411265µs29.1msClass::MOP::Class::::_rebless_as_immutableClass::MOP::Class::_rebless_as_immutable (recurses: max depth 1, inclusive time 124µs)
6511263µs1.15msClass::MOP::Class::::_class_metaclass_can_be_made_compatibleClass::MOP::Class::_class_metaclass_can_be_made_compatible
11332232µs232µsClass::MOP::Class::::_base_metaclassesClass::MOP::Class::_base_metaclasses
1022173µs21.6msClass::MOP::Class::::createClass::MOP::Class::create
3111162µs216µsClass::MOP::Class::::_inline_fallback_constructorClass::MOP::Class::_inline_fallback_constructor
1511147µs597µsClass::MOP::Class::::_superclasses_updatedClass::MOP::Class::_superclasses_updated
5622134µs71.1msClass::MOP::Class::::create_anon_classClass::MOP::Class::create_anon_class
15111133µs133µsClass::MOP::Class::::invalidate_meta_instanceClass::MOP::Class::invalidate_meta_instance
3111123µs1.01msClass::MOP::Class::::_inline_create_instanceClass::MOP::Class::_inline_create_instance
2011122µs363µsClass::MOP::Class::::_class_metaclass_is_compatibleClass::MOP::Class::_class_metaclass_is_compatible
3111118µs214µsClass::MOP::Class::::_inline_preserve_weak_metaclassesClass::MOP::Class::_inline_preserve_weak_metaclasses
311192µs1.10msClass::MOP::Class::::_inline_generate_instanceClass::MOP::Class::_inline_generate_instance
322168µs68µsClass::MOP::Class::::_add_inlined_methodClass::MOP::Class::_add_inlined_method
201157µs420µsClass::MOP::Class::::_check_class_metaclass_compatibilityClass::MOP::Class::_check_class_metaclass_compatibility
301143µs43µsClass::MOP::Class::::_inline_paramsClass::MOP::Class::_inline_params
874342µs42µsClass::MOP::Class::::is_mutableClass::MOP::Class::is_mutable
11142µs756µsClass::MOP::Class::::_inline_destructorClass::MOP::Class::_inline_destructor
22238µs166µsClass::MOP::Class::::find_all_methods_by_nameClass::MOP::Class::find_all_methods_by_name
301137µs37µsClass::MOP::Class::::_generate_fallback_constructorClass::MOP::Class::_generate_fallback_constructor
151131µs31µsClass::MOP::Class::::_superclass_metasClass::MOP::Class::_superclass_metas
391121µs21µsClass::MOP::Class::::is_immutableClass::MOP::Class::is_immutable
151119µs19µsClass::MOP::Class::::update_meta_instance_dependenciesClass::MOP::Class::update_meta_instance_dependencies
21119µs559µsClass::MOP::Class::::add_before_method_modifierClass::MOP::Class::add_before_method_modifier
301116µs16µsClass::MOP::Class::::_inline_extra_initClass::MOP::Class::_inline_extra_init
11113µs98µsClass::MOP::Class::::add_after_method_modifierClass::MOP::Class::add_after_method_modifier
1118µs30µsClass::MOP::Class::::BEGIN@20Class::MOP::Class::BEGIN@20
1118µs8µsClass::MOP::Class::::BEGIN@3Class::MOP::Class::BEGIN@3
1116µs28µsClass::MOP::Class::::BEGIN@19Class::MOP::Class::BEGIN@19
1116µs29µsClass::MOP::Class::::BEGIN@23Class::MOP::Class::BEGIN@23
1116µs31µsClass::MOP::Class::::BEGIN@21Class::MOP::Class::BEGIN@21
1116µs23µsClass::MOP::Class::::BEGIN@24Class::MOP::Class::BEGIN@24
1116µs23µsClass::MOP::Class::::BEGIN@22Class::MOP::Class::BEGIN@22
1116µs4.68msClass::MOP::Class::::BEGIN@26Class::MOP::Class::BEGIN@26
1116µs9µsClass::MOP::Class::::BEGIN@11Class::MOP::Class::BEGIN@11
1115µs16µsClass::MOP::Class::::BEGIN@10Class::MOP::Class::BEGIN@10
0000s0sClass::MOP::Class::::__ANON__[:216]Class::MOP::Class::__ANON__[:216]
0000s0sClass::MOP::Class::::__ANON__[:892]Class::MOP::Class::__ANON__[:892]
0000s0sClass::MOP::Class::::__ANON__[:896]Class::MOP::Class::__ANON__[:896]
0000s0sClass::MOP::Class::::_anon_cache_keyClass::MOP::Class::_anon_cache_key
0000s0sClass::MOP::Class::::_anon_package_prefixClass::MOP::Class::_anon_package_prefix
0000s0sClass::MOP::Class::::_clone_instanceClass::MOP::Class::_clone_instance
0000s0sClass::MOP::Class::::_fix_class_metaclass_incompatibilityClass::MOP::Class::_fix_class_metaclass_incompatibility
0000s0sClass::MOP::Class::::_fix_single_metaclass_incompatibilityClass::MOP::Class::_fix_single_metaclass_incompatibility
0000s0sClass::MOP::Class::::_fixup_attributes_after_reblessClass::MOP::Class::_fixup_attributes_after_rebless
0000s0sClass::MOP::Class::::_force_rebless_instanceClass::MOP::Class::_force_rebless_instance
0000s0sClass::MOP::Class::::_inline_clear_mop_slotClass::MOP::Class::_inline_clear_mop_slot
0000s0sClass::MOP::Class::::_inline_get_mop_slotClass::MOP::Class::_inline_get_mop_slot
0000s0sClass::MOP::Class::::_inline_rebless_instanceClass::MOP::Class::_inline_rebless_instance
0000s0sClass::MOP::Class::::_inline_set_mop_slotClass::MOP::Class::_inline_set_mop_slot
0000s0sClass::MOP::Class::::_inlined_methodsClass::MOP::Class::_inlined_methods
0000s0sClass::MOP::Class::::_rebless_as_mutableClass::MOP::Class::_rebless_as_mutable
0000s0sClass::MOP::Class::::_remove_generated_metaobjectsClass::MOP::Class::_remove_generated_metaobjects
0000s0sClass::MOP::Class::::_remove_inlined_codeClass::MOP::Class::_remove_inlined_code
0000s0sClass::MOP::Class::::_restore_metaobjects_fromClass::MOP::Class::_restore_metaobjects_from
0000s0sClass::MOP::Class::::add_dependent_meta_instanceClass::MOP::Class::add_dependent_meta_instance
0000s0sClass::MOP::Class::::add_meta_instance_dependenciesClass::MOP::Class::add_meta_instance_dependencies
0000s0sClass::MOP::Class::::clone_objectClass::MOP::Class::clone_object
0000s0sClass::MOP::Class::::direct_subclassesClass::MOP::Class::direct_subclasses
0000s0sClass::MOP::Class::::get_all_method_namesClass::MOP::Class::get_all_method_names
0000s0sClass::MOP::Class::::immutable_optionsClass::MOP::Class::immutable_options
0000s0sClass::MOP::Class::::is_anon_classClass::MOP::Class::is_anon_class
0000s0sClass::MOP::Class::::is_pristineClass::MOP::Class::is_pristine
0000s0sClass::MOP::Class::::make_mutableClass::MOP::Class::make_mutable
0000s0sClass::MOP::Class::::rebless_instanceClass::MOP::Class::rebless_instance
0000s0sClass::MOP::Class::::rebless_instance_awayClass::MOP::Class::rebless_instance_away
0000s0sClass::MOP::Class::::rebless_instance_backClass::MOP::Class::rebless_instance_back
0000s0sClass::MOP::Class::::reinitializeClass::MOP::Class::reinitialize
0000s0sClass::MOP::Class::::remove_attributeClass::MOP::Class::remove_attribute
0000s0sClass::MOP::Class::::remove_dependent_meta_instanceClass::MOP::Class::remove_dependent_meta_instance
0000s0sClass::MOP::Class::::remove_meta_instance_dependenciesClass::MOP::Class::remove_meta_instance_dependencies
0000s0sClass::MOP::Class::::subclassesClass::MOP::Class::subclasses
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1
2package Class::MOP::Class;
3
# spent 8µs within Class::MOP::Class::BEGIN@3 which was called: # once (8µs+0s) by Class::MOP::BEGIN@26 at line 5
BEGIN {
414µs $Class::MOP::Class::AUTHORITY = 'cpan:STEVAN';
5126µs18µs}
# spent 8µs making 1 call to Class::MOP::Class::BEGIN@3
6{
721µs $Class::MOP::Class::VERSION = '2.1005';
8}
9
10219µs227µs
# spent 16µs (5+11) within Class::MOP::Class::BEGIN@10 which was called: # once (5µs+11µs) by Class::MOP::BEGIN@26 at line 10
use strict;
# spent 16µs making 1 call to Class::MOP::Class::BEGIN@10 # spent 11µs making 1 call to strict::import
11219µs212µs
# spent 9µs (6+3) within Class::MOP::Class::BEGIN@11 which was called: # once (6µs+3µs) by Class::MOP::BEGIN@26 at line 11
use warnings;
# spent 9µs making 1 call to Class::MOP::Class::BEGIN@11 # spent 3µs making 1 call to warnings::import
12
13291µs11.40ms
# spent 1.40ms (1.29+118µs) within Class::MOP::Class::BEGIN@13 which was called: # once (1.29ms+118µs) by Class::MOP::BEGIN@26 at line 13
use Class::MOP::Instance;
# spent 1.40ms making 1 call to Class::MOP::Class::BEGIN@13
14288µs11.10ms
# spent 1.10ms (957µs+141µs) within Class::MOP::Class::BEGIN@14 which was called: # once (957µs+141µs) by Class::MOP::BEGIN@26 at line 14
use Class::MOP::Method::Wrapped;
# spent 1.10ms making 1 call to Class::MOP::Class::BEGIN@14
15294µs13.22ms
# spent 3.22ms (1.18+2.04) within Class::MOP::Class::BEGIN@15 which was called: # once (1.18ms+2.04ms) by Class::MOP::BEGIN@26 at line 15
use Class::MOP::Method::Accessor;
# spent 3.22ms making 1 call to Class::MOP::Class::BEGIN@15
16296µs11.56ms
# spent 1.56ms (672µs+885µs) within Class::MOP::Class::BEGIN@16 which was called: # once (672µs+885µs) by Class::MOP::BEGIN@26 at line 16
use Class::MOP::Method::Constructor;
# spent 1.56ms making 1 call to Class::MOP::Class::BEGIN@16
17293µs1344µs
# spent 344µs (280+64) within Class::MOP::Class::BEGIN@17 which was called: # once (280µs+64µs) by Class::MOP::BEGIN@26 at line 17
use Class::MOP::MiniTrait;
# spent 344µs making 1 call to Class::MOP::Class::BEGIN@17
18
19224µs250µs
# spent 28µs (6+22) within Class::MOP::Class::BEGIN@19 which was called: # once (6µs+22µs) by Class::MOP::BEGIN@26 at line 19
use Carp 'confess';
# spent 28µs making 1 call to Class::MOP::Class::BEGIN@19 # spent 22µs making 1 call to Exporter::import
20224µs252µs
# spent 30µs (8+22) within Class::MOP::Class::BEGIN@20 which was called: # once (8µs+22µs) by Class::MOP::BEGIN@26 at line 20
use Class::Load 'is_class_loaded', 'load_class';
# spent 30µs making 1 call to Class::MOP::Class::BEGIN@20 # spent 22µs making 1 call to Exporter::import
21222µs256µs
# spent 31µs (6+25) within Class::MOP::Class::BEGIN@21 which was called: # once (6µs+25µs) by Class::MOP::BEGIN@26 at line 21
use Scalar::Util 'blessed', 'reftype', 'weaken';
# spent 31µs making 1 call to Class::MOP::Class::BEGIN@21 # spent 25µs making 1 call to Exporter::import
22220µs241µs
# spent 23µs (6+18) within Class::MOP::Class::BEGIN@22 which was called: # once (6µs+18µs) by Class::MOP::BEGIN@26 at line 22
use Sub::Name 'subname';
# spent 23µs making 1 call to Class::MOP::Class::BEGIN@22 # spent 18µs making 1 call to Exporter::import
23221µs252µs
# spent 29µs (6+23) within Class::MOP::Class::BEGIN@23 which was called: # once (6µs+23µs) by Class::MOP::BEGIN@26 at line 23
use Try::Tiny;
# spent 29µs making 1 call to Class::MOP::Class::BEGIN@23 # spent 23µs making 1 call to Exporter::import
24225µs240µs
# spent 23µs (6+17) within Class::MOP::Class::BEGIN@24 which was called: # once (6µs+17µs) by Class::MOP::BEGIN@26 at line 24
use List::MoreUtils 'all';
# spent 23µs making 1 call to Class::MOP::Class::BEGIN@24 # spent 17µs making 1 call to Exporter::import
25
261200ns
# spent 4.68ms (6µs+4.67) within Class::MOP::Class::BEGIN@26 which was called: # once (6µs+4.67ms) by Class::MOP::BEGIN@26 at line 28
use base 'Class::MOP::Module',
27 'Class::MOP::Mixin::HasAttributes',
2815.58ms29.35ms 'Class::MOP::Mixin::HasMethods';
# spent 4.68ms making 1 call to Class::MOP::Class::BEGIN@26 # spent 4.67ms making 1 call to base::import
29
30# Creation
31
32
# spent 40.7ms (14.3+26.4) within Class::MOP::Class::initialize which was called 2135 times, avg 19µs/call: # 761 times (6.09ms+440µs) by Class::MOP::Class::get_all_attributes at line 928, avg 9µs/call # 414 times (1.37ms+3.08ms) by Atom::meta or Class::MOP::Mixin::meta or Class::MOP::Object::meta or Moose::Meta::Class::__ANON__::SERIAL::1::meta or Moose::Meta::Role::Application::RoleSummation::meta or Moose::Meta::Role::Application::ToClass::meta or Moose::Meta::Role::Application::ToInstance::meta or Moose::Meta::Role::Application::ToRole::meta or Moose::Meta::Role::Application::meta or Moose::Meta::Role::Composite::meta or Moose::Meta::Role::Method::Required::meta or Moose::Meta::Role::meta or Moose::Meta::TypeCoercion::Union::meta or Moose::Meta::TypeCoercion::meta or Moose::Meta::TypeConstraint::Class::meta or Moose::Meta::TypeConstraint::DuckType::meta or Moose::Meta::TypeConstraint::Enum::meta or Moose::Meta::TypeConstraint::Parameterizable::meta or Moose::Meta::TypeConstraint::Parameterized::meta or Moose::Meta::TypeConstraint::Registry::meta or Moose::Meta::TypeConstraint::Role::meta or Moose::Meta::TypeConstraint::Union::meta or Moose::Meta::TypeConstraint::meta or MooseX::Storage::Basic::meta or MooseX::Storage::IO::StorableFile::meta or MooseX::Storage::meta at line 48 of Class/MOP/Method/Meta.pm, avg 11µs/call # 367 times (4.90ms+308µs) by Class::MOP::Class::find_method_by_name at line 1123, avg 14µs/call # 186 times (564µs+136µs) by Class::MOP::Class::find_next_method_by_name at line 1171, avg 4µs/call # 65 times (200µs+-117µs) by Class::MOP::Class::_fix_metaclass_incompatibility at line 300, avg 1µs/call # 54 times (152µs+33µs) by Class::MOP::Class::find_attribute_by_name at line 918, avg 3µs/call # 35 times (116µs+352µs) by Class::MOP::Method::Accessor::_new at line 50 of Class/MOP/Method/Accessor.pm, avg 13µs/call # 35 times (102µs+28µs) by Moose::Meta::Attribute::_new or Moose::Meta::Method::_new at line 7 of (eval 74)[Eval/Closure.pm:135], avg 4µs/call # 33 times (126µs+5.07ms) by Class::MOP::Object::meta at line 20 of Class/MOP/Object.pm, avg 158µs/call # 31 times (89µs+26µs) by Class::MOP::Class::class_precedence_list at line 1028, avg 4µs/call # 24 times (75µs+546µs) by Class::MOP::Method::_new at line 56 of Class/MOP/Method.pm, avg 26µs/call # 19 times (100µs+4.34ms) by metaclass::import at line 48 of metaclass.pm, avg 233µs/call # 18 times (67µs+906µs) by Class::MOP::Mixin::meta at line 16 of Class/MOP/Mixin.pm, avg 54µs/call # 17 times (49µs+13µs) by Class::MOP::Class::get_all_methods at line 1134, avg 4µs/call # 14 times (69µs+1.55ms) by Class::MOP::MiniTrait::apply at line 19 of Class/MOP/MiniTrait.pm, avg 116µs/call # 13 times (70µs+9.18ms) by Moose::Meta::Class::initialize at line 79 of Moose/Meta/Class.pm, avg 712µs/call # 12 times (34µs+10µs) by Class::MOP::Attribute::has_value at line 318 of Class/MOP/Attribute.pm, avg 4µs/call # 12 times (33µs+8µs) by Class::MOP::Attribute::get_raw_value at line 297 of Class/MOP/Attribute.pm, avg 3µs/call # 7 times (33µs+321µs) by Moose::BEGIN@46 at line 15 of Moose/Meta/Attribute/Native.pm, avg 51µs/call # 6 times (17µs+4µs) by Class::MOP::Class::find_all_methods_by_name at line 1154, avg 4µs/call # 4 times (14µs+4µs) by Moose::Object::does at line 122 of Moose/Object.pm, avg 4µs/call # 4 times (13µs+3µs) by Class::MOP::Attribute::set_initial_value at line 261 of Class/MOP/Attribute.pm, avg 4µs/call # 2 times (11µs+126µs) by Class::MOP::Package::create at line 72 of Class/MOP/Package.pm, avg 68µs/call # once (5µs+1µs) by namespace::autoclean::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/namespace/autoclean.pm:57] at line 44 of namespace/autoclean.pm # once (3µs+800ns) by Class::MOP::Attribute::_new at line 64 of Class/MOP/Attribute.pm
sub initialize {
332135288µs my $class = shift;
34
3521351µs my $package_name;
36
372135635µs if ( @_ % 2 ) {
38 $package_name = shift;
39 } else {
40 my %options = @_;
41 $package_name = $options{package};
42 }
43
442135281µs ($package_name && !ref($package_name))
45 || confess "You must pass a package name and it cannot be blessed";
46
4721353.99ms221426.7ms return Class::MOP::get_metaclass_by_name($package_name)
# spent 25.2ms making 79 calls to Class::MOP::Class::_construct_class_instance, avg 318µs/call, recursion: max depth 1, sum of overlapping time 98µs # spent 1.62ms making 2135 calls to Class::MOP::get_metaclass_by_name, avg 758ns/call
48 || $class->_construct_class_instance(package => $package_name, @_);
49}
50
51sub reinitialize {
52 my ( $class, @args ) = @_;
53 unshift @args, "package" if @args % 2;
54 my %options = @args;
55 my $old_metaclass = blessed($options{package})
56 ? $options{package}
57 : Class::MOP::get_metaclass_by_name($options{package});
58 $options{weaken} = Class::MOP::metaclass_is_weak($old_metaclass->name)
59 if !exists $options{weaken}
60 && blessed($old_metaclass)
61 && $old_metaclass->isa('Class::MOP::Class');
62 $old_metaclass->_remove_generated_metaobjects
63 if $old_metaclass && $old_metaclass->isa('Class::MOP::Class');
64 my $new_metaclass = $class->SUPER::reinitialize(%options);
65 $new_metaclass->_restore_metaobjects_from($old_metaclass)
66 if $old_metaclass && $old_metaclass->isa('Class::MOP::Class');
67 return $new_metaclass;
68}
69
70# NOTE: (meta-circularity)
71# this is a special form of _construct_instance
72# (see below), which is used to construct class
73# meta-object instances for any Class::MOP::*
74# class. All other classes will use the more
75# normal &construct_instance.
76
# spent 25.1ms (1.06+24.0) within Class::MOP::Class::_construct_class_instance which was called 79 times, avg 317µs/call: # 79 times (1.06ms+24.0ms) by Class::MOP::Class::initialize at line 47, avg 317µs/call
sub _construct_class_instance {
777913µs my $class = shift;
7879106µs my $options = @_ == 1 ? $_[0] : {@_};
797922µs my $package_name = $options->{package};
807911µs (defined $package_name && $package_name)
81 || confess "You must pass a package name";
82 # NOTE:
83 # return the metaclass if we have it cached,
84 # and it is still defined (it has not been
85 # reaped by DESTROY yet, which can happen
86 # annoyingly enough during global destruction)
87
887956µs7949µs if (defined(my $meta = Class::MOP::get_metaclass_by_name($package_name))) {
# spent 49µs making 79 calls to Class::MOP::get_metaclass_by_name, avg 625ns/call
89 return $meta;
90 }
91
92 $class
937928µs10119µs = ref $class
# spent 119µs making 10 calls to Class::MOP::Class::_real_ref_name, avg 12µs/call
94 ? $class->_real_ref_name
95 : $class;
96
97 # now create the metaclass
98792µs my $meta;
997990µs66507µs if ($class eq 'Class::MOP::Class') {
# spent 507µs making 66 calls to Class::MOP::Class::_new, avg 8µs/call
100 $meta = $class->_new($options);
101 }
102 else {
103 # NOTE:
104 # it is safe to use meta here because
105 # class will always be a subclass of
106 # Class::MOP::Class, which defines meta
1071328µs268.37ms $meta = $class->meta->_construct_instance($options)
# spent 8.26ms making 13 calls to Class::MOP::Class::_construct_instance, avg 636µs/call # spent 106µs making 13 calls to Class::MOP::Object::meta, avg 8µs/call
108 }
109
110 # and check the metaclass compatibility
11179155µs7914.9ms $meta->_check_metaclass_compatibility();
# spent 14.9ms making 79 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 189µs/call, recursion: max depth 1, sum of overlapping time 55µs
112
1137962µs79113µs Class::MOP::store_metaclass_by_name($package_name, $meta);
# spent 113µs making 79 calls to Class::MOP::store_metaclass_by_name, avg 1µs/call
114
115 # NOTE:
116 # we need to weaken any anon classes
117 # so that they can call DESTROY properly
1187918µs Class::MOP::weaken_metaclass($package_name) if $options->{weaken};
119
12079162µs $meta;
121}
122
123
# spent 744µs (329+416) within Class::MOP::Class::_real_ref_name which was called 97 times, avg 8µs/call: # 65 times (208µs+237µs) by Class::MOP::Class::_class_metaclass_can_be_made_compatible at line 345, avg 7µs/call # 20 times (67µs+96µs) by Class::MOP::Class::_class_metaclass_is_compatible at line 255, avg 8µs/call # 10 times (45µs+74µs) by Class::MOP::Class::_construct_class_instance at line 93, avg 12µs/call # 2 times (8µs+9µs) by Class::MOP::Class::_immutable_metaclass at line 1352, avg 8µs/call
sub _real_ref_name {
124979µs my $self = shift;
125
126 # NOTE: we need to deal with the possibility of class immutability here,
127 # and then get the name of the class appropriately
12897251µs155416µs return $self->is_immutable
# spent 322µs making 58 calls to Class::MOP::Class::Immutable::Class::MOP::Class::is_immutable, avg 6µs/call # spent 73µs making 58 calls to Class::MOP::Class::Immutable::Trait::_get_mutable_metaclass_name, avg 1µs/call # spent 21µs making 39 calls to Class::MOP::Class::is_immutable, avg 528ns/call
129 ? $self->_get_mutable_metaclass_name()
130 : ref $self;
131}
132
133
# spent 507µs within Class::MOP::Class::_new which was called 66 times, avg 8µs/call: # 66 times (507µs+0s) by Class::MOP::Class::_construct_class_instance at line 99, avg 8µs/call
sub _new {
134669µs my $class = shift;
135
136669µs return Class::MOP::Class->initialize($class)->new_object(@_)
137 if $class ne __PACKAGE__;
138
1396617µs my $options = @_ == 1 ? $_[0] : {@_};
140
14166514µs return bless {
142 # inherited from Class::MOP::Package
143 'package' => $options->{package},
144
145 # NOTE:
146 # since the following attributes will
147 # actually be loaded from the symbol
148 # table, and actually bypass the instance
149 # entirely, we can just leave these things
150 # listed here for reference, because they
151 # should not actually have a value associated
152 # with the slot.
153 'namespace' => \undef,
154 'methods' => {},
155
156 # inherited from Class::MOP::Module
157 'version' => \undef,
158 'authority' => \undef,
159
160 # defined in Class::MOP::Class
161 'superclasses' => \undef,
162
163 'attributes' => {},
164 'attribute_metaclass' =>
165 ( $options->{'attribute_metaclass'} || 'Class::MOP::Attribute' ),
166 'method_metaclass' =>
167 ( $options->{'method_metaclass'} || 'Class::MOP::Method' ),
168 'wrapped_method_metaclass' => (
169 $options->{'wrapped_method_metaclass'}
170 || 'Class::MOP::Method::Wrapped'
171 ),
172 'instance_metaclass' =>
173 ( $options->{'instance_metaclass'} || 'Class::MOP::Instance' ),
174 'immutable_trait' => (
175 $options->{'immutable_trait'}
176 || 'Class::MOP::Class::Immutable::Trait'
177 ),
178 'constructor_name' => ( $options->{constructor_name} || 'new' ),
179 'constructor_class' => (
180 $options->{constructor_class} || 'Class::MOP::Method::Constructor'
181 ),
182 'destructor_class' => $options->{destructor_class},
183 }, $class;
184}
185
186## Metaclass compatibility
187{
18823µs my %base_metaclass = (
189 attribute_metaclass => 'Class::MOP::Attribute',
190 method_metaclass => 'Class::MOP::Method',
191 wrapped_method_metaclass => 'Class::MOP::Method::Wrapped',
192 instance_metaclass => 'Class::MOP::Instance',
193 constructor_class => 'Class::MOP::Method::Constructor',
194 destructor_class => 'Class::MOP::Method::Destructor',
195 );
196
197113318µs
# spent 232µs within Class::MOP::Class::_base_metaclasses which was called 113 times, avg 2µs/call: # 45 times (106µs+0s) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 333, avg 2µs/call # 35 times (64µs+0s) by Class::MOP::Class::_check_metaclass_compatibility at line 208, avg 2µs/call # 33 times (62µs+0s) by Moose::Meta::Class::_base_metaclasses at line 630 of Moose/Meta/Class.pm, avg 2µs/call
sub _base_metaclasses { %base_metaclass }
198}
199
200
# spent 22.9ms (1.29+21.6) within Class::MOP::Class::_check_metaclass_compatibility which was called 94 times, avg 244µs/call: # 79 times (593µs+14.3ms) by Class::MOP::Class::_construct_class_instance at line 111, avg 188µs/call # 15 times (702µs+7.34ms) by Class::MOP::Class::superclasses at line 958, avg 536µs/call
sub _check_metaclass_compatibility {
2019411µs my $self = shift;
202
20394172µs947.99ms my @superclasses = $self->superclasses
# spent 7.47ms making 68 calls to Class::MOP::Class::superclasses, avg 110µs/call, recursion: max depth 1, sum of overlapping time 22µs # spent 837µs making 26 calls to Moose::Meta::Class::superclasses, avg 32µs/call, recursion: max depth 1, sum of overlapping time 302µs
204 or return;
205
2064851µs489.54ms $self->_fix_metaclass_incompatibility(@superclasses);
# spent 9.54ms making 48 calls to Class::MOP::Class::_fix_metaclass_incompatibility, avg 199µs/call
207
20848100µs48383µs my %base_metaclass = $self->_base_metaclasses;
# spent 319µs making 13 calls to Moose::Meta::Class::_base_metaclasses, avg 25µs/call # spent 64µs making 35 calls to Class::MOP::Class::_base_metaclasses, avg 2µs/call
209
210 # this is always okay ...
211 return
212 if ref($self) eq 'Class::MOP::Class'
213 && all {
214210435µs21095µs my $meta = $self->$_;
# spent 17µs making 35 calls to Class::MOP::Class::instance_metaclass, avg 480ns/call # spent 16µs making 35 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 460ns/call # spent 16µs making 35 calls to Class::MOP::Class::constructor_class, avg 454ns/call # spent 16µs making 35 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 451ns/call # spent 15µs making 35 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 431ns/call # spent 15µs making 35 calls to Class::MOP::Class::destructor_class, avg 429ns/call
215210223µs !defined($meta) || $meta eq $base_metaclass{$_};
216 }
21748171µs35636µs keys %base_metaclass;
# spent 636µs making 35 calls to List::MoreUtils::all, avg 18µs/call
218
219135µs for my $superclass (@superclasses) {
2202028µs20420µs $self->_check_class_metaclass_compatibility($superclass);
# spent 420µs making 20 calls to Class::MOP::Class::_check_class_metaclass_compatibility, avg 21µs/call
221 }
222
2231342µs for my $metaclass_type ( keys %base_metaclass ) {
22491153µs9173µs next unless defined $self->$metaclass_type;
# spent 16µs making 13 calls to Moose::Meta::Class::destructor_class, avg 1µs/call # spent 15µs making 13 calls to Moose::Meta::Class::constructor_class, avg 1µs/call # spent 15µs making 13 calls to Moose::Meta::Class::error_class, avg 1µs/call # spent 7µs making 13 calls to Class::MOP::Class::instance_metaclass, avg 523ns/call # spent 7µs making 13 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 523ns/call # spent 7µs making 13 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 515ns/call # spent 7µs making 13 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 515ns/call
2259132µs for my $superclass (@superclasses) {
226140144µs1402.32ms $self->_check_single_metaclass_compatibility( $metaclass_type,
# spent 2.32ms making 140 calls to Class::MOP::Class::_check_single_metaclass_compatibility, avg 17µs/call
227 $superclass );
228 }
229 }
230}
231
232
# spent 420µs (57+363) within Class::MOP::Class::_check_class_metaclass_compatibility which was called 20 times, avg 21µs/call: # 20 times (57µs+363µs) by Class::MOP::Class::_check_metaclass_compatibility at line 220, avg 21µs/call
sub _check_class_metaclass_compatibility {
233202µs my $self = shift;
234204µs my ( $superclass_name ) = @_;
235
2362040µs20363µs if (!$self->_class_metaclass_is_compatible($superclass_name)) {
# spent 363µs making 20 calls to Class::MOP::Class::_class_metaclass_is_compatible, avg 18µs/call
237 my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name);
238
239 my $super_meta_type = $super_meta->_real_ref_name;
240
241 confess "The metaclass of " . $self->name . " ("
242 . (ref($self)) . ")" . " is not compatible with "
243 . "the metaclass of its superclass, "
244 . $superclass_name . " (" . ($super_meta_type) . ")";
245 }
246}
247
248
# spent 363µs (122+241) within Class::MOP::Class::_class_metaclass_is_compatible which was called 20 times, avg 18µs/call: # 20 times (122µs+241µs) by Class::MOP::Class::_check_class_metaclass_compatibility at line 236, avg 18µs/call
sub _class_metaclass_is_compatible {
249202µs my $self = shift;
250205µs my ( $superclass_name ) = @_;
251
2522014µs2015µs my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name)
# spent 15µs making 20 calls to Class::MOP::get_metaclass_by_name, avg 740ns/call
253 || return 1;
254
2552018µs20163µs my $super_meta_name = $super_meta->_real_ref_name;
# spent 163µs making 20 calls to Class::MOP::Class::_real_ref_name, avg 8µs/call
256
2572042µs2063µs return $self->_is_compatible_with($super_meta_name);
# spent 63µs making 20 calls to Class::MOP::Object::_is_compatible_with, avg 3µs/call
258}
259
260
# spent 2.32ms (316µs+2.01) within Class::MOP::Class::_check_single_metaclass_compatibility which was called 140 times, avg 17µs/call: # 140 times (316µs+2.01ms) by Class::MOP::Class::_check_metaclass_compatibility at line 226, avg 17µs/call
sub _check_single_metaclass_compatibility {
26114015µs my $self = shift;
26214029µs my ( $metaclass_type, $superclass_name ) = @_;
263
264140221µs1402.01ms if (!$self->_single_metaclass_is_compatible($metaclass_type, $superclass_name)) {
# spent 2.01ms making 140 calls to Class::MOP::Class::_single_metaclass_is_compatible, avg 14µs/call
265 my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name);
266 my $metaclass_type_name = $metaclass_type;
267 $metaclass_type_name =~ s/_(?:meta)?class$//;
268 $metaclass_type_name =~ s/_/ /g;
269 confess "The $metaclass_type_name metaclass for "
270 . $self->name . " (" . ($self->$metaclass_type)
271 . ")" . " is not compatible with the "
272 . "$metaclass_type_name metaclass of its "
273 . "superclass, $superclass_name ("
274 . ($super_meta->$metaclass_type) . ")";
275 }
276}
277
278
# spent 2.01ms (1.29+719µs) within Class::MOP::Class::_single_metaclass_is_compatible which was called 140 times, avg 14µs/call: # 140 times (1.29ms+719µs) by Class::MOP::Class::_check_single_metaclass_compatibility at line 264, avg 14µs/call
sub _single_metaclass_is_compatible {
2791402µs my $self = shift;
28014016µs my ( $metaclass_type, $superclass_name ) = @_;
281
28214064µs14076µs my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name)
# spent 76µs making 140 calls to Class::MOP::get_metaclass_by_name, avg 544ns/call
283 || return 1;
284
285 # for instance, Moose::Meta::Class has a error_class attribute, but
286 # Class::MOP::Class doesn't - this shouldn't be an error
287140274µs14075µs return 1 unless $super_meta->can($metaclass_type);
# spent 75µs making 140 calls to UNIVERSAL::can, avg 534ns/call
288 # for instance, Moose::Meta::Class has a destructor_class, but
289 # Class::MOP::Class doesn't - this shouldn't be an error
290124241µs12463µs return 1 unless defined $super_meta->$metaclass_type;
# spent 10µs making 20 calls to Class::MOP::Class::instance_metaclass, avg 485ns/call # spent 9µs making 20 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 455ns/call # spent 9µs making 20 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 440ns/call # spent 8µs making 20 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 405ns/call # spent 8µs making 16 calls to Class::MOP::Class::constructor_class, avg 481ns/call # spent 7µs making 16 calls to Class::MOP::Class::destructor_class, avg 438ns/call # spent 4µs making 4 calls to Moose::Meta::Class::constructor_class, avg 1µs/call # spent 4µs making 4 calls to Moose::Meta::Class::destructor_class, avg 1µs/call # spent 4µs making 4 calls to Moose::Meta::Class::error_class, avg 975ns/call
291 # if metaclass is defined in superclass but not here, it's not compatible
292 # this is a really odd case
293108158µs10858µs return 0 unless defined $self->$metaclass_type;
# spent 20µs making 20 calls to Moose::Meta::Class::constructor_class, avg 995ns/call # spent 8µs making 20 calls to Class::MOP::Class::instance_metaclass, avg 400ns/call # spent 8µs making 20 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 380ns/call # spent 8µs making 20 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 375ns/call # spent 7µs making 20 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 365ns/call # spent 4µs making 4 calls to Moose::Meta::Class::destructor_class, avg 925ns/call # spent 4µs making 4 calls to Moose::Meta::Class::error_class, avg 900ns/call
294
295108505µs324448µs return $self->$metaclass_type->_is_compatible_with($super_meta->$metaclass_type);
# spent 354µs making 108 calls to Class::MOP::Object::_is_compatible_with, avg 3µs/call # spent 22µs making 24 calls to Moose::Meta::Class::constructor_class, avg 933ns/call # spent 13µs making 40 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 318ns/call # spent 13µs making 40 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 315ns/call # spent 12µs making 40 calls to Class::MOP::Class::instance_metaclass, avg 308ns/call # spent 12µs making 40 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 308ns/call # spent 7µs making 8 calls to Moose::Meta::Class::destructor_class, avg 912ns/call # spent 7µs making 8 calls to Moose::Meta::Class::error_class, avg 900ns/call # spent 6µs making 16 calls to Class::MOP::Class::constructor_class, avg 400ns/call
296}
297
298
# spent 9.54ms (418µs+9.12) within Class::MOP::Class::_fix_metaclass_incompatibility which was called 48 times, avg 199µs/call: # 48 times (418µs+9.12ms) by Class::MOP::Class::_check_metaclass_compatibility at line 206, avg 199µs/call
sub _fix_metaclass_incompatibility {
299486µs my $self = shift;
300113116µs6584µs my @supers = map { Class::MOP::Class->initialize($_) } @_;
# spent 355µs making 65 calls to Class::MOP::Class::initialize, avg 5µs/call, recursion: max depth 1, sum of overlapping time 271µs
301
3024811µs my $necessary = 0;
3034821µs for my $super (@supers) {
3046582µs658.77ms $necessary = 1
# spent 8.77ms making 65 calls to Class::MOP::Class::_can_fix_metaclass_incompatibility, avg 135µs/call
305 if $self->_can_fix_metaclass_incompatibility($super);
306 }
3074890µs return unless $necessary;
308
309 for my $super (@supers) {
310 if (!$self->_class_metaclass_is_compatible($super->name)) {
311 $self->_fix_class_metaclass_incompatibility($super);
312 }
313 }
314
315 my %base_metaclass = $self->_base_metaclasses;
316 for my $metaclass_type (keys %base_metaclass) {
317 for my $super (@supers) {
318 if (!$self->_single_metaclass_is_compatible($metaclass_type, $super->name)) {
319 $self->_fix_single_metaclass_incompatibility(
320 $metaclass_type, $super
321 );
322 }
323 }
324 }
325}
326
327
# spent 8.77ms (1.30+7.46) within Class::MOP::Class::_can_fix_metaclass_incompatibility which was called 65 times, avg 135µs/call: # 65 times (1.30ms+7.46ms) by Class::MOP::Class::_fix_metaclass_incompatibility at line 304, avg 135µs/call
sub _can_fix_metaclass_incompatibility {
328658µs my $self = shift;
3296511µs my ($super_meta) = @_;
330
3316564µs651.15ms return 1 if $self->_class_metaclass_can_be_made_compatible($super_meta);
# spent 1.15ms making 65 calls to Class::MOP::Class::_class_metaclass_can_be_made_compatible, avg 18µs/call
332
33365142µs65664µs my %base_metaclass = $self->_base_metaclasses;
# spent 557µs making 20 calls to Moose::Meta::Class::_base_metaclasses, avg 28µs/call # spent 106µs making 45 calls to Class::MOP::Class::_base_metaclasses, avg 2µs/call
3346560µs for my $metaclass_type (keys %base_metaclass) {
335410425µs4105.65ms return 1 if $self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type);
# spent 5.65ms making 410 calls to Class::MOP::Class::_single_metaclass_can_be_made_compatible, avg 14µs/call
336 }
337
33865142µs return;
339}
340
341
# spent 1.15ms (263µs+890µs) within Class::MOP::Class::_class_metaclass_can_be_made_compatible which was called 65 times, avg 18µs/call: # 65 times (263µs+890µs) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 331, avg 18µs/call
sub _class_metaclass_can_be_made_compatible {
342655µs my $self = shift;
343657µs my ($super_meta) = @_;
344
34565185µs130890µs return $self->_can_be_made_compatible_with($super_meta->_real_ref_name);
# spent 446µs making 65 calls to Class::MOP::Class::_real_ref_name, avg 7µs/call # spent 444µs making 65 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 7µs/call
346}
347
348
# spent 5.65ms (3.08+2.57) within Class::MOP::Class::_single_metaclass_can_be_made_compatible which was called 410 times, avg 14µs/call: # 410 times (3.08ms+2.57ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 335, avg 14µs/call
sub _single_metaclass_can_be_made_compatible {
34941043µs my $self = shift;
35041068µs my ($super_meta, $metaclass_type) = @_;
351
352410876µs410247µs my $specific_meta = $self->$metaclass_type;
# spent 32µs making 65 calls to Class::MOP::Class::instance_metaclass, avg 492ns/call # spent 32µs making 65 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 486ns/call # spent 31µs making 65 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 477ns/call # spent 30µs making 65 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 465ns/call # spent 29µs making 20 calls to Moose::Meta::Class::constructor_class, avg 1µs/call # spent 28µs making 20 calls to Moose::Meta::Class::destructor_class, avg 1µs/call # spent 25µs making 20 calls to Moose::Meta::Class::error_class, avg 1µs/call # spent 20µs making 45 calls to Class::MOP::Class::constructor_class, avg 451ns/call # spent 19µs making 45 calls to Class::MOP::Class::destructor_class, avg 431ns/call
353
354410807µs410244µs return unless $super_meta->can($metaclass_type);
# spent 244µs making 410 calls to UNIVERSAL::can, avg 596ns/call
355394749µs394184µs my $super_specific_meta = $super_meta->$metaclass_type;
# spent 32µs making 65 calls to Class::MOP::Class::instance_metaclass, avg 491ns/call # spent 29µs making 61 calls to Class::MOP::Class::constructor_class, avg 475ns/call # spent 28µs making 65 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 438ns/call # spent 28µs making 61 calls to Class::MOP::Class::destructor_class, avg 457ns/call # spent 28µs making 65 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 425ns/call # spent 27µs making 65 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 415ns/call # spent 4µs making 4 calls to Moose::Meta::Class::destructor_class, avg 1µs/call # spent 4µs making 4 calls to Moose::Meta::Class::constructor_class, avg 1µs/call # spent 4µs making 4 calls to Moose::Meta::Class::error_class, avg 1µs/call
356
357 # for instance, Moose::Meta::Class has a destructor_class, but
358 # Class::MOP::Class doesn't - this shouldn't be an error
35939499µs return unless defined $super_specific_meta;
360
361 # if metaclass is defined in superclass but not here, it's fixable
362 # this is a really odd case
3633332µs return 1 unless defined $specific_meta;
364
365333714µs3331.89ms return 1 if $specific_meta->_can_be_made_compatible_with($super_specific_meta);
# spent 1.89ms making 333 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 6µs/call
366}
367
368sub _fix_class_metaclass_incompatibility {
369 my $self = shift;
370 my ( $super_meta ) = @_;
371
372 if ($self->_class_metaclass_can_be_made_compatible($super_meta)) {
373 ($self->is_pristine)
374 || confess "Can't fix metaclass incompatibility for "
375 . $self->name
376 . " because it is not pristine.";
377
378 my $super_meta_name = $super_meta->_real_ref_name;
379
380 $self->_make_compatible_with($super_meta_name);
381 }
382}
383
384sub _fix_single_metaclass_incompatibility {
385 my $self = shift;
386 my ( $metaclass_type, $super_meta ) = @_;
387
388 if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) {
389 ($self->is_pristine)
390 || confess "Can't fix metaclass incompatibility for "
391 . $self->name
392 . " because it is not pristine.";
393
394 my $new_metaclass = $self->$metaclass_type
395 ? $self->$metaclass_type->_get_compatible_metaclass($super_meta->$metaclass_type)
396 : $super_meta->$metaclass_type;
397 $self->{$metaclass_type} = $new_metaclass;
398 }
399}
400
401sub _restore_metaobjects_from {
402 my $self = shift;
403 my ($old_meta) = @_;
404
405 $self->_restore_metamethods_from($old_meta);
406 $self->_restore_metaattributes_from($old_meta);
407}
408
409sub _remove_generated_metaobjects {
410 my $self = shift;
411
412 for my $attr (map { $self->get_attribute($_) } $self->get_attribute_list) {
413 $attr->remove_accessors;
414 }
415}
416
417# creating classes with MOP ...
418
419
# spent 21.6ms (173µs+21.4) within Class::MOP::Class::create which was called 10 times, avg 2.16ms/call: # 8 times (126µs+16.6ms) by Moose::Meta::Class::create at line 102 of Moose/Meta/Class.pm, avg 2.09ms/call # 2 times (47µs+4.85ms) by Class::MOP::Class::_immutable_metaclass at line 1354, avg 2.45ms/call
sub create {
420102µs my $class = shift;
421107µs my @args = @_;
422
4231010µs unshift @args, 'package' if @args % 2 == 1;
424109µs my %options = @args;
425
426107µs (ref $options{superclasses} eq 'ARRAY')
427 || confess "You must pass an ARRAY ref of superclasses"
428 if exists $options{superclasses};
429
430103µs (ref $options{attributes} eq 'ARRAY')
431 || confess "You must pass an ARRAY ref of attributes"
432 if exists $options{attributes};
433
434102µs (ref $options{methods} eq 'HASH')
435 || confess "You must pass a HASH ref of methods"
436 if exists $options{methods};
437
438106µs my $package = delete $options{package};
439104µs my $superclasses = delete $options{superclasses};
440102µs my $attributes = delete $options{attributes};
441102µs my $methods = delete $options{methods};
442103µs my $meta_name = exists $options{meta_name}
443 ? delete $options{meta_name}
444 : 'meta';
445
4461020µs103.81ms my $meta = $class->SUPER::create($package => %options);
# spent 3.81ms making 10 calls to Class::MOP::Module::create, avg 381µs/call
447
4481016µs106.97ms $meta->_add_meta_method($meta_name)
# spent 6.97ms making 10 calls to Class::MOP::Mixin::HasMethods::_add_meta_method, avg 697µs/call
449 if defined $meta_name;
450
4511015µs1010.7ms $meta->superclasses(@{$superclasses})
# spent 6.66ms making 8 calls to Moose::Meta::Class::superclasses, avg 832µs/call # spent 4.01ms making 2 calls to Class::MOP::Class::superclasses, avg 2.00ms/call
452 if defined $superclasses;
453 # NOTE:
454 # process attributes first, so that they can
455 # install accessors, but locally defined methods
456 # can then overwrite them. It is maybe a little odd, but
457 # I think this should be the order of things.
458102µs if (defined $attributes) {
459 foreach my $attr (@{$attributes}) {
460 $meta->add_attribute($attr);
461 }
462 }
463102µs if (defined $methods) {
464 foreach my $method_name (keys %{$methods}) {
465 $meta->add_method($method_name, $methods->{$method_name});
466 }
467 }
4681027µs return $meta;
469}
470
471# XXX: something more intelligent here?
472sub _anon_package_prefix { 'Class::MOP::Class::__ANON__::SERIAL::' }
473
47456120µs5670.9ms
# spent 71.1ms (134µs+70.9) within Class::MOP::Class::create_anon_class which was called 56 times, avg 1.27ms/call: # 52 times (118µs+58.8ms) by Moose::Meta::Attribute::Native::Trait::_native_accessor_class_for at line 205 of Moose/Meta/Attribute/Native/Trait.pm, avg 1.13ms/call # 4 times (16µs+12.1ms) by Moose::Meta::Attribute::interpolate_class at line 188 of Moose/Meta/Attribute.pm, avg 3.04ms/call
sub create_anon_class { shift->create_anon(@_) }
# spent 70.9ms making 56 calls to Class::MOP::Package::create_anon, avg 1.27ms/call
475sub is_anon_class { shift->is_anon(@_) }
476
477sub _anon_cache_key {
478 my $class = shift;
479 my %options = @_;
480 # Makes something like Super::Class|Super::Class::2
481 return join '=' => (
482 join( '|', sort @{ $options{superclasses} || [] } ),
483 );
484}
485
486# Instance Construction & Cloning
487
488
# spent 29.3ms (526µs+28.8) within Class::MOP::Class::new_object which was called 96 times, avg 305µs/call: # 35 times (190µs+13.2ms) by Class::MOP::Method::Accessor::_new at line 50 of Class/MOP/Method/Accessor.pm, avg 382µs/call # 31 times (161µs+7.98ms) by Moose::Meta::Method::_new at line 7 of (eval 74)[Eval/Closure.pm:135], avg 263µs/call # 24 times (135µs+5.39ms) by Class::MOP::Method::_new at line 56 of Class/MOP/Method.pm, avg 230µs/call # 4 times (23µs+1.62ms) by Moose::Meta::Class::new_object at line 284 of Moose/Meta/Class.pm, avg 410µs/call # once (10µs+457µs) by Class::MOP::Attribute::_new at line 64 of Class/MOP/Attribute.pm # once (7µs+173µs) by Class::MOP::Object::_new at line 24 of Class/MOP/Object.pm
sub new_object {
4899611µs my $class = shift;
490
491 # NOTE:
492 # we need to protect the integrity of the
493 # Class::MOP::Class singletons here, so we
494 # delegate this to &construct_class_instance
495 # which will deal with the singletons
49696481µs192196µs return $class->_construct_class_instance(@_)
# spent 148µs making 96 calls to UNIVERSAL::isa, avg 2µs/call # spent 48µs making 96 calls to Class::MOP::Package::name, avg 496ns/call
497 if $class->name->isa('Class::MOP::Class');
498964.05ms9628.6ms return $class->_construct_instance(@_);
# spent 28.6ms making 96 calls to Class::MOP::Class::_construct_instance, avg 298µs/call
499}
500
501
# spent 36.9ms (7.43+29.4) within Class::MOP::Class::_construct_instance which was called 109 times, avg 338µs/call: # 96 times (6.84ms+21.8ms) by Class::MOP::Class::new_object at line 498, avg 298µs/call # 13 times (592µs+7.67ms) by Class::MOP::Class::_construct_class_instance at line 107, avg 636µs/call
sub _construct_instance {
50210912µs my $class = shift;
50310928µs my $params = @_ == 1 ? $_[0] : {@_};
50410981µs1093.92ms my $meta_instance = $class->get_meta_instance();
# spent 3.04ms making 65 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 47µs/call # spent 878µs making 44 calls to Class::MOP::Class::get_meta_instance, avg 20µs/call
505 # FIXME:
506 # the code below is almost certainly incorrect
507 # but this is foreign inheritance, so we might
508 # have to kludge it in the end.
5091091µs my $instance;
510109416µs10986µs if (my $instance_class = blessed($params->{__INSTANCE__})) {
# spent 86µs making 109 calls to Scalar::Util::blessed, avg 789ns/call
511 ($instance_class eq $class->name)
512 || confess "Objects passed as the __INSTANCE__ parameter must "
513 . "already be blessed into the correct class, but "
514 . "$params->{__INSTANCE__} is not a " . $class->name;
515 $instance = $params->{__INSTANCE__};
516 }
517 elsif (exists $params->{__INSTANCE__}) {
518 confess "The __INSTANCE__ parameter must be a blessed reference, not "
519 . $params->{__INSTANCE__};
520 }
521 else {
522109103µs109485µs $instance = $meta_instance->create_instance();
# spent 485µs making 109 calls to Class::MOP::Instance::create_instance, avg 4µs/call
523 }
524109145µs10910.8ms foreach my $attr ($class->get_all_attributes()) {
# spent 6.17ms making 44 calls to Class::MOP::Class::get_all_attributes, avg 140µs/call # spent 4.63ms making 65 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 71µs/call
525974908µs97413.8ms $attr->initialize_instance_slot($meta_instance, $instance, $params);
# spent 13.4ms making 966 calls to Class::MOP::Attribute::initialize_instance_slot, avg 14µs/call # spent 387µs making 8 calls to Moose::Meta::Attribute::initialize_instance_slot, avg 48µs/call
526 }
527109284µs218343µs if (Class::MOP::metaclass_is_weak($class->name)) {
# spent 288µs making 109 calls to Class::MOP::metaclass_is_weak, avg 3µs/call # spent 55µs making 109 calls to Class::MOP::Package::name, avg 506ns/call
528 $meta_instance->_set_mop_slot($instance, $class);
529 }
530109168µs return $instance;
531}
532
533
# spent 45.2ms (2.86+42.4) within Class::MOP::Class::_inline_new_object which was called 31 times, avg 1.46ms/call: # 31 times (2.86ms+42.4ms) by Class::MOP::Method::Constructor::_generate_constructor_method_inline at line 101 of Class/MOP/Method/Constructor.pm, avg 1.46ms/call
sub _inline_new_object {
534313µs my $self = shift;
535
536 return (
53731200µs18642.4ms 'my $class = shift;',
# spent 40.1ms making 31 calls to Class::MOP::Class::_inline_slot_initializers, avg 1.29ms/call # spent 1.10ms making 31 calls to Class::MOP::Class::_inline_generate_instance, avg 36µs/call # spent 455µs making 1 call to Moose::Meta::Class::_inline_extra_init # spent 216µs making 31 calls to Class::MOP::Class::_inline_fallback_constructor, avg 7µs/call # spent 214µs making 31 calls to Class::MOP::Class::_inline_preserve_weak_metaclasses, avg 7µs/call # spent 206µs making 1 call to Moose::Meta::Class::_inline_params # spent 43µs making 30 calls to Class::MOP::Class::_inline_params, avg 1µs/call # spent 16µs making 30 calls to Class::MOP::Class::_inline_extra_init, avg 543ns/call
538 '$class = Scalar::Util::blessed($class) || $class;',
539 $self->_inline_fallback_constructor('$class'),
540 $self->_inline_params('$params', '$class'),
541 $self->_inline_generate_instance('$instance', '$class'),
542 $self->_inline_slot_initializers,
543 $self->_inline_preserve_weak_metaclasses,
544 $self->_inline_extra_init,
545 'return $instance',
546 );
547}
548
549
# spent 216µs (162+55) within Class::MOP::Class::_inline_fallback_constructor which was called 31 times, avg 7µs/call: # 31 times (162µs+55µs) by Class::MOP::Class::_inline_new_object at line 537, avg 7µs/call
sub _inline_fallback_constructor {
5503110µs my $self = shift;
551317µs my ($class) = @_;
552 return (
55331142µs6255µs 'return ' . $self->_generate_fallback_constructor($class),
# spent 37µs making 30 calls to Class::MOP::Class::_generate_fallback_constructor, avg 1µs/call # spent 14µs making 31 calls to Class::MOP::Package::name, avg 465ns/call # spent 3µs making 1 call to Moose::Meta::Class::_generate_fallback_constructor
554 'if ' . $class . ' ne \'' . $self->name . '\';',
555 );
556}
557
558
# spent 37µs within Class::MOP::Class::_generate_fallback_constructor which was called 30 times, avg 1µs/call: # 30 times (37µs+0s) by Class::MOP::Class::_inline_fallback_constructor at line 553, avg 1µs/call
sub _generate_fallback_constructor {
55930400ns my $self = shift;
560303µs my ($class) = @_;
5613057µs return 'Class::MOP::Class->initialize(' . $class . ')->new_object(@_)',
562}
563
564
# spent 43µs within Class::MOP::Class::_inline_params which was called 30 times, avg 1µs/call: # 30 times (43µs+0s) by Class::MOP::Class::_inline_new_object at line 537, avg 1µs/call
sub _inline_params {
565303µs my $self = shift;
566306µs my ($params, $class) = @_;
567 return (
5683051µs 'my ' . $params . ' = @_ == 1 ? $_[0] : {@_};',
569 );
570}
571
572
# spent 1.10ms (92µs+1.01) within Class::MOP::Class::_inline_generate_instance which was called 31 times, avg 36µs/call: # 31 times (92µs+1.01ms) by Class::MOP::Class::_inline_new_object at line 537, avg 36µs/call
sub _inline_generate_instance {
573313µs my $self = shift;
574317µs my ($inst, $class) = @_;
575 return (
5763172µs311.01ms 'my ' . $inst . ' = ' . $self->_inline_create_instance($class) . ';',
# spent 1.01ms making 31 calls to Class::MOP::Class::_inline_create_instance, avg 33µs/call
577 );
578}
579
580
# spent 1.01ms (123µs+887µs) within Class::MOP::Class::_inline_create_instance which was called 31 times, avg 33µs/call: # 31 times (123µs+887µs) by Class::MOP::Class::_inline_generate_instance at line 576, avg 33µs/call
sub _inline_create_instance {
581313µs my $self = shift;
582
5833182µs62887µs return $self->get_meta_instance->inline_create_instance(@_);
# spent 849µs making 31 calls to Class::MOP::Class::get_meta_instance, avg 27µs/call # spent 38µs making 31 calls to Class::MOP::Instance::inline_create_instance, avg 1µs/call
584}
585
586
# spent 40.1ms (700µs+39.4) within Class::MOP::Class::_inline_slot_initializers which was called 31 times, avg 1.29ms/call: # 31 times (700µs+39.4ms) by Class::MOP::Class::_inline_new_object at line 537, avg 1.29ms/call
sub _inline_slot_initializers {
587314µs my $self = shift;
588
589313µs my $idx = 0;
590
59111456.03ms198232.9ms return map { $self->_inline_slot_initializer($_, $idx++) }
# spent 24.0ms making 286 calls to Class::MOP::Class::_inline_slot_initializer, avg 84µs/call # spent 8.36ms making 22 calls to Moose::Meta::Class::_inline_slot_initializer, avg 380µs/call # spent 515µs making 1674 calls to Class::MOP::Mixin::AttributeCore::name, avg 308ns/call
592312.69ms627.04ms sort { $a->name cmp $b->name } $self->get_all_attributes;
# spent 5.89ms making 31 calls to Class::MOP::Class::CORE:sort, avg 190µs/call # spent 1.15ms making 31 calls to Class::MOP::Class::get_all_attributes, avg 37µs/call
593}
594
595
# spent 32.1ms (5.16+26.9) within Class::MOP::Class::_inline_slot_initializer which was called 308 times, avg 104µs/call: # 286 times (4.97ms+19.1ms) by Class::MOP::Class::_inline_slot_initializers at line 591, avg 84µs/call # 22 times (195µs+7.85ms) by Moose::Meta::Class::_inline_slot_initializer at line 376 of Moose/Meta/Class.pm, avg 366µs/call
sub _inline_slot_initializer {
59630832µs my $self = shift;
59730834µs my ($attr, $idx) = @_;
598
5993083.43ms319644µs if (defined(my $init_arg = $attr->init_arg)) {
# spent 512µs making 11 calls to Class::MOP::Class::_inline_init_attr_from_default, avg 47µs/call # spent 131µs making 308 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 426ns/call
600297415µs29721.7ms my @source = (
# spent 14.3ms making 275 calls to Class::MOP::Class::_inline_init_attr_from_constructor, avg 52µs/call # spent 7.42ms making 22 calls to Moose::Meta::Class::_inline_init_attr_from_constructor, avg 337µs/call
601 'if (exists $params->{\'' . $init_arg . '\'}) {',
602 $self->_inline_init_attr_from_constructor($attr, $idx),
603 '}',
604 );
605297330µs2974.58ms if (my @default = $self->_inline_init_attr_from_default($attr, $idx)) {
# spent 4.16ms making 275 calls to Class::MOP::Class::_inline_init_attr_from_default, avg 15µs/call # spent 423µs making 22 calls to Moose::Meta::Class::_inline_init_attr_from_default, avg 19µs/call
606 push @source, (
607 'else {',
608 @default,
609 '}',
610 );
611 }
612297709µs return @source;
613 }
614 elsif (my @default = $self->_inline_init_attr_from_default($attr, $idx)) {
615 return (
616 '{',
617 @default,
618 '}',
619 );
620 }
621 else {
62212µs return ();
623 }
624}
625
626
# spent 14.3ms (4.92+9.34) within Class::MOP::Class::_inline_init_attr_from_constructor which was called 275 times, avg 52µs/call: # 275 times (4.92ms+9.34ms) by Class::MOP::Class::_inline_slot_initializer at line 600, avg 52µs/call
sub _inline_init_attr_from_constructor {
62727528µs my $self = shift;
62827528µs my ($attr, $idx) = @_;
629
630275741µs5509.07ms my @initial_value = $attr->_inline_set_value(
# spent 8.51ms making 273 calls to Class::MOP::Attribute::_inline_set_value, avg 31µs/call # spent 477µs making 2 calls to Moose::Meta::Attribute::_inline_set_value, avg 238µs/call # spent 83µs making 275 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 303ns/call
631 '$instance', '$params->{\'' . $attr->init_arg . '\'}',
632 );
633
634275204µs275271µs push @initial_value, (
# spent 271µs making 275 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 984ns/call
635 '$attrs->[' . $idx . ']->set_initial_value(',
636 '$instance,',
637 $attr->_inline_instance_get('$instance'),
638 ');',
639 ) if $attr->has_initializer;
640
641275461µs return @initial_value;
642}
643
644
# spent 4.67ms (1.14+3.53) within Class::MOP::Class::_inline_init_attr_from_default which was called 286 times, avg 16µs/call: # 275 times (1.07ms+3.08ms) by Class::MOP::Class::_inline_slot_initializer at line 605, avg 15µs/call # 11 times (70µs+443µs) by Class::MOP::Class::_inline_slot_initializer at line 599, avg 47µs/call
sub _inline_init_attr_from_default {
64528629µs my $self = shift;
64628629µs my ($attr, $idx) = @_;
647
648286207µs2861.58ms my $default = $self->_inline_default_value($attr, $idx);
# spent 1.58ms making 286 calls to Class::MOP::Class::_inline_default_value, avg 6µs/call
649286206µs return unless $default;
650
65196110µs961.85ms my @initial_value = $attr->_inline_set_value('$instance', $default);
# spent 1.85ms making 96 calls to Class::MOP::Attribute::_inline_set_value, avg 19µs/call
652
6539671µs9691µs push @initial_value, (
# spent 91µs making 96 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 946ns/call
654 '$attrs->[' . $idx . ']->set_initial_value(',
655 '$instance,',
656 $attr->_inline_instance_get('$instance'),
657 ');',
658 ) if $attr->has_initializer;
659
66096161µs return @initial_value;
661}
662
663
# spent 1.61ms (1.08+529µs) within Class::MOP::Class::_inline_default_value which was called 289 times, avg 6µs/call: # 286 times (1.06ms+523µs) by Class::MOP::Class::_inline_init_attr_from_default at line 648, avg 6µs/call # 3 times (16µs+6µs) by Moose::Meta::Class::_inline_init_attr_from_default at line 430 of Moose/Meta/Class.pm, avg 7µs/call
sub _inline_default_value {
6642893µs my $self = shift;
66528930µs my ($attr, $index) = @_;
666
667289407µs578529µs if ($attr->has_default) {
# spent 224µs making 289 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 774ns/call # spent 158µs making 97 calls to Class::MOP::Mixin::AttributeCore::is_default_a_coderef, avg 2µs/call # spent 147µs making 192 calls to Class::MOP::Mixin::AttributeCore::has_builder, avg 767ns/call
668 # NOTE:
669 # default values can either be CODE refs
670 # in which case we need to call them. Or
671 # they can be scalars (strings/numbers)
672 # in which case we can just deal with them
673 # in the code we eval.
674 if ($attr->is_default_a_coderef) {
675 return '$defaults->[' . $index . ']->($instance)';
676 }
677 else {
6783154µs return '$defaults->[' . $index . ']';
679 }
680 }
681 elsif ($attr->has_builder) {
682 return '$instance->' . $attr->builder;
683 }
684 else {
685192242µs return;
686 }
687}
688
689
# spent 214µs (118+96) within Class::MOP::Class::_inline_preserve_weak_metaclasses which was called 31 times, avg 7µs/call: # 31 times (118µs+96µs) by Class::MOP::Class::_inline_new_object at line 537, avg 7µs/call
sub _inline_preserve_weak_metaclasses {
690314µs my $self = shift;
6913180µs6296µs if (Class::MOP::metaclass_is_weak($self->name)) {
# spent 80µs making 31 calls to Class::MOP::metaclass_is_weak, avg 3µs/call # spent 15µs making 31 calls to Class::MOP::Package::name, avg 487ns/call
692 return (
693 $self->_inline_set_mop_slot(
694 '$instance', 'Class::MOP::class_of($class)'
695 ) . ';'
696 );
697 }
698 else {
6993141µs return ();
700 }
701}
702
7033036µs
# spent 16µs within Class::MOP::Class::_inline_extra_init which was called 30 times, avg 543ns/call: # 30 times (16µs+0s) by Class::MOP::Class::_inline_new_object at line 537, avg 543ns/call
sub _inline_extra_init { }
704
705
# spent 6.60ms (2.82+3.77) within Class::MOP::Class::_eval_environment which was called 31 times, avg 213µs/call: # 30 times (668µs+3.53ms) by Class::MOP::Method::Constructor::_eval_environment at line 89 of Class/MOP/Method/Constructor.pm, avg 140µs/call # once (2.15ms+242µs) by Moose::Meta::Class::_eval_environment at line 550 of Moose/Meta/Class.pm
sub _eval_environment {
706313µs my $self = shift;
707
7088652.32ms17303.99ms my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes;
# spent 2.34ms making 31 calls to Class::MOP::Class::CORE:sort, avg 76µs/call # spent 1.14ms making 31 calls to Class::MOP::Class::get_all_attributes, avg 37µs/call # spent 498µs making 1668 calls to Class::MOP::Mixin::AttributeCore::name, avg 299ns/call
709
710339251µs308286µs my $defaults = [map { $_->default } @attrs];
# spent 286µs making 308 calls to Class::MOP::Mixin::AttributeCore::default, avg 927ns/call
711
712 return {
7133179µs '$defaults' => \$defaults,
714 };
715}
716
717
718
# spent 9.08ms (663µs+8.42) within Class::MOP::Class::get_meta_instance which was called 545 times, avg 17µs/call: # 232 times (273µs+3.38ms) by Class::MOP::Attribute::_inline_instance_set at line 287 of Class/MOP/Attribute.pm, avg 16µs/call # 128 times (163µs+2.08ms) by Class::MOP::Attribute::_inline_instance_get at line 310 of Class/MOP/Attribute.pm, avg 18µs/call # 67 times (71µs+0s) by Class::MOP::Attribute::_inline_instance_has at line 331 of Class/MOP/Attribute.pm, avg 1µs/call # 44 times (56µs+822µs) by Class::MOP::Class::_construct_instance at line 504, avg 20µs/call # 31 times (38µs+811µs) by Class::MOP::Class::_inline_create_instance at line 583, avg 27µs/call # 21 times (38µs+1.23ms) by Class::MOP::Class:::around at line 84 of Class/MOP/Class/Immutable/Trait.pm, avg 60µs/call # 12 times (12µs+0s) by Moose::Meta::Attribute::_inline_weaken_value at line 760 of Moose/Meta/Attribute.pm, avg 958ns/call # 4 times (5µs+0s) by Class::MOP::Attribute::set_initial_value at line 261 of Class/MOP/Attribute.pm, avg 1µs/call # 3 times (3µs+0s) by Class::MOP::Attribute::has_value at line 318 of Class/MOP/Attribute.pm, avg 1µs/call # 2 times (2µs+0s) by Class::MOP::Attribute::get_raw_value at line 297 of Class/MOP/Attribute.pm, avg 1µs/call # once (3µs+92µs) by Moose::Exporter::BEGIN@13 at line 672 of Class/MOP.pm
sub get_meta_instance {
71954550µs my $self = shift;
720545864µs758.42ms $self->{'_meta_instance'} ||= $self->_create_meta_instance();
# spent 8.42ms making 75 calls to Class::MOP::Class::_create_meta_instance, avg 112µs/call
721}
722
723
# spent 8.42ms (618µs+7.80) within Class::MOP::Class::_create_meta_instance which was called 75 times, avg 112µs/call: # 75 times (618µs+7.80ms) by Class::MOP::Class::get_meta_instance at line 720, avg 112µs/call
sub _create_meta_instance {
724755µs my $self = shift;
725
72675331µs2257.75ms my $instance = $self->instance_metaclass->new(
# spent 4.97ms making 75 calls to Class::MOP::Instance::new, avg 66µs/call # spent 2.22ms making 64 calls to Class::MOP::Class::get_all_attributes, avg 35µs/call # spent 531µs making 11 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 48µs/call # spent 34µs making 75 calls to Class::MOP::Class::instance_metaclass, avg 452ns/call
727 associated_metaclass => $self,
728 attributes => [ $self->get_all_attributes() ],
729 );
730
7317566µs7550µs $self->add_meta_instance_dependencies()
# spent 50µs making 75 calls to Class::MOP::Instance::is_dependent_on_superclasses, avg 672ns/call
732 if $instance->is_dependent_on_superclasses();
733
73475102µs return $instance;
735}
736
737# TODO: this is actually not being used!
738sub _inline_rebless_instance {
739 my $self = shift;
740
741 return $self->get_meta_instance->inline_rebless_instance_structure(@_);
742}
743
744sub _inline_get_mop_slot {
745 my $self = shift;
746
747 return $self->get_meta_instance->_inline_get_mop_slot(@_);
748}
749
750sub _inline_set_mop_slot {
751 my $self = shift;
752
753 return $self->get_meta_instance->_inline_set_mop_slot(@_);
754}
755
756sub _inline_clear_mop_slot {
757 my $self = shift;
758
759 return $self->get_meta_instance->_inline_clear_mop_slot(@_);
760}
761
762sub clone_object {
763 my $class = shift;
764 my $instance = shift;
765 (blessed($instance) && $instance->isa($class->name))
766 || confess "You must pass an instance of the metaclass (" . (ref $class ? $class->name : $class) . "), not ($instance)";
767
768 # NOTE:
769 # we need to protect the integrity of the
770 # Class::MOP::Class singletons here, they
771 # should not be cloned.
772 return $instance if $instance->isa('Class::MOP::Class');
773 $class->_clone_instance($instance, @_);
774}
775
776sub _clone_instance {
777 my ($class, $instance, %params) = @_;
778 (blessed($instance))
779 || confess "You can only clone instances, ($instance) is not a blessed instance";
780 my $meta_instance = $class->get_meta_instance();
781 my $clone = $meta_instance->clone_instance($instance);
782 foreach my $attr ($class->get_all_attributes()) {
783 if ( defined( my $init_arg = $attr->init_arg ) ) {
784 if (exists $params{$init_arg}) {
785 $attr->set_value($clone, $params{$init_arg});
786 }
787 }
788 }
789 return $clone;
790}
791
792sub _force_rebless_instance {
793 my ($self, $instance, %params) = @_;
794 my $old_metaclass = Class::MOP::class_of($instance);
795
796 $old_metaclass->rebless_instance_away($instance, $self, %params)
797 if $old_metaclass;
798
799 my $meta_instance = $self->get_meta_instance;
800
801 if (Class::MOP::metaclass_is_weak($old_metaclass->name)) {
802 $meta_instance->_clear_mop_slot($instance);
803 }
804
805 # rebless!
806 # we use $_[1] here because of t/cmop/rebless_overload.t regressions
807 # on 5.8.8
808 $meta_instance->rebless_instance_structure($_[1], $self);
809
810 $self->_fixup_attributes_after_rebless($instance, $old_metaclass, %params);
811
812 if (Class::MOP::metaclass_is_weak($self->name)) {
813 $meta_instance->_set_mop_slot($instance, $self);
814 }
815}
816
817sub rebless_instance {
818 my ($self, $instance, %params) = @_;
819 my $old_metaclass = Class::MOP::class_of($instance);
820
821 my $old_class = $old_metaclass ? $old_metaclass->name : blessed($instance);
822 $self->name->isa($old_class)
823 || confess "You may rebless only into a subclass of ($old_class), of which (". $self->name .") isn't.";
824
825 $self->_force_rebless_instance($_[1], %params);
826
827 return $instance;
828}
829
830sub rebless_instance_back {
831 my ( $self, $instance ) = @_;
832 my $old_metaclass = Class::MOP::class_of($instance);
833
834 my $old_class
835 = $old_metaclass ? $old_metaclass->name : blessed($instance);
836 $old_class->isa( $self->name )
837 || confess
838 "You may rebless only into a superclass of ($old_class), of which ("
839 . $self->name
840 . ") isn't.";
841
842 $self->_force_rebless_instance($_[1]);
843
844 return $instance;
845}
846
847sub rebless_instance_away {
848 # this intentionally does nothing, it is just a hook
849}
850
851sub _fixup_attributes_after_rebless {
852 my $self = shift;
853 my ($instance, $rebless_from, %params) = @_;
854 my $meta_instance = $self->get_meta_instance;
855
856 for my $attr ( $rebless_from->get_all_attributes ) {
857 next if $self->find_attribute_by_name( $attr->name );
858 $meta_instance->deinitialize_slot( $instance, $_ ) for $attr->slots;
859 }
860
861 foreach my $attr ( $self->get_all_attributes ) {
862 if ( $attr->has_value($instance) ) {
863 if ( defined( my $init_arg = $attr->init_arg ) ) {
864 $params{$init_arg} = $attr->get_value($instance)
865 unless exists $params{$init_arg};
866 }
867 else {
868 $attr->set_value($instance, $attr->get_value($instance));
869 }
870 }
871 }
872
873 foreach my $attr ($self->get_all_attributes) {
874 $attr->initialize_instance_slot($meta_instance, $instance, \%params);
875 }
876}
877
878
# spent 1.37ms (346µs+1.02) within Class::MOP::Class::_attach_attribute which was called 151 times, avg 9µs/call: # 151 times (346µs+1.02ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 27 of Class/MOP/Mixin/HasAttributes.pm, avg 9µs/call
sub _attach_attribute {
87915131µs my ($self, $attribute) = @_;
880151249µs1511.02ms $attribute->attach_to_class($self);
# spent 1.02ms making 151 calls to Class::MOP::Attribute::attach_to_class, avg 7µs/call
881}
882
883
# spent 299ms (1.27+298) within Class::MOP::Class::_post_add_attribute which was called 151 times, avg 1.98ms/call: # 151 times (1.27ms+298ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 44 of Class/MOP/Mixin/HasAttributes.pm, avg 1.98ms/call
sub _post_add_attribute {
88415131µs my ( $self, $attribute ) = @_;
885
886151102µs1513.88ms $self->invalidate_meta_instances;
# spent 3.88ms making 151 calls to Class::MOP::Class::invalidate_meta_instances, avg 26µs/call
887
888 # invalidate package flag here
889 try {
890151185µs local $SIG{__DIE__};
891151413µs151291ms $attribute->install_accessors;
# spent 199ms making 4 calls to Moose::Meta::Class::__ANON__::SERIAL::1::install_accessors, avg 49.7ms/call # spent 66.0ms making 25 calls to Moose::Meta::Attribute::install_accessors, avg 2.64ms/call # spent 25.8ms making 122 calls to Class::MOP::Attribute::install_accessors, avg 212µs/call
892 }
893 catch {
894 $self->remove_attribute( $attribute->name );
895 die $_;
8961515.26ms302285ms };
# spent 294ms making 151 calls to Try::Tiny::try, avg 1.95ms/call, recursion: max depth 1, sum of overlapping time 9.49ms # spent 348µs making 151 calls to Try::Tiny::catch, avg 2µs/call
897}
898
899sub remove_attribute {
900 my $self = shift;
901
902 my $removed_attribute = $self->SUPER::remove_attribute(@_)
903 or return;
904
905 $self->invalidate_meta_instances;
906
907 $removed_attribute->remove_accessors;
908 $removed_attribute->detach_from_class;
909
910 return$removed_attribute;
911}
912
913
# spent 1.27ms (403µs+870µs) within Class::MOP::Class::find_attribute_by_name which was called 54 times, avg 24µs/call: # 54 times (403µs+870µs) by Class::MOP::Class::_immutable_metaclass at line 1331, avg 24µs/call
sub find_attribute_by_name {
9145412µs my ( $self, $attr_name ) = @_;
915
9165444µs54342µs foreach my $class ( $self->linearized_isa ) {
# spent 323µs making 50 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 6µs/call # spent 20µs making 4 calls to Class::MOP::Class::linearized_isa, avg 5µs/call
917 # fetch the meta-class ...
9185446µs54185µs my $meta = Class::MOP::Class->initialize($class);
# spent 185µs making 54 calls to Class::MOP::Class::initialize, avg 3µs/call
91954159µs108343µs return $meta->get_attribute($attr_name)
# spent 185µs making 54 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 3µs/call # spent 158µs making 54 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 3µs/call
920 if $meta->has_attribute($attr_name);
921 }
922
923 return;
924}
925
926
# spent 12.1ms (4.04+8.05) within Class::MOP::Class::get_all_attributes which was called 196 times, avg 62µs/call: # 64 times (1.15ms+1.07ms) by Class::MOP::Class::_create_meta_instance at line 726, avg 35µs/call # 44 times (1.06ms+5.11ms) by Class::MOP::Class::_construct_instance at line 524, avg 140µs/call # 31 times (583µs+570µs) by Class::MOP::Class::_inline_slot_initializers at line 592, avg 37µs/call # 31 times (566µs+579µs) by Class::MOP::Class::_eval_environment at line 708, avg 37µs/call # 15 times (305µs+409µs) by Class::MOP::Class:::around at line 78 of Class/MOP/Class/Immutable/Trait.pm, avg 48µs/call # 5 times (197µs+156µs) by Moose::Meta::Attribute::new at line 95 of Moose/Meta/Attribute.pm, avg 71µs/call # 4 times (142µs+126µs) by Moose::Meta::Class::_call_all_triggers at line 296 of Moose/Meta/Class.pm, avg 67µs/call # once (21µs+13µs) by Moose::Meta::Class::_inline_triggers at line 467 of Moose/Meta/Class.pm # once (17µs+13µs) by Moose::Meta::Class::_eval_environment at line 505 of Moose/Meta/Class.pm
sub get_all_attributes {
92719619µs my $self = shift;
92817183.09ms17187.97ms my %attrs = map { %{ Class::MOP::Class->initialize($_)->_attribute_map } }
# spent 6.61ms making 761 calls to Class::MOP::Class::initialize, avg 9µs/call, recursion: max depth 1, sum of overlapping time 75µs # spent 898µs making 181 calls to Class::MOP::Class::linearized_isa, avg 5µs/call # spent 352µs making 761 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 463ns/call # spent 188µs making 15 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 13µs/call
929 reverse $self->linearized_isa;
930196534µs return values %attrs;
931}
932
933# Inheritance
934
935sub superclasses {
93615123µs my $self = shift;
937
938151183µs1518.06ms my $isa = $self->get_or_add_package_symbol('@ISA');
# spent 8.06ms making 151 calls to Class::MOP::Package::get_or_add_package_symbol, avg 53µs/call
939
94015122µs if (@_) {
9411534µs my @supers = @_;
94215150µs @{$isa} = @supers;
943
944 # NOTE:
945 # on 5.8 and below, we need to call
946 # a method to get Perl to detect
947 # a cycle in the class hierarchy
9481543µs1510µs my $class = $self->name;
# spent 10µs making 15 calls to Class::MOP::Package::name, avg 700ns/call
94915122µs1516µs $class->isa($class);
# spent 16µs making 15 calls to UNIVERSAL::isa, avg 1µs/call
950
951 # NOTE:
952 # we need to check the metaclass
953 # compatibility here so that we can
954 # be sure that the superclass is
955 # not potentially creating an issues
956 # we don't know about
957
9581520µs158.05ms $self->_check_metaclass_compatibility();
# spent 8.05ms making 15 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 536µs/call
9591524µs15597µs $self->_superclasses_updated();
# spent 597µs making 15 calls to Class::MOP::Class::_superclasses_updated, avg 40µs/call
960 }
961
962151278µs return @{$isa};
963}
964
965
# spent 597µs (147+449) within Class::MOP::Class::_superclasses_updated which was called 15 times, avg 40µs/call: # 15 times (147µs+449µs) by Class::MOP::Class::superclasses at line 959, avg 40µs/call
sub _superclasses_updated {
966152µs my $self = shift;
9671515µs1519µs $self->update_meta_instance_dependencies();
# spent 19µs making 15 calls to Class::MOP::Class::update_meta_instance_dependencies, avg 1µs/call
968 # keep strong references to all our parents, so they don't disappear if
969 # they are anon classes and don't have any direct instances
9702219µs2269µs $self->_superclass_metas(
# spent 69µs making 22 calls to Class::MOP::class_of, avg 3µs/call
971153.52ms3031µs map { Class::MOP::class_of($_) } $self->superclasses
# spent 31µs making 15 calls to Class::MOP::Class::_superclass_metas, avg 2µs/call # spent 22µs making 2 calls to Class::MOP::Class::superclasses, avg 11µs/call, recursion: max depth 1, sum of overlapping time 22µs # spent 308µs making 13 calls to Moose::Meta::Class::superclasses, avg 24µs/call, recursion: max depth 1, sum of overlapping time 308µs
972 );
973}
974
975
# spent 31µs within Class::MOP::Class::_superclass_metas which was called 15 times, avg 2µs/call: # 15 times (31µs+0s) by Class::MOP::Class::_superclasses_updated at line 971, avg 2µs/call
sub _superclass_metas {
976152µs my $self = shift;
9771534µs $self->{_superclass_metas} = [@_];
978}
979
980sub subclasses {
981 my $self = shift;
982 my $super_class = $self->name;
983
984 return @{ $super_class->mro::get_isarev() };
985}
986
987sub direct_subclasses {
988 my $self = shift;
989 my $super_class = $self->name;
990
991 return grep {
992 grep {
993 $_ eq $super_class
994 } Class::MOP::Class->initialize($_)->superclasses
995 } $self->subclasses;
996}
997
998
# spent 2.19ms (1.45+749µs) within Class::MOP::Class::linearized_isa which was called 430 times, avg 5µs/call: # 230 times (778µs+420µs) by Class::MOP::Class::_method_lookup_order at line 1037, avg 5µs/call # 181 times (601µs+297µs) by Class::MOP::Class::get_all_attributes at line 928, avg 5µs/call # 15 times (53µs+26µs) by Class::MOP::Class:::around at line 60 of Class/MOP/Class/Immutable/Trait.pm, avg 5µs/call # 4 times (14µs+6µs) by Class::MOP::Class::find_attribute_by_name at line 916, avg 5µs/call
sub linearized_isa {
9994302.50ms860749µs return @{ mro::get_linear_isa( (shift)->name ) };
# spent 584µs making 430 calls to mro::get_linear_isa, avg 1µs/call # spent 165µs making 430 calls to Class::MOP::Package::name, avg 383ns/call
1000}
1001
1002
# spent 1.17ms (302µs+869µs) within Class::MOP::Class::class_precedence_list which was called 23 times, avg 51µs/call: # 12 times (133µs+-133µs) by Class::MOP::Class:::around at line 53 of Class/MOP/Class/Immutable/Trait.pm, avg 0s/call # 10 times (161µs+1.01ms) by Moose::Meta::Class::excludes_role at line 267 of Moose/Meta/Class.pm, avg 117µs/call # once (7µs+-7µs) by Class::MOP::Class::class_precedence_list at line 1028
sub class_precedence_list {
1003232µs my $self = shift;
10042347µs239µs my $name = $self->name;
# spent 9µs making 23 calls to Class::MOP::Package::name, avg 400ns/call
1005
10062339µs239µs unless (Class::MOP::IS_RUNNING_ON_5_10()) {
# spent 9µs making 23 calls to Class::MOP::__ANON__, avg 404ns/call
1007 # NOTE:
1008 # We need to check for circular inheritance here
1009 # if we are not on 5.10, cause 5.8 detects it late.
1010 # This will do nothing if all is well, and blow up
1011 # otherwise. Yes, it's an ugly hack, better
1012 # suggestions are welcome.
1013 # - SL
1014 ($name || return)->isa('This is a test for circular inheritance')
1015 }
1016
1017 # if our mro is c3, we can
1018 # just grab the linear_isa
10192370µs2331µs if (mro::get_mro($name) eq 'c3') {
# spent 31µs making 23 calls to mro::get_mro, avg 1µs/call
1020 return @{ mro::get_linear_isa($name) }
1021 }
1022 else {
1023 # NOTE:
1024 # we can't grab the linear_isa for dfs
1025 # since it has all the duplicates
1026 # already removed.
1027 return (
10283155µs62766µs $name,
# spent 1.30ms making 30 calls to Class::MOP::Class::Immutable::Class::MOP::Class::class_precedence_list, avg 43µs/call, recursion: max depth 3, sum of overlapping time 648µs # spent 115µs making 31 calls to Class::MOP::Class::initialize, avg 4µs/call # spent 30µs making 1 call to Class::MOP::Class::class_precedence_list, recursion: max depth 1, sum of overlapping time 30µs
1029 map {
10302380µs23464µs Class::MOP::Class->initialize($_)->class_precedence_list()
# spent 259µs making 11 calls to Moose::Meta::Class::superclasses, avg 24µs/call # spent 206µs making 12 calls to Class::MOP::Class::Immutable::Class::MOP::Class::superclasses, avg 17µs/call
1031 } $self->superclasses()
1032 );
1033 }
1034}
1035
1036
# spent 1.68ms (486µs+1.20) within Class::MOP::Class::_method_lookup_order which was called 230 times, avg 7µs/call: # 112 times (228µs+566µs) by Class::MOP::Class::find_next_method_by_name at line 1168, avg 7µs/call # 108 times (235µs+578µs) by Class::MOP::Class::find_method_by_name at line 1122, avg 8µs/call # 8 times (18µs+45µs) by Class::MOP::Class::get_all_methods at line 1133, avg 8µs/call # 2 times (4µs+9µs) by Class::MOP::Class::find_all_methods_by_name at line 1152, avg 7µs/call
sub _method_lookup_order {
1037230421µs2301.20ms return (shift->linearized_isa, 'UNIVERSAL');
# spent 1.20ms making 230 calls to Class::MOP::Class::linearized_isa, avg 5µs/call
1038}
1039
1040## Methods
1041
1042{
10431100ns
# spent 14.6ms (899µs+13.7) within Class::MOP::Class::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Class/MOP/Class.pm:1072] which was called 68 times, avg 214µs/call: # 65 times (852µs+13.1ms) by Class::MOP::Class::add_around_method_modifier at line 1098, avg 215µs/call # 2 times (36µs+479µs) by Class::MOP::Class::add_before_method_modifier at line 1078, avg 257µs/call # once (12µs+60µs) by Class::MOP::Class::add_after_method_modifier at line 1088
my $fetch_and_prepare_method = sub {
10446810µs my ($self, $method_name) = @_;
104568164µs6831µs my $wrapped_metaclass = $self->wrapped_method_metaclass;
# spent 31µs making 68 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 462ns/call
1046 # fetch it locally
10476850µs681.04ms my $method = $self->get_method($method_name);
# spent 1.04ms making 68 calls to Class::MOP::Mixin::HasMethods::get_method, avg 15µs/call
1048 # if we don't have local ...
10496819µs unless ($method) {
1050 # try to find the next method
10515956µs594.05ms $method = $self->find_next_method_by_name($method_name);
# spent 4.05ms making 59 calls to Class::MOP::Class::find_next_method_by_name, avg 69µs/call
1052 # die if it does not exist
1053596µs (defined $method)
1054 || confess "The method '$method_name' was not found in the inheritance hierarchy for " . $self->name;
1055 # and now make sure to wrap it
1056 # even if it is already wrapped
1057 # because we need a new sub ref
105859197µs1184.73ms $method = $wrapped_metaclass->wrap($method,
# spent 4.70ms making 59 calls to Class::MOP::Method::Wrapped::wrap, avg 80µs/call # spent 33µs making 59 calls to Class::MOP::Package::name, avg 553ns/call
1059 package_name => $self->name,
1060 name => $method_name,
1061 );
1062 }
1063 else {
1064 # now make sure we wrap it properly
1065953µs25314µs $method = $wrapped_metaclass->wrap($method,
# spent 300µs making 8 calls to Class::MOP::Method::Wrapped::wrap, avg 37µs/call # spent 10µs making 9 calls to UNIVERSAL::isa, avg 1µs/call # spent 3µs making 8 calls to Class::MOP::Package::name, avg 400ns/call
1066 package_name => $self->name,
1067 name => $method_name,
1068 ) unless $method->isa($wrapped_metaclass);
1069 }
10706863µs683.50ms $self->add_method($method_name => $method);
# spent 3.50ms making 68 calls to Class::MOP::Mixin::HasMethods::add_method, avg 52µs/call
107168125µs return $method;
107213µs };
1073
1074
# spent 559µs (19+540) within Class::MOP::Class::add_before_method_modifier which was called 2 times, avg 280µs/call: # 2 times (19µs+540µs) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 231 of Moose/Meta/Role/Application/ToClass.pm, avg 280µs/call
sub add_before_method_modifier {
10752800ns my ($self, $method_name, $method_modifier) = @_;
10762900ns (defined $method_name && length $method_name)
1077 || confess "You must pass in a method name";
107823µs2515µs my $method = $fetch_and_prepare_method->($self, $method_name);
# spent 515µs making 2 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:1072], avg 257µs/call
1079214µs425µs $method->add_before_modifier(
# spent 22µs making 2 calls to Class::MOP::Method::Wrapped::add_before_modifier, avg 11µs/call # spent 3µs making 2 calls to Sub::Name::subname, avg 2µs/call
1080 subname(':before' => $method_modifier)
1081 );
1082 }
1083
1084
# spent 98µs (13+85) within Class::MOP::Class::add_after_method_modifier which was called: # once (13µs+85µs) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 231 of Moose/Meta/Role/Application/ToClass.pm
sub add_after_method_modifier {
10851500ns my ($self, $method_name, $method_modifier) = @_;
10861600ns (defined $method_name && length $method_name)
1087 || confess "You must pass in a method name";
108811µs172µs my $method = $fetch_and_prepare_method->($self, $method_name);
1089113µs213µs $method->add_after_modifier(
# spent 11µs making 1 call to Class::MOP::Method::Wrapped::add_after_modifier # spent 2µs making 1 call to Sub::Name::subname
1090 subname(':after' => $method_modifier)
1091 );
1092 }
1093
1094
# spent 15.4ms (401µs+15.0) within Class::MOP::Class::add_around_method_modifier which was called 65 times, avg 237µs/call: # 44 times (274µs+11.6ms) by Class::MOP::MiniTrait::apply at line 25 of Class/MOP/MiniTrait.pm, avg 269µs/call # 21 times (127µs+3.46ms) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 231 of Moose/Meta/Role/Application/ToClass.pm, avg 171µs/call
sub add_around_method_modifier {
10956518µs my ($self, $method_name, $method_modifier) = @_;
10966515µs (defined $method_name && length $method_name)
1097 || confess "You must pass in a method name";
10986557µs6514.0ms my $method = $fetch_and_prepare_method->($self, $method_name);
# spent 14.0ms making 65 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:1072], avg 215µs/call
109965332µs1301.05ms $method->add_around_modifier(
# spent 949µs making 65 calls to Class::MOP::Method::Wrapped::add_around_modifier, avg 15µs/call # spent 104µs making 65 calls to Sub::Name::subname, avg 2µs/call
1100 subname(':around' => $method_modifier)
1101 );
1102 }
1103
1104 # NOTE:
1105 # the methods above used to be named like this:
1106 # ${pkg}::${method}:(before|after|around)
1107 # but this proved problematic when using one modifier
1108 # to wrap multiple methods (something which is likely
1109 # to happen pretty regularly IMO). So instead of naming
1110 # it like this, I have chosen to just name them purely
1111 # with their modifier names, like so:
1112 # :(before|after|around)
1113 # The fact is that in a stack trace, it will be fairly
1114 # evident from the context what method they are attached
1115 # to, and so don't need the fully qualified name.
1116}
1117
1118
# spent 22.8ms (1.58+21.2) within Class::MOP::Class::find_method_by_name which was called 108 times, avg 211µs/call: # 58 times (1.04ms+14.4ms) by Class::MOP::MiniTrait::apply at line 25 of Class/MOP/MiniTrait.pm, avg 267µs/call # 36 times (402µs+5.87ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 28 of Class/MOP/Mixin/HasMethods.pm, avg 174µs/call # 7 times (69µs+318µs) by Moose::BEGIN@46 at line 18 of Moose/Meta/Attribute/Native.pm, avg 55µs/call # 4 times (40µs+283µs) by Moose::Meta::Role::Application::ToClass::check_required_methods at line 69 of Moose/Meta/Role/Application/ToClass.pm, avg 81µs/call # once (8µs+140µs) by MooseX::Storage::import at line 23 of MooseX/Storage.pm # once (11µs+109µs) by Moose::Meta::Class::_inline_BUILDARGS at line 335 of Moose/Meta/Class.pm # once (10µs+88µs) by Moose::Meta::Method::Destructor::is_needed at line 65 of Moose/Meta/Method/Destructor.pm
sub find_method_by_name {
111910826µs my ($self, $method_name) = @_;
112010827µs (defined $method_name && length $method_name)
1121 || confess "You must define a method name to find";
1122108114µs108813µs foreach my $class ($self->_method_lookup_order) {
# spent 813µs making 108 calls to Class::MOP::Class::_method_lookup_order, avg 8µs/call
1123367552µs73420.4ms my $method = Class::MOP::Class->initialize($class)->get_method($method_name);
# spent 15.2ms making 367 calls to Class::MOP::Mixin::HasMethods::get_method, avg 41µs/call # spent 5.21ms making 367 calls to Class::MOP::Class::initialize, avg 14µs/call
1124367187µs return $method if defined $method;
1125 }
11265570µs return;
1127}
1128
1129
# spent 2.61ms (282µs+2.33) within Class::MOP::Class::get_all_methods which was called 8 times, avg 326µs/call: # 8 times (282µs+2.33ms) by Class::MOP::MiniTrait::apply at line 22 of Class/MOP/MiniTrait.pm, avg 326µs/call
sub get_all_methods {
113082µs my $self = shift;
1131
113281µs my %methods;
1133812µs863µs for my $class ( reverse $self->_method_lookup_order ) {
# spent 63µs making 8 calls to Class::MOP::Class::_method_lookup_order, avg 8µs/call
11341717µs1762µs my $meta = Class::MOP::Class->initialize($class);
# spent 62µs making 17 calls to Class::MOP::Class::initialize, avg 4µs/call
1135
113617211µs1072.20ms $methods{ $_->name } = $_ for $meta->_get_local_methods;
# spent 2.17ms making 17 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 128µs/call # spent 35µs making 90 calls to Class::MOP::Method::name, avg 387ns/call
1137 }
1138
1139824µs return values %methods;
1140}
1141
1142sub get_all_method_names {
1143 my $self = shift;
1144 map { $_->name } $self->get_all_methods;
1145}
1146
1147
# spent 166µs (38+128) within Class::MOP::Class::find_all_methods_by_name which was called 2 times, avg 83µs/call: # once (24µs+68µs) by Moose::Meta::Class::_inline_BUILDALL at line 491 of Moose/Meta/Class.pm # once (14µs+60µs) by Moose::Meta::Method::Destructor::_generate_DEMOLISHALL at line 122 of Moose/Meta/Method/Destructor.pm
sub find_all_methods_by_name {
11482700ns my ($self, $method_name) = @_;
11492700ns (defined $method_name && length $method_name)
1150 || confess "You must define a method name to find";
11512200ns my @methods;
115223µs213µs foreach my $class ($self->_method_lookup_order) {
# spent 13µs making 2 calls to Class::MOP::Class::_method_lookup_order, avg 7µs/call
1153 # fetch the meta-class ...
115466µs621µs my $meta = Class::MOP::Class->initialize($class);
# spent 21µs making 6 calls to Class::MOP::Class::initialize, avg 4µs/call
115569µs793µs push @methods => {
# spent 83µs making 6 calls to Class::MOP::Mixin::HasMethods::has_method, avg 14µs/call # spent 10µs making 1 call to Class::MOP::Mixin::HasMethods::get_method
1156 name => $method_name,
1157 class => $class,
1158 code => $meta->get_method($method_name)
1159 } if $meta->has_method($method_name);
1160 }
116126µs return @methods;
1162}
1163
1164
# spent 6.63ms (1.18+5.45) within Class::MOP::Class::find_next_method_by_name which was called 112 times, avg 59µs/call: # 59 times (716µs+3.33ms) by Class::MOP::Class::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Class/MOP/Class.pm:1072] at line 1051, avg 69µs/call # 32 times (275µs+1.40ms) by Class::MOP::Method::Inlined::can_be_inlined at line 40 of Class/MOP/Method/Inlined.pm, avg 52µs/call # 21 times (188µs+721µs) by Moose::Meta::Method::Overridden::new at line 25 of Moose/Meta/Method/Overridden.pm, avg 43µs/call
sub find_next_method_by_name {
116511228µs my ($self, $method_name) = @_;
116611228µs (defined $method_name && length $method_name)
1167 || confess "You must define a method name to find";
1168112186µs112795µs my @cpl = ($self->_method_lookup_order);
# spent 795µs making 112 calls to Class::MOP::Class::_method_lookup_order, avg 7µs/call
116911222µs shift @cpl; # discard ourselves
117011232µs foreach my $class (@cpl) {
1171186309µs3724.65ms my $method = Class::MOP::Class->initialize($class)->get_method($method_name);
# spent 3.95ms making 186 calls to Class::MOP::Mixin::HasMethods::get_method, avg 21µs/call # spent 700µs making 186 calls to Class::MOP::Class::initialize, avg 4µs/call
1172186236µs return $method if defined $method;
1173 }
117423µs return;
1175}
1176
1177
# spent 19µs within Class::MOP::Class::update_meta_instance_dependencies which was called 15 times, avg 1µs/call: # 15 times (19µs+0s) by Class::MOP::Class::_superclasses_updated at line 967, avg 1µs/call
sub update_meta_instance_dependencies {
1178152µs my $self = shift;
1179
11801526µs if ( $self->{meta_instance_dependencies} ) {
1181 return $self->add_meta_instance_dependencies;
1182 }
1183}
1184
1185sub add_meta_instance_dependencies {
1186 my $self = shift;
1187
1188 $self->remove_meta_instance_dependencies;
1189
1190 my @attrs = $self->get_all_attributes();
1191
1192 my %seen;
1193 my @classes = grep { not $seen{ $_->name }++ }
1194 map { $_->associated_class } @attrs;
1195
1196 foreach my $class (@classes) {
1197 $class->add_dependent_meta_instance($self);
1198 }
1199
1200 $self->{meta_instance_dependencies} = \@classes;
1201}
1202
1203sub remove_meta_instance_dependencies {
1204 my $self = shift;
1205
1206 if ( my $classes = delete $self->{meta_instance_dependencies} ) {
1207 foreach my $class (@$classes) {
1208 $class->remove_dependent_meta_instance($self);
1209 }
1210
1211 return $classes;
1212 }
1213
1214 return;
1215
1216}
1217
1218sub add_dependent_meta_instance {
1219 my ( $self, $metaclass ) = @_;
1220 push @{ $self->{dependent_meta_instances} }, $metaclass;
1221}
1222
1223sub remove_dependent_meta_instance {
1224 my ( $self, $metaclass ) = @_;
1225 my $name = $metaclass->name;
1226 @$_ = grep { $_->name ne $name } @$_
1227 for $self->{dependent_meta_instances};
1228}
1229
1230
# spent 3.88ms (3.75+133µs) within Class::MOP::Class::invalidate_meta_instances which was called 151 times, avg 26µs/call: # 151 times (3.75ms+133µs) by Class::MOP::Class::_post_add_attribute at line 886, avg 26µs/call
sub invalidate_meta_instances {
123115116µs my $self = shift;
1232 $_->invalidate_meta_instance()
1233151535µs151133µs for $self, @{ $self->{dependent_meta_instances} };
# spent 133µs making 151 calls to Class::MOP::Class::invalidate_meta_instance, avg 878ns/call
1234}
1235
1236
# spent 133µs within Class::MOP::Class::invalidate_meta_instance which was called 151 times, avg 878ns/call: # 151 times (133µs+0s) by Class::MOP::Class::invalidate_meta_instances at line 1233, avg 878ns/call
sub invalidate_meta_instance {
123715112µs my $self = shift;
12381513.35ms undef $self->{_meta_instance};
1239}
1240
1241# check if we can reinitialize
1242sub is_pristine {
1243 my $self = shift;
1244
1245 # if any local attr is defined
1246 return if $self->get_attribute_list;
1247
1248 # or any non-declared methods
1249 for my $method ( map { $self->get_method($_) } $self->get_method_list ) {
1250 return if $method->isa("Class::MOP::Method::Generated");
1251 # FIXME do we need to enforce this too? return unless $method->isa( $self->method_metaclass );
1252 }
1253
1254 return 1;
1255}
1256
1257## Class closing
1258
125987102µs
# spent 42µs within Class::MOP::Class::is_mutable which was called 87 times, avg 489ns/call: # 54 times (27µs+0s) by Class::MOP::Class::make_immutable at line 1283, avg 504ns/call # 21 times (9µs+0s) by Atom::BEGIN@2 at line 234 of Moose.pm, avg 433ns/call # 9 times (5µs+0s) by Moose::Meta::Attribute::BEGIN@24 at line 707 of Moose/Util/TypeConstraints.pm, avg 511ns/call # 3 times (2µs+0s) by Atom::BEGIN@2 at line 270 of Moose.pm, avg 533ns/call
sub is_mutable { 1 }
12603951µs
# spent 21µs within Class::MOP::Class::is_immutable which was called 39 times, avg 528ns/call: # 39 times (21µs+0s) by Class::MOP::Class::_real_ref_name at line 128, avg 528ns/call
sub is_immutable { 0 }
1261
1262sub immutable_options { %{ $_[0]{__immutable}{options} || {} } }
1263
1264
# spent 635µs (530+106) within Class::MOP::Class::_immutable_options which was called 54 times, avg 12µs/call: # 53 times (503µs+99µs) by Class::MOP::Class::make_immutable at line 1287, avg 11µs/call # once (27µs+7µs) by Moose::Meta::Class::_immutable_options at line 755 of Moose/Meta/Class.pm
sub _immutable_options {
12655440µs my ( $self, @args ) = @_;
1266
1267 return (
126854609µs216106µs inline_accessors => 1,
# spent 31µs making 53 calls to Class::MOP::Class::immutable_trait, avg 591ns/call # spent 27µs making 54 calls to Class::MOP::Class::constructor_name, avg 502ns/call # spent 23µs making 53 calls to Class::MOP::Class::constructor_class, avg 432ns/call # spent 18µs making 53 calls to Class::MOP::Class::destructor_class, avg 345ns/call # spent 3µs making 1 call to Moose::Meta::Class::immutable_trait # spent 2µs making 1 call to Moose::Meta::Class::constructor_class # spent 2µs making 1 call to Moose::Meta::Class::destructor_class
1269 inline_constructor => 1,
1270 inline_destructor => 0,
1271 debug => 0,
1272 immutable_trait => $self->immutable_trait,
1273 constructor_name => $self->constructor_name,
1274 constructor_class => $self->constructor_class,
1275 destructor_class => $self->destructor_class,
1276 @args,
1277 );
1278}
1279
1280
# spent 154ms (615µs+153) within Class::MOP::Class::make_immutable which was called 54 times, avg 2.85ms/call: # 21 times (242µs+68.9ms) by Atom::BEGIN@2 at line 239 of Moose.pm, avg 3.29ms/call # 14 times (146µs+17.5ms) by Moose::Exporter::BEGIN@13 at line 687 of Class/MOP.pm, avg 1.26ms/call # 9 times (105µs+30.3ms) by Moose::Meta::Attribute::BEGIN@24 at line 712 of Moose/Util/TypeConstraints.pm, avg 3.38ms/call # 4 times (39µs+260µs) by Moose::Exporter::BEGIN@13 at line 713 of Class/MOP.pm, avg 75µs/call # 3 times (31µs+9.91ms) by Atom::BEGIN@2 at line 275 of Moose.pm, avg 3.31ms/call # 2 times (31µs+-31µs) by Class::MOP::Class::_immutable_metaclass at line 1361, avg 0s/call # once (21µs+26.2ms) by main::BEGIN@5 at line 127 of lib/HackaMol/Atom.pm
sub make_immutable {
12815448µs my ( $self, @args ) = @_;
1282
12835435µs5427µs return $self unless $self->is_mutable;
# spent 27µs making 54 calls to Class::MOP::Class::is_mutable, avg 504ns/call
1284
12855464µs my ($file, $line) = (caller)[1..2];
1286
128754175µs108124ms $self->_initialize_immutable(
# spent 123ms making 54 calls to Class::MOP::Class::_initialize_immutable, avg 2.28ms/call # spent 602µs making 53 calls to Class::MOP::Class::_immutable_options, avg 11µs/call # spent 41µs making 1 call to Moose::Meta::Class::_immutable_options
1288 file => $file,
1289 line => $line,
1290 $self->_immutable_options(@args),
1291 );
12925459µs5429.1ms $self->_rebless_as_immutable(@args);
# spent 29.3ms making 54 calls to Class::MOP::Class::_rebless_as_immutable, avg 542µs/call, recursion: max depth 1, sum of overlapping time 124µs
1293
12945494µs return $self;
1295}
1296
1297sub make_mutable {
1298 my $self = shift;
1299
1300 if ( $self->is_immutable ) {
1301 my @args = $self->immutable_options;
1302 $self->_rebless_as_mutable();
1303 $self->_remove_inlined_code(@args);
1304 delete $self->{__immutable};
1305 return $self;
1306 }
1307 else {
1308 return;
1309 }
1310}
1311
1312
# spent 29.1ms (265µs+28.9) within Class::MOP::Class::_rebless_as_immutable which was called 54 times, avg 539µs/call: # 54 times (265µs+28.9ms) by Class::MOP::Class::make_immutable at line 1292, avg 539µs/call
sub _rebless_as_immutable {
13135449µs my ( $self, @args ) = @_;
1314
13155431µs $self->{__immutable}{original_class} = ref $self;
1316
131754162µs5428.9ms bless $self => $self->_immutable_metaclass(@args);
# spent 29.0ms making 54 calls to Class::MOP::Class::_immutable_metaclass, avg 537µs/call, recursion: max depth 1, sum of overlapping time 108µs
1318}
1319
1320
# spent 28.9ms (671µs+28.2) within Class::MOP::Class::_immutable_metaclass which was called 54 times, avg 535µs/call: # 54 times (671µs+28.2ms) by Class::MOP::Class::_rebless_as_immutable at line 1317, avg 535µs/call
sub _immutable_metaclass {
13215447µs my ( $self, %args ) = @_;
1322
13235411µs if ( my $class = $args{immutable_metaclass} ) {
1324 return $class;
1325 }
1326
132754128µs5428µs my $trait = $args{immutable_trait} = $self->immutable_trait
# spent 26µs making 53 calls to Class::MOP::Class::immutable_trait, avg 498ns/call # spent 1µs making 1 call to Moose::Meta::Class::immutable_trait
1328 || confess "no immutable trait specified for $self";
1329
13305446µs54426µs my $meta = $self->meta;
# spent 426µs making 54 calls to Class::MOP::Object::meta, avg 8µs/call
13315464µs541.27ms my $meta_attr = $meta->find_attribute_by_name("immutable_trait");
# spent 1.27ms making 54 calls to Class::MOP::Class::find_attribute_by_name, avg 24µs/call
1332
133354600ns my $class_name;
1334
13355477µs5476µs if ( $meta_attr and $trait eq $meta_attr->default ) {
# spent 76µs making 54 calls to Class::MOP::Mixin::AttributeCore::default, avg 1µs/call
1336 # if the trait is the same as the default we try and pick a
1337 # predictable name for the immutable metaclass
1338 $class_name = 'Class::MOP::Class::Immutable::' . ref($self);
1339 }
1340 else {
1341 $class_name = join '::', 'Class::MOP::Class::Immutable::CustomTrait',
1342 $trait, 'ForMetaClass', ref($self);
1343 }
1344
134554291µs54106µs return $class_name
# spent 106µs making 54 calls to Class::Load::XS::is_class_loaded, avg 2µs/call
1346 if is_class_loaded($class_name);
1347
1348 # If the metaclass is a subclass of CMOP::Class which has had
1349 # metaclass roles applied (via Moose), then we want to make sure
1350 # that we preserve that anonymous class (see Fey::ORM for an
1351 # example of where this matters).
135223µs216µs my $meta_name = $meta->_real_ref_name;
# spent 16µs making 2 calls to Class::MOP::Class::_real_ref_name, avg 8µs/call
1353
135426µs24.89ms my $immutable_meta = $meta_name->create(
# spent 4.89ms making 2 calls to Class::MOP::Class::create, avg 2.45ms/call
1355 $class_name,
1356 superclasses => [ ref $self ],
1357 );
1358
135926µs221.3ms Class::MOP::MiniTrait::apply( $immutable_meta, $trait );
# spent 21.3ms making 2 calls to Class::MOP::MiniTrait::apply, avg 10.6ms/call
1360
136125µs20s $immutable_meta->make_immutable(
# spent 209µs making 2 calls to Class::MOP::Class::make_immutable, avg 104µs/call, recursion: max depth 1, sum of overlapping time 209µs
1362 inline_constructor => 0,
1363 inline_accessors => 0,
1364 );
1365
136624µs return $class_name;
1367}
1368
1369sub _remove_inlined_code {
1370 my $self = shift;
1371
1372 $self->remove_method( $_->name ) for $self->_inlined_methods;
1373
1374 delete $self->{__immutable}{inlined_methods};
1375}
1376
1377sub _inlined_methods { @{ $_[0]{__immutable}{inlined_methods} || [] } }
1378
1379
# spent 68µs within Class::MOP::Class::_add_inlined_method which was called 32 times, avg 2µs/call: # 31 times (66µs+0s) by Class::MOP::Class::_inline_constructor at line 1453, avg 2µs/call # once (2µs+0s) by Class::MOP::Class::_inline_destructor at line 1491
sub _add_inlined_method {
1380327µs my ( $self, $method ) = @_;
1381
13823279µs push @{ $self->{__immutable}{inlined_methods} ||= [] }, $method;
1383}
1384
1385
# spent 123ms (420µs+123) within Class::MOP::Class::_initialize_immutable which was called 54 times, avg 2.28ms/call: # 54 times (420µs+123ms) by Class::MOP::Class::make_immutable at line 1287, avg 2.28ms/call
sub _initialize_immutable {
138654185µs my ( $self, %args ) = @_;
1387
13885447µs $self->{__immutable}{options} = \%args;
138954160µs54123ms $self->_install_inlined_code(%args);
# spent 123ms making 54 calls to Class::MOP::Class::_install_inlined_code, avg 2.28ms/call
1390}
1391
1392
# spent 123ms (362µs+123) within Class::MOP::Class::_install_inlined_code which was called 54 times, avg 2.28ms/call: # 54 times (362µs+123ms) by Class::MOP::Class::_initialize_immutable at line 1389, avg 2.28ms/call
sub _install_inlined_code {
13935486µs my ( $self, %args ) = @_;
1394
1395 # FIXME
13965462µs3345.8ms $self->_inline_accessors(%args) if $args{inline_accessors};
# spent 45.8ms making 33 calls to Class::MOP::Class::_inline_accessors, avg 1.39ms/call
13975464µs3176.0ms $self->_inline_constructor(%args) if $args{inline_constructor};
# spent 76.0ms making 31 calls to Class::MOP::Class::_inline_constructor, avg 2.45ms/call
139854122µs1756µs $self->_inline_destructor(%args) if $args{inline_destructor};
# spent 756µs making 1 call to Class::MOP::Class::_inline_destructor
1399}
1400
1401sub _rebless_as_mutable {
1402 my $self = shift;
1403
1404 bless $self, $self->_get_mutable_metaclass_name;
1405
1406 return $self;
1407}
1408
1409
# spent 45.8ms (384µs+45.4) within Class::MOP::Class::_inline_accessors which was called 33 times, avg 1.39ms/call: # 33 times (384µs+45.4ms) by Class::MOP::Class::_install_inlined_code at line 1396, avg 1.39ms/call
sub _inline_accessors {
1410334µs my $self = shift;
1411
14123381µs33110µs foreach my $attr_name ( $self->get_attribute_list ) {
# spent 110µs making 33 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 3µs/call
141376145µs15245.3ms $self->get_attribute($attr_name)->install_accessors(1);
# spent 44.0ms making 75 calls to Class::MOP::Attribute::install_accessors, avg 586µs/call # spent 1.03ms making 1 call to Moose::Meta::Attribute::install_accessors # spent 273µs making 76 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 4µs/call
1414 }
1415}
1416
1417
# spent 76.0ms (629µs+75.4) within Class::MOP::Class::_inline_constructor which was called 31 times, avg 2.45ms/call: # 31 times (629µs+75.4ms) by Class::MOP::Class::_install_inlined_code at line 1397, avg 2.45ms/call
sub _inline_constructor {
14183176µs my ( $self, %args ) = @_;
1419
1420317µs my $name = $args{constructor_name};
1421 # A class may not even have a constructor, and that's okay.
1422314µs return unless defined $name;
1423
14243127µs31566µs if ( $self->has_method($name) && !$args{replace_constructor} ) {
# spent 566µs making 31 calls to Class::MOP::Mixin::HasMethods::has_method, avg 18µs/call
1425 my $class = $self->name;
1426 warn "Not inlining a constructor for $class since it defines"
1427 . " its own constructor.\n"
1428 . "If you are certain you don't need to inline your"
1429 . " constructor, specify inline_constructor => 0 in your"
1430 . " call to $class->meta->make_immutable\n";
1431 return;
1432 }
1433
1434318µs my $constructor_class = $args{constructor_class};
1435
14363123µs31654µs load_class($constructor_class);
# spent 654µs making 31 calls to Class::Load::load_class, avg 21µs/call
1437
143831212µs9370.4ms my $constructor = $constructor_class->new(
# spent 55.3ms making 30 calls to Class::MOP::Method::Constructor::new, avg 1.84ms/call # spent 15.1ms making 1 call to Moose::Meta::Method::Constructor::new # spent 28µs making 62 calls to Class::MOP::Package::name, avg 455ns/call
1439 options => \%args,
1440 metaclass => $self,
1441 is_inline => 1,
1442 package_name => $self->name,
1443 name => $name,
1444 definition_context => {
1445 description => "constructor " . $self->name . "::" . $name,
1446 file => $args{file},
1447 line => $args{line},
1448 },
1449 );
1450
14513196µs312.10ms if ( $args{replace_constructor} or $constructor->can_be_inlined ) {
# spent 2.10ms making 31 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 68µs/call
14523128µs311.64ms $self->add_method( $name => $constructor );
# spent 1.64ms making 31 calls to Class::MOP::Mixin::HasMethods::add_method, avg 53µs/call
14533134µs3166µs $self->_add_inlined_method($constructor);
# spent 66µs making 31 calls to Class::MOP::Class::_add_inlined_method, avg 2µs/call
1454 }
1455}
1456
1457
# spent 756µs (42+715) within Class::MOP::Class::_inline_destructor which was called: # once (42µs+715µs) by Class::MOP::Class::_install_inlined_code at line 1398
sub _inline_destructor {
145813µs my ( $self, %args ) = @_;
1459
14601800ns ( exists $args{destructor_class} && defined $args{destructor_class} )
1461 || confess "The 'inline_destructor' option is present, but "
1462 . "no destructor class was specified";
1463
146411µs116µs if ( $self->has_method('DESTROY') && ! $args{replace_destructor} ) {
# spent 16µs making 1 call to Class::MOP::Mixin::HasMethods::has_method
1465 my $class = $self->name;
1466 warn "Not inlining a destructor for $class since it defines"
1467 . " its own destructor.\n";
1468 return;
1469 }
1470
14711600ns my $destructor_class = $args{destructor_class};
1472
147311µs121µs load_class($destructor_class);
# spent 21µs making 1 call to Class::Load::load_class
1474
147514µs1111µs return unless $destructor_class->is_needed($self);
# spent 111µs making 1 call to Moose::Meta::Method::Destructor::is_needed
1476
1477110µs3410µs my $destructor = $destructor_class->new(
# spent 409µs making 1 call to Moose::Meta::Method::Destructor::new # spent 1µs making 2 calls to Class::MOP::Package::name, avg 500ns/call
1478 options => \%args,
1479 metaclass => $self,
1480 package_name => $self->name,
1481 name => 'DESTROY',
1482 definition_context => {
1483 description => "destructor " . $self->name . "::DESTROY",
1484 file => $args{file},
1485 line => $args{line},
1486 },
1487 );
1488
148918µs1101µs if ( $args{replace_destructor} or $destructor->can_be_inlined ) {
# spent 101µs making 1 call to Class::MOP::Method::Inlined::can_be_inlined
149011µs155µs $self->add_method( 'DESTROY' => $destructor );
# spent 55µs making 1 call to Class::MOP::Mixin::HasMethods::add_method
149111µs12µs $self->_add_inlined_method($destructor);
# spent 2µs making 1 call to Class::MOP::Class::_add_inlined_method
1492 }
1493}
1494
149516µs1;
1496
1497# ABSTRACT: Class Meta Object
1498
1499__END__
 
# spent 8.23ms (7.22+1.01) within Class::MOP::Class::CORE:sort which was called 62 times, avg 133µs/call: # 31 times (5.37ms+515µs) by Class::MOP::Class::_inline_slot_initializers at line 592, avg 190µs/call # 31 times (1.85ms+498µs) by Class::MOP::Class::_eval_environment at line 708, avg 76µs/call
sub Class::MOP::Class::CORE:sort; # opcode