Profile of Moose/Meta/Role/Attribute.pm

← Index
NYTProf Performance Profile «line view»
For script/ponapi
Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:11 2016

Filename | /usr/local/lib/perl/5.18.2/Moose/Meta/Role/Attribute.pm
Statements | Executed 1109 statements in 3.36ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
60 | 1 | 1 | 776µs | 78.4ms | Moose::Meta::Role::Attribute::::attribute_for_classMoose::Meta::Role::Attribute::attribute_for_class (recurses: max depth 1, inclusive time 435µs)
72 | 2 | 2 | 527µs | 527µs | Moose::Meta::Role::Attribute::::newMoose::Meta::Role::Attribute::new
57 | 2 | 2 | 509µs | 1.40ms | Moose::Meta::Role::Attribute::::cloneMoose::Meta::Role::Attribute::clone
72 | 1 | 1 | 430µs | 559µs | Moose::Meta::Role::Attribute::::attach_to_roleMoose::Meta::Role::Attribute::attach_to_role
117 | 2 | 1 | 416µs | 696µs | Moose::Meta::Role::Attribute::::original_roleMoose::Meta::Role::Attribute::original_role
1 | 1 | 1 | 14µs | 57µs | Moose::Meta::Role::Attribute::::BEGIN@7Moose::Meta::Role::Attribute::BEGIN@7
1 | 1 | 1 | 8µs | 17µs | Moose::Meta::Role::Attribute::::BEGIN@4Moose::Meta::Role::Attribute::BEGIN@4
1 | 1 | 1 | 7µs | 169µs | Moose::Meta::Role::Attribute::::BEGIN@12Moose::Meta::Role::Attribute::BEGIN@12
1 | 1 | 1 | 7µs | 38µs | Moose::Meta::Role::Attribute::::BEGIN@10Moose::Meta::Role::Attribute::BEGIN@10
1 | 1 | 1 | 6µs | 9µs | Moose::Meta::Role::Attribute::::BEGIN@5Moose::Meta::Role::Attribute::BEGIN@5
1 | 1 | 1 | 6µs | 26µs | Moose::Meta::Role::Attribute::::BEGIN@8Moose::Meta::Role::Attribute::BEGIN@8
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Attribute::::__ANON__[:119]Moose::Meta::Role::Attribute::__ANON__[:119]
0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Attribute::::is_same_asMoose::Meta::Role::Attribute::is_same_as

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package Moose::Meta::Role::Attribute;
2 | 1 | 800ns |  |  | our $VERSION = '2.1604';
3 |  |  |  |  |
4 | 2 | 18µs | 2 | 26µs | # spent 17µs (8+9) within Moose::Meta::Role::Attribute::BEGIN@4 which was called: # once (8µs+9µs) by Moose::Meta::Role::BEGIN@11 at line 4 use strict; # spent 17µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@4 # spent 9µs making 1 call to strict::import
5 | 2 | 26µs | 2 | 12µs | # spent 9µs (6+3) within Moose::Meta::Role::Attribute::BEGIN@5 which was called: # once (6µs+3µs) by Moose::Meta::Role::BEGIN@11 at line 5 use warnings; # spent 9µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@5 # spent 3µs making 1 call to warnings::import
6 |  |  |  |  |
7 | 3 | 43µs | 3 | 79µs | # spent 57µs (14+42) within Moose::Meta::Role::Attribute::BEGIN@7 which was called: # once (14µs+42µs) by Moose::Meta::Role::BEGIN@11 at line 7 use List::Util 1.33 'all'; # spent 57µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@7 # spent 14µs making 1 call to UNIVERSAL::VERSION # spent 8µs making 1 call to List::Util::import
8 | 2 | 22µs | 2 | 47µs | # spent 26µs (6+20) within Moose::Meta::Role::Attribute::BEGIN@8 which was called: # once (6µs+20µs) by Moose::Meta::Role::BEGIN@11 at line 8 use Scalar::Util 'blessed', 'weaken'; # spent 26µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@8 # spent 20µs making 1 call to Exporter::import
9 |  |  |  |  |
10 | 2 | 24µs | 2 | 70µs | # spent 38µs (7+32) within Moose::Meta::Role::Attribute::BEGIN@10 which was called: # once (7µs+32µs) by Moose::Meta::Role::BEGIN@11 at line 10 use parent 'Moose::Meta::Mixin::AttributeCore', 'Class::MOP::Object'; # spent 38µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@10 # spent 32µs making 1 call to parent::import
11 |  |  |  |  |
12 | 2 | 449µs | 2 | 330µs | # spent 169µs (7+162) within Moose::Meta::Role::Attribute::BEGIN@12 which was called: # once (7µs+162µs) by Moose::Meta::Role::BEGIN@11 at line 12 use Moose::Util 'throw_exception'; # spent 169µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@12 # spent 162µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
13 |  |  |  |  |
14 | 1 | 11µs | 3 | 738µs | __PACKAGE__->meta->add_attribute( # spent 392µs making 1 call to Class::MOP::Mixin::meta # spent 340µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 6µs making 1 call to Class::MOP::_definition_context
15 |  |  |  |  | 'metaclass' => (
16 |  |  |  |  | reader => 'metaclass',
17 |  |  |  |  | Class::MOP::_definition_context(),
18 |  |  |  |  | )
19 |  |  |  |  | );
20 |  |  |  |  |
21 | 1 | 3µs | 3 | 244µs | __PACKAGE__->meta->add_attribute( # spent 232µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µs making 1 call to Class::MOP::Mixin::meta # spent 4µ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 | 3µs | 3 | 260µs | __PACKAGE__->meta->add_attribute( # spent 248µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µs making 1 call to Class::MOP::Mixin::meta # spent 4µ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 | 3µs | 3 | 247µs | __PACKAGE__->meta->add_attribute( # spent 235µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µs making 1 call to Class::MOP::Mixin::meta # spent 4µs making 1 call to Class::MOP::_definition_context
36 |  |  |  |  | 'is' => (
37 |  |  |  |  | reader => 'is',
38 |  |  |  |  | Class::MOP::_definition_context(),
39 |  |  |  |  | )
40 |  |  |  |  | );
41 |  |  |  |  |
42 | 1 | 2µs | 3 | 238µs | __PACKAGE__->meta->add_attribute( # spent 226µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µs making 1 call to Class::MOP::Mixin::meta # spent 4µ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 527µs within Moose::Meta::Role::Attribute::new which was called 72 times, avg 7µs/call: # 57 times (402µs+0s) by Moose::Meta::Role::Attribute::clone at line 100, avg 7µs/call # 15 times (124µs+0s) by Class::MOP::Mixin::HasAttributes::add_attribute at line 14 of Class/MOP/Mixin/HasAttributes.pm, avg 8µs/call sub new {
50 | 72 | 146µs |  |  | my ( $class, $name, %options ) = @_;
51 |  |  |  |  |
52 | 72 | 13µs |  |  | (defined $name)
53 |  |  |  |  | || throw_exception( MustProvideANameForTheAttribute => params => \%options,
54 |  |  |  |  | class => $class
55 |  |  |  |  | );
56 |  |  |  |  |
57 | 72 | 34µs |  |  | my $role = delete $options{_original_role};
58 |  |  |  |  |
59 | 72 | 412µs |  |  | return bless {
60 |  |  |  |  | name => $name,
61 |  |  |  |  | original_options => \%options,
62 |  |  |  |  | _original_role => $role,
63 |  |  |  |  | %options,
64 |  |  |  |  | }, $class;
65 |  |  |  |  | }
66 |  |  |  |  |
67 |  |  |  |  | # spent 559µs (430+128) within Moose::Meta::Role::Attribute::attach_to_role which was called 72 times, avg 8µs/call: # 72 times (430µs+128µs) by Moose::Meta::Role::_attach_attribute at line 256 of Moose/Meta/Role.pm, avg 8µs/call sub attach_to_role {
68 | 72 | 12µs |  |  | my ( $self, $role ) = @_;
69 |  |  |  |  |
70 | 72 | 302µs | 144 | 77µs | ( blessed($role) && $role->isa('Moose::Meta::Role') ) # spent 41µs making 72 calls to Scalar::Util::blessed, avg 564ns/call # spent 36µs making 72 calls to UNIVERSAL::isa, avg 501ns/call
71 |  |  |  |  | || throw_exception( MustPassAMooseMetaRoleInstanceOrSubclass => class => $self,
72 |  |  |  |  | role => $role
73 |  |  |  |  | );
74 |  |  |  |  |
75 | 72 | 291µs | 72 | 52µs | weaken( $self->{'associated_role'} = $role ); # spent 52µs making 72 calls to Scalar::Util::weaken, avg 715ns/call
76 |  |  |  |  | }
77 |  |  |  |  |
78 |  |  |  |  | # spent 696µs (416+280) within Moose::Meta::Role::Attribute::original_role which was called 117 times, avg 6µs/call: # 60 times (174µs+128µs) by Moose::Meta::Role::Attribute::attribute_for_class at line 87, avg 5µs/call # 57 times (242µs+151µs) by Moose::Meta::Role::Attribute::clone at line 96, avg 7µs/call sub original_role {
79 | 117 | 14µs |  |  | my $self = shift;
80 |  |  |  |  |
81 | 117 | 372µs | 177 | 280µs | return $self->_original_role || $self->associated_role; # spent 199µs making 117 calls to Moose::Meta::Role::Attribute::_original_role, avg 2µs/call # spent 80µs making 60 calls to Moose::Meta::Role::Attribute::associated_role, avg 1µs/call
82 |  |  |  |  | }
83 |  |  |  |  |
84 |  |  |  |  | # spent 78.4ms (776µs+77.6) within Moose::Meta::Role::Attribute::attribute_for_class which was called 60 times, avg 1.31ms/call: # 60 times (776µs+77.6ms) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 126 of Moose/Meta/Role/Application/ToClass.pm, avg 1.31ms/call sub attribute_for_class {
85 | 60 | 23µs |  |  | my $self = shift;
86 |  |  |  |  |
87 | 60 | 194µs | 120 | 443µs | my $metaclass = $self->original_role->applied_attribute_metaclass; # spent 302µs making 60 calls to Moose::Meta::Role::Attribute::original_role, avg 5µs/call # spent 141µs making 60 calls to Moose::Meta::Role::applied_attribute_metaclass, avg 2µs/call
88 |  |  |  |  |
89 |  |  |  |  | return $metaclass->interpolate_class_and_new(
90 | 60 | 507µs | 180 | 76.9ms | $self->name => %{ $self->original_options } ); # spent 77.5ms making 60 calls to Moose::Meta::Attribute::interpolate_class_and_new, avg 1.29ms/call, recursion: max depth 1, sum of overlapping time 687µs # spent 89µs making 60 calls to Moose::Meta::Role::Attribute::original_options, avg 1µs/call # spent 36µs making 60 calls to Class::MOP::Mixin::AttributeCore::name, avg 600ns/call
91 |  |  |  |  | }
92 |  |  |  |  |
93 |  |  |  |  | # spent 1.40ms (509µs+893µs) within Moose::Meta::Role::Attribute::clone which was called 57 times, avg 25µs/call: # 55 times (485µs+850µs) by Moose::Meta::Role::Application::RoleSummation::apply_attributes at line 148 of Moose/Meta/Role/Application/RoleSummation.pm, avg 24µs/call # 2 times (24µs+43µs) by Moose::Meta::Role::Application::ToRole::apply_attributes at line 68 of Moose/Meta/Role/Application/ToRole.pm, avg 34µs/call sub clone {
94 | 57 | 11µs |  |  | my $self = shift;
95 |  |  |  |  |
96 | 57 | 60µs | 57 | 393µs | my $role = $self->original_role; # spent 393µs making 57 calls to Moose::Meta::Role::Attribute::original_role, avg 7µs/call
97 |  |  |  |  |
98 |  |  |  |  | return ( ref $self )->new(
99 |  |  |  |  | $self->name,
100 | 57 | 360µs | 171 | 500µs | %{ $self->original_options }, # spent 402µs making 57 calls to Moose::Meta::Role::Attribute::new, avg 7µs/call # spent 74µs making 57 calls to Moose::Meta::Role::Attribute::original_options, avg 1µs/call # spent 24µs making 57 calls to Class::MOP::Mixin::AttributeCore::name, avg 423ns/call
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 | 6µs |  |  | 1;
128 |  |  |  |  |
129 |  |  |  |  | # ABSTRACT: The Moose attribute metaclass for Roles
130 |  |  |  |  |
131 |  |  |  |  | __END__