Profile of Moose/Meta/Attribute/Native/Trait.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/Attribute/Native/Trait.pm
Statements | Executed 2314 statements in 6.45ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
32 | 1 | 1 | 4.60ms | 21.1ms | Moose::Meta::Attribute::Native::Trait::::_check_helper_typeMoose::Meta::Attribute::Native::Trait::_check_helper_type
100 | 2 | 1 | 1.82ms | 202ms | Moose::Meta::Attribute::Native::Trait::::_native_accessor_class_forMoose::Meta::Attribute::Native::Trait::_native_accessor_class_for
32 | 1 | 1 | 679µs | 198ms | Moose::Meta::Attribute::Native::Trait::::_check_handles_valuesMoose::Meta::Attribute::Native::Trait::_check_handles_values
32 | 1 | 1 | 450µs | 2.01ms | Moose::Meta::Attribute::Native::Trait::::_build_native_typeMoose::Meta::Attribute::Native::Trait::_build_native_type
50 | 1 | 1 | 212µs | 294µs | Moose::Meta::Attribute::Native::Trait::::_root_typesMoose::Meta::Attribute::Native::Trait::_root_types
100 | 1 | 1 | 207µs | 207µs | Moose::Meta::Attribute::Native::Trait::::_canonicalize_handles_valueMoose::Meta::Attribute::Native::Trait::_canonicalize_handles_value
32 | 1 | 1 | 134µs | 134µs | Moose::Meta::Attribute::Native::Trait::::CORE:matchMoose::Meta::Attribute::Native::Trait::CORE:match (opcode)
1 | 1 | 1 | 10µs | 2.02ms | Moose::Meta::Attribute::Native::Trait::::BEGIN@4Moose::Meta::Attribute::Native::Trait::BEGIN@4
1 | 1 | 1 | 8µs | 82µs | Moose::Meta::Attribute::Native::Trait::::BEGIN@161Moose::Meta::Attribute::Native::Trait::BEGIN@161
1 | 1 | 1 | 7µs | 22µs | Moose::Meta::Attribute::Native::Trait::::BEGIN@5Moose::Meta::Attribute::Native::Trait::BEGIN@5
1 | 1 | 1 | 7µs | 12µs | Moose::Meta::Attribute::Native::Trait::::BEGIN@6Moose::Meta::Attribute::Native::Trait::BEGIN@6
1 | 1 | 1 | 7µs | 1.17ms | Moose::Meta::Attribute::Native::Trait::::BEGIN@8Moose::Meta::Attribute::Native::Trait::BEGIN@8
1 | 1 | 1 | 7µs | 102µs | Moose::Meta::Attribute::Native::Trait::::BEGIN@7Moose::Meta::Attribute::Native::Trait::BEGIN@7
1 | 1 | 1 | 6µs | 70µs | Moose::Meta::Attribute::Native::Trait::::BEGIN@162Moose::Meta::Attribute::Native::Trait::BEGIN@162
0 | 0 | 0 | 0s | 0s | Moose::Meta::Attribute::Native::Trait::::__ANON__[:121]Moose::Meta::Attribute::Native::Trait::__ANON__[:121]
0 | 0 | 0 | 0s | 0s | Moose::Meta::Attribute::Native::Trait::::__ANON__[:16]Moose::Meta::Attribute::Native::Trait::__ANON__[:16]
0 | 0 | 0 | 0s | 0s | Moose::Meta::Attribute::Native::Trait::::__ANON__[:52]Moose::Meta::Attribute::Native::Trait::__ANON__[:52]
0 | 0 | 0 | 0s | 0s | Moose::Meta::Attribute::Native::Trait::::__ANON__[:86]Moose::Meta::Attribute::Native::Trait::__ANON__[:86]

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::Attribute::Native::Trait;
2 | 1 | 9µs |  |  | our $VERSION = '2.1604';
3 |  |  |  |  |
4 | 2 | 39µs | 2 | 4.02ms | # spent 2.02ms (10µs+2.01) within Moose::Meta::Attribute::Native::Trait::BEGIN@4 which was called: # once (10µs+2.01ms) by Module::Runtime::require_module at line 4 use Moose::Role; # spent 2.02ms making 1 call to Moose::Meta::Attribute::Native::Trait::BEGIN@4 # spent 2.01ms making 1 call to Moose::Role::import
5 | 2 | 22µs | 2 | 37µs | # spent 22µs (7+15) within Moose::Meta::Attribute::Native::Trait::BEGIN@5 which was called: # once (7µs+15µs) by Module::Runtime::require_module at line 5 use Module::Runtime 'require_module'; # spent 22µs making 1 call to Moose::Meta::Attribute::Native::Trait::BEGIN@5 # spent 15µs making 1 call to Module::Runtime::import
6 | 2 | 20µs | 2 | 17µs | # spent 12µs (7+5) within Moose::Meta::Attribute::Native::Trait::BEGIN@6 which was called: # once (7µs+5µs) by Module::Runtime::require_module at line 6 use Moose::Deprecated; # spent 12µs making 1 call to Moose::Meta::Attribute::Native::Trait::BEGIN@6 # spent 5µs making 1 call to Package::DeprecationManager::__ANON__[Package/DeprecationManager.pm:61]
7 | 2 | 26µs | 2 | 197µs | # spent 102µs (7+95) within Moose::Meta::Attribute::Native::Trait::BEGIN@7 which was called: # once (7µs+95µs) by Module::Runtime::require_module at line 7 use Moose::Util 'throw_exception'; # spent 102µs making 1 call to Moose::Meta::Attribute::Native::Trait::BEGIN@7 # spent 95µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
8 | 2 | 664µs | 2 | 2.34ms | # spent 1.17ms (7µs+1.17) within Moose::Meta::Attribute::Native::Trait::BEGIN@8 which was called: # once (7µs+1.17ms) by Module::Runtime::require_module at line 8 use Moose::Util::TypeConstraints; # spent 1.17ms making 1 call to Moose::Meta::Attribute::Native::Trait::BEGIN@8 # spent 1.17ms making 1 call to Moose::Util::TypeConstraints::import
9 |  |  |  |  |
10 | 1 | 1µs | 1 | 66µs | requires '_helper_type'; # spent 66µs making 1 call to Moose::Role::requires
11 |  |  |  |  |
12 |  |  |  |  | before '_process_options' => sub {
13 | 32 | 20µs |  |  | my ( $self, $name, $options ) = @_;
14 |  |  |  |  |
15 | 32 | 124µs | 32 | 21.1ms | $self->_check_helper_type( $options, $name ); # spent 21.1ms making 32 calls to Moose::Meta::Attribute::Native::Trait::_check_helper_type, avg 659µs/call
16 | 1 | 3µs | 1 | 51µs | }; # spent 51µs making 1 call to Moose::Role::before
17 |  |  |  |  |
18 |  |  |  |  | # spent 21.1ms (4.60+16.5) within Moose::Meta::Attribute::Native::Trait::_check_helper_type which was called 32 times, avg 659µs/call: # 32 times (4.60ms+16.5ms) by Class::MOP::Class:::before at line 15, avg 659µs/call sub _check_helper_type {
19 | 32 | 15µs |  |  | my ( $self, $options, $name ) = @_;
20 |  |  |  |  |
21 | 32 | 74µs | 32 | 51µs | my $type = $self->_helper_type; # spent 33µs making 21 calls to Moose::Meta::Attribute::Native::Trait::Hash::_helper_type, avg 2µs/call # spent 18µs making 11 calls to Moose::Meta::Attribute::Native::Trait::Array::_helper_type, avg 2µs/call
22 |  |  |  |  |
23 | 32 | 21µs |  |  | $options->{isa} = $type
24 |  |  |  |  | unless exists $options->{isa};
25 |  |  |  |  |
26 | 32 | 6µs |  |  | my $isa;
27 | 32 | 5µs |  |  | my $isa_name;
28 |  |  |  |  |
29 | 32 | 93µs | 32 | 18µs | if ( blessed( $options->{isa} ) # spent 18µs making 32 calls to Scalar::Util::blessed, avg 559ns/call
30 |  |  |  |  | && $options->{isa}->can('does')
31 |  |  |  |  | && $options->{isa}->does('Specio::Constraint::Role::Interface') ) {
32 |  |  |  |  |
33 |  |  |  |  | $isa = $options->{isa};
34 |  |  |  |  | require Specio::Library::Builtins;
35 |  |  |  |  | return if $isa->is_a_type_of( Specio::Library::Builtins::t($type) );
36 |  |  |  |  | $isa_name = $isa->name() || $isa->description();
37 |  |  |  |  | }
38 |  |  |  |  | else {
39 | 32 | 76µs | 32 | 10.8ms | $isa = Moose::Util::TypeConstraints::find_or_create_type_constraint( # spent 10.8ms making 32 calls to Moose::Util::TypeConstraints::find_or_create_type_constraint, avg 338µs/call
40 |  |  |  |  | $options->{isa} );
41 | 32 | 119µs | 32 | 5.60ms | return if $isa->is_a_type_of($type); # spent 5.60ms making 32 calls to Moose::Meta::TypeConstraint::is_a_type_of, avg 175µs/call
42 |  |  |  |  | $isa_name = $isa->name();
43 |  |  |  |  | }
44 |  |  |  |  |
45 |  |  |  |  | throw_exception( WrongTypeConstraintGiven => required_type => $type,
46 |  |  |  |  | given_type => $isa_name,
47 |  |  |  |  | attribute_name => $name,
48 |  |  |  |  | params => $options
49 |  |  |  |  | );
50 |  |  |  |  | }
51 |  |  |  |  |
52 | 33 | 114µs | 33 | 198ms | before 'install_accessors' => sub { (shift)->_check_handles_values }; # spent 198ms making 32 calls to Moose::Meta::Attribute::Native::Trait::_check_handles_values, avg 6.17ms/call # spent 28µs making 1 call to Moose::Role::before
53 |  |  |  |  |
54 |  |  |  |  | # spent 198ms (679µs+197) within Moose::Meta::Attribute::Native::Trait::_check_handles_values which was called 32 times, avg 6.17ms/call: # 32 times (679µs+197ms) by Class::MOP::Class:::before at line 52, avg 6.17ms/call sub _check_handles_values {
55 | 32 | 8µs |  |  | my $self = shift;
56 |  |  |  |  |
57 | 32 | 87µs | 32 | 874µs | my %handles = $self->_canonicalize_handles; # spent 567µs making 21 calls to Moose::Meta::Class::__ANON__::SERIAL::1::_canonicalize_handles, avg 27µs/call # spent 307µs making 11 calls to Moose::Meta::Class::__ANON__::SERIAL::7::_canonicalize_handles, avg 28µs/call
58 |  |  |  |  |
59 | 32 | 114µs |  |  | for my $original_method ( values %handles ) {
60 | 50 | 31µs |  |  | my $name = $original_method->[0];
61 |  |  |  |  |
62 | 50 | 129µs | 50 | 196ms | my $accessor_class = $self->_native_accessor_class_for($name); # spent 196ms making 50 calls to Moose::Meta::Attribute::Native::Trait::_native_accessor_class_for, avg 3.92ms/call
63 |  |  |  |  |
64 | 50 | 356µs | 50 | 105µs | ( $accessor_class && $accessor_class->can('new') ) # spent 105µs making 50 calls to UNIVERSAL::can, avg 2µs/call
65 |  |  |  |  | || confess
66 |  |  |  |  | "$name is an unsupported method type - $accessor_class";
67 |  |  |  |  | }
68 |  |  |  |  | }
69 |  |  |  |  |
70 |  |  |  |  | around '_canonicalize_handles' => sub {
71 | 64 | 12µs |  |  | shift;
72 | 64 | 19µs |  |  | my $self = shift;
73 | 64 | 115µs | 64 | 150µs | my $handles = $self->handles; # spent 150µs making 64 calls to Moose::Meta::Mixin::AttributeCore::handles, avg 2µs/call
74 |  |  |  |  |
75 | 64 | 15µs |  |  | return unless $handles;
76 |  |  |  |  |
77 | 64 | 43µs |  |  | unless ( 'HASH' eq ref $handles ) {
78 |  |  |  |  | throw_exception( HandlesMustBeAHashRef => instance => $self,
79 |  |  |  |  | given_handles => $handles
80 |  |  |  |  | );
81 |  |  |  |  | }
82 |  |  |  |  |
83 |  |  |  |  | return
84 | 64 | 352µs | 100 | 207µs | map { $_ => $self->_canonicalize_handles_value( $handles->{$_} ) } # spent 207µs making 100 calls to Moose::Meta::Attribute::Native::Trait::_canonicalize_handles_value, avg 2µs/call
85 |  |  |  |  | keys %$handles;
86 | 1 | 2µs | 1 | 38µs | }; # spent 38µs making 1 call to Moose::Role::around
87 |  |  |  |  |
88 |  |  |  |  | # spent 207µs within Moose::Meta::Attribute::Native::Trait::_canonicalize_handles_value which was called 100 times, avg 2µs/call: # 100 times (207µs+0s) by Class::MOP::Class:::around at line 84, avg 2µs/call sub _canonicalize_handles_value {
89 | 100 | 26µs |  |  | my $self = shift;
90 | 100 | 27µs |  |  | my $value = shift;
91 |  |  |  |  |
92 | 100 | 22µs |  |  | if ( ref $value && 'ARRAY' ne ref $value ) {
93 |  |  |  |  | throw_exception( InvalidHandleValue => instance => $self,
94 |  |  |  |  | handle_value => $value
95 |  |  |  |  | );
96 |  |  |  |  | }
97 |  |  |  |  |
98 | 100 | 207µs |  |  | return ref $value ? $value : [$value];
99 |  |  |  |  | }
100 |  |  |  |  |
101 |  |  |  |  | around '_make_delegation_method' => sub {
102 | 50 | 16µs |  |  | my $next = shift;
103 | 50 | 22µs |  |  | my ( $self, $handle_name, $method_to_call ) = @_;
104 |  |  |  |  |
105 | 50 | 45µs |  |  | my ( $name, @curried_args ) = @$method_to_call;
106 |  |  |  |  |
107 | 50 | 122µs | 50 | 6.21ms | my $accessor_class = $self->_native_accessor_class_for($name); # spent 6.21ms making 50 calls to Moose::Meta::Attribute::Native::Trait::_native_accessor_class_for, avg 124µs/call
108 |  |  |  |  |
109 | 50 | 264µs | 50 | 120µs | die "Cannot find an accessor class for $name" # spent 120µs making 50 calls to UNIVERSAL::can, avg 2µs/call
110 |  |  |  |  | unless $accessor_class && $accessor_class->can('new');
111 |  |  |  |  |
112 | 50 | 558µs | 200 | 61.4ms | return $accessor_class->new( # spent 23.8ms making 21 calls to Moose::Meta::Class::__ANON__::SERIAL::2::new, avg 1.14ms/call # spent 9.57ms making 11 calls to Moose::Meta::Class::__ANON__::SERIAL::8::new, avg 870µs/call # spent 7.27ms making 4 calls to Moose::Meta::Class::__ANON__::SERIAL::10::new, avg 1.82ms/call # spent 5.60ms making 3 calls to Moose::Meta::Class::__ANON__::SERIAL::6::new, avg 1.87ms/call # spent 3.93ms making 3 calls to Moose::Meta::Class::__ANON__::SERIAL::3::new, avg 1.31ms/call # spent 3.74ms making 2 calls to Moose::Meta::Class::__ANON__::SERIAL::9::new, avg 1.87ms/call # spent 3.63ms making 3 calls to Moose::Meta::Class::__ANON__::SERIAL::4::new, avg 1.21ms/call # spent 3.49ms making 3 calls to Moose::Meta::Class::__ANON__::SERIAL::5::new, avg 1.16ms/call # spent 294µs making 50 calls to Moose::Meta::Attribute::Native::Trait::_root_types, avg 6µs/call # spent 29µs making 50 calls to Class::MOP::Attribute::associated_class, avg 578ns/call # spent 19µs making 50 calls to Class::MOP::Package::name, avg 384ns/call
113 |  |  |  |  | name => $handle_name,
114 |  |  |  |  | package_name => $self->associated_class->name,
115 |  |  |  |  | delegate_to_method => $name,
116 |  |  |  |  | attribute => $self,
117 |  |  |  |  | is_inline => 1,
118 |  |  |  |  | curried_arguments => \@curried_args,
119 |  |  |  |  | root_types => [ $self->_root_types ],
120 |  |  |  |  | );
121 | 1 | 2µs | 1 | 27µs | }; # spent 27µs making 1 call to Moose::Role::around
122 |  |  |  |  |
123 |  |  |  |  | # spent 294µs (212+82) within Moose::Meta::Attribute::Native::Trait::_root_types which was called 50 times, avg 6µs/call: # 50 times (212µs+82µs) by Class::MOP::Class:::around at line 112, avg 6µs/call sub _root_types {
124 | 50 | 194µs | 50 | 82µs | return $_[0]->_helper_type; # spent 51µs making 33 calls to Moose::Meta::Attribute::Native::Trait::Hash::_helper_type, avg 2µs/call # spent 31µs making 17 calls to Moose::Meta::Attribute::Native::Trait::Array::_helper_type, avg 2µs/call
125 |  |  |  |  | }
126 |  |  |  |  |
127 |  |  |  |  | # spent 202ms (1.82+200) within Moose::Meta::Attribute::Native::Trait::_native_accessor_class_for which was called 100 times, avg 2.02ms/call: # 50 times (912µs+195ms) by Moose::Meta::Attribute::Native::Trait::_check_handles_values at line 62, avg 3.92ms/call # 50 times (907µs+5.30ms) by Class::MOP::Class:::around at line 107, avg 124µs/call sub _native_accessor_class_for {
128 | 100 | 38µs |  |  | my ( $self, $suffix ) = @_;
129 |  |  |  |  |
130 | 100 | 223µs | 100 | 2.61ms | my $role # spent 1.69ms making 66 calls to Moose::Meta::Class::__ANON__::SERIAL::1::_native_type, avg 26µs/call # spent 916µs making 34 calls to Moose::Meta::Class::__ANON__::SERIAL::7::_native_type, avg 27µs/call
131 |  |  |  |  | = 'Moose::Meta::Method::Accessor::Native::'
132 |  |  |  |  | . $self->_native_type . '::'
133 |  |  |  |  | . $suffix;
134 |  |  |  |  |
135 | 100 | 147µs | 100 | 1.00ms | require_module($role); # spent 122ms making 100 calls to Module::Runtime::require_module, avg 1.22ms/call, recursion: max depth 2, sum of overlapping time 121ms
136 | 100 | 1.16ms | 400 | 75.8ms | return Moose::Meta::Class->create_anon_class( # spent 75.5ms making 100 calls to Class::MOP::Class::create_anon_class, avg 755µs/call # spent 137µs making 100 calls to Moose::Meta::Attribute::accessor_metaclass, avg 1µs/call # spent 117µs making 100 calls to Moose::Meta::Attribute::delegation_metaclass, avg 1µs/call # spent 99µs making 100 calls to Class::MOP::Package::name, avg 994ns/call
137 |  |  |  |  | superclasses =>
138 |  |  |  |  | [ $self->accessor_metaclass, $self->delegation_metaclass ],
139 |  |  |  |  | roles => [$role],
140 |  |  |  |  | cache => 1,
141 |  |  |  |  | )->name;
142 |  |  |  |  | }
143 |  |  |  |  |
144 |  |  |  |  | # spent 2.01ms (450µs+1.56) within Moose::Meta::Attribute::Native::Trait::_build_native_type which was called 32 times, avg 63µs/call: # 32 times (450µs+1.56ms) by Moose::Meta::Class::__ANON__::SERIAL::1::_native_type or Moose::Meta::Class::__ANON__::SERIAL::7::_native_type at line 12 of (eval 45)[Eval/Closure.pm:144], avg 63µs/call sub _build_native_type {
145 | 32 | 11µs |  |  | my $self = shift;
146 |  |  |  |  |
147 | 96 | 243µs | 128 | 1.43ms | for my $role_name ( map { $_->name } $self->meta->calculate_all_roles ) { # spent 1.14ms making 32 calls to Moose::Meta::Class::calculate_all_roles, avg 36µs/call # spent 178µs making 21 calls to Moose::Meta::Class::__ANON__::SERIAL::1::meta, avg 8µs/call # spent 90µs making 11 calls to Moose::Meta::Class::__ANON__::SERIAL::7::meta, avg 8µs/call # spent 20µs making 64 calls to Class::MOP::Package::name, avg 306ns/call
148 | 32 | 325µs | 32 | 134µs | return $1 if $role_name =~ /::Native::Trait::(\w+)$/; # spent 134µs making 32 calls to Moose::Meta::Attribute::Native::Trait::CORE:match, avg 4µs/call
149 |  |  |  |  | }
150 |  |  |  |  |
151 |  |  |  |  | throw_exception( CannotCalculateNativeType => instance => $self );
152 |  |  |  |  | }
153 |  |  |  |  |
154 | 1 | 1µs | 1 | 113µs | has '_native_type' => ( # spent 113µs making 1 call to Moose::Role::has
155 |  |  |  |  | is => 'ro',
156 |  |  |  |  | isa => 'Str',
157 |  |  |  |  | lazy => 1,
158 |  |  |  |  | builder => '_build_native_type',
159 |  |  |  |  | );
160 |  |  |  |  |
161 | 2 | 23µs | 2 | 155µs | # spent 82µs (8+74) within Moose::Meta::Attribute::Native::Trait::BEGIN@161 which was called: # once (8µs+74µs) by Module::Runtime::require_module at line 161 no Moose::Role; # spent 82µs making 1 call to Moose::Meta::Attribute::Native::Trait::BEGIN@161 # spent 74µs making 1 call to Moose::Role::unimport
162 | 2 | 28µs | 2 | 134µs | # spent 70µs (6+64) within Moose::Meta::Attribute::Native::Trait::BEGIN@162 which was called: # once (6µs+64µs) by Module::Runtime::require_module at line 162 no Moose::Util::TypeConstraints; # spent 70µs making 1 call to Moose::Meta::Attribute::Native::Trait::BEGIN@162 # spent 64µs making 1 call to Moose::Util::TypeConstraints::unimport
163 |  |  |  |  |
164 | 1 | 11µs |  |  | 1;
165 |  |  |  |  |
166 |  |  |  |  | # ABSTRACT: Shared role for native delegation traits
167 |  |  |  |  |
168 |  |  |  |  | __END__
|  |  |  |  | # spent 134µs within Moose::Meta::Attribute::Native::Trait::CORE:match which was called 32 times, avg 4µs/call: # 32 times (134µs+0s) by Moose::Meta::Attribute::Native::Trait::_build_native_type at line 148, avg 4µs/call sub Moose::Meta::Attribute::Native::Trait::CORE:match; # opcode