← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:45:08 2010
Reported on Wed Nov 17 22:13:48 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 91 statements in 4.16ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111580µs580µsMoose::Meta::Method::Delegation::::_newMoose::Meta::Method::Delegation::_new
2821301µs301µsMoose::Meta::Method::Delegation::::curried_argumentsMoose::Meta::Method::Delegation::curried_arguments
1743194µs194µsMoose::Meta::Method::Delegation::::delegate_to_methodMoose::Meta::Method::Delegation::delegate_to_method
111140µs1.15msMoose::Meta::Method::Delegation::::newMoose::Meta::Method::Delegation::new
111122µs291µsMoose::Meta::Method::Delegation::::_get_delegate_accessorMoose::Meta::Method::Delegation::_get_delegate_accessor
111100µs407µsMoose::Meta::Method::Delegation::::_initialize_bodyMoose::Meta::Method::Delegation::_initialize_body
11176µs96µsMoose::Meta::Method::Delegation::::BEGIN@4Moose::Meta::Method::Delegation::BEGIN@4
11145µs495µsMoose::Meta::Method::Delegation::::BEGIN@14Moose::Meta::Method::Delegation::BEGIN@14
11140µs110µsMoose::Meta::Method::Delegation::::BEGIN@5Moose::Meta::Method::Delegation::BEGIN@5
11139µs201µsMoose::Meta::Method::Delegation::::BEGIN@8Moose::Meta::Method::Delegation::BEGIN@8
11139µs222µsMoose::Meta::Method::Delegation::::BEGIN@7Moose::Meta::Method::Delegation::BEGIN@7
1118µs8µsMoose::Meta::Method::Delegation::::associated_attributeMoose::Meta::Method::Delegation::associated_attribute
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
43103µs2115µs
# spent 96µs (76+20) within Moose::Meta::Method::Delegation::BEGIN@4 which was called: # once (76µs+20µs) by Moose::Meta::Attribute::BEGIN@18 at line 4
use strict;
# spent 96µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@4 # spent 20µs making 1 call to strict::import
53105µs2180µs
# spent 110µs (40+70) within Moose::Meta::Method::Delegation::BEGIN@5 which was called: # once (40µs+70µs) by Moose::Meta::Attribute::BEGIN@18 at line 5
use warnings;
# spent 110µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@5 # spent 70µs making 1 call to warnings::import
6
73114µs2404µs
# spent 222µs (39+182) within Moose::Meta::Method::Delegation::BEGIN@7 which was called: # once (39µs+182µs) by Moose::Meta::Attribute::BEGIN@18 at line 7
use Carp 'confess';
# spent 222µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@7 # spent 182µs making 1 call to Exporter::import
83219µs2362µs
# spent 201µs (39+161) within Moose::Meta::Method::Delegation::BEGIN@8 which was called: # once (39µs+161µs) by Moose::Meta::Attribute::BEGIN@18 at line 8
use Scalar::Util 'blessed', 'weaken';
# spent 201µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@8 # spent 161µs making 1 call to Exporter::import
9
1015µsour $VERSION = '1.19';
11161µs$VERSION = eval $VERSION;
# spent 11µs executing statements in string eval
1214µsour $AUTHORITY = 'cpan:STEVAN';
13
14137µs1450µs
# spent 495µs (45+449) within Moose::Meta::Method::Delegation::BEGIN@14 which was called: # once (45µs+449µs) by Moose::Meta::Attribute::BEGIN@18 at line 15
use base 'Moose::Meta::Method',
# spent 450µs making 1 call to base::import
1521.81ms1495µs 'Class::MOP::Method::Generated';
# spent 495µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@14
16
17
18
# spent 1.15ms (140µs+1.01) within Moose::Meta::Method::Delegation::new which was called: # once (140µs+1.01ms) by Moose::Meta::Attribute::_make_delegation_method at line 864 of Moose/Meta/Attribute.pm
sub new {
1915µs my $class = shift;
20112µs my %options = @_;
21
2213µs ( exists $options{attribute} )
23 || confess "You must supply an attribute to construct with";
24
25143µs213µs ( blessed( $options{attribute} )
# spent 6µs making 1 call to Scalar::Util::blessed # spent 6µs making 1 call to UNIVERSAL::isa
26 && $options{attribute}->isa('Moose::Meta::Attribute') )
27 || confess
28 "You must supply an attribute which is a 'Moose::Meta::Attribute' instance";
29
3014µs ( $options{package_name} && $options{name} )
31 || confess
32 "You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT";
33
3414µs ( $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
3913µs exists $options{curried_arguments}
40 || ( $options{curried_arguments} = [] );
41
4215µs ( $options{curried_arguments} &&
43 ( 'ARRAY' eq ref $options{curried_arguments} ) )
44 || confess 'You must supply a curried_arguments which is an ARRAY reference';
45
46114µs1580µs my $self = $class->_new( \%options );
# spent 580µs making 1 call to Moose::Meta::Method::Delegation::_new
47
48125µs17µs weaken( $self->{'attribute'} );
# spent 7µs making 1 call to Scalar::Util::weaken
49
50111µs1407µs $self->_initialize_body;
# spent 407µs making 1 call to Moose::Meta::Method::Delegation::_initialize_body
51
52117µs return $self;
53}
54
55
# spent 580µs within Moose::Meta::Method::Delegation::_new which was called: # once (580µs+0s) by Moose::Meta::Method::Delegation::new at line 46
sub _new {
5614µs my $class = shift;
5714µs my $options = @_ == 1 ? $_[0] : {@_};
58
591584µs return bless $options, $class;
60}
61
6228453µs
# spent 301µs within Moose::Meta::Method::Delegation::curried_arguments which was called 28 times, avg 11µs/call: # 14 times (159µ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 11µs/call # 14 times (142µs+0s) by Moose::Meta::Method::Accessor::Native::_inline_curried_arguments at line 56 of Moose/Meta/Method/Accessor/Native.pm, avg 10µs/call
sub curried_arguments { (shift)->{'curried_arguments'} }
63
64118µs
# spent 8µs within Moose::Meta::Method::Delegation::associated_attribute which was called: # once (8µs+0s) by Moose::Meta::Method::Delegation::_get_delegate_accessor at line 114
sub associated_attribute { (shift)->{'attribute'} }
65
6617283µs
# spent 194µs within Moose::Meta::Method::Delegation::delegate_to_method which was called 17 times, avg 11µs/call: # 9 times (109µ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 # 5 times (58µs+0s) by Moose::Meta::Method::Accessor::Native::_inline_check_argument_count at line 67 of Moose/Meta/Method/Accessor/Native.pm, avg 12µs/call # 2 times (17µs+0s) by Moose::Meta::Method::Accessor::Native::Hash::_inline_check_var_is_valid_key at line 15 of Moose/Meta/Method/Accessor/Native/Hash.pm, avg 9µs/call # once (10µs+0s) by Moose::Meta::Method::Delegation::_initialize_body at line 71
sub delegate_to_method { (shift)->{'delegate_to_method'} }
67
68
# spent 407µs (100+307) within Moose::Meta::Method::Delegation::_initialize_body which was called: # once (100µs+307µs) by Moose::Meta::Method::Delegation::new at line 50
sub _initialize_body {
6913µs my $self = shift;
70
71111µs110µs my $method_to_call = $self->delegate_to_method;
7212µs return $self->{body} = $method_to_call
73 if ref $method_to_call;
74
75111µs1291µs my $accessor = $self->_get_delegate_accessor;
76
77136µs16µs my $handle_name = $self->name;
# spent 6µs making 1 call to Class::MOP::Method::name
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(@_);
109131µs };
110}
111
112
# spent 291µs (122+170) within Moose::Meta::Method::Delegation::_get_delegate_accessor which was called: # once (122µs+170µs) by Moose::Meta::Method::Delegation::_initialize_body at line 75
sub _get_delegate_accessor {
11313µs my $self = shift;
114110µs18µs my $attr = $self->associated_attribute;
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
125149µs2156µs my $accessor = $attr->has_read_method
# spent 92µs making 1 call to Class::MOP::Attribute::get_read_method # spent 64µs making 1 call to Class::MOP::Mixin::AttributeCore::has_read_method
126 ? $attr->get_read_method
127 : $attr->get_read_method_ref;
128
129121µs15µs $accessor = $accessor->body if Scalar::Util::blessed $accessor;
# spent 5µs making 1 call to Scalar::Util::blessed
130
131119µs return $accessor;
132}
133
134112µs1;
135
136__END__