| File | /usr/lib/perl5/vendor_perl/5.10.1/i386-linux-thread-multi/Moose/Meta/Role/Attribute.pm |
| Statements Executed | 273 |
| Statement Execution Time | 6.91ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 25 | 2 | 2 | 1.11ms | 1.11ms | Moose::Meta::Role::Attribute::new |
| 25 | 1 | 1 | 1.05ms | 1.43ms | Moose::Meta::Role::Attribute::attach_to_role |
| 17 | 2 | 2 | 801µs | 1.85ms | Moose::Meta::Role::Attribute::clone |
| 12 | 1 | 1 | 699µs | 18.8ms | Moose::Meta::Role::Attribute::attribute_for_class |
| 1 | 1 | 1 | 509µs | 881µs | Moose::Meta::Role::Attribute::is_same_as |
| 1 | 1 | 1 | 39µs | 51µs | Moose::Meta::Role::Attribute::BEGIN@3 |
| 1 | 1 | 1 | 24µs | 70µs | Moose::Meta::Role::Attribute::BEGIN@4 |
| 1 | 1 | 1 | 22µs | 172µs | Moose::Meta::Role::Attribute::BEGIN@8 |
| 1 | 1 | 1 | 22µs | 240µs | Moose::Meta::Role::Attribute::BEGIN@13 |
| 1 | 1 | 1 | 22µs | 112µs | Moose::Meta::Role::Attribute::BEGIN@6 |
| 1 | 1 | 1 | 22µs | 90µs | Moose::Meta::Role::Attribute::BEGIN@7 |
| 2 | 1 | 2 | 22µs | 22µs | Moose::Meta::Role::Attribute::CORE:sort (opcode) |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Attribute::__ANON__[:90] |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moose::Meta::Role::Attribute; | ||||
| 2 | |||||
| 3 | 3 | 128µs | 2 | 64µs | # spent 51µs (39+12) within Moose::Meta::Role::Attribute::BEGIN@3 which was called
# once (39µs+12µs) by Moose::Meta::Role::BEGIN@17 at line 3 # spent 51µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@3
# spent 12µs making 1 call to strict::import |
| 4 | 3 | 62µs | 2 | 117µs | # spent 70µs (24+46) within Moose::Meta::Role::Attribute::BEGIN@4 which was called
# once (24µs+46µs) by Moose::Meta::Role::BEGIN@17 at line 4 # spent 70µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@4
# spent 46µs making 1 call to warnings::import |
| 5 | |||||
| 6 | 3 | 59µs | 2 | 201µs | # spent 112µs (22+90) within Moose::Meta::Role::Attribute::BEGIN@6 which was called
# once (22µs+90µs) by Moose::Meta::Role::BEGIN@17 at line 6 # spent 112µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@6
# spent 90µs making 1 call to Exporter::import |
| 7 | 3 | 61µs | 2 | 158µs | # spent 90µs (22+68) within Moose::Meta::Role::Attribute::BEGIN@7 which was called
# once (22µs+68µs) by Moose::Meta::Role::BEGIN@17 at line 7 # spent 90µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@7
# spent 68µs making 1 call to Exporter::import |
| 8 | 3 | 105µs | 2 | 323µs | # spent 172µs (22+150) within Moose::Meta::Role::Attribute::BEGIN@8 which was called
# once (22µs+150µs) by Moose::Meta::Role::BEGIN@17 at line 8 # spent 172µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@8
# spent 150µs making 1 call to Exporter::import |
| 9 | |||||
| 10 | 1 | 3µs | our $VERSION = '1.01'; | ||
| 11 | 1 | 1µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 12 | |||||
| 13 | 3 | 1.57ms | 2 | 458µs | # spent 240µs (22+218) within Moose::Meta::Role::Attribute::BEGIN@13 which was called
# once (22µs+218µs) by Moose::Meta::Role::BEGIN@17 at line 13 # spent 240µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@13
# spent 218µs making 1 call to base::import |
| 14 | |||||
| 15 | 1 | 33µs | 2 | 1.84ms | __PACKAGE__->meta->add_attribute( # spent 1.56ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 285µs making 1 call to Class::MOP::Mixin::meta |
| 16 | 'metaclass' => ( | ||||
| 17 | reader => 'metaclass', | ||||
| 18 | ) | ||||
| 19 | ); | ||||
| 20 | |||||
| 21 | 1 | 12µs | 2 | 1.44ms | __PACKAGE__->meta->add_attribute( # spent 1.39ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 47µs making 1 call to Class::MOP::Mixin::meta |
| 22 | 'associated_role' => ( | ||||
| 23 | reader => 'associated_role', | ||||
| 24 | ) | ||||
| 25 | ); | ||||
| 26 | |||||
| 27 | 1 | 11µs | 2 | 1.10ms | __PACKAGE__->meta->add_attribute( # spent 1.06ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 46µs making 1 call to Class::MOP::Mixin::meta |
| 28 | 'is' => ( | ||||
| 29 | reader => 'is', | ||||
| 30 | ) | ||||
| 31 | ); | ||||
| 32 | |||||
| 33 | 1 | 7µs | 2 | 815µs | __PACKAGE__->meta->add_attribute( # spent 786µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 29µs making 1 call to Class::MOP::Mixin::meta |
| 34 | 'original_options' => ( | ||||
| 35 | reader => 'original_options', | ||||
| 36 | ) | ||||
| 37 | ); | ||||
| 38 | |||||
| 39 | # spent 1.11ms within Moose::Meta::Role::Attribute::new which was called 25 times, avg 44µs/call:
# 17 times (830µs+0s) by Moose::Meta::Role::Attribute::clone at line 73, avg 49µs/call
# 8 times (281µs+0s) by Class::MOP::Mixin::HasAttributes::add_attribute at line 21 of Class/MOP/Mixin/HasAttributes.pm, avg 35µs/call | ||||
| 40 | 75 | 1.20ms | my ( $class, $name, %options ) = @_; | ||
| 41 | |||||
| 42 | (defined $name) | ||||
| 43 | || confess "You must provide a name for the attribute"; | ||||
| 44 | |||||
| 45 | return bless { | ||||
| 46 | name => $name, | ||||
| 47 | original_options => \%options, | ||||
| 48 | %options, | ||||
| 49 | }, $class; | ||||
| 50 | } | ||||
| 51 | |||||
| 52 | # spent 1.43ms (1.05+380µs) within Moose::Meta::Role::Attribute::attach_to_role which was called 25 times, avg 57µs/call:
# 25 times (1.05ms+380µs) by Moose::Meta::Role::_attach_attribute at line 207 of Moose/Meta/Role.pm, avg 57µs/call | ||||
| 53 | 75 | 1.53ms | my ( $self, $role ) = @_; | ||
| 54 | |||||
| 55 | ( blessed($role) && $role->isa('Moose::Meta::Role') ) # spent 96µs making 25 calls to Scalar::Util::blessed, avg 4µs/call
# spent 96µs making 25 calls to UNIVERSAL::isa, avg 4µs/call | ||||
| 56 | || confess | ||||
| 57 | "You must pass a Moose::Meta::Role instance (or a subclass)"; | ||||
| 58 | |||||
| 59 | weaken( $self->{'associated_role'} = $role ); # spent 188µs making 25 calls to Scalar::Util::weaken, avg 8µs/call | ||||
| 60 | } | ||||
| 61 | |||||
| 62 | # spent 18.8ms (699µs+18.1) within Moose::Meta::Role::Attribute::attribute_for_class which was called 12 times, avg 1.57ms/call:
# 12 times (699µs+18.1ms) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 142 of Moose/Meta/Role/Application/ToClass.pm, avg 1.57ms/call | ||||
| 63 | 36 | 688µs | my $self = shift; | ||
| 64 | my $metaclass = shift; | ||||
| 65 | |||||
| 66 | return $metaclass->interpolate_class_and_new( | ||||
| 67 | $self->name => %{ $self->original_options } ); # spent 18.0ms making 12 calls to Moose::Meta::Attribute::interpolate_class_and_new, avg 1.50ms/call
# spent 112µs making 12 calls to Moose::Meta::Role::Attribute::original_options, avg 9µs/call
# spent 64µs making 12 calls to Class::MOP::Mixin::AttributeCore::name, avg 5µs/call | ||||
| 68 | } | ||||
| 69 | |||||
| 70 | # spent 1.85ms (801µs+1.05) within Moose::Meta::Role::Attribute::clone which was called 17 times, avg 109µs/call:
# 11 times (550µs+521µs) by Moose::Meta::Role::Application::ToRole::apply_attributes at line 65 of Moose/Meta/Role/Application/ToRole.pm, avg 97µs/call
# 6 times (250µs+525µs) by Moose::Meta::Role::Application::RoleSummation::apply_attributes at line 148 of Moose/Meta/Role/Application/RoleSummation.pm, avg 129µs/call | ||||
| 71 | 34 | 806µs | my $self = shift; | ||
| 72 | |||||
| 73 | return ( ref $self )->new( $self->name, %{ $self->original_options } ); # spent 830µs making 17 calls to Moose::Meta::Role::Attribute::new, avg 49µs/call
# spent 144µs making 17 calls to Moose::Meta::Role::Attribute::original_options, avg 8µs/call
# spent 72µs making 17 calls to Class::MOP::Mixin::AttributeCore::name, avg 4µs/call | ||||
| 74 | } | ||||
| 75 | |||||
| 76 | # spent 881µs (509+372) within Moose::Meta::Role::Attribute::is_same_as which was called
# once (509µs+372µs) by Moose::Meta::Role::Application::RoleSummation::apply_attributes at line 131 of Moose/Meta/Role/Application/RoleSummation.pm | ||||
| 77 | 7 | 254µs | my $self = shift; | ||
| 78 | my $attr = shift; | ||||
| 79 | |||||
| 80 | my $self_options = $self->original_options; # spent 9µs making 1 call to Moose::Meta::Role::Attribute::original_options | ||||
| 81 | my $other_options = $attr->original_options; # spent 11µs making 1 call to Moose::Meta::Role::Attribute::original_options | ||||
| 82 | |||||
| 83 | return 0 | ||||
| 84 | unless ( join q{|}, sort keys %{$self_options} ) eq ( join q{|}, sort keys %{$other_options} ); # spent 22µs making 2 calls to Moose::Meta::Role::Attribute::CORE:sort, avg 11µs/call | ||||
| 85 | |||||
| 86 | for my $key ( keys %{$self_options} ) { | ||||
| 87 | 16 | 115µs | return 0 if defined $self_options->{$key} && ! defined $other_options->{$key}; | ||
| 88 | return 0 if ! defined $self_options->{$key} && defined $other_options->{$key}; | ||||
| 89 | |||||
| 90 | 4 | 234µs | 4 | 99µs | next if all { ! defined } $self_options->{$key}, $other_options->{$key}; # spent 99µs making 4 calls to List::MoreUtils::all, avg 25µs/call |
| 91 | |||||
| 92 | 1 | 11µs | 2 | 231µs | return 0 unless $self_options->{$key} eq $other_options->{$key}; # spent 231µs making 2 calls to MooseX::Types::TypeDecorator::__ANON__[MooseX/Types/TypeDecorator.pm:21], avg 116µs/call |
| 93 | } | ||||
| 94 | |||||
| 95 | return 1; | ||||
| 96 | } | ||||
| 97 | |||||
| 98 | 1 | 16µs | 1; | ||
| 99 | |||||
| 100 | =pod | ||||
| 101 | |||||
| 102 | =head1 NAME | ||||
| 103 | |||||
| 104 | Moose::Meta::Role::Attribute - A Moose Attribute metaclass for Roles | ||||
| 105 | |||||
| 106 | =head1 DESCRIPTION | ||||
| 107 | |||||
| 108 | This class implements the API for attributes in roles. Attributes in roles are | ||||
| 109 | more like attribute prototypes than full blown attributes. While they are | ||||
| 110 | introspectable, they have very little behavior. | ||||
| 111 | |||||
| 112 | =head1 METHODS | ||||
| 113 | |||||
| 114 | This class provides the following methods: | ||||
| 115 | |||||
| 116 | =over 4 | ||||
| 117 | |||||
| 118 | =item B<< Moose::Meta::Role::Attribute->new(...) >> | ||||
| 119 | |||||
| 120 | This method accepts all the options that would be passed to the constructor | ||||
| 121 | for L<Moose::Meta::Attribute>. | ||||
| 122 | |||||
| 123 | =item B<< $attr->metaclass >> | ||||
| 124 | |||||
| 125 | =item B<< $attr->is >> | ||||
| 126 | |||||
| 127 | Returns the option as passed to the constructor. | ||||
| 128 | |||||
| 129 | =item B<< $attr->associated_role >> | ||||
| 130 | |||||
| 131 | Returns the L<Moose::Meta::Role> to which this attribute belongs, if any. | ||||
| 132 | |||||
| 133 | =item B<< $attr->original_options >> | ||||
| 134 | |||||
| 135 | Returns a hash reference of options passed to the constructor. This is used | ||||
| 136 | when creating a L<Moose::Meta::Attribute> object from this object. | ||||
| 137 | |||||
| 138 | =item B<< $attr->attach_to_role($role) >> | ||||
| 139 | |||||
| 140 | Attaches the attribute to the given L<Moose::Meta::Role>. | ||||
| 141 | |||||
| 142 | =item B<< $attr->attribute_for_class($metaclass) >> | ||||
| 143 | |||||
| 144 | Given an attribute metaclass name, this method calls C<< | ||||
| 145 | $metaclass->interpolate_class_and_new >> to construct an attribute object | ||||
| 146 | which can be added to a L<Moose::Meta::Class>. | ||||
| 147 | |||||
| 148 | =item B<< $attr->clone >> | ||||
| 149 | |||||
| 150 | Creates a new object identical to the object on which the method is called. | ||||
| 151 | |||||
| 152 | =item B<< $attr->is_same_as($other_attr) >> | ||||
| 153 | |||||
| 154 | Compares two role attributes and returns true if they are identical. | ||||
| 155 | |||||
| 156 | =back | ||||
| 157 | |||||
| 158 | In addition, this class implements all informational predicates implements by | ||||
| 159 | L<Moose::Meta::Attribute> (and L<Class::MOP::Attribute>). | ||||
| 160 | |||||
| 161 | =head1 BUGS | ||||
| 162 | |||||
| 163 | See L<Moose/BUGS> for details on reporting bugs. | ||||
| 164 | |||||
| 165 | =head1 AUTHOR | ||||
| 166 | |||||
| 167 | Dave Rolsky E<lt>autarch@urth.orgE<gt> | ||||
| 168 | |||||
| 169 | =head1 COPYRIGHT AND LICENSE | ||||
| 170 | |||||
| 171 | Copyright 2006-2010 by Infinity Interactive, Inc. | ||||
| 172 | |||||
| 173 | L<http://www.iinteractive.com> | ||||
| 174 | |||||
| 175 | This library is free software; you can redistribute it and/or modify | ||||
| 176 | it under the same terms as Perl itself. | ||||
| 177 | |||||
| 178 | =cut | ||||
# spent 22µs within Moose::Meta::Role::Attribute::CORE:sort which was called 2 times, avg 11µs/call:
# 2 times (22µs+0s) by Moose::Meta::Role::Attribute::is_same_as at line 84 of Moose/Meta/Role/Attribute.pm, avg 11µs/call |