| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP/Mixin/HasAttributes.pm |
| Statements | Executed 11960 statements in 159ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 211 | 114 | 23 | 36.6ms | 1.69s | Class::MOP::Mixin::HasAttributes::add_attribute |
| 745 | 4 | 4 | 21.5ms | 28.7ms | Class::MOP::Mixin::HasAttributes::has_attribute |
| 320 | 6 | 5 | 8.74ms | 12.0ms | Class::MOP::Mixin::HasAttributes::get_attribute_list |
| 240 | 4 | 3 | 6.98ms | 9.00ms | Class::MOP::Mixin::HasAttributes::get_attribute |
| 42 | 1 | 1 | 1.83ms | 3.54ms | Class::MOP::Mixin::HasAttributes::_restore_metaattributes_from |
| 42 | 1 | 1 | 170µs | 170µs | Class::MOP::Mixin::HasAttributes::CORE:sort (opcode) |
| 1 | 1 | 1 | 68µs | 88µs | Class::MOP::Mixin::HasAttributes::BEGIN@3 |
| 1 | 1 | 1 | 56µs | 191µs | Class::MOP::Mixin::HasAttributes::BEGIN@11 |
| 1 | 1 | 1 | 41µs | 350µs | Class::MOP::Mixin::HasAttributes::BEGIN@13 |
| 1 | 1 | 1 | 39µs | 213µs | Class::MOP::Mixin::HasAttributes::BEGIN@10 |
| 1 | 1 | 1 | 38µs | 107µs | Class::MOP::Mixin::HasAttributes::BEGIN@4 |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasAttributes::remove_attribute |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Class::MOP::Mixin::HasAttributes; | ||||
| 2 | |||||
| 3 | 3 | 100µs | 2 | 106µs | # spent 88µs (68+19) within Class::MOP::Mixin::HasAttributes::BEGIN@3 which was called:
# once (68µs+19µs) by Class::MOP::BEGIN@17 at line 3 # spent 88µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@3
# spent 19µs making 1 call to strict::import |
| 4 | 3 | 206µs | 2 | 175µs | # spent 107µs (38+69) within Class::MOP::Mixin::HasAttributes::BEGIN@4 which was called:
# once (38µs+69µs) by Class::MOP::BEGIN@17 at line 4 # spent 107µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@4
# spent 69µs making 1 call to warnings::import |
| 5 | |||||
| 6 | 1 | 5µs | our $VERSION = '1.11'; | ||
| 7 | 1 | 61µs | $VERSION = eval $VERSION; # spent 12µs executing statements in string eval | ||
| 8 | 1 | 4µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 9 | |||||
| 10 | 3 | 112µs | 2 | 386µs | # spent 213µs (39+173) within Class::MOP::Mixin::HasAttributes::BEGIN@10 which was called:
# once (39µs+173µs) by Class::MOP::BEGIN@17 at line 10 # spent 213µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@10
# spent 173µs making 1 call to Exporter::import |
| 11 | 3 | 108µs | 2 | 326µs | # spent 191µs (56+135) within Class::MOP::Mixin::HasAttributes::BEGIN@11 which was called:
# once (56µs+135µs) by Class::MOP::BEGIN@17 at line 11 # spent 191µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@11
# spent 135µs making 1 call to Exporter::import |
| 12 | |||||
| 13 | 3 | 1.55ms | 2 | 350µs | # spent 350µs (41+310) within Class::MOP::Mixin::HasAttributes::BEGIN@13 which was called:
# once (41µs+310µs) by Class::MOP::BEGIN@17 at line 13 # spent 350µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@13
# spent 310µs making 1 call to base::import, recursion: max depth 1, sum of overlapping time 310µs |
| 14 | |||||
| 15 | 4413 | 59.2ms | sub _attribute_map { $_[0]->{'attributes'} } | ||
| 16 | 1486 | 21.3ms | sub attribute_metaclass { $_[0]->{'attribute_metaclass'} } | ||
| 17 | |||||
| 18 | # spent 1.69s (36.6ms+1.65) within Class::MOP::Mixin::HasAttributes::add_attribute which was called 211 times, avg 7.99ms/call:
# 72 times (12.7ms+1.41s) by Moose::Meta::Class::add_attribute at line 304 of Moose/Meta/Class.pm, avg 19.7ms/call
# 24 times (3.50ms+4.58ms) by Moose::Meta::Role::add_attribute at line 240 of Moose/Meta/Role.pm, avg 337µs/call
# 3 times (564µs+5.79ms) by Moose::BEGIN@27 at line 296 of Moose/Meta/Role.pm, avg 2.12ms/call
# 2 times (458µs+4.39ms) by Moose::BEGIN@27 at line 90 of Moose/Meta/Role.pm, avg 2.42ms/call
# once (186µs+12.8ms) by Moose::BEGIN@21 at line 20 of Moose/Meta/TypeCoercion.pm
# once (193µs+7.53ms) by Moose::BEGIN@19 at line 60 of Moose/Meta/Class.pm
# once (269µs+4.49ms) by Moose::BEGIN@20 at line 56 of Moose/Meta/TypeConstraint.pm
# once (191µs+4.00ms) by Moose::Util::TypeConstraints::BEGIN@39 at line 16 of Moose/Meta/TypeConstraint/Registry.pm
# once (183µs+3.94ms) by base::import at line 35 of Moose/Meta/Mixin/AttributeCore.pm
# once (194µs+3.60ms) by Moose::BEGIN@20 at line 43 of Moose/Meta/TypeConstraint.pm
# once (182µs+3.40ms) by Moose::BEGIN@20 at line 23 of Moose/Meta/TypeConstraint.pm
# once (187µs+3.07ms) by Moose::Meta::TypeCoercion::BEGIN@8 at line 27 of Moose/Meta/Attribute.pm
# once (221µs+3.00ms) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 at line 15 of Moose/Meta/TypeConstraint/Parameterizable.pm
# once (183µs+3.02ms) by Moose::BEGIN@20 at line 33 of Moose/Meta/TypeConstraint.pm
# once (187µs+2.98ms) by base::import at line 29 of Moose/Meta/Mixin/AttributeCore.pm
# once (186µs+2.98ms) by Moose::BEGIN@20 at line 34 of Moose/Meta/TypeConstraint.pm
# once (186µs+2.97ms) by base::import at line 42 of Moose/Meta/Mixin/AttributeCore.pm
# once (196µs+2.93ms) by Moose::Util::TypeConstraints::BEGIN@31 at line 17 of Moose/Meta/TypeConstraint/Parameterized.pm
# once (181µs+2.93ms) by Moose::BEGIN@20 at line 38 of Moose/Meta/TypeConstraint.pm
# once (247µs+2.86ms) by Moose::Util::TypeConstraints::BEGIN@30 at line 21 of Moose/Meta/TypeConstraint/Union.pm
# once (190µs+2.90ms) by base::import at line 23 of Moose/Meta/Mixin/AttributeCore.pm
# once (155µs+2.72ms) by MooseX::Types::Combine::BEGIN@12 at line 483 of Class/MOP.pm
# once (240µs+2.48ms) by Moose::BEGIN@20 at line 22 of Moose/Meta/TypeConstraint.pm
# once (205µs+2.50ms) by Moose::BEGIN@19 at line 36 of Moose/Meta/Class.pm
# once (238µs+2.30ms) by MooseX::Types::Combine::BEGIN@12 at line 193 of Class/MOP.pm
# once (190µs+2.28ms) by Moose::Meta::Role::BEGIN@19 at line 20 of Moose/Meta/Role/Method/Required.pm
# once (150µs+2.12ms) by MooseX::Types::Combine::BEGIN@12 at line 441 of Class/MOP.pm
# once (156µs+2.08ms) by MooseX::Types::Combine::BEGIN@12 at line 414 of Class/MOP.pm
# once (207µs+1.97ms) by Moose::BEGIN@33 at line 18 of Moose/Meta/Role/Application/ToInstance.pm
# once (196µs+1.98ms) by Moose::Util::TypeConstraints::BEGIN@39 at line 25 of Moose/Meta/TypeConstraint/Registry.pm
# once (149µs+2.02ms) by MooseX::Types::Combine::BEGIN@12 at line 545 of Class/MOP.pm
# once (177µs+1.99ms) by MooseX::Types::Combine::BEGIN@12 at line 462 of Class/MOP.pm
# once (195µs+1.97ms) by Moose::BEGIN@30 at line 20 of Moose/Meta/Role/Application/RoleSummation.pm
# once (201µs+1.96ms) by Moose::BEGIN@29 at line 15 of Moose/Meta/Role/Application.pm
# once (162µs+1.99ms) by MooseX::Types::Combine::BEGIN@12 at line 421 of Class/MOP.pm
# once (147µs+2.00ms) by MooseX::Types::Combine::BEGIN@12 at line 448 of Class/MOP.pm
# once (222µs+1.92ms) by Moose::BEGIN@21 at line 18 of Moose/Meta/TypeCoercion.pm
# once (186µs+1.94ms) by Moose::Util::TypeConstraints::BEGIN@33 at line 16 of Moose/Meta/TypeConstraint/Class.pm
# once (152µs+1.98ms) by MooseX::Types::Combine::BEGIN@12 at line 455 of Class/MOP.pm
# once (193µs+1.93ms) by Moose::BEGIN@27 at line 136 of Moose/Meta/Role.pm
# once (148µs+1.97ms) by MooseX::Types::Combine::BEGIN@12 at line 469 of Class/MOP.pm
# once (180µs+1.93ms) by Moose::BEGIN@19 at line 41 of Moose/Meta/Class.pm
# once (205µs+1.90ms) by Moose::Util::TypeConstraints::BEGIN@35 at line 15 of Moose/Meta/TypeConstraint/Enum.pm
# once (152µs+1.96ms) by MooseX::Types::Combine::BEGIN@12 at line 428 of Class/MOP.pm
# once (191µs+1.91ms) by Moose::BEGIN@27 at line 341 of Moose/Meta/Role.pm
# once (189µs+1.91ms) by Moose::BEGIN@28 at line 21 of Moose/Meta/Role/Composite.pm
# once (191µs+1.90ms) by Moose::Meta::Role::BEGIN@17 at line 15 of Moose/Meta/Role/Attribute.pm
# once (183µs+1.91ms) by Moose::BEGIN@21 at line 28 of Moose/Meta/TypeCoercion.pm
# once (193µs+1.90ms) by Moose::BEGIN@31 at line 16 of Moose/Meta/Role/Application/ToClass.pm
# once (179µs+1.91ms) by Moose::BEGIN@19 at line 55 of Moose/Meta/Class.pm
# once (191µs+1.89ms) by Moose::BEGIN@27 at line 393 of Moose/Meta/Role.pm
# once (186µs+1.90ms) by Moose::Util::TypeConstraints::BEGIN@34 at line 16 of Moose/Meta/TypeConstraint/Role.pm
# once (191µs+1.89ms) by Moose::BEGIN@29 at line 21 of Moose/Meta/Role/Application.pm
# once (182µs+1.89ms) by base::import at line 13 of Moose/Meta/Mixin/AttributeCore.pm
# once (186µs+1.89ms) by Moose::BEGIN@28 at line 33 of Moose/Meta/Role/Composite.pm
# once (187µs+1.89ms) by Moose::Util::TypeConstraints::BEGIN@36 at line 19 of Moose/Meta/TypeConstraint/DuckType.pm
# once (196µs+1.87ms) by Moose::BEGIN@27 at line 142 of Moose/Meta/Role.pm
# once (185µs+1.87ms) by Moose::BEGIN@27 at line 125 of Moose/Meta/Role.pm
# once (181µs+1.88ms) by Moose::Meta::Role::BEGIN@17 at line 21 of Moose/Meta/Role/Attribute.pm
# once (182µs+1.87ms) by Moose::Meta::Role::BEGIN@17 at line 27 of Moose/Meta/Role/Attribute.pm
# once (185µs+1.87ms) by Moose::BEGIN@27 at line 148 of Moose/Meta/Role.pm
# once (191µs+1.86ms) by base::import at line 11 of Moose/Meta/Mixin/AttributeCore.pm
# once (183µs+1.86ms) by base::import at line 12 of Moose/Meta/Mixin/AttributeCore.pm
# once (185µs+1.86ms) by Moose::BEGIN@20 at line 60 of Moose/Meta/TypeConstraint.pm
# once (183µs+1.86ms) by Moose::BEGIN@19 at line 50 of Moose/Meta/Class.pm
# once (183µs+1.86ms) by base::import at line 15 of Moose/Meta/Mixin/AttributeCore.pm
# once (216µs+1.83ms) by base::import at line 20 of Moose/Meta/Mixin/AttributeCore.pm
# once (182µs+1.86ms) by Moose::Meta::Role::BEGIN@20 at line 15 of Moose/Meta/Role/Method/Conflicting.pm
# once (185µs+1.85ms) by base::import at line 17 of Moose/Meta/Mixin/AttributeCore.pm
# once (187µs+1.85ms) by Moose::BEGIN@27 at line 130 of Moose/Meta/Role.pm
# once (184µs+1.85ms) by Moose::BEGIN@28 at line 31 of Moose/Meta/Role/Composite.pm
# once (183µs+1.85ms) by base::import at line 16 of Moose/Meta/Mixin/AttributeCore.pm
# once (183µs+1.84ms) by Moose::Meta::Role::BEGIN@17 at line 33 of Moose/Meta/Role/Attribute.pm
# once (182µs+1.83ms) by base::import at line 21 of Moose/Meta/Mixin/AttributeCore.pm
# once (184µs+1.82ms) by Moose::BEGIN@31 at line 20 of Moose/Meta/Role/Application/ToClass.pm
# once (183µs+1.82ms) by base::import at line 19 of Moose/Meta/Mixin/AttributeCore.pm
# once (187µs+1.80ms) by Moose::BEGIN@27 at line 154 of Moose/Meta/Role.pm
# once (150µs+1.72ms) by Moose::BEGIN@19 at line 43 of Moose/Meta/Class.pm
# once (148µs+1.40ms) by MooseX::Types::Combine::BEGIN@12 at line 656 of Class/MOP.pm
# once (147µs+1.40ms) by MooseX::Types::Combine::BEGIN@12 at line 356 of Class/MOP.pm
# once (150µs+1.39ms) by MooseX::Types::Combine::BEGIN@12 at line 539 of Class/MOP.pm
# once (179µs+1.36ms) by MooseX::Types::Combine::BEGIN@12 at line 616 of Class/MOP.pm
# once (150µs+1.38ms) by MooseX::Types::Combine::BEGIN@12 at line 253 of Class/MOP.pm
# once (148µs+1.38ms) by MooseX::Types::Combine::BEGIN@12 at line 641 of Class/MOP.pm
# once (147µs+1.38ms) by MooseX::Types::Combine::BEGIN@12 at line 511 of Class/MOP.pm
# once (211µs+1.31ms) by MooseX::Types::Combine::BEGIN@12 at line 374 of Class/MOP.pm
# once (147µs+1.38ms) by MooseX::Types::Combine::BEGIN@12 at line 235 of Class/MOP.pm
# once (149µs+1.37ms) by MooseX::Types::Combine::BEGIN@12 at line 662 of Class/MOP.pm
# once (149µs+1.37ms) by MooseX::Types::Combine::BEGIN@12 at line 338 of Class/MOP.pm
# once (148µs+1.37ms) by MooseX::Types::Combine::BEGIN@12 at line 584 of Class/MOP.pm
# once (150µs+1.36ms) by MooseX::Types::Combine::BEGIN@12 at line 635 of Class/MOP.pm
# once (148µs+1.36ms) by MooseX::Types::Combine::BEGIN@12 at line 521 of Class/MOP.pm
# once (147µs+1.35ms) by MooseX::Types::Combine::BEGIN@12 at line 533 of Class/MOP.pm
# once (149µs+1.35ms) by MooseX::Types::Combine::BEGIN@12 at line 341 of Class/MOP.pm
# once (150µs+1.34ms) by MooseX::Types::Combine::BEGIN@12 at line 196 of Class/MOP.pm
# once (209µs+1.28ms) by MooseX::Types::Combine::BEGIN@12 at line 601 of Class/MOP.pm
# once (147µs+1.34ms) by MooseX::Types::Combine::BEGIN@12 at line 384 of Class/MOP.pm
# once (147µs+1.33ms) by MooseX::Types::Combine::BEGIN@12 at line 574 of Class/MOP.pm
# once (147µs+1.33ms) by MooseX::Types::Combine::BEGIN@12 at line 493 of Class/MOP.pm
# once (147µs+1.33ms) by MooseX::Types::Combine::BEGIN@12 at line 277 of Class/MOP.pm
# once (149µs+1.33ms) by MooseX::Types::Combine::BEGIN@12 at line 435 of Class/MOP.pm
# once (148µs+1.33ms) by MooseX::Types::Combine::BEGIN@12 at line 567 of Class/MOP.pm
# once (147µs+1.33ms) by MooseX::Types::Combine::BEGIN@12 at line 650 of Class/MOP.pm
# once (153µs+1.31ms) by MooseX::Types::Combine::BEGIN@12 at line 322 of Class/MOP.pm
# once (148µs+1.31ms) by MooseX::Types::Combine::BEGIN@12 at line 365 of Class/MOP.pm
# once (157µs+1.30ms) by MooseX::Types::Combine::BEGIN@12 at line 593 of Class/MOP.pm
# once (150µs+1.31ms) by MooseX::Types::Combine::BEGIN@12 at line 303 of Class/MOP.pm
# once (148µs+1.30ms) by MooseX::Types::Combine::BEGIN@12 at line 619 of Class/MOP.pm
# once (146µs+1.29ms) by MooseX::Types::Combine::BEGIN@12 at line 400 of Class/MOP.pm
# once (149µs+1.28ms) by MooseX::Types::Combine::BEGIN@12 at line 208 of Class/MOP.pm
# once (147µs+1.28ms) by MooseX::Types::Combine::BEGIN@12 at line 238 of Class/MOP.pm
# once (148µs+1.28ms) by MooseX::Types::Combine::BEGIN@12 at line 527 of Class/MOP.pm
# once (146µs+1.27ms) by MooseX::Types::Combine::BEGIN@12 at line 476 of Class/MOP.pm
# once (146µs+638µs) by MooseX::Types::Combine::BEGIN@12 at line 560 of Class/MOP.pm | ||||
| 19 | 2321 | 39.8ms | my $self = shift; | ||
| 20 | |||||
| 21 | 361 | 11.9ms | my $attribute # spent 9.34ms making 66 calls to Class::MOP::Attribute::new, avg 142µs/call
# spent 1.27ms making 211 calls to Scalar::Util::blessed, avg 6µs/call
# spent 876µs making 75 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 12µs/call
# spent 428µs making 9 calls to Moose::Meta::Role::Attribute::new, avg 48µs/call | ||
| 22 | = blessed( $_[0] ) ? $_[0] : $self->attribute_metaclass->new(@_); | ||||
| 23 | |||||
| 24 | 211 | 1.46ms | ( $attribute->isa('Class::MOP::Mixin::AttributeCore') ) # spent 1.46ms making 211 calls to UNIVERSAL::isa, avg 7µs/call | ||
| 25 | || confess | ||||
| 26 | "Your attribute must be an instance of Class::MOP::Mixin::AttributeCore (or a subclass)"; | ||||
| 27 | |||||
| 28 | 211 | 17.6ms | $self->_attach_attribute($attribute); # spent 15.7ms making 187 calls to Class::MOP::Class::_attach_attribute, avg 84µs/call
# spent 1.89ms making 24 calls to Moose::Meta::Role::_attach_attribute, avg 79µs/call | ||
| 29 | |||||
| 30 | 211 | 1.37ms | my $attr_name = $attribute->name; # spent 1.37ms making 211 calls to Class::MOP::Mixin::AttributeCore::name, avg 6µs/call | ||
| 31 | |||||
| 32 | 211 | 8.30ms | $self->remove_attribute($attr_name) # spent 8.30ms making 211 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 39µs/call | ||
| 33 | if $self->has_attribute($attr_name); | ||||
| 34 | |||||
| 35 | 211 | 1.79ms | my $order = ( scalar keys %{ $self->_attribute_map } ); # spent 1.79ms making 211 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 8µs/call | ||
| 36 | 211 | 2.34ms | $attribute->_set_insertion_order($order); # spent 2.34ms making 211 calls to Class::MOP::Mixin::AttributeCore::_set_insertion_order, avg 11µs/call | ||
| 37 | |||||
| 38 | 211 | 1.88ms | $self->_attribute_map->{$attr_name} = $attribute; # spent 1.88ms making 211 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 9µs/call | ||
| 39 | |||||
| 40 | # This method is called to allow for installing accessors. Ideally, we'd | ||||
| 41 | # use method overriding, but then the subclass would be responsible for | ||||
| 42 | # making the attribute, which would end up with lots of code | ||||
| 43 | # duplication. Even more ideally, we'd use augment/inner, but this is | ||||
| 44 | # Class::MOP! | ||||
| 45 | 398 | 1.60s | $self->_post_add_attribute($attribute) # spent 1.60s making 187 calls to Class::MOP::Class::_post_add_attribute, avg 8.56ms/call
# spent 1.55ms making 211 calls to UNIVERSAL::can, avg 7µs/call | ||
| 46 | if $self->can('_post_add_attribute'); | ||||
| 47 | |||||
| 48 | return $attribute; | ||||
| 49 | } | ||||
| 50 | |||||
| 51 | # spent 28.7ms (21.5+7.15) within Class::MOP::Mixin::HasAttributes::has_attribute which was called 745 times, avg 38µs/call:
# 498 times (14.2ms+4.61ms) by Class::MOP::Class::find_attribute_by_name at line 817 of Class/MOP/Class.pm, avg 38µs/call
# 211 times (6.11ms+2.19ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 32, avg 39µs/call
# 21 times (768µs+224µs) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 136 of Moose/Meta/Role/Application/ToClass.pm, avg 47µs/call
# 15 times (422µs+119µs) by Moose::Meta::Role::Application::ToRole::apply_attributes at line 56 of Moose/Meta/Role/Application/ToRole.pm, avg 36µs/call | ||||
| 52 | 2235 | 20.2ms | my ( $self, $attribute_name ) = @_; | ||
| 53 | |||||
| 54 | ( defined $attribute_name ) | ||||
| 55 | || confess "You must define an attribute name"; | ||||
| 56 | |||||
| 57 | 745 | 7.15ms | exists $self->_attribute_map->{$attribute_name}; # spent 7.15ms making 745 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 10µs/call | ||
| 58 | } | ||||
| 59 | |||||
| 60 | # spent 9.00ms (6.98+2.02) within Class::MOP::Mixin::HasAttributes::get_attribute which was called 240 times, avg 37µs/call:
# 136 times (3.85ms+1.08ms) by Class::MOP::Class::find_attribute_by_name at line 817 of Class/MOP/Class.pm, avg 36µs/call
# 68 times (2.08ms+626µs) by Class::MOP::Class::_inline_accessors at line 1305 of Class/MOP/Class.pm, avg 40µs/call
# 21 times (631µs+173µs) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 142 of Moose/Meta/Role/Application/ToClass.pm, avg 38µs/call
# 15 times (411µs+148µs) by Moose::Meta::Role::Application::ToRole::apply_attributes at line 71 of Moose/Meta/Role/Application/ToRole.pm, avg 37µs/call | ||||
| 61 | 720 | 6.67ms | my ( $self, $attribute_name ) = @_; | ||
| 62 | |||||
| 63 | ( defined $attribute_name ) | ||||
| 64 | || confess "You must define an attribute name"; | ||||
| 65 | |||||
| 66 | 240 | 2.02ms | return $self->_attribute_map->{$attribute_name}; # spent 2.02ms making 240 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 8µs/call | ||
| 67 | } | ||||
| 68 | |||||
| 69 | sub remove_attribute { | ||||
| 70 | my ( $self, $attribute_name ) = @_; | ||||
| 71 | |||||
| 72 | ( defined $attribute_name ) | ||||
| 73 | || confess "You must define an attribute name"; | ||||
| 74 | |||||
| 75 | my $removed_attribute = $self->_attribute_map->{$attribute_name}; | ||||
| 76 | return unless defined $removed_attribute; | ||||
| 77 | |||||
| 78 | delete $self->_attribute_map->{$attribute_name}; | ||||
| 79 | |||||
| 80 | return $removed_attribute; | ||||
| 81 | } | ||||
| 82 | |||||
| 83 | # spent 12.0ms (8.74+3.30) within Class::MOP::Mixin::HasAttributes::get_attribute_list which was called 320 times, avg 38µs/call:
# 111 times (3.10ms+1.17ms) by Moose::Meta::Role::Application::ToRole::apply_attributes at line 54 of Moose/Meta/Role/Application/ToRole.pm, avg 39µs/call
# 73 times (2.06ms+755µs) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 134 of Moose/Meta/Role/Application/ToClass.pm, avg 39µs/call
# 42 times (1.13ms+455µs) by Class::MOP::Class::_remove_generated_metaobjects at line 422 of Class/MOP/Class.pm, avg 38µs/call
# 42 times (1.09ms+449µs) by Class::MOP::Mixin::HasAttributes::_restore_metaattributes_from at line 92, avg 37µs/call
# 32 times (861µs+285µs) by Class::MOP::Class::_inline_accessors at line 1304 of Class/MOP/Class.pm, avg 36µs/call
# 20 times (489µs+182µs) by Moose::Meta::Role::Application::RoleSummation::apply_attributes at line 123 of Moose/Meta/Role/Application/RoleSummation.pm, avg 34µs/call | ||||
| 84 | 640 | 8.00ms | my $self = shift; | ||
| 85 | 320 | 3.30ms | keys %{ $self->_attribute_map }; # spent 3.30ms making 320 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 10µs/call | ||
| 86 | } | ||||
| 87 | |||||
| 88 | # spent 3.54ms (1.83+1.71) within Class::MOP::Mixin::HasAttributes::_restore_metaattributes_from which was called 42 times, avg 84µs/call:
# 42 times (1.83ms+1.71ms) by Class::MOP::Class::_restore_metaobjects_from at line 416 of Class/MOP/Class.pm, avg 84µs/call | ||||
| 89 | 126 | 1.89ms | my $self = shift; | ||
| 90 | my ($old_meta) = @_; | ||||
| 91 | |||||
| 92 | 84 | 1.71ms | for my $attr (sort { $a->insertion_order <=> $b->insertion_order } # spent 1.54ms making 42 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 37µs/call
# spent 170µs making 42 calls to Class::MOP::Mixin::HasAttributes::CORE:sort, avg 4µs/call | ||
| 93 | map { $old_meta->get_attribute($_) } | ||||
| 94 | $old_meta->get_attribute_list) { | ||||
| 95 | $attr->_make_compatible_with($self->attribute_metaclass); | ||||
| 96 | $self->add_attribute($attr); | ||||
| 97 | } | ||||
| 98 | } | ||||
| 99 | |||||
| 100 | 1 | 12µs | 1; | ||
| 101 | |||||
| 102 | __END__ | ||||
# spent 170µs within Class::MOP::Mixin::HasAttributes::CORE:sort which was called 42 times, avg 4µs/call:
# 42 times (170µs+0s) by Class::MOP::Mixin::HasAttributes::_restore_metaattributes_from at line 92, avg 4µs/call |