Profile of Moose/Meta/Method/Delegation.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:10 2016

Filename | /usr/local/lib/perl/5.18.2/Moose/Meta/Method/Delegation.pm
Statements | Executed 600351 statements in 2.62s

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
100101 | 3 | 2 | 366ms | 366ms | Moose::Meta::Method::Delegation::::curried_argumentsMoose::Meta::Method::Delegation::curried_arguments
6 | 1 | 1 | 212µs | 437µs | Moose::Meta::Method::Delegation::::newMoose::Meta::Method::Delegation::new
71 | 7 | 5 | 98µs | 98µs | Moose::Meta::Method::Delegation::::delegate_to_methodMoose::Meta::Method::Delegation::delegate_to_method
6 | 1 | 1 | 72µs | 197µs | Moose::Meta::Method::Delegation::::_initialize_bodyMoose::Meta::Method::Delegation::_initialize_body
6 | 1 | 1 | 59µs | 117µs | Moose::Meta::Method::Delegation::::_get_delegate_accessorMoose::Meta::Method::Delegation::_get_delegate_accessor
6 | 1 | 1 | 16µs | 16µs | Moose::Meta::Method::Delegation::::_newMoose::Meta::Method::Delegation::_new
1 | 1 | 1 | 10µs | 19µs | Moose::Meta::Method::Delegation::::BEGIN@4Moose::Meta::Method::Delegation::BEGIN@4
1 | 1 | 1 | 8µs | 11µs | Moose::Meta::Method::Delegation::::BEGIN@5Moose::Meta::Method::Delegation::BEGIN@5
1 | 1 | 1 | 7µs | 125µs | Moose::Meta::Method::Delegation::::BEGIN@12Moose::Meta::Method::Delegation::BEGIN@12
1 | 1 | 1 | 6µs | 32µs | Moose::Meta::Method::Delegation::::BEGIN@7Moose::Meta::Method::Delegation::BEGIN@7
1 | 1 | 1 | 6µs | 29µs | Moose::Meta::Method::Delegation::::BEGIN@9Moose::Meta::Method::Delegation::BEGIN@9
6 | 1 | 1 | 5µs | 5µs | Moose::Meta::Method::Delegation::::associated_attributeMoose::Meta::Method::Delegation::associated_attribute
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Delegation::::__ANON__[:111]Moose::Meta::Method::Delegation::__ANON__[:111]

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::Method::Delegation;
2 | 1 | 500ns |  |  | our $VERSION = '2.1604';
3 |  |  |  |  |
4 | 2 | 19µs | 2 | 29µs | # spent 19µs (10+9) within Moose::Meta::Method::Delegation::BEGIN@4 which was called: # once (10µs+9µs) by Moose::Meta::Attribute::BEGIN@14 at line 4 use strict; # spent 19µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@4 # spent 10µs making 1 call to strict::import
5 | 2 | 24µs | 2 | 14µs | # spent 11µs (8+3) within Moose::Meta::Method::Delegation::BEGIN@5 which was called: # once (8µs+3µs) by Moose::Meta::Attribute::BEGIN@14 at line 5 use warnings; # spent 11µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@5 # spent 3µs making 1 call to warnings::import
6 |  |  |  |  |
7 | 2 | 24µs | 2 | 58µs | # spent 32µs (6+26) within Moose::Meta::Method::Delegation::BEGIN@7 which was called: # once (6µs+26µs) by Moose::Meta::Attribute::BEGIN@14 at line 7 use Scalar::Util 'blessed', 'weaken'; # spent 32µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@7 # spent 26µs making 1 call to Exporter::import
8 |  |  |  |  |
9 | 1 | 6µs | 1 | 24µs | # spent 29µs (6+24) within Moose::Meta::Method::Delegation::BEGIN@9 which was called: # once (6µs+24µs) by Moose::Meta::Attribute::BEGIN@14 at line 10 use parent 'Moose::Meta::Method', # spent 24µs making 1 call to parent::import
10 | 1 | 20µs | 1 | 29µs | 'Class::MOP::Method::Generated'; # spent 29µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@9
11 |  |  |  |  |
12 | 2 | 397µs | 2 | 243µs | # spent 125µs (7+118) within Moose::Meta::Method::Delegation::BEGIN@12 which was called: # once (7µs+118µs) by Moose::Meta::Attribute::BEGIN@14 at line 12 use Moose::Util 'throw_exception'; # spent 125µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@12 # spent 118µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
13 |  |  |  |  |
14 |  |  |  |  | # spent 437µs (212+225) within Moose::Meta::Method::Delegation::new which was called 6 times, avg 73µs/call: # 6 times (212µs+225µs) by Moose::Meta::Attribute::_make_delegation_method at line 1236 of Moose/Meta/Attribute.pm, avg 73µs/call sub new {
15 | 6 | 2µs |  |  | my $class = shift;
16 | 6 | 11µs |  |  | my %options = @_;
17 |  |  |  |  |
18 | 6 | 3µs |  |  | ( exists $options{attribute} )
19 |  |  |  |  | || throw_exception( MustSupplyAnAttributeToConstructWith => params => \%options,
20 |  |  |  |  | class => $class
21 |  |  |  |  | );
22 |  |  |  |  |
23 | 6 | 31µs | 12 | 8µs | ( blessed( $options{attribute} ) # spent 5µs making 6 calls to Scalar::Util::blessed, avg 767ns/call # spent 4µs making 6 calls to UNIVERSAL::isa, avg 600ns/call
24 |  |  |  |  | && $options{attribute}->isa('Moose::Meta::Attribute') )
25 |  |  |  |  | || throw_exception( MustSupplyAMooseMetaAttributeInstance => params => \%options,
26 |  |  |  |  | class => $class
27 |  |  |  |  | );
28 |  |  |  |  |
29 | 6 | 4µs |  |  | ( $options{package_name} && $options{name} )
30 |  |  |  |  | || throw_exception( MustSupplyPackageNameAndName => params => \%options,
31 |  |  |  |  | class => $class
32 |  |  |  |  | );
33 |  |  |  |  |
34 | 6 | 3µs |  |  | ( $options{delegate_to_method} && ( !ref $options{delegate_to_method} )
35 |  |  |  |  | || ( 'CODE' eq ref $options{delegate_to_method} ) )
36 |  |  |  |  | || throw_exception( MustSupplyADelegateToMethod => params => \%options,
37 |  |  |  |  | class => $class
38 |  |  |  |  | );
39 |  |  |  |  |
40 | 6 | 2µs |  |  | exists $options{curried_arguments}
41 |  |  |  |  | || ( $options{curried_arguments} = [] );
42 |  |  |  |  |
43 | 6 | 4µs |  |  | ( $options{curried_arguments} &&
44 |  |  |  |  | ( 'ARRAY' eq ref $options{curried_arguments} ) )
45 |  |  |  |  | || throw_exception( MustSupplyArrayRefAsCurriedArguments => params => \%options,
46 |  |  |  |  | class_name => $class
47 |  |  |  |  | );
48 |  |  |  |  |
49 | 6 | 8µs | 6 | 16µs | my $self = $class->_new( \%options ); # spent 16µs making 6 calls to Moose::Meta::Method::Delegation::_new, avg 3µs/call
50 |  |  |  |  |
51 | 6 | 126µs | 6 | 4µs | weaken( $self->{'attribute'} ); # spent 4µs making 6 calls to Scalar::Util::weaken, avg 583ns/call
52 |  |  |  |  |
53 | 6 | 7µs | 6 | 197µs | $self->_initialize_body; # spent 197µs making 6 calls to Moose::Meta::Method::Delegation::_initialize_body, avg 33µs/call
54 |  |  |  |  |
55 | 6 | 13µs |  |  | return $self;
56 |  |  |  |  | }
57 |  |  |  |  |
58 |  |  |  |  | # spent 16µs within Moose::Meta::Method::Delegation::_new which was called 6 times, avg 3µs/call: # 6 times (16µs+0s) by Moose::Meta::Method::Delegation::new at line 49, avg 3µs/call sub _new {
59 | 6 | 1µs |  |  | my $class = shift;
60 | 6 | 3µs |  |  | my $options = @_ == 1 ? $_[0] : {@_};
61 |  |  |  |  |
62 | 6 | 18µs |  |  | return bless $options, $class;
63 |  |  |  |  | }
64 |  |  |  |  |
65 | 100101 | 679ms |  |  | # spent 366ms within Moose::Meta::Method::Delegation::curried_arguments which was called 100101 times, avg 4µs/call: # 100001 times (366ms+0s) by PONAPI::Builder::Document::has_link at line 109, avg 4µs/call # 50 times (78µs+0s) by Moose::Meta::Method::Accessor::Native::_inline_curried_arguments at line 64 of Moose/Meta/Method/Accessor/Native.pm, avg 2µs/call # 50 times (56µs+0s) by Moose::Meta::Method::Accessor::Native::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Meta/Method/Accessor/Native.pm:147] at line 132 of Moose/Meta/Method/Accessor/Native.pm, avg 1µs/call sub curried_arguments { (shift)->{'curried_arguments'} }
66 |  |  |  |  |
67 | 6 | 12µs |  |  | # spent 5µs within Moose::Meta::Method::Delegation::associated_attribute which was called 6 times, avg 850ns/call: # 6 times (5µs+0s) by Moose::Meta::Method::Delegation::_get_delegate_accessor at line 116, avg 850ns/call sub associated_attribute { (shift)->{'attribute'} }
68 |  |  |  |  |
69 | 71 | 5.42ms |  |  | # spent 98µs within Moose::Meta::Method::Delegation::delegate_to_method which was called 71 times, avg 1µs/call: # 40 times (58µs+0s) by Moose::Meta::Method::Accessor::Native::_inline_check_argument_count at line 85 of Moose/Meta/Method/Accessor/Native.pm, avg 1µs/call # 11 times (22µs+0s) by Moose::Meta::Method::Accessor::Native::_inline_check_argument_count at line 74 of Moose/Meta/Method/Accessor/Native.pm, avg 2µs/call # 6 times (6µs+0s) by Moose::Meta::Method::Delegation::_initialize_body at line 74, avg 1µs/call # 6 times (6µs+0s) by Moose::Meta::Method::Accessor::Native::Hash::_inline_check_var_is_valid_key at line 14 of Moose/Meta/Method/Accessor/Native/Hash.pm, avg 917ns/call # 3 times (2µs+0s) by Class::MOP::Class:::around at line 21 of Moose/Meta/Method/Accessor/Native/Hash/set.pm, avg 833ns/call # 3 times (2µs+0s) by Moose::Meta::Method::Accessor::Native::Hash::set::_inline_check_arguments at line 44 of Moose/Meta/Method/Accessor/Native/Hash/set.pm, avg 567ns/call # 2 times (3µs+0s) by Moose::Meta::Method::Accessor::Native::Array::_inline_check_var_is_valid_index at line 14 of Moose/Meta/Method/Accessor/Native/Array.pm, avg 1µs/call sub delegate_to_method { (shift)->{'delegate_to_method'} }
70 |  |  |  |  |
71 |  |  |  |  | # spent 197µs (72+126) within Moose::Meta::Method::Delegation::_initialize_body which was called 6 times, avg 33µs/call: # 6 times (72µs+126µs) by Moose::Meta::Method::Delegation::new at line 53, avg 33µs/call sub _initialize_body {
72 | 6 | 1µs |  |  | my $self = shift;
73 |  |  |  |  |
74 | 6 | 7µs | 6 | 6µs | my $method_to_call = $self->delegate_to_method; # spent 6µs making 6 calls to Moose::Meta::Method::Delegation::delegate_to_method, avg 1µs/call
75 | 6 | 2µs |  |  | return $self->{body} = $method_to_call
76 |  |  |  |  | if ref $method_to_call;
77 |  |  |  |  |
78 | 6 | 7µs | 6 | 117µs | my $accessor = $self->_get_delegate_accessor; # spent 117µs making 6 calls to Moose::Meta::Method::Delegation::_get_delegate_accessor, avg 19µs/call
79 |  |  |  |  |
80 | 6 | 18µs | 6 | 3µs | my $handle_name = $self->name; # spent 3µs making 6 calls to Class::MOP::Method::name, avg 533ns/call
81 |  |  |  |  |
82 |  |  |  |  | # NOTE: we used to do a goto here, but the goto didn't handle
83 |  |  |  |  | # failure correctly (it just returned nothing), so I took that
84 |  |  |  |  | # out. However, the more I thought about it, the less I liked it
85 |  |  |  |  | # doing the goto, and I preferred the act of delegation being
86 |  |  |  |  | # actually represented in the stack trace. - SL
87 |  |  |  |  | # not inlining this, since it won't really speed things up at
88 |  |  |  |  | # all... the only thing that would end up different would be
89 |  |  |  |  | # interpolating in $method_to_call, and a bunch of things in the
90 |  |  |  |  | # error handling that mostly never gets called - doy
91 |  |  |  |  | $self->{body} = sub {
92 | 100001 | 51.8ms |  |  | my $instance = shift;
93 | 100001 | 279ms | 100001 | 14.0s | my $proxy = $instance->$accessor(); # spent 14.0s making 100001 calls to PONAPI::Builder::Document::links_builder, avg 140µs/call
94 |  |  |  |  |
95 | 100001 | 510ms | 100001 | 110ms | if( !defined $proxy ) { # spent 110ms making 100001 calls to Scalar::Util::blessed, avg 1µs/call
96 |  |  |  |  | throw_exception( AttributeValueIsNotDefined => method => $self,
97 |  |  |  |  | instance => $instance,
98 |  |  |  |  | attribute => $self->associated_attribute,
99 |  |  |  |  | );
100 |  |  |  |  | }
101 |  |  |  |  | elsif( ref($proxy) && !blessed($proxy) ) {
102 |  |  |  |  | throw_exception( AttributeValueIsNotAnObject => method => $self,
103 |  |  |  |  | instance => $instance,
104 |  |  |  |  | attribute => $self->associated_attribute,
105 |  |  |  |  | given_value => $proxy
106 |  |  |  |  | );
107 |  |  |  |  | }
108 |  |  |  |  |
109 | 100001 | 416ms | 100001 | 366ms | unshift @_, @{ $self->curried_arguments }; # spent 366ms making 100001 calls to Moose::Meta::Method::Delegation::curried_arguments, avg 4µs/call
110 | 100001 | 677ms | 100001 | 1.34s | $proxy->$method_to_call(@_); # spent 1.34s making 100001 calls to PONAPI::Builder::Links::has_link, avg 13µs/call
111 | 6 | 32µs |  |  | };
112 |  |  |  |  | }
113 |  |  |  |  |
114 |  |  |  |  | # spent 117µs (59+58) within Moose::Meta::Method::Delegation::_get_delegate_accessor which was called 6 times, avg 19µs/call: # 6 times (59µs+58µs) by Moose::Meta::Method::Delegation::_initialize_body at line 78, avg 19µs/call sub _get_delegate_accessor {
115 | 6 | 1µs |  |  | my $self = shift;
116 | 6 | 6µs | 6 | 5µs | my $attr = $self->associated_attribute; # spent 5µs making 6 calls to Moose::Meta::Method::Delegation::associated_attribute, avg 850ns/call
117 |  |  |  |  |
118 |  |  |  |  | # NOTE:
119 |  |  |  |  | # always use a named method when
120 |  |  |  |  | # possible, if you use the method
121 |  |  |  |  | # ref and there are modifiers on
122 |  |  |  |  | # the accessors then it will not
123 |  |  |  |  | # pick up the modifiers too. Only
124 |  |  |  |  | # the named method will assure that
125 |  |  |  |  | # we also have any modifiers run.
126 |  |  |  |  | # - SL
127 | 6 | 20µs | 12 | 50µs | my $accessor = $attr->has_read_method # spent 26µs making 6 calls to Class::MOP::Mixin::AttributeCore::has_read_method, avg 4µs/call # spent 24µs making 6 calls to Class::MOP::Attribute::get_read_method, avg 4µs/call
128 |  |  |  |  | ? $attr->get_read_method
129 |  |  |  |  | : $attr->get_read_method_ref;
130 |  |  |  |  |
131 | 6 | 13µs | 6 | 2µs | $accessor = $accessor->body if Scalar::Util::blessed $accessor; # spent 2µs making 6 calls to Scalar::Util::blessed, avg 383ns/call
132 |  |  |  |  |
133 | 6 | 12µs |  |  | return $accessor;
134 |  |  |  |  | }
135 |  |  |  |  |
136 | 1 | 2µs |  |  | 1;
137 |  |  |  |  |
138 |  |  |  |  | # ABSTRACT: A Moose Method metaclass for delegation methods
139 |  |  |  |  |
140 |  |  |  |  | __END__