← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:39:01 2010
Reported on Wed Nov 17 22:04:53 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Method/Delegation.pm
StatementsExecuted 677 statements in 12.3ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
23112.60ms11.2msMoose::Meta::Method::Delegation::::newMoose::Meta::Method::Delegation::new
23112.53ms2.53msMoose::Meta::Method::Delegation::::_newMoose::Meta::Method::Delegation::_new
23111.80ms5.65msMoose::Meta::Method::Delegation::::_initialize_bodyMoose::Meta::Method::Delegation::_initialize_body
23111.55ms3.51msMoose::Meta::Method::Delegation::::_get_delegate_accessorMoose::Meta::Method::Delegation::_get_delegate_accessor
2722259µs259µsMoose::Meta::Method::Delegation::::delegate_to_methodMoose::Meta::Method::Delegation::delegate_to_method
2311199µs199µsMoose::Meta::Method::Delegation::::associated_attributeMoose::Meta::Method::Delegation::associated_attribute
1021111µs111µsMoose::Meta::Method::Delegation::::curried_argumentsMoose::Meta::Method::Delegation::curried_arguments
11171µs90µsMoose::Meta::Method::Delegation::::BEGIN@4Moose::Meta::Method::Delegation::BEGIN@4
11160µs226µsMoose::Meta::Method::Delegation::::BEGIN@8Moose::Meta::Method::Delegation::BEGIN@8
11144µs115µsMoose::Meta::Method::Delegation::::BEGIN@5Moose::Meta::Method::Delegation::BEGIN@5
11141µs485µsMoose::Meta::Method::Delegation::::BEGIN@14Moose::Meta::Method::Delegation::BEGIN@14
11139µs202µsMoose::Meta::Method::Delegation::::BEGIN@7Moose::Meta::Method::Delegation::BEGIN@7
0000s0sMoose::Meta::Method::Delegation::::__ANON__[:109]Moose::Meta::Method::Delegation::__ANON__[:109]
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1
2package Moose::Meta::Method::Delegation;
3
43180µs2109µs
# spent 90µs (71+19) within Moose::Meta::Method::Delegation::BEGIN@4 which was called: # once (71µs+19µs) by Moose::Meta::Attribute::BEGIN@18 at line 4
use strict;
# spent 90µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@4 # spent 19µs making 1 call to strict::import
53107µs2186µs
# spent 115µs (44+71) within Moose::Meta::Method::Delegation::BEGIN@5 which was called: # once (44µs+71µs) by Moose::Meta::Attribute::BEGIN@18 at line 5
use warnings;
# spent 115µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@5 # spent 71µs making 1 call to warnings::import
6
73131µs2366µs
# spent 202µs (39+163) within Moose::Meta::Method::Delegation::BEGIN@7 which was called: # once (39µs+163µs) by Moose::Meta::Attribute::BEGIN@18 at line 7
use Carp 'confess';
# spent 202µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@7 # spent 163µs making 1 call to Exporter::import
83239µs2391µs
# spent 226µs (60+166) within Moose::Meta::Method::Delegation::BEGIN@8 which was called: # once (60µs+166µs) by Moose::Meta::Attribute::BEGIN@18 at line 8
use Scalar::Util 'blessed', 'weaken';
# spent 226µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@8 # spent 166µs making 1 call to Exporter::import
9
1015µsour $VERSION = '1.19';
11160µs$VERSION = eval $VERSION;
# spent 11µs executing statements in string eval
1214µsour $AUTHORITY = 'cpan:STEVAN';
13
141444µs
# spent 485µs (41+444) within Moose::Meta::Method::Delegation::BEGIN@14 which was called: # once (41µs+444µs) by Moose::Meta::Attribute::BEGIN@18 at line 15
use base 'Moose::Meta::Method',
# spent 444µs making 1 call to base::import
1531.86ms1485µs 'Class::MOP::Method::Generated';
# spent 485µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@14
16
17
18
# spent 11.2ms (2.60+8.61) within Moose::Meta::Method::Delegation::new which was called 23 times, avg 487µs/call: # 23 times (2.60ms+8.61ms) by Moose::Meta::Attribute::_make_delegation_method at line 864 of Moose/Meta/Attribute.pm, avg 487µs/call
sub new {
192762.83ms my $class = shift;
20 my %options = @_;
21
22 ( exists $options{attribute} )
23 || confess "You must supply an attribute to construct with";
24
2546280µs ( blessed( $options{attribute} )
# spent 145µs making 23 calls to UNIVERSAL::isa, avg 6µs/call # spent 135µs making 23 calls to Scalar::Util::blessed, avg 6µs/call
26 && $options{attribute}->isa('Moose::Meta::Attribute') )
27 || confess
28 "You must supply an attribute which is a 'Moose::Meta::Attribute' instance";
29
30 ( $options{package_name} && $options{name} )
31 || confess
32 "You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT";
33
34 ( $options{delegate_to_method} && ( !ref $options{delegate_to_method} )
35 || ( 'CODE' eq ref $options{delegate_to_method} ) )
36 || confess
37 'You must supply a delegate_to_method which is a method name or a CODE reference';
38
39 exists $options{curried_arguments}
40 || ( $options{curried_arguments} = [] );
41
42 ( $options{curried_arguments} &&
43 ( 'ARRAY' eq ref $options{curried_arguments} ) )
44 || confess 'You must supply a curried_arguments which is an ARRAY reference';
45
46232.53ms my $self = $class->_new( \%options );
# spent 2.53ms making 23 calls to Moose::Meta::Method::Delegation::_new, avg 110µs/call
47
4823148µs weaken( $self->{'attribute'} );
# spent 148µs making 23 calls to Scalar::Util::weaken, avg 6µs/call
49
50235.65ms $self->_initialize_body;
# spent 5.65ms making 23 calls to Moose::Meta::Method::Delegation::_initialize_body, avg 246µs/call
51
52 return $self;
53}
54
55
# spent 2.53ms within Moose::Meta::Method::Delegation::_new which was called 23 times, avg 110µs/call: # 23 times (2.53ms+0s) by Moose::Meta::Method::Delegation::new at line 46, avg 110µs/call
sub _new {
56692.67ms my $class = shift;
57 my $options = @_ == 1 ? $_[0] : {@_};
58
59 return bless $options, $class;
60}
61
6210160µs
# spent 111µs within Moose::Meta::Method::Delegation::curried_arguments which was called 10 times, avg 11µs/call: # 5 times (59µs+0s) by Moose::Meta::Method::Accessor::Native::_inline_curried_arguments at line 56 of Moose/Meta/Method/Accessor/Native.pm, avg 12µs/call # 5 times (52µs+0s) by Moose::Meta::Method::Accessor::Native::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Method/Accessor/Native.pm:136] at line 121 of Moose/Meta/Method/Accessor/Native.pm, avg 10µs/call
sub curried_arguments { (shift)->{'curried_arguments'} }
63
6423294µs
# spent 199µs within Moose::Meta::Method::Delegation::associated_attribute which was called 23 times, avg 9µs/call: # 23 times (199µs+0s) by Moose::Meta::Method::Delegation::_get_delegate_accessor at line 114, avg 9µs/call
sub associated_attribute { (shift)->{'attribute'} }
65
6627392µs
# spent 259µs within Moose::Meta::Method::Delegation::delegate_to_method which was called 27 times, avg 10µs/call: # 23 times (212µs+0s) by Moose::Meta::Method::Delegation::_initialize_body at line 71, avg 9µs/call # 4 times (47µs+0s) by Moose::Meta::Method::Accessor::Native::_inline_check_argument_count at line 81 of Moose/Meta/Method/Accessor/Native.pm, avg 12µs/call
sub delegate_to_method { (shift)->{'delegate_to_method'} }
67
68
# spent 5.65ms (1.80+3.85) within Moose::Meta::Method::Delegation::_initialize_body which was called 23 times, avg 246µs/call: # 23 times (1.80ms+3.85ms) by Moose::Meta::Method::Delegation::new at line 50, avg 246µs/call
sub _initialize_body {
691381.84ms my $self = shift;
70
7123212µs my $method_to_call = $self->delegate_to_method;
# spent 212µs making 23 calls to Moose::Meta::Method::Delegation::delegate_to_method, avg 9µs/call
72 return $self->{body} = $method_to_call
73 if ref $method_to_call;
74
75233.51ms my $accessor = $self->_get_delegate_accessor;
# spent 3.51ms making 23 calls to Moose::Meta::Method::Delegation::_get_delegate_accessor, avg 152µs/call
76
7723131µs my $handle_name = $self->name;
# spent 131µs making 23 calls to Class::MOP::Method::name, avg 6µs/call
78
79 # NOTE: we used to do a goto here, but the goto didn't handle
80 # failure correctly (it just returned nothing), so I took that
81 # out. However, the more I thought about it, the less I liked it
82 # doing the goto, and I preferred the act of delegation being
83 # actually represented in the stack trace. - SL
84 # not inlining this, since it won't really speed things up at
85 # all... the only thing that would end up different would be
86 # interpolating in $method_to_call, and a bunch of things in the
87 # error handling that mostly never gets called - doy
88 $self->{body} = sub {
89 my $instance = shift;
90 my $proxy = $instance->$accessor();
91
92 my $error
93 = !defined $proxy ? ' is not defined'
94 : ref($proxy) && !blessed($proxy) ? qq{ is not an object (got '$proxy')}
95 : undef;
96
97 if ($error) {
98 $self->throw_error(
99 "Cannot delegate $handle_name to $method_to_call because "
100 . "the value of "
101 . $self->associated_attribute->name
102 . $error,
103 method_name => $method_to_call,
104 object => $instance
105 );
106 }
107 unshift @_, @{ $self->curried_arguments };
108 $proxy->$method_to_call(@_);
109 };
110}
111
112
# spent 3.51ms (1.55+1.96) within Moose::Meta::Method::Delegation::_get_delegate_accessor which was called 23 times, avg 152µs/call: # 23 times (1.55ms+1.96ms) by Moose::Meta::Method::Delegation::_initialize_body at line 75, avg 152µs/call
sub _get_delegate_accessor {
1131151.50ms my $self = shift;
11423199µs my $attr = $self->associated_attribute;
# spent 199µs making 23 calls to Moose::Meta::Method::Delegation::associated_attribute, avg 9µs/call
115
116 # NOTE:
117 # always use a named method when
118 # possible, if you use the method
119 # ref and there are modifiers on
120 # the accessors then it will not
121 # pick up the modifiers too. Only
122 # the named method will assure that
123 # we also have any modifiers run.
124 # - SL
125461.65ms my $accessor = $attr->has_read_method
# spent 901µs making 23 calls to Class::MOP::Attribute::get_read_method, avg 39µs/call # spent 746µs making 23 calls to Class::MOP::Mixin::AttributeCore::has_read_method, avg 32µs/call
126 ? $attr->get_read_method
127 : $attr->get_read_method_ref;
128
12923113µs $accessor = $accessor->body if Scalar::Util::blessed $accessor;
# spent 113µs making 23 calls to Scalar::Util::blessed, avg 5µs/call
130
131 return $accessor;
132}
133
134112µs1;
135
136__END__