← 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
StatementsExecuted 600351 statements in 2.62s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
10010132366ms366msMoose::Meta::Method::Delegation::::curried_argumentsMoose::Meta::Method::Delegation::curried_arguments
611212µs437µsMoose::Meta::Method::Delegation::::newMoose::Meta::Method::Delegation::new
717598µs98µsMoose::Meta::Method::Delegation::::delegate_to_methodMoose::Meta::Method::Delegation::delegate_to_method
61172µs197µsMoose::Meta::Method::Delegation::::_initialize_bodyMoose::Meta::Method::Delegation::_initialize_body
61159µs117µsMoose::Meta::Method::Delegation::::_get_delegate_accessorMoose::Meta::Method::Delegation::_get_delegate_accessor
61116µs16µsMoose::Meta::Method::Delegation::::_newMoose::Meta::Method::Delegation::_new
11110µs19µsMoose::Meta::Method::Delegation::::BEGIN@4Moose::Meta::Method::Delegation::BEGIN@4
1118µs11µsMoose::Meta::Method::Delegation::::BEGIN@5Moose::Meta::Method::Delegation::BEGIN@5
1117µs125µsMoose::Meta::Method::Delegation::::BEGIN@12Moose::Meta::Method::Delegation::BEGIN@12
1116µs32µsMoose::Meta::Method::Delegation::::BEGIN@7Moose::Meta::Method::Delegation::BEGIN@7
1116µs29µsMoose::Meta::Method::Delegation::::BEGIN@9Moose::Meta::Method::Delegation::BEGIN@9
6115µs5µsMoose::Meta::Method::Delegation::::associated_attributeMoose::Meta::Method::Delegation::associated_attribute
0000s0sMoose::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
1package Moose::Meta::Method::Delegation;
21500nsour $VERSION = '2.1604';
3
4219µs229µ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
5224µs214µ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
7224µs258µ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
916µs124µ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
10120µs129µs 'Class::MOP::Method::Generated';
# spent 29µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@9
11
122397µs2243µ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 {
1562µs my $class = shift;
16611µs my %options = @_;
17
1863µs ( exists $options{attribute} )
19 || throw_exception( MustSupplyAnAttributeToConstructWith => params => \%options,
20 class => $class
21 );
22
23631µs128µ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
2964µs ( $options{package_name} && $options{name} )
30 || throw_exception( MustSupplyPackageNameAndName => params => \%options,
31 class => $class
32 );
33
3463µ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
4062µs exists $options{curried_arguments}
41 || ( $options{curried_arguments} = [] );
42
4364µs ( $options{curried_arguments} &&
44 ( 'ARRAY' eq ref $options{curried_arguments} ) )
45 || throw_exception( MustSupplyArrayRefAsCurriedArguments => params => \%options,
46 class_name => $class
47 );
48
4968µs616µs my $self = $class->_new( \%options );
# spent 16µs making 6 calls to Moose::Meta::Method::Delegation::_new, avg 3µs/call
50
516126µs64µs weaken( $self->{'attribute'} );
# spent 4µs making 6 calls to Scalar::Util::weaken, avg 583ns/call
52
5367µs6197µs $self->_initialize_body;
# spent 197µs making 6 calls to Moose::Meta::Method::Delegation::_initialize_body, avg 33µs/call
54
55613µ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 {
5961µs my $class = shift;
6063µs my $options = @_ == 1 ? $_[0] : {@_};
61
62618µs return bless $options, $class;
63}
64
65100101679ms
# 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
67612µ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
69715.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 {
7261µs my $self = shift;
73
7467µs66µ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
7562µs return $self->{body} = $method_to_call
76 if ref $method_to_call;
77
7867µs6117µ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
80618µs63µ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 {
9210000151.8ms my $instance = shift;
93100001279ms10000114.0s my $proxy = $instance->$accessor();
# spent 14.0s making 100001 calls to PONAPI::Builder::Document::links_builder, avg 140µs/call
94
95100001510ms100001110ms 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
109100001416ms100001366ms unshift @_, @{ $self->curried_arguments };
# spent 366ms making 100001 calls to Moose::Meta::Method::Delegation::curried_arguments, avg 4µs/call
110100001677ms1000011.34s $proxy->$method_to_call(@_);
# spent 1.34s making 100001 calls to PONAPI::Builder::Links::has_link, avg 13µs/call
111632µ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 {
11561µs my $self = shift;
11666µs65µ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
127620µs1250µ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
131613µs62µs $accessor = $accessor->body if Scalar::Util::blessed $accessor;
# spent 2µs making 6 calls to Scalar::Util::blessed, avg 383ns/call
132
133612µs return $accessor;
134}
135
13612µs1;
137
138# ABSTRACT: A Moose Method metaclass for delegation methods
139
140__END__