Filename | /Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Meta/Role/Attribute.pm |
Statements | Executed 196 statements in 1.26ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
17 | 1 | 1 | 294µs | 7.33ms | attribute_for_class | Moose::Meta::Role::Attribute::
13 | 1 | 1 | 122µs | 122µs | new | Moose::Meta::Role::Attribute::
17 | 1 | 1 | 117µs | 196µs | original_role | Moose::Meta::Role::Attribute::
13 | 1 | 1 | 92µs | 119µs | attach_to_role | Moose::Meta::Role::Attribute::
1 | 1 | 1 | 19µs | 65µs | BEGIN@7 | Moose::Meta::Role::Attribute::
1 | 1 | 1 | 13µs | 25µs | BEGIN@4 | Moose::Meta::Role::Attribute::
1 | 1 | 1 | 10µs | 57µs | BEGIN@10 | Moose::Meta::Role::Attribute::
1 | 1 | 1 | 9µs | 201µs | BEGIN@12 | Moose::Meta::Role::Attribute::
1 | 1 | 1 | 8µs | 32µs | BEGIN@8 | Moose::Meta::Role::Attribute::
1 | 1 | 1 | 8µs | 12µs | BEGIN@5 | Moose::Meta::Role::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:119] | Moose::Meta::Role::Attribute::
0 | 0 | 0 | 0s | 0s | clone | Moose::Meta::Role::Attribute::
0 | 0 | 0 | 0s | 0s | is_same_as | Moose::Meta::Role::Attribute::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moose::Meta::Role::Attribute; | ||||
2 | 1 | 600ns | our $VERSION = '2.1403'; | ||
3 | |||||
4 | 2 | 28µs | 2 | 38µs | # spent 25µs (13+13) within Moose::Meta::Role::Attribute::BEGIN@4 which was called:
# once (13µs+13µs) by Moose::Meta::Role::BEGIN@11 at line 4 # spent 25µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@4
# spent 13µs making 1 call to strict::import |
5 | 2 | 28µs | 2 | 17µs | # spent 12µs (8+4) within Moose::Meta::Role::Attribute::BEGIN@5 which was called:
# once (8µs+4µs) by Moose::Meta::Role::BEGIN@11 at line 5 # spent 12µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@5
# spent 4µs making 1 call to warnings::import |
6 | |||||
7 | 3 | 50µs | 3 | 90µs | # spent 65µs (19+46) within Moose::Meta::Role::Attribute::BEGIN@7 which was called:
# once (19µs+46µs) by Moose::Meta::Role::BEGIN@11 at line 7 # spent 65µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@7
# spent 14µs making 1 call to UNIVERSAL::VERSION
# spent 11µs making 1 call to List::Util::import |
8 | 2 | 24µs | 2 | 56µs | # spent 32µs (8+24) within Moose::Meta::Role::Attribute::BEGIN@8 which was called:
# once (8µs+24µs) by Moose::Meta::Role::BEGIN@11 at line 8 # spent 32µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@8
# spent 24µs making 1 call to Exporter::import |
9 | |||||
10 | 2 | 27µs | 2 | 104µs | # spent 57µs (10+47) within Moose::Meta::Role::Attribute::BEGIN@10 which was called:
# once (10µs+47µs) by Moose::Meta::Role::BEGIN@11 at line 10 # spent 57µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@10
# spent 47µs making 1 call to parent::import |
11 | |||||
12 | 2 | 460µs | 2 | 394µs | # spent 201µs (9+193) within Moose::Meta::Role::Attribute::BEGIN@12 which was called:
# once (9µs+193µs) by Moose::Meta::Role::BEGIN@11 at line 12 # spent 201µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@12
# spent 192µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
13 | |||||
14 | 1 | 11µs | 3 | 931µs | __PACKAGE__->meta->add_attribute( # spent 487µs making 1 call to Class::MOP::Mixin::meta
# spent 436µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 8µs making 1 call to Class::MOP::_definition_context |
15 | 'metaclass' => ( | ||||
16 | reader => 'metaclass', | ||||
17 | Class::MOP::_definition_context(), | ||||
18 | ) | ||||
19 | ); | ||||
20 | |||||
21 | 1 | 4µs | 3 | 309µs | __PACKAGE__->meta->add_attribute( # spent 293µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 11µs making 1 call to Class::MOP::Mixin::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
22 | 'associated_role' => ( | ||||
23 | reader => 'associated_role', | ||||
24 | Class::MOP::_definition_context(), | ||||
25 | ) | ||||
26 | ); | ||||
27 | |||||
28 | 1 | 4µs | 3 | 304µs | __PACKAGE__->meta->add_attribute( # spent 288µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 10µs making 1 call to Class::MOP::Mixin::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
29 | '_original_role' => ( | ||||
30 | reader => '_original_role', | ||||
31 | Class::MOP::_definition_context(), | ||||
32 | ) | ||||
33 | ); | ||||
34 | |||||
35 | 1 | 4µs | 3 | 313µs | __PACKAGE__->meta->add_attribute( # spent 298µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 10µs making 1 call to Class::MOP::Mixin::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
36 | 'is' => ( | ||||
37 | reader => 'is', | ||||
38 | Class::MOP::_definition_context(), | ||||
39 | ) | ||||
40 | ); | ||||
41 | |||||
42 | 1 | 4µs | 3 | 298µs | __PACKAGE__->meta->add_attribute( # spent 283µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 10µs making 1 call to Class::MOP::Mixin::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
43 | 'original_options' => ( | ||||
44 | reader => 'original_options', | ||||
45 | Class::MOP::_definition_context(), | ||||
46 | ) | ||||
47 | ); | ||||
48 | |||||
49 | # spent 122µs within Moose::Meta::Role::Attribute::new which was called 13 times, avg 9µs/call:
# 13 times (122µs+0s) by Class::MOP::Mixin::HasAttributes::add_attribute at line 14 of Class/MOP/Mixin/HasAttributes.pm, avg 9µs/call | ||||
50 | 13 | 24µs | my ( $class, $name, %options ) = @_; | ||
51 | |||||
52 | 13 | 2µs | (defined $name) | ||
53 | || throw_exception( MustProvideANameForTheAttribute => params => \%options, | ||||
54 | class => $class | ||||
55 | ); | ||||
56 | |||||
57 | 13 | 5µs | my $role = delete $options{_original_role}; | ||
58 | |||||
59 | 13 | 98µs | return bless { | ||
60 | name => $name, | ||||
61 | original_options => \%options, | ||||
62 | _original_role => $role, | ||||
63 | %options, | ||||
64 | }, $class; | ||||
65 | } | ||||
66 | |||||
67 | # spent 119µs (92+27) within Moose::Meta::Role::Attribute::attach_to_role which was called 13 times, avg 9µs/call:
# 13 times (92µs+27µs) by Moose::Meta::Role::_attach_attribute at line 256 of Moose/Meta/Role.pm, avg 9µs/call | ||||
68 | 13 | 5µs | my ( $self, $role ) = @_; | ||
69 | |||||
70 | 13 | 58µs | 26 | 17µs | ( blessed($role) && $role->isa('Moose::Meta::Role') ) # spent 9µs making 13 calls to Scalar::Util::blessed, avg 708ns/call
# spent 8µs making 13 calls to UNIVERSAL::isa, avg 592ns/call |
71 | || throw_exception( MustPassAMooseMetaRoleInstanceOrSubclass => class => $self, | ||||
72 | role => $role | ||||
73 | ); | ||||
74 | |||||
75 | 13 | 62µs | 13 | 10µs | weaken( $self->{'associated_role'} = $role ); # spent 10µs making 13 calls to Scalar::Util::weaken, avg 754ns/call |
76 | } | ||||
77 | |||||
78 | # spent 196µs (117+79) within Moose::Meta::Role::Attribute::original_role which was called 17 times, avg 12µs/call:
# 17 times (117µs+79µs) by Moose::Meta::Role::Attribute::attribute_for_class at line 87, avg 12µs/call | ||||
79 | 17 | 4µs | my $self = shift; | ||
80 | |||||
81 | 17 | 88µs | 34 | 79µs | return $self->_original_role || $self->associated_role; # spent 42µs making 17 calls to Moose::Meta::Role::Attribute::_original_role, avg 2µs/call
# spent 37µs making 17 calls to Moose::Meta::Role::Attribute::associated_role, avg 2µs/call |
82 | } | ||||
83 | |||||
84 | # spent 7.33ms (294µs+7.04) within Moose::Meta::Role::Attribute::attribute_for_class which was called 17 times, avg 431µs/call:
# 17 times (294µs+7.04ms) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 126 of Moose/Meta/Role/Application/ToClass.pm, avg 431µs/call | ||||
85 | 17 | 6µs | my $self = shift; | ||
86 | |||||
87 | 17 | 61µs | 34 | 242µs | my $metaclass = $self->original_role->applied_attribute_metaclass; # spent 196µs making 17 calls to Moose::Meta::Role::Attribute::original_role, avg 12µs/call
# spent 46µs making 17 calls to Moose::Meta::Role::applied_attribute_metaclass, avg 3µs/call |
88 | |||||
89 | return $metaclass->interpolate_class_and_new( | ||||
90 | 17 | 185µs | 51 | 6.80ms | $self->name => %{ $self->original_options } ); # spent 6.75ms making 17 calls to Moose::Meta::Attribute::interpolate_class_and_new, avg 397µs/call
# spent 39µs making 17 calls to Moose::Meta::Role::Attribute::original_options, avg 2µs/call
# spent 12µs making 17 calls to Class::MOP::Mixin::AttributeCore::name, avg 700ns/call |
91 | } | ||||
92 | |||||
93 | sub clone { | ||||
94 | my $self = shift; | ||||
95 | |||||
96 | my $role = $self->original_role; | ||||
97 | |||||
98 | return ( ref $self )->new( | ||||
99 | $self->name, | ||||
100 | %{ $self->original_options }, | ||||
101 | _original_role => $role, | ||||
102 | ); | ||||
103 | } | ||||
104 | |||||
105 | sub is_same_as { | ||||
106 | my $self = shift; | ||||
107 | my $attr = shift; | ||||
108 | |||||
109 | my $self_options = $self->original_options; | ||||
110 | my $other_options = $attr->original_options; | ||||
111 | |||||
112 | return 0 | ||||
113 | unless ( join q{|}, sort keys %{$self_options} ) eq ( join q{|}, sort keys %{$other_options} ); | ||||
114 | |||||
115 | for my $key ( keys %{$self_options} ) { | ||||
116 | return 0 if defined $self_options->{$key} && ! defined $other_options->{$key}; | ||||
117 | return 0 if ! defined $self_options->{$key} && defined $other_options->{$key}; | ||||
118 | |||||
119 | next if all { ! defined } $self_options->{$key}, $other_options->{$key}; | ||||
120 | |||||
121 | return 0 unless $self_options->{$key} eq $other_options->{$key}; | ||||
122 | } | ||||
123 | |||||
124 | return 1; | ||||
125 | } | ||||
126 | |||||
127 | 1 | 15µs | 1; | ||
128 | |||||
129 | # ABSTRACT: The Moose attribute metaclass for Roles | ||||
130 | |||||
131 | __END__ |