← Index
Performance Profile   « block view • line view • sub view »
For t/test-parsing
  Run on Sun Nov 14 09:49:57 2010
Reported on Sun Nov 14 09:50:11 2010

File /usr/local/lib/perl/5.10.0/Class/MOP/Mixin/HasAttributes.pm
Statements Executed 3630
Total Time 0.0119933 seconds
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
123113233.43ms79.3msClass::MOP::Mixin::HasAttributes::::add_attributeClass::MOP::Mixin::HasAttributes::add_attribute
181221.28ms2.06msClass::MOP::Mixin::HasAttributes::::has_attributeClass::MOP::Mixin::HasAttributes::has_attribute
126211.03ms1.52msClass::MOP::Mixin::HasAttributes::::get_attributeClass::MOP::Mixin::HasAttributes::get_attribute
3211196µs391µsClass::MOP::Mixin::HasAttributes::::get_attribute_listClass::MOP::Mixin::HasAttributes::get_attribute_list
0000s0sClass::MOP::Mixin::HasAttributes::::BEGINClass::MOP::Mixin::HasAttributes::BEGIN
0000s0sClass::MOP::Mixin::HasAttributes::::_restore_metaattributes_fromClass::MOP::Mixin::HasAttributes::_restore_metaattributes_from
0000s0sClass::MOP::Mixin::HasAttributes::::remove_attributeClass::MOP::Mixin::HasAttributes::remove_attribute
LineStmts.Exclusive
Time
Avg.Code
1package Class::MOP::Mixin::HasAttributes;
2
3329µs10µsuse strict;
# spent 9µs making 1 call to strict::import
4357µs19µsuse warnings;
# spent 17µs making 1 call to warnings::import
5
61700ns700nsour $VERSION = '1.09';
7129µs29µs$VERSION = eval $VERSION;
81500ns500nsour $AUTHORITY = 'cpan:STEVAN';
9
10326µs9µsuse Carp 'confess';
# spent 50µs making 1 call to Exporter::import
11324µs8µsuse Scalar::Util 'blessed';
# spent 40µs making 1 call to Exporter::import
12
133561µs187µsuse base 'Class::MOP::Mixin';
# spent 71µs making 1 call to base::import
14
1510071.80ms2µssub _attribute_map { $_[0]->{'attributes'} }
16266572µs2µssub attribute_metaclass { $_[0]->{'attribute_metaclass'} }
17
18
# spent 79.3ms (3.43+75.8) within Class::MOP::Mixin::HasAttributes::add_attribute which was called 123 times, avg 644µs/call: # 8 times (237µs+15.4ms) by Moose::Meta::Class::add_attribute at line 298 of /usr/local/lib/perl/5.10.0/Moose/Meta/Class.pm, avg 1.95ms/call # 3 times (88µs+1.55ms) at line 280 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role.pm, avg 544µs/call # 2 times (68µs+1.06ms) at line 90 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role.pm, avg 563µs/call # once (46µs+3.68ms) at line 20 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeCoercion.pm # once (34µs+1.67ms) at line 43 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint.pm # once (27µs+1.13ms) at line 16 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint/Registry.pm # once (23µs+991µs) at line 35 of /usr/local/lib/perl/5.10.0/Moose/Meta/Mixin/AttributeCore.pm # once (37µs+898µs) at line 36 of /usr/local/lib/perl/5.10.0/Moose/Meta/Class.pm # once (36µs+868µs) at line 17 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint/Parameterized.pm # once (32µs+872µs) at line 15 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint/Parameterizable.pm # once (40µs+791µs) at line 192 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (28µs+785µs) at line 26 of /usr/local/lib/perl/5.10.0/Moose/Meta/Attribute.pm # once (25µs+774µs) at line 20 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Method/Required.pm # once (29µs+768µs) at line 23 of /usr/local/lib/perl/5.10.0/Moose/Meta/Mixin/AttributeCore.pm # once (34µs+761µs) at line 23 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint.pm # once (33µs+758µs) at line 33 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint.pm # once (30µs+744µs) at line 22 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint.pm # once (33µs+709µs) at line 56 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint.pm # once (28µs+707µs) at line 38 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint.pm # once (24µs+698µs) at line 42 of /usr/local/lib/perl/5.10.0/Moose/Meta/Mixin/AttributeCore.pm # once (28µs+684µs) at line 29 of /usr/local/lib/perl/5.10.0/Moose/Meta/Mixin/AttributeCore.pm # once (32µs+680µs) at line 34 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint.pm # once (36µs+617µs) at line 18 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeCoercion.pm # once (18µs+631µs) at line 482 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (44µs+594µs) at line 20 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Application/RoleSummation.pm # once (27µs+603µs) at line 15 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint/Enum.pm # once (49µs+571µs) at line 16 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint/Class.pm # once (31µs+576µs) at line 15 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Attribute.pm # once (28µs+575µs) at line 21 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Composite.pm # once (42µs+558µs) at line 16 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Application/ToClass.pm # once (40µs+559µs) at line 15 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Application.pm # once (34µs+563µs) at line 21 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint/Union.pm # once (33µs+559µs) at line 15 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Method/Conflicting.pm # once (32µs+555µs) at line 18 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Application/ToInstance.pm # once (40µs+547µs) at line 125 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role.pm # once (36µs+549µs) at line 41 of /usr/local/lib/perl/5.10.0/Moose/Meta/Class.pm # once (36µs+547µs) at line 28 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeCoercion.pm # once (36µs+546µs) at line 16 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint/Role.pm # once (32µs+548µs) at line 11 of /usr/local/lib/perl/5.10.0/Moose/Meta/Mixin/AttributeCore.pm # once (24µs+552µs) at line 25 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint/Registry.pm # once (31µs+544µs) at line 21 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Attribute.pm # once (28µs+546µs) at line 19 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint/DuckType.pm # once (30µs+536µs) at line 12 of /usr/local/lib/perl/5.10.0/Moose/Meta/Mixin/AttributeCore.pm # once (35µs+524µs) at line 325 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role.pm # once (31µs+509µs) at line 20 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Application/ToClass.pm # once (40µs+494µs) at line 130 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role.pm # once (28µs+497µs) at line 21 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Application.pm # once (36µs+489µs) at line 13 of /usr/local/lib/perl/5.10.0/Moose/Meta/Mixin/AttributeCore.pm # once (19µs+501µs) at line 440 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (24µs+494µs) at line 43 of /usr/local/lib/perl/5.10.0/Moose/Meta/Class.pm # once (42µs+473µs) at line 27 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Attribute.pm # once (18µs+496µs) at line 413 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (36µs+474µs) at line 31 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Composite.pm # once (29µs+476µs) at line 16 of /usr/local/lib/perl/5.10.0/Moose/Meta/Mixin/AttributeCore.pm # once (31µs+472µs) at line 33 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Attribute.pm # once (36µs+467µs) at line 20 of /usr/local/lib/perl/5.10.0/Moose/Meta/Mixin/AttributeCore.pm # once (48µs+454µs) at line 454 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (34µs+464µs) at line 15 of /usr/local/lib/perl/5.10.0/Moose/Meta/Mixin/AttributeCore.pm # once (23µs+476µs) at line 377 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role.pm # once (22µs+474µs) at line 21 of /usr/local/lib/perl/5.10.0/Moose/Meta/Mixin/AttributeCore.pm # once (23µs+472µs) at line 50 of /usr/local/lib/perl/5.10.0/Moose/Meta/Class.pm # once (23µs+470µs) at line 420 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (27µs+465µs) at line 136 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role.pm # once (36µs+455µs) at line 17 of /usr/local/lib/perl/5.10.0/Moose/Meta/Mixin/AttributeCore.pm # once (19µs+469µs) at line 447 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (23µs+460µs) at line 60 of /usr/local/lib/perl/5.10.0/Moose/Meta/Class.pm # once (23µs+460µs) at line 33 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role/Composite.pm # once (18µs+461µs) at line 427 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (33µs+441µs) at line 19 of /usr/local/lib/perl/5.10.0/Moose/Meta/Mixin/AttributeCore.pm # once (18µs+451µs) at line 544 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (18µs+450µs) at line 468 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (28µs+439µs) at line 148 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role.pm # once (24µs+441µs) at line 154 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role.pm # once (33µs+429µs) at line 142 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role.pm # once (24µs+435µs) at line 55 of /usr/local/lib/perl/5.10.0/Moose/Meta/Class.pm # once (18µs+434µs) at line 461 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (29µs+416µs) at line 60 of /usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint.pm # once (24µs+385µs) at line 195 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (24µs+356µs) at line 276 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (30µs+339µs) at line 302 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (30µs+338µs) at line 207 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (20µs+345µs) at line 615 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (20µs+340µs) at line 566 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (28µs+330µs) at line 252 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (24µs+334µs) at line 337 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (20µs+335µs) at line 234 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (25µs+328µs) at line 399 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (23µs+326µs) at line 364 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (20µs+326µs) at line 492 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (19µs+326µs) at line 583 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (19µs+324µs) at line 634 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (20µs+323µs) at line 373 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (18µs+323µs) at line 321 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (23µs+312µs) at line 237 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (28µs+305µs) at line 592 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (24µs+308µs) at line 520 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (18µs+313µs) at line 340 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (18µs+311µs) at line 510 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (18µs+302µs) at line 526 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (27µs+291µs) at line 600 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (18µs+300µs) at line 640 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (19µs+299µs) at line 618 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (18µs+299µs) at line 649 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (18µs+296µs) at line 355 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (18µs+296µs) at line 383 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (18µs+292µs) at line 655 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (28µs+281µs) at line 538 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (18µs+286µs) at line 573 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (19µs+285µs) at line 434 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (18µs+281µs) at line 661 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (18µs+277µs) at line 475 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (18µs+275µs) at line 532 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (25µs+160µs) at line 559 of /usr/local/lib/perl/5.10.0/Class/MOP.pm
sub add_attribute {
1912356µs457ns my $self = shift;
20
211231.07ms9µs my $attribute
# spent 2.88ms making 66 calls to Class::MOP::Attribute::new, avg 44µs/call # spent 310µs making 123 calls to Scalar::Util::blessed, avg 3µs/call # spent 299µs making 66 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call
22 = blessed( $_[0] ) ? $_[0] : $self->attribute_metaclass->new(@_);
23
24123859µs7µs ( $attribute->isa('Class::MOP::Mixin::AttributeCore') )
# spent 710µs making 123 calls to UNIVERSAL::isa, avg 6µs/call
25 || confess
26 "Your attribute must be an instance of Class::MOP::Mixin::AttributeCore (or a subclass)";
27
28123441µs4µs $self->_attach_attribute($attribute);
# spent 2.51ms making 123 calls to Class::MOP::Class::_attach_attribute, avg 20µs/call
29
30123534µs4µs my $attr_name = $attribute->name;
# spent 384µs making 123 calls to Class::MOP::Mixin::AttributeCore::name, avg 3µs/call
31
32123459µs4µs $self->remove_attribute($attr_name)
# spent 1.32ms making 123 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 11µs/call
33 if $self->has_attribute($attr_name);
34
35123542µs4µs my $order = ( scalar keys %{ $self->_attribute_map } );
# spent 413µs making 123 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 3µs/call
36123473µs4µs $attribute->_set_insertion_order($order);
# spent 477µs making 123 calls to Class::MOP::Mixin::AttributeCore::_set_insertion_order, avg 4µs/call
37
38123562µs5µs $self->_attribute_map->{$attr_name} = $attribute;
# spent 393µs making 123 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 3µ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!
451231.37ms11µs $self->_post_add_attribute($attribute)
# spent 65.8ms making 123 calls to Class::MOP::Class::_post_add_attribute, avg 535µs/call # spent 367µs making 123 calls to UNIVERSAL::can, avg 3µs/call
46 if $self->can('_post_add_attribute');
47
48123154µs1µs return $attribute;
49}
50
51
# spent 2.06ms (1.28+786µs) within Class::MOP::Mixin::HasAttributes::has_attribute which was called 181 times, avg 11µs/call: # 123 times (807µs+518µs) by Class::MOP::Mixin::HasAttributes::add_attribute at line 32, avg 11µs/call # 58 times (469µs+267µs) by Class::MOP::Class::find_attribute_by_name at line 795 of /usr/local/lib/perl/5.10.0/Class/MOP/Class.pm, avg 13µs/call
sub has_attribute {
52181245µs1µs my ( $self, $attribute_name ) = @_;
53
5418165µs358ns ( defined $attribute_name )
55 || confess "You must define an attribute name";
56
57181911µs5µs exists $self->_attribute_map->{$attribute_name};
# spent 786µs making 181 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 4µs/call
58}
59
60
# spent 1.52ms (1.03+486µs) within Class::MOP::Mixin::HasAttributes::get_attribute which was called 126 times, avg 12µs/call: # 68 times (622µs+298µs) by Class::MOP::Class::_inline_accessors at line 1273 of /usr/local/lib/perl/5.10.0/Class/MOP/Class.pm, avg 14µs/call # 58 times (409µs+188µs) by Class::MOP::Class::find_attribute_by_name at line 795 of /usr/local/lib/perl/5.10.0/Class/MOP/Class.pm, avg 10µs/call
sub get_attribute {
61126159µs1µs my ( $self, $attribute_name ) = @_;
62
6312645µs360ns ( defined $attribute_name )
64 || confess "You must define an attribute name";
65
66126770µs6µs return $self->_attribute_map->{$attribute_name};
# spent 486µs making 126 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 4µs/call
67}
68
69sub 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 391µs (196+195) within Class::MOP::Mixin::HasAttributes::get_attribute_list which was called 32 times, avg 12µs/call: # 32 times (196µs+195µs) by Class::MOP::Class::_inline_accessors at line 1272 of /usr/local/lib/perl/5.10.0/Class/MOP/Class.pm, avg 12µs/call
sub get_attribute_list {
843214µs450ns my $self = shift;
8532164µs5µs keys %{ $self->_attribute_map };
# spent 195µs making 32 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 6µs/call
86}
87
88sub _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
10014µs4µs1;
101
102__END__
103
104=pod
105
106=head1 NAME
107
108Class::MOP::Mixin::HasMethods - Methods for metaclasses which have attributes
109
110=head1 DESCRIPTION
111
112This class implements methods for metaclasses which have attributes
113(L<Class::MOP::Class> and L<Moose::Meta::Role>). See L<Class::MOP::Class> for
114API details.
115
116=head1 AUTHORS
117
118Dave Rolsky E<lt>autarch@urth.orgE<gt>
119
120=head1 COPYRIGHT AND LICENSE
121
122Copyright 2006-2010 by Infinity Interactive, Inc.
123
124L<http://www.iinteractive.com>
125
126This library is free software; you can redistribute it and/or modify
127it under the same terms as Perl itself.
128
129=cut