| 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 7602 statements in 109ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 253 | 114 | 23 | 44.6ms | 1.58s | Class::MOP::Mixin::HasAttributes::add_attribute |
| 345 | 4 | 4 | 10.00ms | 13.7ms | Class::MOP::Mixin::HasAttributes::has_attribute |
| 160 | 5 | 4 | 4.65ms | 5.98ms | Class::MOP::Mixin::HasAttributes::get_attribute |
| 128 | 4 | 4 | 3.62ms | 4.88ms | Class::MOP::Mixin::HasAttributes::get_attribute_list |
| 1 | 1 | 1 | 67µs | 86µs | Class::MOP::Mixin::HasAttributes::BEGIN@3 |
| 1 | 1 | 1 | 53µs | 122µs | Class::MOP::Mixin::HasAttributes::BEGIN@4 |
| 1 | 1 | 1 | 41µs | 275µs | Class::MOP::Mixin::HasAttributes::BEGIN@13 |
| 1 | 1 | 1 | 39µs | 194µs | Class::MOP::Mixin::HasAttributes::BEGIN@10 |
| 1 | 1 | 1 | 37µs | 165µs | Class::MOP::Mixin::HasAttributes::BEGIN@11 |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasAttributes::_restore_metaattributes_from |
| 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 | 112µs | 2 | 104µs | # spent 86µs (67+18) within Class::MOP::Mixin::HasAttributes::BEGIN@3 which was called:
# once (67µs+18µs) by Class::MOP::BEGIN@17 at line 3 # spent 86µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@3
# spent 18µs making 1 call to strict::import |
| 4 | 3 | 206µs | 2 | 192µs | # spent 122µs (53+70) within Class::MOP::Mixin::HasAttributes::BEGIN@4 which was called:
# once (53µs+70µs) by Class::MOP::BEGIN@17 at line 4 # spent 122µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@4
# spent 70µs making 1 call to warnings::import |
| 5 | |||||
| 6 | 1 | 5µs | our $VERSION = '1.11'; | ||
| 7 | 1 | 76µs | $VERSION = eval $VERSION; # spent 11µs executing statements in string eval | ||
| 8 | 1 | 4µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 9 | |||||
| 10 | 3 | 103µs | 2 | 350µs | # spent 194µs (39+156) within Class::MOP::Mixin::HasAttributes::BEGIN@10 which was called:
# once (39µs+156µs) by Class::MOP::BEGIN@17 at line 10 # spent 194µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@10
# spent 156µs making 1 call to Exporter::import |
| 11 | 3 | 100µs | 2 | 293µs | # spent 165µs (37+128) within Class::MOP::Mixin::HasAttributes::BEGIN@11 which was called:
# once (37µs+128µs) by Class::MOP::BEGIN@17 at line 11 # spent 165µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@11
# spent 128µs making 1 call to Exporter::import |
| 12 | |||||
| 13 | 3 | 1.61ms | 2 | 510µs | # spent 275µs (41+234) within Class::MOP::Mixin::HasAttributes::BEGIN@13 which was called:
# once (41µs+234µs) by Class::MOP::BEGIN@17 at line 13 # spent 275µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@13
# spent 234µs making 1 call to base::import |
| 14 | |||||
| 15 | 2433 | 32.3ms | sub _attribute_map { $_[0]->{'attributes'} } | ||
| 16 | 596 | 8.65ms | sub attribute_metaclass { $_[0]->{'attribute_metaclass'} } | ||
| 17 | |||||
| 18 | # spent 1.58s (44.6ms+1.53) within Class::MOP::Mixin::HasAttributes::add_attribute which was called 253 times, avg 6.23ms/call:
# 123 times (21.3ms+1.29s) by Moose::Meta::Class::add_attribute at line 304 of Moose/Meta/Class.pm, avg 10.7ms/call
# 15 times (2.70ms+3.82ms) by Moose::Meta::Role::add_attribute at line 240 of Moose/Meta/Role.pm, avg 435µs/call
# 3 times (562µs+5.80ms) by Moose::BEGIN@27 at line 296 of Moose/Meta/Role.pm, avg 2.12ms/call
# 2 times (466µs+4.40ms) by Moose::BEGIN@27 at line 90 of Moose/Meta/Role.pm, avg 2.43ms/call
# once (187µs+12.7ms) by Moose::BEGIN@21 at line 20 of Moose/Meta/TypeCoercion.pm
# once (198µs+4.42ms) by base::import at line 23 of Moose/Meta/Mixin/AttributeCore.pm
# once (188µs+4.20ms) by Moose::Util::TypeConstraints::BEGIN@39 at line 16 of Moose/Meta/TypeConstraint/Registry.pm
# once (215µs+4.01ms) by base::import at line 35 of Moose/Meta/Mixin/AttributeCore.pm
# once (181µs+3.94ms) by Moose::BEGIN@20 at line 56 of Moose/Meta/TypeConstraint.pm
# once (272µs+3.69ms) by base::import at line 29 of Moose/Meta/Mixin/AttributeCore.pm
# once (185µs+3.10ms) by base::import at line 42 of Moose/Meta/Mixin/AttributeCore.pm
# once (252µs+3.03ms) by Moose::BEGIN@20 at line 33 of Moose/Meta/TypeConstraint.pm
# once (193µs+3.03ms) by Moose::Meta::TypeCoercion::BEGIN@8 at line 27 of Moose/Meta/Attribute.pm
# once (198µs+3.01ms) by Moose::BEGIN@20 at line 43 of Moose/Meta/TypeConstraint.pm
# once (189µs+3.01ms) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 at line 15 of Moose/Meta/TypeConstraint/Parameterizable.pm
# once (184µs+3.00ms) by Moose::Util::TypeConstraints::BEGIN@31 at line 17 of Moose/Meta/TypeConstraint/Parameterized.pm
# once (183µs+2.99ms) by Moose::BEGIN@20 at line 23 of Moose/Meta/TypeConstraint.pm
# once (280µs+2.89ms) by Moose::Meta::Role::BEGIN@17 at line 33 of Moose/Meta/Role/Attribute.pm
# once (178µs+2.96ms) by Moose::BEGIN@20 at line 38 of Moose/Meta/TypeConstraint.pm
# once (179µs+2.93ms) by Moose::BEGIN@20 at line 34 of Moose/Meta/TypeConstraint.pm
# once (196µs+2.67ms) by Moose::Meta::Role::BEGIN@17 at line 27 of Moose/Meta/Role/Attribute.pm
# once (149µs+2.70ms) by Moose::Exporter::BEGIN@11 at line 483 of Class/MOP.pm
# once (254µs+2.59ms) by Moose::BEGIN@33 at line 18 of Moose/Meta/Role/Application/ToInstance.pm
# once (201µs+2.60ms) by Moose::BEGIN@19 at line 36 of Moose/Meta/Class.pm
# once (245µs+2.31ms) by Moose::Exporter::BEGIN@11 at line 193 of Class/MOP.pm
# once (189µs+2.34ms) by Moose::Meta::Role::BEGIN@19 at line 20 of Moose/Meta/Role/Method/Required.pm
# once (198µs+2.27ms) by Moose::BEGIN@20 at line 22 of Moose/Meta/TypeConstraint.pm
# once (147µs+2.15ms) by Moose::Exporter::BEGIN@11 at line 469 of Class/MOP.pm
# once (200µs+2.02ms) by Moose::BEGIN@19 at line 41 of Moose/Meta/Class.pm
# once (148µs+2.06ms) by Moose::Exporter::BEGIN@11 at line 441 of Class/MOP.pm
# once (147µs+2.06ms) by Moose::Exporter::BEGIN@11 at line 414 of Class/MOP.pm
# once (194µs+2.01ms) by Moose::BEGIN@21 at line 18 of Moose/Meta/TypeCoercion.pm
# once (150µs+2.03ms) by Moose::Exporter::BEGIN@11 at line 448 of Class/MOP.pm
# once (152µs+2.03ms) by Moose::Exporter::BEGIN@11 at line 428 of Class/MOP.pm
# once (203µs+1.97ms) by Moose::BEGIN@29 at line 15 of Moose/Meta/Role/Application.pm
# once (147µs+2.02ms) by Moose::Exporter::BEGIN@11 at line 545 of Class/MOP.pm
# once (260µs+1.90ms) by Moose::Exporter::BEGIN@11 at line 574 of Class/MOP.pm
# once (150µs+2.01ms) by Moose::Exporter::BEGIN@11 at line 421 of Class/MOP.pm
# once (192µs+1.95ms) by Moose::BEGIN@28 at line 31 of Moose/Meta/Role/Composite.pm
# once (195µs+1.94ms) by Moose::BEGIN@27 at line 341 of Moose/Meta/Role.pm
# once (153µs+1.98ms) by Moose::Exporter::BEGIN@11 at line 455 of Class/MOP.pm
# once (183µs+1.94ms) by Moose::Meta::Role::BEGIN@17 at line 21 of Moose/Meta/Role/Attribute.pm
# once (151µs+1.97ms) by Moose::Exporter::BEGIN@11 at line 462 of Class/MOP.pm
# once (200µs+1.92ms) by Moose::BEGIN@30 at line 20 of Moose/Meta/Role/Application/RoleSummation.pm
# once (181µs+1.93ms) by base::import at line 16 of Moose/Meta/Mixin/AttributeCore.pm
# once (181µs+1.93ms) by Moose::BEGIN@27 at line 136 of Moose/Meta/Role.pm
# once (200µs+1.91ms) by Moose::BEGIN@31 at line 16 of Moose/Meta/Role/Application/ToClass.pm
# once (182µs+1.93ms) by Moose::BEGIN@29 at line 21 of Moose/Meta/Role/Application.pm
# once (185µs+1.93ms) by Moose::Util::TypeConstraints::BEGIN@36 at line 19 of Moose/Meta/TypeConstraint/DuckType.pm
# once (184µs+1.93ms) by Moose::Util::TypeConstraints::BEGIN@33 at line 16 of Moose/Meta/TypeConstraint/Class.pm
# once (217µs+1.89ms) by Moose::Meta::Role::BEGIN@20 at line 15 of Moose/Meta/Role/Method/Conflicting.pm
# once (186µs+1.91ms) by Moose::Util::TypeConstraints::BEGIN@30 at line 21 of Moose/Meta/TypeConstraint/Union.pm
# once (185µs+1.91ms) by Moose::Util::TypeConstraints::BEGIN@35 at line 15 of Moose/Meta/TypeConstraint/Enum.pm
# once (183µs+1.92ms) by Moose::BEGIN@27 at line 142 of Moose/Meta/Role.pm
# once (195µs+1.90ms) by Moose::BEGIN@28 at line 33 of Moose/Meta/Role/Composite.pm
# once (182µs+1.90ms) by Moose::BEGIN@20 at line 60 of Moose/Meta/TypeConstraint.pm
# once (183µs+1.89ms) by base::import at line 11 of Moose/Meta/Mixin/AttributeCore.pm
# once (190µs+1.88ms) by base::import at line 21 of Moose/Meta/Mixin/AttributeCore.pm
# once (191µs+1.88ms) by Moose::BEGIN@27 at line 130 of Moose/Meta/Role.pm
# once (180µs+1.89ms) by Moose::BEGIN@19 at line 60 of Moose/Meta/Class.pm
# once (181µs+1.89ms) by base::import at line 12 of Moose/Meta/Mixin/AttributeCore.pm
# once (182µs+1.88ms) by Moose::Util::TypeConstraints::BEGIN@39 at line 25 of Moose/Meta/TypeConstraint/Registry.pm
# once (186µs+1.88ms) by Moose::BEGIN@27 at line 125 of Moose/Meta/Role.pm
# once (186µs+1.88ms) by Moose::Util::TypeConstraints::BEGIN@34 at line 16 of Moose/Meta/TypeConstraint/Role.pm
# once (177µs+1.88ms) by Moose::BEGIN@19 at line 55 of Moose/Meta/Class.pm
# once (190µs+1.86ms) by base::import at line 13 of Moose/Meta/Mixin/AttributeCore.pm
# once (188µs+1.86ms) by Moose::BEGIN@28 at line 21 of Moose/Meta/Role/Composite.pm
# once (183µs+1.86ms) by Moose::Meta::Role::BEGIN@17 at line 15 of Moose/Meta/Role/Attribute.pm
# once (178µs+1.87ms) by Moose::BEGIN@31 at line 20 of Moose/Meta/Role/Application/ToClass.pm
# once (185µs+1.86ms) by Moose::BEGIN@27 at line 148 of Moose/Meta/Role.pm
# once (184µs+1.86ms) by Moose::BEGIN@21 at line 28 of Moose/Meta/TypeCoercion.pm
# once (181µs+1.86ms) by Moose::BEGIN@27 at line 393 of Moose/Meta/Role.pm
# once (184µs+1.85ms) by base::import at line 20 of Moose/Meta/Mixin/AttributeCore.pm
# once (183µs+1.83ms) by base::import at line 17 of Moose/Meta/Mixin/AttributeCore.pm
# once (178µs+1.83ms) by Moose::BEGIN@19 at line 50 of Moose/Meta/Class.pm
# once (191µs+1.81ms) by Moose::BEGIN@27 at line 154 of Moose/Meta/Role.pm
# once (179µs+1.82ms) by base::import at line 19 of Moose/Meta/Mixin/AttributeCore.pm
# once (180µs+1.81ms) by base::import at line 15 of Moose/Meta/Mixin/AttributeCore.pm
# once (224µs+1.71ms) by Moose::Exporter::BEGIN@11 at line 584 of Class/MOP.pm
# once (154µs+1.75ms) by Moose::BEGIN@19 at line 43 of Moose/Meta/Class.pm
# once (149µs+1.45ms) by Moose::Exporter::BEGIN@11 at line 338 of Class/MOP.pm
# once (148µs+1.42ms) by Moose::Exporter::BEGIN@11 at line 601 of Class/MOP.pm
# once (151µs+1.40ms) by Moose::Exporter::BEGIN@11 at line 662 of Class/MOP.pm
# once (152µs+1.40ms) by Moose::Exporter::BEGIN@11 at line 593 of Class/MOP.pm
# once (148µs+1.38ms) by Moose::Exporter::BEGIN@11 at line 341 of Class/MOP.pm
# once (151µs+1.37ms) by Moose::Exporter::BEGIN@11 at line 521 of Class/MOP.pm
# once (151µs+1.37ms) by Moose::Exporter::BEGIN@11 at line 277 of Class/MOP.pm
# once (153µs+1.36ms) by Moose::Exporter::BEGIN@11 at line 384 of Class/MOP.pm
# once (158µs+1.36ms) by Moose::Exporter::BEGIN@11 at line 235 of Class/MOP.pm
# once (148µs+1.36ms) by Moose::Exporter::BEGIN@11 at line 322 of Class/MOP.pm
# once (163µs+1.34ms) by Moose::Exporter::BEGIN@11 at line 356 of Class/MOP.pm
# once (155µs+1.34ms) by Moose::Exporter::BEGIN@11 at line 539 of Class/MOP.pm
# once (151µs+1.34ms) by Moose::Exporter::BEGIN@11 at line 641 of Class/MOP.pm
# once (148µs+1.34ms) by Moose::Exporter::BEGIN@11 at line 196 of Class/MOP.pm
# once (180µs+1.30ms) by Moose::Exporter::BEGIN@11 at line 616 of Class/MOP.pm
# once (156µs+1.33ms) by Moose::Exporter::BEGIN@11 at line 435 of Class/MOP.pm
# once (156µs+1.32ms) by Moose::Exporter::BEGIN@11 at line 619 of Class/MOP.pm
# once (151µs+1.33ms) by Moose::Exporter::BEGIN@11 at line 635 of Class/MOP.pm
# once (148µs+1.33ms) by Moose::Exporter::BEGIN@11 at line 493 of Class/MOP.pm
# once (147µs+1.33ms) by Moose::Exporter::BEGIN@11 at line 650 of Class/MOP.pm
# once (148µs+1.33ms) by Moose::Exporter::BEGIN@11 at line 567 of Class/MOP.pm
# once (147µs+1.33ms) by Moose::Exporter::BEGIN@11 at line 208 of Class/MOP.pm
# once (146µs+1.32ms) by Moose::Exporter::BEGIN@11 at line 400 of Class/MOP.pm
# once (150µs+1.32ms) by Moose::Exporter::BEGIN@11 at line 253 of Class/MOP.pm
# once (155µs+1.30ms) by Moose::Exporter::BEGIN@11 at line 303 of Class/MOP.pm
# once (178µs+1.27ms) by Moose::Exporter::BEGIN@11 at line 511 of Class/MOP.pm
# once (148µs+1.30ms) by Moose::Exporter::BEGIN@11 at line 656 of Class/MOP.pm
# once (148µs+1.29ms) by Moose::Exporter::BEGIN@11 at line 476 of Class/MOP.pm
# once (146µs+1.29ms) by Moose::Exporter::BEGIN@11 at line 238 of Class/MOP.pm
# once (146µs+1.29ms) by Moose::Exporter::BEGIN@11 at line 365 of Class/MOP.pm
# once (147µs+1.29ms) by Moose::Exporter::BEGIN@11 at line 527 of Class/MOP.pm
# once (149µs+1.28ms) by Moose::Exporter::BEGIN@11 at line 533 of Class/MOP.pm
# once (146µs+1.28ms) by Moose::Exporter::BEGIN@11 at line 374 of Class/MOP.pm
# once (145µs+577µs) by Moose::Exporter::BEGIN@11 at line 560 of Class/MOP.pm | ||||
| 19 | 253 | 829µs | my $self = shift; | ||
| 20 | |||||
| 21 | 253 | 7.30ms | 399 | 12.7ms | my $attribute # spent 9.55ms making 66 calls to Class::MOP::Attribute::new, avg 145µs/call
# spent 1.74ms making 253 calls to Scalar::Util::blessed, avg 7µs/call
# spent 908µs making 73 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 12µs/call
# spent 496µs making 7 calls to Moose::Meta::Role::Attribute::new, avg 71µs/call |
| 22 | = blessed( $_[0] ) ? $_[0] : $self->attribute_metaclass->new(@_); | ||||
| 23 | |||||
| 24 | 253 | 5.48ms | 253 | 2.00ms | ( $attribute->isa('Class::MOP::Mixin::AttributeCore') ) # spent 2.00ms making 253 calls to UNIVERSAL::isa, avg 8µs/call |
| 25 | || confess | ||||
| 26 | "Your attribute must be an instance of Class::MOP::Mixin::AttributeCore (or a subclass)"; | ||||
| 27 | |||||
| 28 | 253 | 3.09ms | 253 | 22.1ms | $self->_attach_attribute($attribute); # spent 20.5ms making 238 calls to Class::MOP::Class::_attach_attribute, avg 86µs/call
# spent 1.62ms making 15 calls to Moose::Meta::Role::_attach_attribute, avg 108µs/call |
| 29 | |||||
| 30 | 253 | 5.31ms | 253 | 1.81ms | my $attr_name = $attribute->name; # spent 1.81ms making 253 calls to Class::MOP::Mixin::AttributeCore::name, avg 7µs/call |
| 31 | |||||
| 32 | 253 | 2.96ms | 253 | 10.0ms | $self->remove_attribute($attr_name) # spent 10.0ms making 253 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 40µs/call |
| 33 | if $self->has_attribute($attr_name); | ||||
| 34 | |||||
| 35 | 253 | 3.12ms | 253 | 2.21ms | my $order = ( scalar keys %{ $self->_attribute_map } ); # spent 2.21ms making 253 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 9µs/call |
| 36 | 253 | 3.06ms | 253 | 2.78ms | $attribute->_set_insertion_order($order); # spent 2.78ms making 253 calls to Class::MOP::Mixin::AttributeCore::_set_insertion_order, avg 11µs/call |
| 37 | |||||
| 38 | 253 | 3.29ms | 253 | 2.15ms | $self->_attribute_map->{$attr_name} = $attribute; # spent 2.15ms making 253 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 | 253 | 10.2ms | 491 | 1.48s | $self->_post_add_attribute($attribute) # spent 1.47s making 238 calls to Class::MOP::Class::_post_add_attribute, avg 6.19ms/call
# spent 2.07ms making 253 calls to UNIVERSAL::can, avg 8µs/call |
| 46 | if $self->can('_post_add_attribute'); | ||||
| 47 | |||||
| 48 | 253 | 4.40ms | return $attribute; | ||
| 49 | } | ||||
| 50 | |||||
| 51 | # spent 13.7ms (10.00+3.70) within Class::MOP::Mixin::HasAttributes::has_attribute which was called 345 times, avg 40µs/call:
# 253 times (7.25ms+2.76ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 32, avg 40µs/call
# 79 times (2.37ms+820µs) by Class::MOP::Class::find_attribute_by_name at line 817 of Class/MOP/Class.pm, avg 40µs/call
# 7 times (211µs+68µs) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 136 of Moose/Meta/Role/Application/ToClass.pm, avg 40µs/call
# 6 times (169µs+46µs) by Moose::Meta::Role::Application::ToRole::apply_attributes at line 56 of Moose/Meta/Role/Application/ToRole.pm, avg 36µs/call | ||||
| 52 | 345 | 1.35ms | my ( $self, $attribute_name ) = @_; | ||
| 53 | |||||
| 54 | 345 | 773µs | ( defined $attribute_name ) | ||
| 55 | || confess "You must define an attribute name"; | ||||
| 56 | |||||
| 57 | 345 | 7.58ms | 345 | 3.70ms | exists $self->_attribute_map->{$attribute_name}; # spent 3.70ms making 345 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 11µs/call |
| 58 | } | ||||
| 59 | |||||
| 60 | # spent 5.98ms (4.65+1.32) within Class::MOP::Mixin::HasAttributes::get_attribute which was called 160 times, avg 37µs/call:
# 77 times (2.07ms+584µs) by Class::MOP::Class::find_attribute_by_name at line 817 of Class/MOP/Class.pm, avg 34µs/call
# 68 times (2.15ms+622µs) by Class::MOP::Class::_inline_accessors at line 1305 of Class/MOP/Class.pm, avg 41µs/call
# 7 times (207µs+57µs) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 142 of Moose/Meta/Role/Application/ToClass.pm, avg 38µs/call
# 6 times (170µs+46µs) by Moose::Meta::Role::Application::ToRole::apply_attributes at line 71 of Moose/Meta/Role/Application/ToRole.pm, avg 36µs/call
# 2 times (60µs+15µs) by Moose::Meta::Role::Application::RoleSummation::apply_attributes at line 122 of Moose/Meta/Role/Application/RoleSummation.pm, avg 37µs/call | ||||
| 61 | 160 | 663µs | my ( $self, $attribute_name ) = @_; | ||
| 62 | |||||
| 63 | 160 | 355µs | ( defined $attribute_name ) | ||
| 64 | || confess "You must define an attribute name"; | ||||
| 65 | |||||
| 66 | 160 | 3.24ms | 160 | 1.32ms | return $self->_attribute_map->{$attribute_name}; # spent 1.32ms making 160 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 4.88ms (3.62+1.27) within Class::MOP::Mixin::HasAttributes::get_attribute_list which was called 128 times, avg 38µs/call:
# 51 times (1.54ms+531µs) by Moose::Meta::Role::Application::ToRole::apply_attributes at line 54 of Moose/Meta/Role/Application/ToRole.pm, avg 41µs/call
# 32 times (873µs+289µs) by Class::MOP::Class::_inline_accessors at line 1304 of Class/MOP/Class.pm, avg 36µs/call
# 24 times (612µs+219µs) by Moose::Meta::Role::Application::RoleSummation::apply_attributes at line 123 of Moose/Meta/Role/Application/RoleSummation.pm, avg 35µs/call
# 21 times (588µs+227µs) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 134 of Moose/Meta/Role/Application/ToClass.pm, avg 39µs/call | ||||
| 84 | 128 | 377µs | my $self = shift; | ||
| 85 | 128 | 2.80ms | 128 | 1.27ms | keys %{ $self->_attribute_map }; # spent 1.27ms making 128 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 10µs/call |
| 86 | } | ||||
| 87 | |||||
| 88 | sub _restore_metaattributes_from { | ||||
| 89 | my $self = shift; | ||||
| 90 | my ($old_meta) = @_; | ||||
| 91 | |||||
| 92 | for my $attr (sort { $a->insertion_order <=> $b->insertion_order } | ||||
| 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__ |