← Index
NYTProf Performance Profile   « line view »
For fastest.pl
  Run on Fri Jan 31 20:48:16 2014
Reported on Fri Jan 31 20:49:40 2014

Filename/opt/perl-5.18.1/lib/site_perl/5.18.1/darwin-thread-multi-2level/Class/MOP/Mixin/HasAttributes.pm
StatementsExecuted 2368 statements in 16.4ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
124121239.23ms92.7msClass::MOP::Mixin::HasAttributes::::add_attributeClass::MOP::Mixin::HasAttributes::add_attribute
130214.82ms4.89msClass::MOP::Mixin::HasAttributes::::get_attributeClass::MOP::Mixin::HasAttributes::get_attribute
17822769µs884µsClass::MOP::Mixin::HasAttributes::::has_attributeClass::MOP::Mixin::HasAttributes::has_attribute
3311164µs188µsClass::MOP::Mixin::HasAttributes::::get_attribute_listClass::MOP::Mixin::HasAttributes::get_attribute_list
11116µs16µsClass::MOP::Mixin::HasAttributes::::BEGIN@2Class::MOP::Mixin::HasAttributes::BEGIN@2
1119µs14µsClass::MOP::Mixin::HasAttributes::::BEGIN@10Class::MOP::Mixin::HasAttributes::BEGIN@10
1119µs35µsClass::MOP::Mixin::HasAttributes::::BEGIN@13Class::MOP::Mixin::HasAttributes::BEGIN@13
1119µs39µsClass::MOP::Mixin::HasAttributes::::BEGIN@12Class::MOP::Mixin::HasAttributes::BEGIN@12
1119µs25µsClass::MOP::Mixin::HasAttributes::::BEGIN@9Class::MOP::Mixin::HasAttributes::BEGIN@9
1118µs87µsClass::MOP::Mixin::HasAttributes::::BEGIN@15Class::MOP::Mixin::HasAttributes::BEGIN@15
0000s0sClass::MOP::Mixin::HasAttributes::::_restore_metaattributes_fromClass::MOP::Mixin::HasAttributes::_restore_metaattributes_from
0000s0sClass::MOP::Mixin::HasAttributes::::remove_attributeClass::MOP::Mixin::HasAttributes::remove_attribute
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Class::MOP::Mixin::HasAttributes;
2
# spent 16µs within Class::MOP::Mixin::HasAttributes::BEGIN@2 which was called: # once (16µs+0s) by Class::MOP::BEGIN@24 at line 4
BEGIN {
317µs $Class::MOP::Mixin::HasAttributes::AUTHORITY = 'cpan:STEVAN';
4145µs116µs}
# spent 16µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@2
5{
621µs $Class::MOP::Mixin::HasAttributes::VERSION = '2.1005';
7}
8
9231µs241µs
# spent 25µs (9+16) within Class::MOP::Mixin::HasAttributes::BEGIN@9 which was called: # once (9µs+16µs) by Class::MOP::BEGIN@24 at line 9
use strict;
# spent 25µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@9 # spent 16µs making 1 call to strict::import
10231µs218µs
# spent 14µs (9+5) within Class::MOP::Mixin::HasAttributes::BEGIN@10 which was called: # once (9µs+5µs) by Class::MOP::BEGIN@24 at line 10
use warnings;
# spent 14µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@10 # spent 5µs making 1 call to warnings::import
11
12233µs269µs
# spent 39µs (9+30) within Class::MOP::Mixin::HasAttributes::BEGIN@12 which was called: # once (9µs+30µs) by Class::MOP::BEGIN@24 at line 12
use Carp 'confess';
# spent 39µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@12 # spent 30µs making 1 call to Exporter::import
13233µs262µs
# spent 35µs (9+26) within Class::MOP::Mixin::HasAttributes::BEGIN@13 which was called: # once (9µs+26µs) by Class::MOP::BEGIN@24 at line 13
use Scalar::Util 'blessed';
# spent 35µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@13 # spent 26µs making 1 call to Exporter::import
14
152520µs2165µs
# spent 87µs (8+78) within Class::MOP::Mixin::HasAttributes::BEGIN@15 which was called: # once (8µs+78µs) by Class::MOP::BEGIN@24 at line 15
use base 'Class::MOP::Mixin';
# spent 87µs making 1 call to Class::MOP::Mixin::HasAttributes::BEGIN@15 # spent 78µs making 1 call to base::import
16
17
# spent 92.7ms (9.23+83.5) within Class::MOP::Mixin::HasAttributes::add_attribute which was called 124 times, avg 748µs/call: # 3 times (107µs+1.04ms) by Moose::BEGIN@35 at line 309 of Moose/Meta/Role.pm, avg 381µs/call # 2 times (71µs+703µs) by Moose::BEGIN@35 at line 92 of Moose/Meta/Role.pm, avg 387µs/call # once (51µs+8.25ms) by Moose::Meta::Class::add_attribute at line 580 of Moose/Meta/Class.pm # once (38µs+7.76ms) by Moose::BEGIN@29 at line 23 of Moose/Meta/TypeCoercion.pm # once (33µs+6.57ms) by Moose::Exporter::BEGIN@13 at line 250 of Class/MOP.pm # once (42µs+5.52ms) by Moose::Util::TypeConstraints::BEGIN@38 at line 23 of Moose/Meta/TypeConstraint/Enum.pm # once (34µs+5.31ms) by base::import at line 35 of Moose/Meta/Mixin/AttributeCore.pm # once (4.94ms+360µs) by Moose::BEGIN@28 at line 102 of Moose/Meta/TypeConstraint.pm # once (30µs+5.18ms) by Moose::Exporter::BEGIN@13 at line 497 of Class/MOP.pm # once (76µs+944µs) by Moose::Exporter::BEGIN@13 at line 133 of Class/MOP.pm # once (37µs+804µs) by Moose::Util::TypeConstraints::BEGIN@42 at line 18 of Moose/Meta/TypeConstraint/Registry.pm # once (35µs+767µs) by base::import at line 92 of Moose/Meta/Mixin/AttributeCore.pm # once (29µs+650µs) by Moose::Exporter::BEGIN@13 at line 518 of Class/MOP.pm # once (36µs+580µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 19 of Moose/Meta/TypeConstraint/Parameterized.pm # once (36µs+577µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 19 of Moose/Meta/TypeConstraint/Parameterizable.pm # once (36µs+575µs) by Moose::BEGIN@28 at line 78 of Moose/Meta/TypeConstraint.pm # once (35µs+574µs) by Moose::BEGIN@28 at line 43 of Moose/Meta/TypeConstraint.pm # once (36µs+572µs) by Moose::Exporter::BEGIN@13 at line 449 of Class/MOP.pm # once (40µs+562µs) by Moose::Meta::TypeCoercion::BEGIN@14 at line 31 of Moose/Meta/Attribute.pm # once (36µs+565µs) by base::import at line 101 of Moose/Meta/Mixin/AttributeCore.pm # once (34µs+566µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 25 of Moose/Meta/TypeConstraint/Parameterizable.pm # once (35µs+562µs) by Moose::BEGIN@28 at line 46 of Moose/Meta/TypeConstraint.pm # once (35µs+562µs) by Moose::BEGIN@28 at line 84 of Moose/Meta/TypeConstraint.pm # once (36µs+557µs) by Moose::BEGIN@28 at line 91 of Moose/Meta/TypeConstraint.pm # once (36µs+557µs) by base::import at line 76 of Moose/Meta/Mixin/AttributeCore.pm # once (35µs+557µs) by Moose::BEGIN@28 at line 32 of Moose/Meta/TypeConstraint.pm # once (35µs+554µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 25 of Moose/Meta/TypeConstraint/Parameterized.pm # once (36µs+551µs) by Moose::BEGIN@28 at line 112 of Moose/Meta/TypeConstraint.pm # once (34µs+545µs) by base::import at line 84 of Moose/Meta/Mixin/AttributeCore.pm # once (51µs+468µs) by Moose::BEGIN@27 at line 38 of Moose/Meta/Class.pm # once (43µs+439µs) by base::import at line 14 of Moose/Meta/Mixin/AttributeCore.pm # once (37µs+430µs) by Moose::Exporter::BEGIN@13 at line 417 of Class/MOP.pm # once (34µs+419µs) by Moose::Exporter::BEGIN@13 at line 409 of Class/MOP.pm # once (35µs+412µs) by Moose::Exporter::BEGIN@13 at line 378 of Class/MOP.pm # once (36µs+406µs) by Moose::Exporter::BEGIN@13 at line 425 of Class/MOP.pm # once (36µs+406µs) by Moose::Exporter::BEGIN@13 at line 370 of Class/MOP.pm # once (36µs+400µs) by Moose::Exporter::BEGIN@13 at line 433 of Class/MOP.pm # once (38µs+392µs) by Moose::Util::TypeConstraints::BEGIN@33 at line 24 of Moose/Meta/TypeConstraint/Union.pm # once (36µs+392µs) by Moose::Exporter::BEGIN@13 at line 386 of Class/MOP.pm # once (35µs+387µs) by Moose::Exporter::BEGIN@13 at line 401 of Class/MOP.pm # once (30µs+390µs) by Moose::Exporter::BEGIN@13 at line 543 of Class/MOP.pm # once (30µs+387µs) by Moose::Exporter::BEGIN@13 at line 562 of Class/MOP.pm # once (35µs+381µs) by Moose::BEGIN@38 at line 22 of Moose/Meta/Role/Application/RoleSummation.pm # once (30µs+380µs) by Moose::Exporter::BEGIN@13 at line 504 of Class/MOP.pm # once (29µs+374µs) by Moose::Exporter::BEGIN@13 at line 551 of Class/MOP.pm # once (35µs+366µs) by Moose::BEGIN@29 at line 32 of Moose/Meta/TypeCoercion.pm # once (36µs+364µs) by Moose::BEGIN@41 at line 21 of Moose/Meta/Role/Application/ToInstance.pm # once (37µs+362µs) by Moose::Meta::Role::BEGIN@19 at line 18 of Moose/Meta/Role/Attribute.pm # once (36µs+362µs) by Moose::Util::TypeConstraints::BEGIN@37 at line 19 of Moose/Meta/TypeConstraint/Role.pm # once (30µs+368µs) by Moose::Exporter::BEGIN@13 at line 597 of Class/MOP.pm # once (36µs+362µs) by Moose::Util::TypeConstraints::BEGIN@36 at line 19 of Moose/Meta/TypeConstraint/Class.pm # once (36µs+360µs) by Moose::BEGIN@37 at line 17 of Moose/Meta/Role/Application.pm # once (29µs+368µs) by Moose::Exporter::BEGIN@13 at line 511 of Class/MOP.pm # once (36µs+360µs) by Moose::BEGIN@28 at line 28 of Moose/Meta/TypeConstraint.pm # once (37µs+359µs) by Moose::Util::TypeConstraints::BEGIN@38 at line 18 of Moose/Meta/TypeConstraint/Enum.pm # once (35µs+361µs) by Moose::Meta::Role::BEGIN@21 at line 22 of Moose/Meta/Role/Method/Required.pm # once (37µs+357µs) by Moose::Util::TypeConstraints::BEGIN@39 at line 22 of Moose/Meta/TypeConstraint/DuckType.pm # once (36µs+357µs) by Moose::Exporter::BEGIN@13 at line 287 of Class/MOP.pm # once (36µs+356µs) by Moose::BEGIN@29 at line 20 of Moose/Meta/TypeCoercion.pm # once (35µs+357µs) by Moose::BEGIN@36 at line 37 of Moose/Meta/Role/Composite.pm # once (36µs+355µs) by Moose::Meta::Role::BEGIN@22 at line 17 of Moose/Meta/Role/Method/Conflicting.pm # once (29µs+361µs) by Moose::Exporter::BEGIN@13 at line 581 of Class/MOP.pm # once (37µs+353µs) by Moose::BEGIN@36 at line 24 of Moose/Meta/Role/Composite.pm # once (34µs+354µs) by Moose::Util::TypeConstraints::BEGIN@42 at line 28 of Moose/Meta/TypeConstraint/Registry.pm # once (34µs+353µs) by Moose::BEGIN@37 at line 24 of Moose/Meta/Role/Application.pm # once (35µs+352µs) by Moose::BEGIN@35 at line 355 of Moose/Meta/Role.pm # once (36µs+350µs) by Moose::BEGIN@36 at line 40 of Moose/Meta/Role/Composite.pm # once (35µs+350µs) by Moose::BEGIN@39 at line 19 of Moose/Meta/Role/Application/ToClass.pm # once (34µs+348µs) by Moose::BEGIN@35 at line 155 of Moose/Meta/Role.pm # once (34µs+348µs) by Moose::BEGIN@35 at line 134 of Moose/Meta/Role.pm # once (38µs+342µs) by Moose::BEGIN@35 at line 128 of Moose/Meta/Role.pm # once (38µs+342µs) by Moose::BEGIN@27 at line 61 of Moose/Meta/Class.pm # once (35µs+345µs) by base::import at line 42 of Moose/Meta/Mixin/AttributeCore.pm # once (34µs+346µs) by Moose::Meta::Role::BEGIN@19 at line 25 of Moose/Meta/Role/Attribute.pm # once (34µs+345µs) by base::import at line 21 of Moose/Meta/Mixin/AttributeCore.pm # once (35µs+343µs) by base::import at line 48 of Moose/Meta/Mixin/AttributeCore.pm # once (34µs+344µs) by Moose::BEGIN@35 at line 169 of Moose/Meta/Role.pm # once (35µs+341µs) by Moose::BEGIN@27 at line 55 of Moose/Meta/Class.pm # once (35µs+341µs) by base::import at line 69 of Moose/Meta/Mixin/AttributeCore.pm # once (34µs+341µs) by Moose::BEGIN@39 at line 24 of Moose/Meta/Role/Application/ToClass.pm # once (34µs+341µs) by Moose::Meta::Role::BEGIN@19 at line 46 of Moose/Meta/Role/Attribute.pm # once (35µs+339µs) by base::import at line 62 of Moose/Meta/Mixin/AttributeCore.pm # once (35µs+339µs) by Moose::BEGIN@27 at line 44 of Moose/Meta/Class.pm # once (34µs+339µs) by Moose::Meta::Role::BEGIN@19 at line 32 of Moose/Meta/Role/Attribute.pm # once (34µs+338µs) by Moose::Meta::Role::BEGIN@19 at line 39 of Moose/Meta/Role/Attribute.pm # once (36µs+337µs) by Moose::BEGIN@28 at line 118 of Moose/Meta/TypeConstraint.pm # once (35µs+335µs) by Moose::BEGIN@28 at line 52 of Moose/Meta/TypeConstraint.pm # once (35µs+335µs) by base::import at line 55 of Moose/Meta/Mixin/AttributeCore.pm # once (34µs+335µs) by Moose::BEGIN@35 at line 141 of Moose/Meta/Role.pm # once (34µs+331µs) by Moose::BEGIN@27 at line 67 of Moose/Meta/Class.pm # once (35µs+328µs) by Moose::BEGIN@35 at line 162 of Moose/Meta/Role.pm # once (29µs+335µs) by Moose::BEGIN@27 at line 47 of Moose/Meta/Class.pm # once (34µs+330µs) by Moose::BEGIN@35 at line 401 of Moose/Meta/Role.pm # once (34µs+327µs) by Moose::BEGIN@35 at line 148 of Moose/Meta/Role.pm # once (34µs+323µs) by base::import at line 28 of Moose/Meta/Mixin/AttributeCore.pm # once (30µs+308µs) by Moose::Exporter::BEGIN@13 at line 618 of Class/MOP.pm # once (34µs+301µs) by Moose::Exporter::BEGIN@13 at line 460 of Class/MOP.pm # once (33µs+293µs) by Moose::Exporter::BEGIN@13 at line 198 of Class/MOP.pm # once (29µs+289µs) by Moose::Exporter::BEGIN@13 at line 642 of Class/MOP.pm # once (42µs+272µs) by Moose::Exporter::BEGIN@13 at line 150 of Class/MOP.pm # once (33µs+279µs) by Moose::Exporter::BEGIN@13 at line 178 of Class/MOP.pm # once (41µs+270µs) by Moose::Exporter::BEGIN@13 at line 137 of Class/MOP.pm # once (36µs+274µs) by Moose::Exporter::BEGIN@13 at line 223 of Class/MOP.pm # once (36µs+273µs) by Moose::Exporter::BEGIN@13 at line 182 of Class/MOP.pm # once (29µs+278µs) by Moose::Exporter::BEGIN@13 at line 649 of Class/MOP.pm # once (36µs+269µs) by Moose::Exporter::BEGIN@13 at line 270 of Class/MOP.pm # once (36µs+268µs) by Moose::Exporter::BEGIN@13 at line 394 of Class/MOP.pm # once (30µs+272µs) by Moose::Exporter::BEGIN@13 at line 355 of Class/MOP.pm # once (30µs+271µs) by Moose::Exporter::BEGIN@13 at line 572 of Class/MOP.pm # once (29µs+268µs) by Moose::Exporter::BEGIN@13 at line 490 of Class/MOP.pm # once (35µs+254µs) by Moose::Exporter::BEGIN@13 at line 441 of Class/MOP.pm # once (30µs+259µs) by Moose::Exporter::BEGIN@13 at line 635 of Class/MOP.pm # once (29µs+258µs) by Moose::Exporter::BEGIN@13 at line 327 of Class/MOP.pm # once (28µs+257µs) by Moose::Exporter::BEGIN@13 at line 307 of Class/MOP.pm # once (29µs+249µs) by Moose::Exporter::BEGIN@13 at line 625 of Class/MOP.pm # once (29µs+249µs) by Moose::Exporter::BEGIN@13 at line 291 of Class/MOP.pm # once (29µs+246µs) by Moose::Exporter::BEGIN@13 at line 338 of Class/MOP.pm # once (29µs+244µs) by Moose::Exporter::BEGIN@13 at line 479 of Class/MOP.pm # once (28µs+245µs) by Moose::Exporter::BEGIN@13 at line 317 of Class/MOP.pm # once (29µs+239µs) by Moose::Exporter::BEGIN@13 at line 601 of Class/MOP.pm # once (29µs+95µs) by Moose::Exporter::BEGIN@13 at line 534 of Class/MOP.pm
sub add_attribute {
1812428µs my $self = shift;
19
20124835µs2722.06ms my $attribute
# spent 1.91ms making 74 calls to Class::MOP::Attribute::new, avg 26µs/call # spent 91µs making 124 calls to Scalar::Util::blessed, avg 732ns/call # spent 60µs making 74 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 812ns/call
21 = blessed( $_[0] ) ? $_[0] : $self->attribute_metaclass->new(@_);
22
23124448µs124137µs ( $attribute->isa('Class::MOP::Mixin::AttributeCore') )
# spent 137µs making 124 calls to UNIVERSAL::isa, avg 1µs/call
24 || confess
25 "Your attribute must be an instance of Class::MOP::Mixin::AttributeCore (or a subclass)";
26
27124146µs1241.64ms $self->_attach_attribute($attribute);
# spent 1.64ms making 124 calls to Class::MOP::Class::_attach_attribute, avg 13µs/call
28
291245.29ms124101µs my $attr_name = $attribute->name;
# spent 101µs making 124 calls to Class::MOP::Mixin::AttributeCore::name, avg 818ns/call
30
31124192µs124606µs $self->remove_attribute($attr_name)
# spent 606µs making 124 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 5µs/call
32 if $self->has_attribute($attr_name);
33
34124342µs12462µs my $order = ( scalar keys %{ $self->_attribute_map } );
# spent 62µs making 124 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 496ns/call
35124159µs124182µs $attribute->_set_insertion_order($order);
# spent 182µs making 124 calls to Class::MOP::Mixin::AttributeCore::_set_insertion_order, avg 1µs/call
36
37124351µs12463µs $self->_attribute_map->{$attr_name} = $attribute;
# spent 63µs making 124 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 510ns/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!
441241.15ms24878.6ms $self->_post_add_attribute($attribute)
# spent 78.5ms making 124 calls to Class::MOP::Class::_post_add_attribute, avg 633µs/call # spent 135µs making 124 calls to UNIVERSAL::can, avg 1µs/call
45 if $self->can('_post_add_attribute');
46
47124610µs return $attribute;
48}
49
50
# spent 884µs (769+115) within Class::MOP::Mixin::HasAttributes::has_attribute which was called 178 times, avg 5µs/call: # 124 times (529µs+77µs) by Class::MOP::Mixin::HasAttributes::add_attribute at line 31, avg 5µs/call # 54 times (240µs+38µs) by Class::MOP::Class::find_attribute_by_name at line 919 of Class/MOP/Class.pm, avg 5µs/call
sub has_attribute {
5117851µs my ( $self, $attribute_name ) = @_;
52
5317824µs ( defined $attribute_name )
54 || confess "You must define an attribute name";
55
56178897µs178115µs exists $self->_attribute_map->{$attribute_name};
# spent 115µs making 178 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 644ns/call
57}
58
59
# spent 4.89ms (4.82+73µs) within Class::MOP::Mixin::HasAttributes::get_attribute which was called 130 times, avg 38µs/call: # 76 times (348µs+46µs) by Class::MOP::Class::_inline_accessors at line 1413 of Class/MOP/Class.pm, avg 5µs/call # 54 times (4.47ms+27µs) by Class::MOP::Class::find_attribute_by_name at line 919 of Class/MOP/Class.pm, avg 83µs/call
sub get_attribute {
6013055µs my ( $self, $attribute_name ) = @_;
61
6213021µs ( defined $attribute_name )
63 || confess "You must define an attribute name";
64
651304.90ms13073µs return $self->_attribute_map->{$attribute_name};
# spent 73µs making 130 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 559ns/call
66}
67
68sub 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 188µs (164+23) within Class::MOP::Mixin::HasAttributes::get_attribute_list which was called 33 times, avg 6µs/call: # 33 times (164µs+23µs) by Class::MOP::Class::_inline_accessors at line 1412 of Class/MOP/Class.pm, avg 6µs/call
sub get_attribute_list {
83334µs my $self = shift;
8433207µs3323µs keys %{ $self->_attribute_map };
# spent 23µs making 33 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 709ns/call
85}
86
87sub _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
9914µs1;
100
101# ABSTRACT: Methods for metaclasses which have attributes
102
103__END__