Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Class/MOP/Mixin/HasAttributes.pm |
Statements | Executed 3513 statements in 6.51ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
189 | 122 | 23 | 8.54ms | 312ms | add_attribute | Class::MOP::Mixin::HasAttributes::
264 | 4 | 4 | 768µs | 879µs | has_attribute | Class::MOP::Mixin::HasAttributes::
168 | 5 | 4 | 466µs | 541µs | get_attribute | Class::MOP::Mixin::HasAttributes::
62 | 4 | 4 | 179µs | 207µs | get_attribute_list | Class::MOP::Mixin::HasAttributes::
1 | 1 | 1 | 8µs | 18µs | BEGIN@9 | Class::MOP::Mixin::HasAttributes::
1 | 1 | 1 | 8µs | 8µs | BEGIN@2 | Class::MOP::Mixin::HasAttributes::
1 | 1 | 1 | 6µs | 9µs | BEGIN@10 | Class::MOP::Mixin::HasAttributes::
1 | 1 | 1 | 5µs | 25µs | BEGIN@12 | Class::MOP::Mixin::HasAttributes::
1 | 1 | 1 | 5µs | 22µs | BEGIN@13 | Class::MOP::Mixin::HasAttributes::
1 | 1 | 1 | 5µs | 55µs | BEGIN@15 | Class::MOP::Mixin::HasAttributes::
0 | 0 | 0 | 0s | 0s | _restore_metaattributes_from | Class::MOP::Mixin::HasAttributes::
0 | 0 | 0 | 0s | 0s | remove_attribute | Class::MOP::Mixin::HasAttributes::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Class::MOP::Mixin::HasAttributes; | ||||
2 | # spent 8µs within Class::MOP::Mixin::HasAttributes::BEGIN@2 which was called:
# once (8µs+0s) by Class::MOP::BEGIN@24 at line 4 | ||||
3 | 1 | 4µs | $Class::MOP::Mixin::HasAttributes::AUTHORITY = 'cpan:STEVAN'; | ||
4 | 1 | 25µs | 1 | 8µs | } # spent 8µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@2 |
5 | { | ||||
6 | 2 | 800ns | $Class::MOP::Mixin::HasAttributes::VERSION = '2.1005'; | ||
7 | } | ||||
8 | |||||
9 | 2 | 21µs | 2 | 28µs | # spent 18µs (8+10) within Class::MOP::Mixin::HasAttributes::BEGIN@9 which was called:
# once (8µs+10µs) by Class::MOP::BEGIN@24 at line 9 # spent 18µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@9
# spent 10µs making 1 call to strict::import |
10 | 2 | 20µs | 2 | 12µs | # spent 9µs (6+3) within Class::MOP::Mixin::HasAttributes::BEGIN@10 which was called:
# once (6µs+3µs) by Class::MOP::BEGIN@24 at line 10 # spent 9µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@10
# spent 3µs making 1 call to warnings::import |
11 | |||||
12 | 2 | 19µs | 2 | 45µs | # spent 25µs (5+20) within Class::MOP::Mixin::HasAttributes::BEGIN@12 which was called:
# once (5µs+20µs) by Class::MOP::BEGIN@24 at line 12 # spent 25µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@12
# spent 20µs making 1 call to Exporter::import |
13 | 2 | 20µs | 2 | 40µs | # spent 22µs (5+17) within Class::MOP::Mixin::HasAttributes::BEGIN@13 which was called:
# once (5µs+17µs) by Class::MOP::BEGIN@24 at line 13 # spent 22µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@13
# spent 17µs making 1 call to Exporter::import |
14 | |||||
15 | 2 | 340µs | 2 | 106µs | # spent 55µs (5+50) within Class::MOP::Mixin::HasAttributes::BEGIN@15 which was called:
# once (5µs+50µs) by Class::MOP::BEGIN@24 at line 15 # spent 55µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@15
# spent 50µs making 1 call to base::import |
16 | |||||
17 | # spent 312ms (8.54+304) within Class::MOP::Mixin::HasAttributes::add_attribute which was called 189 times, avg 1.65ms/call:
# 38 times (664µs+740µs) by Moose::Meta::Role::add_attribute at line 253 of Moose/Meta/Role.pm, avg 37µs/call
# 28 times (591µs+265ms) by Moose::Meta::Class::add_attribute at line 580 of Moose/Meta/Class.pm, avg 9.47ms/call
# 3 times (68µs+681µs) by Moose::BEGIN@35 at line 309 of Moose/Meta/Role.pm, avg 250µs/call
# 2 times (48µs+481µs) by Moose::BEGIN@35 at line 92 of Moose/Meta/Role.pm, avg 264µs/call
# once (4.45ms+196µs) by Moose::Exporter::BEGIN@13 at line 198 of Class/MOP.pm
# once (24µs+3.35ms) by Moose::BEGIN@29 at line 32 of Moose/Meta/TypeCoercion.pm
# once (24µs+2.70ms) by base::import at line 35 of Moose/Meta/Mixin/AttributeCore.pm
# once (25µs+1.85ms) by Moose::BEGIN@29 at line 23 of Moose/Meta/TypeCoercion.pm
# once (44µs+552µs) by Moose::Exporter::BEGIN@13 at line 133 of Class/MOP.pm
# once (25µs+542µs) by Moose::Util::TypeConstraints::BEGIN@42 at line 18 of Moose/Meta/TypeConstraint/Registry.pm
# once (23µs+516µs) by base::import at line 92 of Moose/Meta/Mixin/AttributeCore.pm
# once (25µs+414µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 19 of Moose/Meta/TypeConstraint/Parameterizable.pm
# once (20µs+395µs) by Moose::Exporter::BEGIN@13 at line 518 of Class/MOP.pm
# once (24µs+387µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 19 of Moose/Meta/TypeConstraint/Parameterized.pm
# once (24µs+384µs) by Moose::BEGIN@28 at line 43 of Moose/Meta/TypeConstraint.pm
# once (24µs+380µs) by Moose::Meta::TypeCoercion::BEGIN@14 at line 31 of Moose/Meta/Attribute.pm
# once (23µs+380µs) by Moose::BEGIN@28 at line 32 of Moose/Meta/TypeConstraint.pm
# once (24µs+378µs) by Moose::BEGIN@28 at line 112 of Moose/Meta/TypeConstraint.pm
# once (23µs+378µs) by Moose::BEGIN@28 at line 46 of Moose/Meta/TypeConstraint.pm
# once (23µs+373µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 25 of Moose/Meta/TypeConstraint/Parameterizable.pm
# once (23µs+372µs) by Moose::Exporter::BEGIN@13 at line 449 of Class/MOP.pm
# once (24µs+371µs) by base::import at line 84 of Moose/Meta/Mixin/AttributeCore.pm
# once (24µs+368µs) by base::import at line 101 of Moose/Meta/Mixin/AttributeCore.pm
# once (24µs+366µs) by Moose::BEGIN@28 at line 91 of Moose/Meta/TypeConstraint.pm
# once (23µs+367µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 25 of Moose/Meta/TypeConstraint/Parameterized.pm
# once (23µs+367µs) by base::import at line 76 of Moose/Meta/Mixin/AttributeCore.pm
# once (22µs+365µs) by Moose::BEGIN@28 at line 78 of Moose/Meta/TypeConstraint.pm
# once (23µs+360µs) by Moose::BEGIN@28 at line 84 of Moose/Meta/TypeConstraint.pm
# once (35µs+343µs) by Moose::BEGIN@27 at line 38 of Moose/Meta/Class.pm
# once (24µs+290µs) by Moose::Exporter::BEGIN@13 at line 378 of Class/MOP.pm
# once (23µs+283µs) by Moose::Exporter::BEGIN@13 at line 370 of Class/MOP.pm
# once (23µs+279µs) by Moose::Exporter::BEGIN@13 at line 409 of Class/MOP.pm
# once (24µs+278µs) by Moose::Exporter::BEGIN@13 at line 386 of Class/MOP.pm
# once (23µs+274µs) by base::import at line 69 of Moose/Meta/Mixin/AttributeCore.pm
# once (23µs+272µs) by Moose::Exporter::BEGIN@13 at line 401 of Class/MOP.pm
# once (24µs+270µs) by Moose::Exporter::BEGIN@13 at line 417 of Class/MOP.pm
# once (23µs+271µs) by Moose::Exporter::BEGIN@13 at line 425 of Class/MOP.pm
# once (23µs+267µs) by Moose::Exporter::BEGIN@13 at line 433 of Class/MOP.pm
# once (26µs+262µs) by Moose::Util::TypeConstraints::BEGIN@33 at line 24 of Moose/Meta/TypeConstraint/Union.pm
# once (29µs+255µs) by base::import at line 14 of Moose/Meta/Mixin/AttributeCore.pm
# once (24µs+259µs) by Moose::Meta::Role::BEGIN@21 at line 22 of Moose/Meta/Role/Method/Required.pm
# once (25µs+257µs) by Moose::BEGIN@41 at line 21 of Moose/Meta/Role/Application/ToInstance.pm
# once (25µs+256µs) by Moose::BEGIN@28 at line 28 of Moose/Meta/TypeConstraint.pm
# once (25µs+256µs) by Moose::BEGIN@35 at line 162 of Moose/Meta/Role.pm
# once (32µs+249µs) by Moose::BEGIN@35 at line 355 of Moose/Meta/Role.pm
# once (25µs+252µs) by Moose::BEGIN@38 at line 22 of Moose/Meta/Role/Application/RoleSummation.pm
# once (26µs+251µs) by Moose::Meta::Role::BEGIN@22 at line 17 of Moose/Meta/Role/Method/Conflicting.pm
# once (25µs+251µs) by Moose::BEGIN@29 at line 20 of Moose/Meta/TypeCoercion.pm
# once (20µs+255µs) by Moose::Exporter::BEGIN@13 at line 543 of Class/MOP.pm
# once (25µs+248µs) by Moose::Util::TypeConstraints::BEGIN@38 at line 18 of Moose/Meta/TypeConstraint/Enum.pm
# once (25µs+247µs) by Moose::BEGIN@39 at line 19 of Moose/Meta/Role/Application/ToClass.pm
# once (29µs+243µs) by Moose::Exporter::BEGIN@13 at line 551 of Class/MOP.pm
# once (24µs+246µs) by Moose::BEGIN@37 at line 17 of Moose/Meta/Role/Application.pm
# once (19µs+251µs) by Moose::Exporter::BEGIN@13 at line 597 of Class/MOP.pm
# once (24µs+244µs) by Moose::Util::TypeConstraints::BEGIN@36 at line 19 of Moose/Meta/TypeConstraint/Class.pm
# once (23µs+243µs) by Moose::BEGIN@28 at line 102 of Moose/Meta/TypeConstraint.pm
# once (25µs+241µs) by Moose::BEGIN@36 at line 24 of Moose/Meta/Role/Composite.pm
# once (25µs+241µs) by Moose::Util::TypeConstraints::BEGIN@39 at line 22 of Moose/Meta/TypeConstraint/DuckType.pm
# once (24µs+241µs) by base::import at line 42 of Moose/Meta/Mixin/AttributeCore.pm
# once (24µs+240µs) by Moose::Util::TypeConstraints::BEGIN@37 at line 19 of Moose/Meta/TypeConstraint/Role.pm
# once (22µs+241µs) by Moose::Exporter::BEGIN@13 at line 287 of Class/MOP.pm
# once (24µs+237µs) by Moose::Meta::Role::BEGIN@19 at line 18 of Moose/Meta/Role/Attribute.pm
# once (24µs+237µs) by Moose::BEGIN@28 at line 118 of Moose/Meta/TypeConstraint.pm
# once (20µs+238µs) by Moose::Exporter::BEGIN@13 at line 504 of Class/MOP.pm
# once (23µs+235µs) by Moose::BEGIN@36 at line 37 of Moose/Meta/Role/Composite.pm
# once (24µs+234µs) by Moose::BEGIN@37 at line 24 of Moose/Meta/Role/Application.pm
# once (20µs+238µs) by Moose::Exporter::BEGIN@13 at line 497 of Class/MOP.pm
# once (20µs+237µs) by Moose::Exporter::BEGIN@13 at line 511 of Class/MOP.pm
# once (23µs+233µs) by Moose::BEGIN@35 at line 155 of Moose/Meta/Role.pm
# once (24µs+232µs) by Moose::BEGIN@39 at line 24 of Moose/Meta/Role/Application/ToClass.pm
# once (23µs+232µs) by Moose::BEGIN@27 at line 44 of Moose/Meta/Class.pm
# once (24µs+231µs) by Moose::Util::TypeConstraints::BEGIN@38 at line 23 of Moose/Meta/TypeConstraint/Enum.pm
# once (24µs+231µs) by Moose::BEGIN@36 at line 40 of Moose/Meta/Role/Composite.pm
# once (23µs+231µs) by Moose::Util::TypeConstraints::BEGIN@42 at line 28 of Moose/Meta/TypeConstraint/Registry.pm
# once (23µs+230µs) by base::import at line 21 of Moose/Meta/Mixin/AttributeCore.pm
# once (23µs+229µs) by base::import at line 48 of Moose/Meta/Mixin/AttributeCore.pm
# once (22µs+228µs) by base::import at line 55 of Moose/Meta/Mixin/AttributeCore.pm
# once (23µs+226µs) by Moose::Meta::Role::BEGIN@19 at line 25 of Moose/Meta/Role/Attribute.pm
# once (19µs+230µs) by Moose::Exporter::BEGIN@13 at line 562 of Class/MOP.pm
# once (23µs+225µs) by base::import at line 28 of Moose/Meta/Mixin/AttributeCore.pm
# once (23µs+225µs) by Moose::Meta::Role::BEGIN@19 at line 32 of Moose/Meta/Role/Attribute.pm
# once (24µs+224µs) by Moose::Exporter::BEGIN@13 at line 460 of Class/MOP.pm
# once (22µs+224µs) by Moose::BEGIN@27 at line 55 of Moose/Meta/Class.pm
# once (23µs+223µs) by base::import at line 62 of Moose/Meta/Mixin/AttributeCore.pm
# once (22µs+224µs) by Moose::BEGIN@35 at line 401 of Moose/Meta/Role.pm
# once (23µs+223µs) by Moose::BEGIN@28 at line 52 of Moose/Meta/TypeConstraint.pm
# once (23µs+222µs) by Moose::BEGIN@27 at line 67 of Moose/Meta/Class.pm
# once (23µs+221µs) by Moose::BEGIN@35 at line 134 of Moose/Meta/Role.pm
# once (23µs+221µs) by Moose::BEGIN@35 at line 141 of Moose/Meta/Role.pm
# once (22µs+221µs) by Moose::Meta::Role::BEGIN@19 at line 39 of Moose/Meta/Role/Attribute.pm
# once (23µs+220µs) by Moose::BEGIN@27 at line 61 of Moose/Meta/Class.pm
# once (23µs+220µs) by Moose::Meta::Role::BEGIN@19 at line 46 of Moose/Meta/Role/Attribute.pm
# once (23µs+219µs) by Moose::BEGIN@35 at line 128 of Moose/Meta/Role.pm
# once (23µs+219µs) by Moose::BEGIN@35 at line 148 of Moose/Meta/Role.pm
# once (25µs+214µs) by Moose::Exporter::BEGIN@13 at line 137 of Class/MOP.pm
# once (20µs+218µs) by Moose::Exporter::BEGIN@13 at line 642 of Class/MOP.pm
# once (23µs+214µs) by Moose::BEGIN@35 at line 169 of Moose/Meta/Role.pm
# once (19µs+217µs) by Moose::Exporter::BEGIN@13 at line 581 of Class/MOP.pm
# once (19µs+215µs) by Moose::BEGIN@27 at line 47 of Moose/Meta/Class.pm
# once (26µs+203µs) by Moose::Exporter::BEGIN@13 at line 223 of Class/MOP.pm
# once (21µs+200µs) by Moose::Exporter::BEGIN@13 at line 490 of Class/MOP.pm
# once (23µs+196µs) by Moose::Exporter::BEGIN@13 at line 178 of Class/MOP.pm
# once (19µs+194µs) by Moose::Exporter::BEGIN@13 at line 649 of Class/MOP.pm
# once (20µs+194µs) by Moose::Exporter::BEGIN@13 at line 572 of Class/MOP.pm
# once (22µs+187µs) by Moose::Exporter::BEGIN@13 at line 250 of Class/MOP.pm
# once (24µs+184µs) by Moose::Exporter::BEGIN@13 at line 150 of Class/MOP.pm
# once (19µs+187µs) by Moose::Exporter::BEGIN@13 at line 618 of Class/MOP.pm
# once (23µs+181µs) by Moose::Exporter::BEGIN@13 at line 182 of Class/MOP.pm
# once (23µs+181µs) by Moose::Exporter::BEGIN@13 at line 270 of Class/MOP.pm
# once (20µs+183µs) by Moose::Exporter::BEGIN@13 at line 635 of Class/MOP.pm
# once (20µs+177µs) by Moose::Exporter::BEGIN@13 at line 338 of Class/MOP.pm
# once (23µs+173µs) by Moose::Exporter::BEGIN@13 at line 441 of Class/MOP.pm
# once (19µs+176µs) by Moose::Exporter::BEGIN@13 at line 355 of Class/MOP.pm
# once (19µs+173µs) by Moose::Exporter::BEGIN@13 at line 307 of Class/MOP.pm
# once (23µs+169µs) by Moose::Exporter::BEGIN@13 at line 394 of Class/MOP.pm
# once (20µs+168µs) by Moose::Exporter::BEGIN@13 at line 291 of Class/MOP.pm
# once (19µs+167µs) by Moose::Exporter::BEGIN@13 at line 317 of Class/MOP.pm
# once (28µs+157µs) by Moose::Exporter::BEGIN@13 at line 625 of Class/MOP.pm
# once (19µs+166µs) by Moose::Exporter::BEGIN@13 at line 327 of Class/MOP.pm
# once (19µs+165µs) by Moose::Exporter::BEGIN@13 at line 479 of Class/MOP.pm
# once (19µs+164µs) by Moose::Exporter::BEGIN@13 at line 601 of Class/MOP.pm
# once (20µs+72µs) by Moose::Exporter::BEGIN@13 at line 534 of Class/MOP.pm | ||||
18 | 189 | 21µs | my $self = shift; | ||
19 | |||||
20 | 189 | 735µs | 375 | 1.48ms | my $attribute # spent 1.21ms making 74 calls to Class::MOP::Attribute::new, avg 16µs/call
# spent 126µs making 19 calls to Moose::Meta::Role::Attribute::new, avg 7µs/call
# spent 86µs making 189 calls to Scalar::Util::blessed, avg 456ns/call
# spent 52µs making 93 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 555ns/call |
21 | = blessed( $_[0] ) ? $_[0] : $self->attribute_metaclass->new(@_); | ||||
22 | |||||
23 | 189 | 402µs | 189 | 125µs | ( $attribute->isa('Class::MOP::Mixin::AttributeCore') ) # spent 125µs making 189 calls to UNIVERSAL::isa, avg 661ns/call |
24 | || confess | ||||
25 | "Your attribute must be an instance of Class::MOP::Mixin::AttributeCore (or a subclass)"; | ||||
26 | |||||
27 | 189 | 133µs | 189 | 1.70ms | $self->_attach_attribute($attribute); # spent 1.37ms making 151 calls to Class::MOP::Class::_attach_attribute, avg 9µs/call
# spent 333µs making 38 calls to Moose::Meta::Role::_attach_attribute, avg 9µs/call |
28 | |||||
29 | 189 | 413µs | 189 | 106µs | my $attr_name = $attribute->name; # spent 106µs making 189 calls to Class::MOP::Mixin::AttributeCore::name, avg 563ns/call |
30 | |||||
31 | 189 | 162µs | 189 | 614µs | $self->remove_attribute($attr_name) # spent 614µs making 189 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 3µs/call |
32 | if $self->has_attribute($attr_name); | ||||
33 | |||||
34 | 189 | 357µs | 189 | 77µs | my $order = ( scalar keys %{ $self->_attribute_map } ); # spent 77µs making 189 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 405ns/call |
35 | 189 | 143µs | 189 | 195µs | $attribute->_set_insertion_order($order); # spent 195µs making 189 calls to Class::MOP::Mixin::AttributeCore::_set_insertion_order, avg 1µs/call |
36 | |||||
37 | 189 | 406µs | 189 | 78µs | $self->_attribute_map->{$attr_name} = $attribute; # spent 78µs making 189 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 412ns/call |
38 | |||||
39 | # This method is called to allow for installing accessors. Ideally, we'd | ||||
40 | # use method overriding, but then the subclass would be responsible for | ||||
41 | # making the attribute, which would end up with lots of code | ||||
42 | # duplication. Even more ideally, we'd use augment/inner, but this is | ||||
43 | # Class::MOP! | ||||
44 | 189 | 958µs | 340 | 299ms | $self->_post_add_attribute($attribute) # spent 299ms making 151 calls to Class::MOP::Class::_post_add_attribute, avg 1.98ms/call
# spent 126µs making 189 calls to UNIVERSAL::can, avg 668ns/call |
45 | if $self->can('_post_add_attribute'); | ||||
46 | |||||
47 | 189 | 480µs | return $attribute; | ||
48 | } | ||||
49 | |||||
50 | # spent 879µs (768+111) within Class::MOP::Mixin::HasAttributes::has_attribute which was called 264 times, avg 3µs/call:
# 189 times (539µs+75µs) by Class::MOP::Mixin::HasAttributes::add_attribute at line 31, avg 3µs/call
# 54 times (159µs+26µs) by Class::MOP::Class::find_attribute_by_name at line 919 of Class/MOP/Class.pm, avg 3µs/call
# 19 times (64µs+10µs) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 146 of Moose/Meta/Role/Application/ToClass.pm, avg 4µs/call
# 2 times (6µs+800ns) by Moose::Meta::Role::Application::ToRole::apply_attributes at line 58 of Moose/Meta/Role/Application/ToRole.pm, avg 3µs/call | ||||
51 | 264 | 57µs | my ( $self, $attribute_name ) = @_; | ||
52 | |||||
53 | 264 | 27µs | ( defined $attribute_name ) | ||
54 | || confess "You must define an attribute name"; | ||||
55 | |||||
56 | 264 | 902µs | 264 | 111µs | exists $self->_attribute_map->{$attribute_name}; # spent 111µs making 264 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 421ns/call |
57 | } | ||||
58 | |||||
59 | # spent 541µs (466+74) within Class::MOP::Mixin::HasAttributes::get_attribute which was called 168 times, avg 3µs/call:
# 76 times (230µs+42µs) by Class::MOP::Class::_inline_accessors at line 1413 of Class/MOP/Class.pm, avg 4µs/call
# 54 times (140µs+18µs) by Class::MOP::Class::find_attribute_by_name at line 919 of Class/MOP/Class.pm, avg 3µs/call
# 19 times (52µs+8µs) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 152 of Moose/Meta/Role/Application/ToClass.pm, avg 3µs/call
# 17 times (39µs+5µs) by Moose::Meta::Role::Application::RoleSummation::apply_attributes at line 125 of Moose/Meta/Role/Application/RoleSummation.pm, avg 3µs/call
# 2 times (5µs+800ns) by Moose::Meta::Role::Application::ToRole::apply_attributes at line 73 of Moose/Meta/Role/Application/ToRole.pm, avg 3µs/call | ||||
60 | 168 | 42µs | my ( $self, $attribute_name ) = @_; | ||
61 | |||||
62 | 168 | 12µs | ( defined $attribute_name ) | ||
63 | || confess "You must define an attribute name"; | ||||
64 | |||||
65 | 168 | 557µs | 168 | 74µs | return $self->_attribute_map->{$attribute_name}; # spent 74µs making 168 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 443ns/call |
66 | } | ||||
67 | |||||
68 | sub remove_attribute { | ||||
69 | my ( $self, $attribute_name ) = @_; | ||||
70 | |||||
71 | ( defined $attribute_name ) | ||||
72 | || confess "You must define an attribute name"; | ||||
73 | |||||
74 | my $removed_attribute = $self->_attribute_map->{$attribute_name}; | ||||
75 | return unless defined $removed_attribute; | ||||
76 | |||||
77 | delete $self->_attribute_map->{$attribute_name}; | ||||
78 | |||||
79 | return $removed_attribute; | ||||
80 | } | ||||
81 | |||||
82 | # spent 207µs (179+28) within Class::MOP::Mixin::HasAttributes::get_attribute_list which was called 62 times, avg 3µs/call:
# 33 times (96µs+14µs) by Class::MOP::Class::_inline_accessors at line 1412 of Class/MOP/Class.pm, avg 3µs/call
# 11 times (31µs+5µs) by Moose::Meta::Role::Application::ToRole::apply_attributes at line 56 of Moose/Meta/Role/Application/ToRole.pm, avg 3µs/call
# 10 times (31µs+5µs) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 144 of Moose/Meta/Role/Application/ToClass.pm, avg 4µs/call
# 8 times (21µs+4µs) by Moose::Meta::Role::Application::RoleSummation::apply_attributes at line 126 of Moose/Meta/Role/Application/RoleSummation.pm, avg 3µs/call | ||||
83 | 62 | 7µs | my $self = shift; | ||
84 | 62 | 240µs | 62 | 28µs | keys %{ $self->_attribute_map }; # spent 28µs making 62 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 455ns/call |
85 | } | ||||
86 | |||||
87 | sub _restore_metaattributes_from { | ||||
88 | my $self = shift; | ||||
89 | my ($old_meta) = @_; | ||||
90 | |||||
91 | for my $attr (sort { $a->insertion_order <=> $b->insertion_order } | ||||
92 | map { $old_meta->get_attribute($_) } | ||||
93 | $old_meta->get_attribute_list) { | ||||
94 | $attr->_make_compatible_with($self->attribute_metaclass); | ||||
95 | $self->add_attribute($attr); | ||||
96 | } | ||||
97 | } | ||||
98 | |||||
99 | 1 | 2µs | 1; | ||
100 | |||||
101 | # ABSTRACT: Methods for metaclasses which have attributes | ||||
102 | |||||
103 | __END__ |