| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Class.pm |
| Statements | Executed 14341 statements in 262ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 785 | 8 | 3 | 55.2ms | 817ms | Moose::Meta::Class::superclasses (recurses: max depth 1, inclusive time 57.2ms) |
| 312 | 2 | 1 | 47.5ms | 71.0ms | Moose::Meta::Class::_base_metaclasses |
| 110 | 2 | 2 | 32.4ms | 428ms | Moose::Meta::Class::new_object |
| 73 | 1 | 1 | 18.8ms | 128ms | Moose::Meta::Class::excludes_role |
| 1872 | 1 | 1 | 17.8ms | 17.8ms | Moose::Meta::Class::CORE:subst (opcode) |
| 42 | 1 | 1 | 10.9ms | 628ms | Moose::Meta::Class::reinitialize |
| 1 | 1 | 1 | 10.1ms | 13.9ms | Moose::Meta::Class::BEGIN@26 |
| 72 | 3 | 3 | 7.58ms | 5.19s | Moose::Meta::Class::add_attribute (recurses: max depth 1, inclusive time 79.9ms) |
| 44 | 2 | 2 | 6.80ms | 42.6ms | Moose::Meta::Class::does_role |
| 116 | 4 | 4 | 6.72ms | 1.18s | Moose::Meta::Class::create_anon_class |
| 1 | 1 | 1 | 6.49ms | 7.50ms | Moose::Meta::Class::BEGIN@23 |
| 110 | 4 | 4 | 6.17ms | 687ms | Moose::Meta::Class::initialize |
| 73 | 1 | 1 | 3.69ms | 5.66ms | Moose::Meta::Class::add_role |
| 73 | 1 | 1 | 3.48ms | 5.41ms | Moose::Meta::Class::add_role_application |
| 116 | 1 | 1 | 3.28ms | 3.76ms | Moose::Meta::Class::_anon_cache_key |
| 1 | 1 | 1 | 2.84ms | 3.93ms | Moose::Meta::Class::BEGIN@24 |
| 50 | 1 | 1 | 2.74ms | 3.84s | Moose::Meta::Class::_process_new_attribute |
| 45 | 1 | 1 | 2.69ms | 70.1ms | Moose::Meta::Class::add_override_method_modifier |
| 51 | 1 | 1 | 2.65ms | 3.84s | Moose::Meta::Class::_process_attribute |
| 1 | 1 | 1 | 1.95ms | 16.0ms | Moose::Meta::Class::BEGIN@21 |
| 42 | 1 | 1 | 1.79ms | 7.35ms | Moose::Meta::Class::_immutable_options |
| 22 | 1 | 1 | 1.72ms | 1.17s | Moose::Meta::Class::create |
| 1 | 1 | 1 | 1.61ms | 2.48ms | Moose::Meta::Class::BEGIN@22 |
| 1 | 1 | 1 | 1.58ms | 2.11ms | Moose::Meta::Class::BEGIN@20 |
| 1 | 1 | 1 | 1.39ms | 16.1ms | Moose::Meta::Class::BEGIN@19 |
| 1 | 1 | 1 | 1.30ms | 1.98ms | Moose::Meta::Class::BEGIN@25 |
| 110 | 1 | 1 | 1.26ms | 1.26ms | Moose::Meta::Class::__ANON__[:40] |
| 110 | 1 | 1 | 1.23ms | 1.23ms | Moose::Meta::Class::__ANON__[:35] |
| 68 | 1 | 1 | 662µs | 662µs | Moose::Meta::Class::_meta_method_class |
| 6 | 1 | 1 | 485µs | 1.69ms | Moose::Meta::Class::calculate_all_roles |
| 116 | 1 | 1 | 484µs | 484µs | Moose::Meta::Class::CORE:sort (opcode) |
| 51 | 1 | 1 | 293µs | 293µs | Moose::Meta::Class::CORE:match (opcode) |
| 1 | 1 | 1 | 116µs | 143µs | Moose::Meta::Class::BEGIN@4 |
| 1 | 1 | 1 | 114µs | 2.66ms | Moose::Meta::Class::_process_inherited_attribute |
| 1 | 1 | 1 | 67µs | 224µs | Moose::Meta::Class::BEGIN@11 |
| 1 | 1 | 1 | 54µs | 147µs | Moose::Meta::Class::BEGIN@5 |
| 1 | 1 | 1 | 42µs | 319µs | Moose::Meta::Class::BEGIN@29 |
| 1 | 1 | 1 | 42µs | 66µs | Moose::Meta::Class::BEGIN@10 |
| 1 | 1 | 1 | 38µs | 254µs | Moose::Meta::Class::BEGIN@12 |
| 1 | 1 | 1 | 37µs | 37µs | Moose::Meta::Class::BEGIN@7 |
| 1 | 1 | 1 | 37µs | 203µs | Moose::Meta::Class::BEGIN@9 |
| 1 | 1 | 1 | 36µs | 194µs | Moose::Meta::Class::BEGIN@13 |
| 1 | 1 | 1 | 29µs | 29µs | Moose::Meta::Class::BEGIN@27 |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_find_next_method_by_name_which_is_not_overridden |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_fix_class_metaclass_incompatibility |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_fix_single_metaclass_incompatibility |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_replace_self |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::add_augment_method_modifier |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::calculate_all_roles_with_inheritance |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::create_error |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::raise_error |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::role_applications |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::throw_error |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | package Moose::Meta::Class; | ||||
| 3 | |||||
| 4 | 3 | 156µs | 2 | 169µs | # spent 143µs (116+26) within Moose::Meta::Class::BEGIN@4 which was called:
# once (116µs+26µs) by Moose::BEGIN@19 at line 4 # spent 143µs making 1 call to Moose::Meta::Class::BEGIN@4
# spent 26µs making 1 call to strict::import |
| 5 | 3 | 148µs | 2 | 239µs | # spent 147µs (54+93) within Moose::Meta::Class::BEGIN@5 which was called:
# once (54µs+93µs) by Moose::BEGIN@19 at line 5 # spent 147µs making 1 call to Moose::Meta::Class::BEGIN@5
# spent 93µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 3 | 119µs | 1 | 37µs | # spent 37µs within Moose::Meta::Class::BEGIN@7 which was called:
# once (37µs+0s) by Moose::BEGIN@19 at line 7 # spent 37µs making 1 call to Moose::Meta::Class::BEGIN@7 |
| 8 | |||||
| 9 | 3 | 194µs | 2 | 368µs | # spent 203µs (37+166) within Moose::Meta::Class::BEGIN@9 which was called:
# once (37µs+166µs) by Moose::BEGIN@19 at line 9 # spent 203µs making 1 call to Moose::Meta::Class::BEGIN@9
# spent 166µs making 1 call to Exporter::import |
| 10 | 3 | 100µs | 2 | 90µs | # spent 66µs (42+24) within Moose::Meta::Class::BEGIN@10 which was called:
# once (42µs+24µs) by Moose::BEGIN@19 at line 10 # spent 66µs making 1 call to Moose::Meta::Class::BEGIN@10
# spent 24µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:284] |
| 11 | 3 | 113µs | 2 | 381µs | # spent 224µs (67+157) within Moose::Meta::Class::BEGIN@11 which was called:
# once (67µs+157µs) by Moose::BEGIN@19 at line 11 # spent 224µs making 1 call to Moose::Meta::Class::BEGIN@11
# spent 156µs making 1 call to Exporter::import |
| 12 | 3 | 108µs | 2 | 470µs | # spent 254µs (38+216) within Moose::Meta::Class::BEGIN@12 which was called:
# once (38µs+216µs) by Moose::BEGIN@19 at line 12 # spent 254µs making 1 call to Moose::Meta::Class::BEGIN@12
# spent 216µs making 1 call to Exporter::import |
| 13 | 3 | 215µs | 2 | 353µs | # spent 194µs (36+158) within Moose::Meta::Class::BEGIN@13 which was called:
# once (36µs+158µs) by Moose::BEGIN@19 at line 13 # spent 194µs making 1 call to Moose::Meta::Class::BEGIN@13
# spent 158µs making 1 call to Exporter::import |
| 14 | |||||
| 15 | 1 | 7µs | our $VERSION = '1.19'; | ||
| 16 | 1 | 108µs | $VERSION = eval $VERSION; # spent 16µs executing statements in string eval | ||
| 17 | 1 | 6µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 18 | |||||
| 19 | 3 | 490µs | 1 | 16.1ms | # spent 16.1ms (1.39+14.7) within Moose::Meta::Class::BEGIN@19 which was called:
# once (1.39ms+14.7ms) by Moose::BEGIN@19 at line 19 # spent 16.1ms making 1 call to Moose::Meta::Class::BEGIN@19 |
| 20 | 3 | 517µs | 1 | 2.11ms | # spent 2.11ms (1.58+524µs) within Moose::Meta::Class::BEGIN@20 which was called:
# once (1.58ms+524µs) by Moose::BEGIN@19 at line 20 # spent 2.11ms making 1 call to Moose::Meta::Class::BEGIN@20 |
| 21 | 3 | 628µs | 1 | 16.0ms | # spent 16.0ms (1.95+14.1) within Moose::Meta::Class::BEGIN@21 which was called:
# once (1.95ms+14.1ms) by Moose::BEGIN@19 at line 21 # spent 16.0ms making 1 call to Moose::Meta::Class::BEGIN@21 |
| 22 | 3 | 489µs | 1 | 2.48ms | # spent 2.48ms (1.61+870µs) within Moose::Meta::Class::BEGIN@22 which was called:
# once (1.61ms+870µs) by Moose::BEGIN@19 at line 22 # spent 2.48ms making 1 call to Moose::Meta::Class::BEGIN@22 |
| 23 | 3 | 516µs | 1 | 7.50ms | # spent 7.50ms (6.49+1.01) within Moose::Meta::Class::BEGIN@23 which was called:
# once (6.49ms+1.01ms) by Moose::BEGIN@19 at line 23 # spent 7.50ms making 1 call to Moose::Meta::Class::BEGIN@23 |
| 24 | 3 | 494µs | 1 | 3.93ms | # spent 3.93ms (2.84+1.09) within Moose::Meta::Class::BEGIN@24 which was called:
# once (2.84ms+1.09ms) by Moose::BEGIN@19 at line 24 # spent 3.93ms making 1 call to Moose::Meta::Class::BEGIN@24 |
| 25 | 3 | 586µs | 1 | 1.98ms | # spent 1.98ms (1.30+676µs) within Moose::Meta::Class::BEGIN@25 which was called:
# once (1.30ms+676µs) by Moose::BEGIN@19 at line 25 # spent 1.98ms making 1 call to Moose::Meta::Class::BEGIN@25 |
| 26 | 3 | 765µs | 2 | 14.5ms | # spent 13.9ms (10.1+3.86) within Moose::Meta::Class::BEGIN@26 which was called:
# once (10.1ms+3.86ms) by Moose::BEGIN@19 at line 26 # spent 13.9ms making 1 call to Moose::Meta::Class::BEGIN@26
# spent 589µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756] |
| 27 | 3 | 107µs | 1 | 29µs | # spent 29µs within Moose::Meta::Class::BEGIN@27 which was called:
# once (29µs+0s) by Moose::BEGIN@19 at line 27 # spent 29µs making 1 call to Moose::Meta::Class::BEGIN@27 |
| 28 | |||||
| 29 | 3 | 8.07ms | 2 | 595µs | # spent 319µs (42+277) within Moose::Meta::Class::BEGIN@29 which was called:
# once (42µs+277µs) by Moose::BEGIN@19 at line 29 # spent 319µs making 1 call to Moose::Meta::Class::BEGIN@29
# spent 277µs making 1 call to base::import |
| 30 | |||||
| 31 | 1 | 21µs | 1 | 12.8ms | Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait'); # spent 12.8ms making 1 call to Class::MOP::MiniTrait::apply |
| 32 | |||||
| 33 | __PACKAGE__->meta->add_attribute('roles' => ( | ||||
| 34 | reader => 'roles', | ||||
| 35 | 110 | 1.56ms | # spent 1.23ms within Moose::Meta::Class::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Class.pm:35] which was called 110 times, avg 11µs/call:
# 110 times (1.23ms+0s) by Class::MOP::Mixin::AttributeCore::default at line 53 of Class/MOP/Mixin/AttributeCore.pm, avg 11µs/call | ||
| 36 | 1 | 70µs | 2 | 2.79ms | )); # spent 2.71ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 84µs making 1 call to Class::MOP::Object::meta |
| 37 | |||||
| 38 | __PACKAGE__->meta->add_attribute('role_applications' => ( | ||||
| 39 | reader => '_get_role_applications', | ||||
| 40 | 110 | 1.40ms | # spent 1.26ms within Moose::Meta::Class::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Class.pm:40] which was called 110 times, avg 11µs/call:
# 110 times (1.26ms+0s) by Class::MOP::Mixin::AttributeCore::default at line 53 of Class/MOP/Mixin/AttributeCore.pm, avg 11µs/call | ||
| 41 | 1 | 33µs | 2 | 2.20ms | )); # spent 2.11ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 87µs making 1 call to Class::MOP::Object::meta |
| 42 | |||||
| 43 | 1 | 45µs | 3 | 2.11ms | __PACKAGE__->meta->add_attribute( # spent 1.87ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 125µs making 1 call to Class::MOP::Attribute::new
# spent 110µs making 1 call to Class::MOP::Object::meta |
| 44 | Class::MOP::Attribute->new('immutable_trait' => ( | ||||
| 45 | accessor => "immutable_trait", | ||||
| 46 | default => 'Moose::Meta::Class::Immutable::Trait', | ||||
| 47 | )) | ||||
| 48 | ); | ||||
| 49 | |||||
| 50 | 1 | 26µs | 2 | 2.13ms | __PACKAGE__->meta->add_attribute('constructor_class' => ( # spent 2.04ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 86µs making 1 call to Class::MOP::Object::meta |
| 51 | accessor => 'constructor_class', | ||||
| 52 | default => 'Moose::Meta::Method::Constructor', | ||||
| 53 | )); | ||||
| 54 | |||||
| 55 | 1 | 24µs | 2 | 2.17ms | __PACKAGE__->meta->add_attribute('destructor_class' => ( # spent 2.09ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 84µs making 1 call to Class::MOP::Object::meta |
| 56 | accessor => 'destructor_class', | ||||
| 57 | default => 'Moose::Meta::Method::Destructor', | ||||
| 58 | )); | ||||
| 59 | |||||
| 60 | 1 | 26µs | 2 | 7.81ms | __PACKAGE__->meta->add_attribute('error_class' => ( # spent 7.72ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 84µs making 1 call to Class::MOP::Object::meta |
| 61 | accessor => 'error_class', | ||||
| 62 | default => 'Moose::Error::Default', | ||||
| 63 | )); | ||||
| 64 | |||||
| 65 | # spent 687ms (6.17+680) within Moose::Meta::Class::initialize which was called 110 times, avg 6.24ms/call:
# 45 times (2.59ms+211ms) by Moose::init_meta at line 199 of Moose.pm, avg 4.74ms/call
# 42 times (2.32ms+371ms) by Class::MOP::Package::reinitialize at line 60 of Class/MOP/Package.pm, avg 8.90ms/call
# 22 times (1.16ms+91.9ms) by Class::MOP::Class::create at line 525 of Class/MOP/Class.pm, avg 4.23ms/call
# once (110µs+6.52ms) by metaclass::import at line 45 of metaclass.pm | ||||
| 66 | 110 | 511µs | my $class = shift; | ||
| 67 | 110 | 316µs | my $pkg = shift; | ||
| 68 | 110 | 5.10ms | 220 | 680ms | return Class::MOP::get_metaclass_by_name($pkg) # spent 679ms making 110 calls to Class::MOP::Class::initialize, avg 6.18ms/call
# spent 1.02ms making 110 calls to Class::MOP::get_metaclass_by_name, avg 9µs/call |
| 69 | || $class->SUPER::initialize($pkg, | ||||
| 70 | 'attribute_metaclass' => 'Moose::Meta::Attribute', | ||||
| 71 | 'method_metaclass' => 'Moose::Meta::Method', | ||||
| 72 | 'instance_metaclass' => 'Moose::Meta::Instance', | ||||
| 73 | @_ | ||||
| 74 | ); | ||||
| 75 | } | ||||
| 76 | |||||
| 77 | # spent 1.17s (1.72ms+1.17) within Moose::Meta::Class::create which was called 22 times, avg 53.2ms/call:
# 22 times (1.72ms+1.17s) by Class::MOP::Class::create_anon_class at line 453 of Class/MOP/Class.pm, avg 53.2ms/call | ||||
| 78 | 22 | 178µs | my ($class, $package_name, %options) = @_; | ||
| 79 | |||||
| 80 | 22 | 125µs | (ref $options{roles} eq 'ARRAY') | ||
| 81 | || $class->throw_error("You must pass an ARRAY ref of roles", data => $options{roles}) | ||||
| 82 | if exists $options{roles}; | ||||
| 83 | 22 | 86µs | my $roles = delete $options{roles}; | ||
| 84 | |||||
| 85 | 22 | 575µs | 22 | 331ms | my $new_meta = $class->SUPER::create($package_name, %options); # spent 331ms making 22 calls to Class::MOP::Class::create, avg 15.0ms/call |
| 86 | |||||
| 87 | 22 | 344µs | 20 | 838ms | if ($roles) { # spent 838ms making 20 calls to Moose::Util::apply_all_roles, avg 41.9ms/call |
| 88 | Moose::Util::apply_all_roles( $new_meta, @$roles ); | ||||
| 89 | } | ||||
| 90 | |||||
| 91 | 22 | 410µs | return $new_meta; | ||
| 92 | } | ||||
| 93 | |||||
| 94 | 1 | 3µs | my %ANON_CLASSES; | ||
| 95 | |||||
| 96 | # spent 1.18s (6.72ms+1.18) within Moose::Meta::Class::create_anon_class which was called 116 times, avg 10.2ms/call:
# 80 times (3.81ms+70.3ms) by Moose::Util::MetaRole::_make_new_class at line 163 of Moose/Util/MetaRole.pm, avg 927µs/call
# 28 times (2.06ms+791ms) by Moose::Meta::Attribute::Native::Trait::_native_accessor_class_for at line 172 of Moose/Meta/Attribute/Native/Trait.pm, avg 28.3ms/call
# 6 times (629µs+285ms) by Moose::Meta::Attribute::interpolate_class at line 124 of Moose/Meta/Attribute.pm, avg 47.6ms/call
# 2 times (219µs+29.8ms) by MooseX::Role::Parameterized::Meta::Role::Parameterizable::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm:31] at line 27 of MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm, avg 15.0ms/call | ||||
| 97 | 116 | 1.18ms | my ($self, %options) = @_; | ||
| 98 | |||||
| 99 | 116 | 549µs | my $cache_ok = delete $options{cache}; | ||
| 100 | |||||
| 101 | 116 | 1.46ms | 116 | 3.76ms | my $cache_key # spent 3.76ms making 116 calls to Moose::Meta::Class::_anon_cache_key, avg 32µs/call |
| 102 | = _anon_cache_key( $options{superclasses}, $options{roles} ); | ||||
| 103 | |||||
| 104 | 116 | 1.74ms | if ($cache_ok && defined $ANON_CLASSES{$cache_key}) { | ||
| 105 | return $ANON_CLASSES{$cache_key}; | ||||
| 106 | } | ||||
| 107 | |||||
| 108 | 22 | 131µs | $options{weaken} = !$cache_ok | ||
| 109 | unless exists $options{weaken}; | ||||
| 110 | |||||
| 111 | 22 | 775µs | 22 | 1.17s | my $new_class = $self->SUPER::create_anon_class(%options); # spent 1.17s making 22 calls to Class::MOP::Class::create_anon_class, avg 53.3ms/call |
| 112 | |||||
| 113 | 22 | 92µs | if ($cache_ok) { | ||
| 114 | 20 | 153µs | $ANON_CLASSES{$cache_key} = $new_class; | ||
| 115 | 20 | 444µs | 20 | 166µs | weaken($ANON_CLASSES{$cache_key}); # spent 166µs making 20 calls to Scalar::Util::weaken, avg 8µs/call |
| 116 | } | ||||
| 117 | |||||
| 118 | 22 | 476µs | return $new_class; | ||
| 119 | } | ||||
| 120 | |||||
| 121 | 68 | 876µs | # spent 662µs within Moose::Meta::Class::_meta_method_class which was called 68 times, avg 10µs/call:
# 68 times (662µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 30 of Class/MOP/Mixin/HasMethods.pm, avg 10µs/call | ||
| 122 | |||||
| 123 | # spent 3.76ms (3.28+484µs) within Moose::Meta::Class::_anon_cache_key which was called 116 times, avg 32µs/call:
# 116 times (3.28ms+484µs) by Moose::Meta::Class::create_anon_class at line 101, avg 32µs/call | ||||
| 124 | # Makes something like Super::Class|Super::Class::2=Role|Role::1 | ||||
| 125 | return join '=' => ( | ||||
| 126 | join( '|', @{ $_[0] || [] } ), | ||||
| 127 | 116 | 4.01ms | 116 | 484µs | join( '|', sort @{ $_[1] || [] } ), # spent 484µs making 116 calls to Moose::Meta::Class::CORE:sort, avg 4µs/call |
| 128 | ); | ||||
| 129 | } | ||||
| 130 | |||||
| 131 | # spent 628ms (10.9+617) within Moose::Meta::Class::reinitialize which was called 42 times, avg 14.9ms/call:
# 42 times (10.9ms+617ms) by Moose::Util::MetaRole::_make_new_metaclass at line 128 of Moose/Util/MetaRole.pm, avg 14.9ms/call | ||||
| 132 | 42 | 165µs | my $self = shift; | ||
| 133 | 42 | 98µs | my $pkg = shift; | ||
| 134 | |||||
| 135 | 42 | 809µs | 42 | 291µs | my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg); # spent 291µs making 42 calls to Scalar::Util::blessed, avg 7µs/call |
| 136 | |||||
| 137 | 42 | 77µs | my $cache_key; | ||
| 138 | |||||
| 139 | 42 | 85µs | my %existing_classes; | ||
| 140 | 42 | 210µs | if ($meta) { | ||
| 141 | 42 | 5.50ms | 294 | 3.80ms | %existing_classes = map { $_ => $meta->$_() } qw( # spent 601µs making 42 calls to Moose::Meta::Class::destructor_class, avg 14µs/call
# spent 566µs making 42 calls to Moose::Meta::Class::error_class, avg 13µs/call
# spent 565µs making 42 calls to Moose::Meta::Class::constructor_class, avg 13µs/call
# spent 557µs making 42 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 13µs/call
# spent 525µs making 42 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 13µs/call
# spent 514µs making 42 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 12µs/call
# spent 475µs making 42 calls to Class::MOP::Class::instance_metaclass, avg 11µs/call |
| 142 | attribute_metaclass | ||||
| 143 | method_metaclass | ||||
| 144 | wrapped_method_metaclass | ||||
| 145 | instance_metaclass | ||||
| 146 | constructor_class | ||||
| 147 | destructor_class | ||||
| 148 | error_class | ||||
| 149 | ); | ||||
| 150 | |||||
| 151 | $cache_key = _anon_cache_key( | ||||
| 152 | [ $meta->superclasses ], | ||||
| 153 | 42 | 594µs | 42 | 1.81ms | [ map { $_->name } @{ $meta->roles } ], # spent 1.81ms making 42 calls to Class::MOP::Class::is_anon_class, avg 43µs/call |
| 154 | ) if $meta->is_anon_class; | ||||
| 155 | } | ||||
| 156 | |||||
| 157 | 42 | 1.70ms | 42 | 611ms | my $new_meta = $self->SUPER::reinitialize( # spent 611ms making 42 calls to Class::MOP::Class::reinitialize, avg 14.5ms/call |
| 158 | $pkg, | ||||
| 159 | %existing_classes, | ||||
| 160 | @_, | ||||
| 161 | ); | ||||
| 162 | |||||
| 163 | 42 | 862µs | return $new_meta unless defined $cache_key; | ||
| 164 | |||||
| 165 | my $new_cache_key = _anon_cache_key( | ||||
| 166 | [ $meta->superclasses ], | ||||
| 167 | [ map { $_->name } @{ $meta->roles } ], | ||||
| 168 | ); | ||||
| 169 | |||||
| 170 | delete $ANON_CLASSES{$cache_key}; | ||||
| 171 | $ANON_CLASSES{$new_cache_key} = $new_meta; | ||||
| 172 | weaken($ANON_CLASSES{$new_cache_key}); | ||||
| 173 | |||||
| 174 | return $new_meta; | ||||
| 175 | } | ||||
| 176 | |||||
| 177 | # spent 5.66ms (3.69+1.97) within Moose::Meta::Class::add_role which was called 73 times, avg 77µs/call:
# 73 times (3.69ms+1.97ms) by Moose::Meta::Role::Application::ToClass::apply at line 33 of Moose/Meta/Role/Application/ToClass.pm, avg 77µs/call | ||||
| 178 | 73 | 261µs | my ($self, $role) = @_; | ||
| 179 | 73 | 2.60ms | 146 | 988µs | (blessed($role) && $role->isa('Moose::Meta::Role')) # spent 527µs making 73 calls to Scalar::Util::blessed, avg 7µs/call
# spent 460µs making 73 calls to UNIVERSAL::isa, avg 6µs/call |
| 180 | || $self->throw_error("Roles must be instances of Moose::Meta::Role", data => $role); | ||||
| 181 | 73 | 1.67ms | 73 | 982µs | push @{$self->roles} => $role; # spent 982µs making 73 calls to Moose::Meta::Class::roles, avg 13µs/call |
| 182 | } | ||||
| 183 | |||||
| 184 | sub role_applications { | ||||
| 185 | my ($self) = @_; | ||||
| 186 | |||||
| 187 | return @{$self->_get_role_applications}; | ||||
| 188 | } | ||||
| 189 | |||||
| 190 | # spent 5.41ms (3.48+1.93) within Moose::Meta::Class::add_role_application which was called 73 times, avg 74µs/call:
# 73 times (3.48ms+1.93ms) by Moose::Meta::Role::Application::ToClass::apply at line 34 of Moose/Meta/Role/Application/ToClass.pm, avg 74µs/call | ||||
| 191 | 73 | 253µs | my ($self, $application) = @_; | ||
| 192 | 73 | 2.26ms | 146 | 799µs | (blessed($application) && $application->isa('Moose::Meta::Role::Application::ToClass')) # spent 406µs making 73 calls to UNIVERSAL::isa, avg 6µs/call
# spent 393µs making 73 calls to Scalar::Util::blessed, avg 5µs/call |
| 193 | || $self->throw_error("Role applications must be instances of Moose::Meta::Role::Application::ToClass", data => $application); | ||||
| 194 | 73 | 1.81ms | 73 | 1.13ms | push @{$self->_get_role_applications} => $application; # spent 1.13ms making 73 calls to Moose::Meta::Class::_get_role_applications, avg 15µs/call |
| 195 | } | ||||
| 196 | |||||
| 197 | # spent 1.69ms (485µs+1.20) within Moose::Meta::Class::calculate_all_roles which was called 6 times, avg 281µs/call:
# 6 times (485µs+1.20ms) by Moose::Meta::Attribute::Native::Trait::_build_native_type at line 183 of Moose/Meta/Attribute/Native/Trait.pm, avg 281µs/call | ||||
| 198 | 6 | 18µs | my $self = shift; | ||
| 199 | 6 | 11µs | my %seen; | ||
| 200 | 24 | 492µs | 24 | 1.20ms | grep { !$seen{$_->name}++ } map { $_->calculate_all_roles } @{ $self->roles }; # spent 1.07ms making 6 calls to Moose::Meta::Role::calculate_all_roles, avg 178µs/call
# spent 77µs making 6 calls to Moose::Meta::Class::roles, avg 13µs/call
# spent 57µs making 12 calls to Class::MOP::Package::name, avg 5µs/call |
| 201 | } | ||||
| 202 | |||||
| 203 | sub calculate_all_roles_with_inheritance { | ||||
| 204 | my $self = shift; | ||||
| 205 | my %seen; | ||||
| 206 | grep { !$seen{$_->name}++ } | ||||
| 207 | map { Class::MOP::class_of($_)->can('calculate_all_roles') | ||||
| 208 | ? Class::MOP::class_of($_)->calculate_all_roles | ||||
| 209 | : () } | ||||
| 210 | $self->linearized_isa; | ||||
| 211 | } | ||||
| 212 | |||||
| 213 | # spent 42.6ms (6.80+35.8) within Moose::Meta::Class::does_role which was called 44 times, avg 969µs/call:
# 38 times (4.94ms+30.2ms) by List::MoreUtils::all at line 160 of Moose/Util/MetaRole.pm, avg 926µs/call
# 6 times (1.86ms+5.58ms) by Moose::Object::does at line 125 of Moose/Object.pm, avg 1.24ms/call | ||||
| 214 | 44 | 228µs | my ($self, $role_name) = @_; | ||
| 215 | |||||
| 216 | 44 | 124µs | (defined $role_name) | ||
| 217 | || $self->throw_error("You must supply a role name to look for"); | ||||
| 218 | |||||
| 219 | 44 | 924µs | 44 | 29.7ms | foreach my $class ($self->class_precedence_list) { # spent 29.7ms making 44 calls to Class::MOP::Class::class_precedence_list, avg 675µs/call |
| 220 | 130 | 1.35ms | 130 | 3.68ms | my $meta = Class::MOP::class_of($class); # spent 3.68ms making 130 calls to Class::MOP::class_of, avg 28µs/call |
| 221 | # when a Moose metaclass is itself extended with a role, | ||||
| 222 | # this check needs to be done since some items in the | ||||
| 223 | # class_precedence_list might in fact be Class::MOP | ||||
| 224 | # based still. | ||||
| 225 | 130 | 2.37ms | 130 | 859µs | next unless $meta && $meta->can('roles'); # spent 859µs making 130 calls to UNIVERSAL::can, avg 7µs/call |
| 226 | 82 | 1.47ms | 82 | 1.03ms | foreach my $role (@{$meta->roles}) { # spent 1.03ms making 82 calls to Moose::Meta::Class::roles, avg 13µs/call |
| 227 | 6 | 107µs | 6 | 542µs | return 1 if $role->does_role($role_name); # spent 542µs making 6 calls to Moose::Meta::Role::does_role, avg 90µs/call |
| 228 | } | ||||
| 229 | } | ||||
| 230 | 44 | 585µs | return 0; | ||
| 231 | } | ||||
| 232 | |||||
| 233 | # spent 128ms (18.8+109) within Moose::Meta::Class::excludes_role which was called 73 times, avg 1.75ms/call:
# 73 times (18.8ms+109ms) by Moose::Meta::Role::Application::ToClass::check_role_exclusions at line 39 of Moose/Meta/Role/Application/ToClass.pm, avg 1.75ms/call | ||||
| 234 | 73 | 336µs | my ($self, $role_name) = @_; | ||
| 235 | |||||
| 236 | 73 | 184µs | (defined $role_name) | ||
| 237 | || $self->throw_error("You must supply a role name to look for"); | ||||
| 238 | |||||
| 239 | 73 | 2.20ms | 73 | 88.9ms | foreach my $class ($self->class_precedence_list) { # spent 88.9ms making 73 calls to Class::MOP::Class::class_precedence_list, avg 1.22ms/call |
| 240 | 427 | 4.26ms | 427 | 11.9ms | my $meta = Class::MOP::class_of($class); # spent 11.9ms making 427 calls to Class::MOP::class_of, avg 28µs/call |
| 241 | # when a Moose metaclass is itself extended with a role, | ||||
| 242 | # this check needs to be done since some items in the | ||||
| 243 | # class_precedence_list might in fact be Class::MOP | ||||
| 244 | # based still. | ||||
| 245 | 427 | 7.81ms | 427 | 2.83ms | next unless $meta && $meta->can('roles'); # spent 2.83ms making 427 calls to UNIVERSAL::can, avg 7µs/call |
| 246 | 182 | 3.10ms | 182 | 2.23ms | foreach my $role (@{$meta->roles}) { # spent 2.23ms making 182 calls to Moose::Meta::Class::roles, avg 12µs/call |
| 247 | 76 | 1.27ms | 76 | 3.29ms | return 1 if $role->excludes_role($role_name); # spent 3.29ms making 76 calls to Moose::Meta::Role::excludes_role, avg 43µs/call |
| 248 | } | ||||
| 249 | } | ||||
| 250 | 73 | 947µs | return 0; | ||
| 251 | } | ||||
| 252 | |||||
| 253 | # spent 428ms (32.4+396) within Moose::Meta::Class::new_object which was called 110 times, avg 3.89ms/call:
# 68 times (28.1ms+346ms) by Moose::Meta::Attribute::_new or Moose::Meta::Role::_new at line 4 of (eval 76)[Class/MOP/Method/Generated.pm:53], avg 5.50ms/call
# 42 times (4.27ms+50.0ms) by MooseX::Role::Parameterized::Meta::Role::Parameterizable::construct_parameters at line 68 of MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm, avg 1.29ms/call | ||||
| 254 | 110 | 447µs | my $self = shift; | ||
| 255 | 110 | 375µs | my $params = @_ == 1 ? $_[0] : {@_}; | ||
| 256 | 110 | 2.92ms | 110 | 350ms | my $object = $self->SUPER::new_object($params); # spent 350ms making 110 calls to Class::MOP::Class::new_object, avg 3.18ms/call |
| 257 | |||||
| 258 | 110 | 5.50ms | 110 | 33.5ms | foreach my $attr ( $self->get_all_attributes() ) { # spent 30.7ms making 66 calls to Class::MOP::Class::get_all_attributes, avg 465µs/call
# spent 2.80ms making 44 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::get_all_attributes, avg 64µs/call |
| 259 | |||||
| 260 | 1706 | 28.0ms | 1816 | 10.3ms | next unless $attr->can('has_trigger') && $attr->has_trigger; # spent 9.16ms making 1706 calls to UNIVERSAL::can, avg 5µs/call
# spent 1.16ms making 110 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 11µs/call |
| 261 | |||||
| 262 | my $init_arg = $attr->init_arg; | ||||
| 263 | |||||
| 264 | next unless defined $init_arg; | ||||
| 265 | |||||
| 266 | next unless exists $params->{$init_arg}; | ||||
| 267 | |||||
| 268 | $attr->trigger->( | ||||
| 269 | $object, | ||||
| 270 | ( | ||||
| 271 | $attr->should_coerce | ||||
| 272 | ? $attr->get_read_method_ref->($object) | ||||
| 273 | : $params->{$init_arg} | ||||
| 274 | ), | ||||
| 275 | ); | ||||
| 276 | } | ||||
| 277 | |||||
| 278 | 110 | 3.03ms | 152 | 1.98ms | $object->BUILDALL($params) if $object->can('BUILDALL'); # spent 1.04ms making 42 calls to Moose::Object::BUILDALL, avg 25µs/call
# spent 940µs making 110 calls to UNIVERSAL::can, avg 9µs/call |
| 279 | |||||
| 280 | 110 | 1.46ms | return $object; | ||
| 281 | } | ||||
| 282 | |||||
| 283 | # spent 817ms (55.2+762) within Moose::Meta::Class::superclasses which was called 785 times, avg 1.04ms/call:
# 264 times (14.7ms+50.5ms) by Class::MOP::Class::class_precedence_list at line 929 of Class/MOP/Class.pm, avg 247µs/call
# 218 times (13.8ms+32.5ms) by Class::MOP::Class::_check_metaclass_compatibility at line 213 of Class/MOP/Class.pm, avg 212µs/call
# 108 times (7.19ms+-7.19ms) by Class::MOP::Class::_superclasses_updated at line 870 of Class/MOP/Class.pm, avg 0s/call
# 90 times (8.39ms+283ms) by Moose::init_meta at line 218 of Moose.pm, avg 3.24ms/call
# 42 times (2.93ms+8.80ms) by Moose::Util::MetaRole::apply_base_class_roles at line 140 of Moose/Util/MetaRole.pm, avg 279µs/call
# 38 times (4.41ms+211ms) by Moose::Util::MetaRole::apply_base_class_roles at line 146 of Moose/Util/MetaRole.pm, avg 5.67ms/call
# 22 times (3.40ms+165ms) by Class::MOP::Class::create at line 532 of Class/MOP/Class.pm, avg 7.66ms/call
# 3 times (402µs+17.8ms) by Moose::extends at line 54 of Moose.pm, avg 6.06ms/call | ||||
| 284 | 785 | 2.29ms | my $self = shift; | ||
| 285 | 785 | 9.64ms | 785 | 29.6ms | my $supers = Data::OptList::mkopt(\@_); # spent 29.6ms making 785 calls to Data::OptList::mkopt, avg 38µs/call |
| 286 | 785 | 4.82ms | foreach my $super (@{ $supers }) { | ||
| 287 | 120 | 512µs | my ($name, $opts) = @{ $super }; | ||
| 288 | 120 | 1.31ms | 120 | 24.8ms | Class::MOP::load_class($name, $opts); # spent 27.0ms making 120 calls to Class::MOP::load_class, avg 225µs/call, recursion: max depth 2, sum of overlapping time 2.28ms |
| 289 | 120 | 1.41ms | 120 | 3.87ms | my $meta = Class::MOP::class_of($name); # spent 3.87ms making 120 calls to Class::MOP::class_of, avg 32µs/call |
| 290 | 120 | 3.98ms | 119 | 1.55ms | $self->throw_error("You cannot inherit from a Moose Role ($name)") # spent 1.55ms making 119 calls to UNIVERSAL::isa, avg 13µs/call |
| 291 | if $meta && $meta->isa('Moose::Meta::Role') | ||||
| 292 | } | ||||
| 293 | 785 | 29.9ms | 785 | 720ms | return $self->SUPER::superclasses(map { $_->[0] } @{ $supers }); # spent 757ms making 785 calls to Class::MOP::Class::superclasses, avg 964µs/call, recursion: max depth 1, sum of overlapping time 36.5ms |
| 294 | } | ||||
| 295 | |||||
| 296 | ### --------------------------------------------- | ||||
| 297 | |||||
| 298 | # spent 5.19s (7.58ms+5.18) within Moose::Meta::Class::add_attribute which was called 72 times, avg 72.1ms/call:
# 50 times (5.15ms+5.09s) by Moose::has at line 70 of Moose.pm, avg 102ms/call
# 21 times (2.28ms+85.3ms) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 142 of Moose/Meta/Role/Application/ToClass.pm, avg 4.17ms/call
# once (154µs+9.03ms) by MooseX::Role::Parameterized::Meta::Role::Parameterizable::add_parameter at line 55 of MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm | ||||
| 299 | 72 | 224µs | my $self = shift; | ||
| 300 | 72 | 2.78ms | 144 | 3.84s | my $attr = # spent 3.84s making 51 calls to Moose::Meta::Class::_process_attribute, avg 75.3ms/call
# spent 427µs making 72 calls to Scalar::Util::blessed, avg 6µs/call
# spent 148µs making 21 calls to UNIVERSAL::isa, avg 7µs/call |
| 301 | (blessed $_[0] && $_[0]->isa('Class::MOP::Attribute') | ||||
| 302 | ? $_[0] | ||||
| 303 | : $self->_process_attribute(@_)); | ||||
| 304 | 72 | 1.97ms | 72 | 1.42s | $self->SUPER::add_attribute($attr); # spent 1.42s making 72 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 19.7ms/call |
| 305 | # it may be a Class::MOP::Attribute, theoretically, which doesn't have | ||||
| 306 | # 'bare' and doesn't implement this method | ||||
| 307 | 72 | 2.65ms | 143 | 3.59ms | if ($attr->can('_check_associated_methods')) { # spent 2.73ms making 71 calls to Moose::Meta::Attribute::_check_associated_methods, avg 38µs/call
# spent 859µs making 72 calls to UNIVERSAL::can, avg 12µs/call |
| 308 | $attr->_check_associated_methods; | ||||
| 309 | } | ||||
| 310 | 72 | 970µs | return $attr; | ||
| 311 | } | ||||
| 312 | |||||
| 313 | # spent 70.1ms (2.69+67.5) within Moose::Meta::Class::add_override_method_modifier which was called 45 times, avg 1.56ms/call:
# 45 times (2.69ms+67.5ms) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 208 of Moose/Meta/Role/Application/ToClass.pm, avg 1.56ms/call | ||||
| 314 | 45 | 233µs | my ($self, $name, $method, $_super_package) = @_; | ||
| 315 | |||||
| 316 | 45 | 490µs | 45 | 9.08ms | (!$self->has_method($name)) # spent 9.08ms making 45 calls to Class::MOP::Mixin::HasMethods::has_method, avg 202µs/call |
| 317 | || $self->throw_error("Cannot add an override method if a local method is already present"); | ||||
| 318 | |||||
| 319 | 45 | 1.65ms | 90 | 58.4ms | $self->add_method($name => Moose::Meta::Method::Overridden->new( # spent 36.5ms making 45 calls to Moose::Meta::Method::Overridden::new, avg 812µs/call
# spent 21.9ms making 45 calls to Class::MOP::Mixin::HasMethods::add_method, avg 486µs/call |
| 320 | method => $method, | ||||
| 321 | class => $self, | ||||
| 322 | package => $_super_package, # need this for roles | ||||
| 323 | name => $name, | ||||
| 324 | )); | ||||
| 325 | } | ||||
| 326 | |||||
| 327 | sub add_augment_method_modifier { | ||||
| 328 | my ($self, $name, $method) = @_; | ||||
| 329 | (!$self->has_method($name)) | ||||
| 330 | || $self->throw_error("Cannot add an augment method if a local method is already present"); | ||||
| 331 | |||||
| 332 | $self->add_method($name => Moose::Meta::Method::Augmented->new( | ||||
| 333 | method => $method, | ||||
| 334 | class => $self, | ||||
| 335 | name => $name, | ||||
| 336 | )); | ||||
| 337 | } | ||||
| 338 | |||||
| 339 | ## Private Utility methods ... | ||||
| 340 | |||||
| 341 | sub _find_next_method_by_name_which_is_not_overridden { | ||||
| 342 | my ($self, $name) = @_; | ||||
| 343 | foreach my $method ($self->find_all_methods_by_name($name)) { | ||||
| 344 | return $method->{code} | ||||
| 345 | if blessed($method->{code}) && !$method->{code}->isa('Moose::Meta::Method::Overridden'); | ||||
| 346 | } | ||||
| 347 | return undef; | ||||
| 348 | } | ||||
| 349 | |||||
| 350 | ## Metaclass compatibility | ||||
| 351 | |||||
| 352 | # spent 71.0ms (47.5+23.6) within Moose::Meta::Class::_base_metaclasses which was called 312 times, avg 228µs/call:
# 162 times (25.1ms+12.4ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 343 of Class/MOP/Class.pm, avg 232µs/call
# 150 times (22.4ms+11.2ms) by Class::MOP::Class::_check_metaclass_compatibility at line 218 of Class/MOP/Class.pm, avg 224µs/call | ||||
| 353 | 312 | 1.01ms | my $self = shift; | ||
| 354 | 312 | 11.4ms | 312 | 5.82ms | my %metaclasses = $self->SUPER::_base_metaclasses; # spent 5.82ms making 312 calls to Class::MOP::Class::_base_metaclasses, avg 19µs/call |
| 355 | 312 | 3.15ms | for my $class (keys %metaclasses) { | ||
| 356 | 1872 | 41.9ms | 1872 | 17.8ms | $metaclasses{$class} =~ s/^Class::MOP/Moose::Meta/; # spent 17.8ms making 1872 calls to Moose::Meta::Class::CORE:subst, avg 9µs/call |
| 357 | } | ||||
| 358 | return ( | ||||
| 359 | 312 | 7.30ms | %metaclasses, | ||
| 360 | error_class => 'Moose::Error::Default', | ||||
| 361 | ); | ||||
| 362 | } | ||||
| 363 | |||||
| 364 | sub _fix_class_metaclass_incompatibility { | ||||
| 365 | my $self = shift; | ||||
| 366 | my ($super_meta) = @_; | ||||
| 367 | |||||
| 368 | $self->SUPER::_fix_class_metaclass_incompatibility(@_); | ||||
| 369 | |||||
| 370 | if ($self->_class_metaclass_can_be_made_compatible($super_meta)) { | ||||
| 371 | ($self->is_pristine) | ||||
| 372 | || confess "Can't fix metaclass incompatibility for " | ||||
| 373 | . $self->name | ||||
| 374 | . " because it is not pristine."; | ||||
| 375 | my $super_meta_name = $super_meta->_real_ref_name; | ||||
| 376 | my $class_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass(blessed($self), $super_meta_name); | ||||
| 377 | my $new_self = $class_meta_subclass_meta_name->reinitialize( | ||||
| 378 | $self->name, | ||||
| 379 | ); | ||||
| 380 | |||||
| 381 | $self->_replace_self( $new_self, $class_meta_subclass_meta_name ); | ||||
| 382 | } | ||||
| 383 | } | ||||
| 384 | |||||
| 385 | sub _fix_single_metaclass_incompatibility { | ||||
| 386 | my $self = shift; | ||||
| 387 | my ($metaclass_type, $super_meta) = @_; | ||||
| 388 | |||||
| 389 | $self->SUPER::_fix_single_metaclass_incompatibility(@_); | ||||
| 390 | |||||
| 391 | if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) { | ||||
| 392 | ($self->is_pristine) | ||||
| 393 | || confess "Can't fix metaclass incompatibility for " | ||||
| 394 | . $self->name | ||||
| 395 | . " because it is not pristine."; | ||||
| 396 | my $super_meta_name = $super_meta->_real_ref_name; | ||||
| 397 | my $class_specific_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass($self->$metaclass_type, $super_meta->$metaclass_type); | ||||
| 398 | my $new_self = $super_meta->reinitialize( | ||||
| 399 | $self->name, | ||||
| 400 | $metaclass_type => $class_specific_meta_subclass_meta_name, | ||||
| 401 | ); | ||||
| 402 | |||||
| 403 | $self->_replace_self( $new_self, $super_meta_name ); | ||||
| 404 | } | ||||
| 405 | } | ||||
| 406 | |||||
| 407 | sub _replace_self { | ||||
| 408 | my $self = shift; | ||||
| 409 | my ( $new_self, $new_class) = @_; | ||||
| 410 | |||||
| 411 | %$self = %$new_self; | ||||
| 412 | bless $self, $new_class; | ||||
| 413 | |||||
| 414 | # We need to replace the cached metaclass instance or else when it goes | ||||
| 415 | # out of scope Class::MOP::Class destroy's the namespace for the | ||||
| 416 | # metaclass's class, causing much havoc. | ||||
| 417 | my $weaken = Class::MOP::metaclass_is_weak( $self->name ); | ||||
| 418 | Class::MOP::store_metaclass_by_name( $self->name, $self ); | ||||
| 419 | Class::MOP::weaken_metaclass( $self->name ) if $weaken; | ||||
| 420 | } | ||||
| 421 | |||||
| 422 | # spent 3.84s (2.65ms+3.84) within Moose::Meta::Class::_process_attribute which was called 51 times, avg 75.3ms/call:
# 51 times (2.65ms+3.84s) by Moose::Meta::Class::add_attribute at line 300, avg 75.3ms/call | ||||
| 423 | 51 | 556µs | my ( $self, $name, @args ) = @_; | ||
| 424 | |||||
| 425 | 51 | 162µs | @args = %{$args[0]} if scalar @args == 1 && ref($args[0]) eq 'HASH'; | ||
| 426 | |||||
| 427 | 51 | 892µs | 51 | 293µs | if (($name || '') =~ /^\+(.*)/) { # spent 293µs making 51 calls to Moose::Meta::Class::CORE:match, avg 6µs/call |
| 428 | 1 | 28µs | 1 | 2.66ms | return $self->_process_inherited_attribute($1, @args); # spent 2.66ms making 1 call to Moose::Meta::Class::_process_inherited_attribute |
| 429 | } | ||||
| 430 | else { | ||||
| 431 | 50 | 1.30ms | 50 | 3.84s | return $self->_process_new_attribute($name, @args); # spent 3.84s making 50 calls to Moose::Meta::Class::_process_new_attribute, avg 76.7ms/call |
| 432 | } | ||||
| 433 | } | ||||
| 434 | |||||
| 435 | # spent 3.84s (2.74ms+3.83) within Moose::Meta::Class::_process_new_attribute which was called 50 times, avg 76.7ms/call:
# 50 times (2.74ms+3.83s) by Moose::Meta::Class::_process_attribute at line 431, avg 76.7ms/call | ||||
| 436 | 50 | 511µs | my ( $self, $name, @args ) = @_; | ||
| 437 | |||||
| 438 | 50 | 2.01ms | 100 | 3.83s | $self->attribute_metaclass->interpolate_class_and_new($name, @args); # spent 3.83s making 50 calls to Moose::Meta::Attribute::interpolate_class_and_new, avg 76.7ms/call
# spent 672µs making 50 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 13µs/call |
| 439 | } | ||||
| 440 | |||||
| 441 | # spent 2.66ms (114µs+2.54) within Moose::Meta::Class::_process_inherited_attribute which was called:
# once (114µs+2.54ms) by Moose::Meta::Class::_process_attribute at line 428 | ||||
| 442 | 1 | 14µs | my ($self, $attr_name, %options) = @_; | ||
| 443 | 1 | 29µs | 1 | 933µs | my $inherited_attr = $self->find_attribute_by_name($attr_name); # spent 933µs making 1 call to Class::MOP::Class::find_attribute_by_name |
| 444 | (defined $inherited_attr) | ||||
| 445 | 1 | 2µs | || $self->throw_error("Could not find an attribute by the name of '$attr_name' to inherit from in ${\$self->name}", data => $attr_name); | ||
| 446 | 1 | 35µs | 1 | 15µs | if ($inherited_attr->isa('Moose::Meta::Attribute')) { # spent 15µs making 1 call to UNIVERSAL::isa |
| 447 | return $inherited_attr->clone_and_inherit_options(%options); | ||||
| 448 | } | ||||
| 449 | else { | ||||
| 450 | # NOTE: | ||||
| 451 | # kind of a kludge to handle Class::MOP::Attributes | ||||
| 452 | 1 | 40µs | 1 | 1.60ms | return $inherited_attr->Moose::Meta::Attribute::clone_and_inherit_options(%options); # spent 1.60ms making 1 call to Moose::Meta::Attribute::clone_and_inherit_options |
| 453 | } | ||||
| 454 | } | ||||
| 455 | |||||
| 456 | ## Immutability | ||||
| 457 | |||||
| 458 | # spent 7.35ms (1.79+5.56) within Moose::Meta::Class::_immutable_options which was called 42 times, avg 175µs/call:
# 42 times (1.79ms+5.56ms) by Class::MOP::Class::make_immutable at line 1180 of Class/MOP/Class.pm, avg 175µs/call | ||||
| 459 | 42 | 165µs | my ( $self, @args ) = @_; | ||
| 460 | |||||
| 461 | 42 | 1.64ms | 42 | 5.56ms | $self->SUPER::_immutable_options( # spent 5.56ms making 42 calls to Class::MOP::Class::_immutable_options, avg 132µs/call |
| 462 | inline_destructor => 1, | ||||
| 463 | |||||
| 464 | # Moose always does this when an attribute is created | ||||
| 465 | inline_accessors => 0, | ||||
| 466 | |||||
| 467 | @args, | ||||
| 468 | ); | ||||
| 469 | } | ||||
| 470 | |||||
| 471 | ## ------------------------------------------------- | ||||
| 472 | |||||
| 473 | 1 | 3µs | our $error_level; | ||
| 474 | |||||
| 475 | sub throw_error { | ||||
| 476 | my ( $self, @args ) = @_; | ||||
| 477 | local $error_level = ($error_level || 0) + 1; | ||||
| 478 | $self->raise_error($self->create_error(@args)); | ||||
| 479 | } | ||||
| 480 | |||||
| 481 | sub raise_error { | ||||
| 482 | my ( $self, @args ) = @_; | ||||
| 483 | die @args; | ||||
| 484 | } | ||||
| 485 | |||||
| 486 | sub create_error { | ||||
| 487 | my ( $self, @args ) = @_; | ||||
| 488 | |||||
| 489 | require Carp::Heavy; | ||||
| 490 | |||||
| 491 | local $error_level = ($error_level || 0 ) + 1; | ||||
| 492 | |||||
| 493 | if ( @args % 2 == 1 ) { | ||||
| 494 | unshift @args, "message"; | ||||
| 495 | } | ||||
| 496 | |||||
| 497 | my %args = ( metaclass => $self, last_error => $@, @args ); | ||||
| 498 | |||||
| 499 | $args{depth} += $error_level; | ||||
| 500 | |||||
| 501 | my $class = ref $self ? $self->error_class : "Moose::Error::Default"; | ||||
| 502 | |||||
| 503 | Class::MOP::load_class($class); | ||||
| 504 | |||||
| 505 | $class->new( | ||||
| 506 | Carp::caller_info($args{depth}), | ||||
| 507 | %args | ||||
| 508 | ); | ||||
| 509 | } | ||||
| 510 | |||||
| 511 | 1 | 80µs | 1; | ||
| 512 | |||||
| 513 | __END__ | ||||
# spent 293µs within Moose::Meta::Class::CORE:match which was called 51 times, avg 6µs/call:
# 51 times (293µs+0s) by Moose::Meta::Class::_process_attribute at line 427, avg 6µs/call | |||||
# spent 484µs within Moose::Meta::Class::CORE:sort which was called 116 times, avg 4µs/call:
# 116 times (484µs+0s) by Moose::Meta::Class::_anon_cache_key at line 127, avg 4µs/call | |||||
# spent 17.8ms within Moose::Meta::Class::CORE:subst which was called 1872 times, avg 9µs/call:
# 1872 times (17.8ms+0s) by Moose::Meta::Class::_base_metaclasses at line 356, avg 9µs/call |