← Index
NYTProf Performance Profile   « block view • line view • sub view »
For xt/tapper-mcp-scheduler-with-db-longrun.t
  Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:23:33 2012

Filename/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Meta/Method/Delegation.pm
StatementsExecuted 19 statements in 543µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1118µs33µsMoose::Meta::Method::Delegation::::BEGIN@13Moose::Meta::Method::Delegation::BEGIN@13
1118µs8µsMoose::Meta::Method::Delegation::::BEGIN@3Moose::Meta::Method::Delegation::BEGIN@3
1118µs16µsMoose::Meta::Method::Delegation::::BEGIN@11Moose::Meta::Method::Delegation::BEGIN@11
1117µs10µsMoose::Meta::Method::Delegation::::BEGIN@10Moose::Meta::Method::Delegation::BEGIN@10
1117µs31µsMoose::Meta::Method::Delegation::::BEGIN@14Moose::Meta::Method::Delegation::BEGIN@14
1117µs100µsMoose::Meta::Method::Delegation::::BEGIN@16Moose::Meta::Method::Delegation::BEGIN@16
0000s0sMoose::Meta::Method::Delegation::::__ANON__[:111]Moose::Meta::Method::Delegation::__ANON__[:111]
0000s0sMoose::Meta::Method::Delegation::::_get_delegate_accessorMoose::Meta::Method::Delegation::_get_delegate_accessor
0000s0sMoose::Meta::Method::Delegation::::_initialize_bodyMoose::Meta::Method::Delegation::_initialize_body
0000s0sMoose::Meta::Method::Delegation::::_newMoose::Meta::Method::Delegation::_new
0000s0sMoose::Meta::Method::Delegation::::associated_attributeMoose::Meta::Method::Delegation::associated_attribute
0000s0sMoose::Meta::Method::Delegation::::curried_argumentsMoose::Meta::Method::Delegation::curried_arguments
0000s0sMoose::Meta::Method::Delegation::::delegate_to_methodMoose::Meta::Method::Delegation::delegate_to_method
0000s0sMoose::Meta::Method::Delegation::::newMoose::Meta::Method::Delegation::new
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
# spent 8µs within Moose::Meta::Method::Delegation::BEGIN@3 which was called: # once (8µs+0s) by Moose::Meta::Attribute::BEGIN@22 at line 5
BEGIN {
414µs $Moose::Meta::Method::Delegation::AUTHORITY = 'cpan:STEVAN';
5122µs18µs}
# spent 8µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@3
6{
721µs $Moose::Meta::Method::Delegation::VERSION = '2.0602';
8}
9
10318µs213µs
# spent 10µs (7+3) within Moose::Meta::Method::Delegation::BEGIN@10 which was called: # once (7µs+3µs) by Moose::Meta::Attribute::BEGIN@22 at line 10
use strict;
# spent 10µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@10 # spent 3µs making 1 call to strict::import
11322µs225µs
# spent 16µs (8+9) within Moose::Meta::Method::Delegation::BEGIN@11 which was called: # once (8µs+9µs) by Moose::Meta::Attribute::BEGIN@22 at line 11
use warnings;
# spent 16µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@11 # spent 9µs making 1 call to warnings::import
12
13324µs258µs
# spent 33µs (8+25) within Moose::Meta::Method::Delegation::BEGIN@13 which was called: # once (8µs+25µs) by Moose::Meta::Attribute::BEGIN@22 at line 13
use Carp 'confess';
# spent 33µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@13 # spent 25µs making 1 call to Exporter::import
14320µs256µs
# spent 31µs (7+24) within Moose::Meta::Method::Delegation::BEGIN@14 which was called: # once (7µs+24µs) by Moose::Meta::Attribute::BEGIN@22 at line 14
use Scalar::Util 'blessed', 'weaken';
# spent 31µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@14 # spent 24µs making 1 call to Exporter::import
15
1614µs194µs
# spent 100µs (7+93) within Moose::Meta::Method::Delegation::BEGIN@16 which was called: # once (7µs+93µs) by Moose::Meta::Attribute::BEGIN@22 at line 17
use base 'Moose::Meta::Method',
# spent 94µs making 1 call to base::import
172427µs1100µs 'Class::MOP::Method::Generated';
# spent 100µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@16
18
19
20sub new {
21 my $class = shift;
22 my %options = @_;
23
24 ( exists $options{attribute} )
25 || confess "You must supply an attribute to construct with";
26
27 ( blessed( $options{attribute} )
28 && $options{attribute}->isa('Moose::Meta::Attribute') )
29 || confess
30 "You must supply an attribute which is a 'Moose::Meta::Attribute' instance";
31
32 ( $options{package_name} && $options{name} )
33 || confess
34 "You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT";
35
36 ( $options{delegate_to_method} && ( !ref $options{delegate_to_method} )
37 || ( 'CODE' eq ref $options{delegate_to_method} ) )
38 || confess
39 'You must supply a delegate_to_method which is a method name or a CODE reference';
40
41 exists $options{curried_arguments}
42 || ( $options{curried_arguments} = [] );
43
44 ( $options{curried_arguments} &&
45 ( 'ARRAY' eq ref $options{curried_arguments} ) )
46 || confess 'You must supply a curried_arguments which is an ARRAY reference';
47
48 my $self = $class->_new( \%options );
49
50 weaken( $self->{'attribute'} );
51
52 $self->_initialize_body;
53
54 return $self;
55}
56
57sub _new {
58 my $class = shift;
59 my $options = @_ == 1 ? $_[0] : {@_};
60
61 return bless $options, $class;
62}
63
64sub curried_arguments { (shift)->{'curried_arguments'} }
65
66sub associated_attribute { (shift)->{'attribute'} }
67
68sub delegate_to_method { (shift)->{'delegate_to_method'} }
69
70sub _initialize_body {
71 my $self = shift;
72
73 my $method_to_call = $self->delegate_to_method;
74 return $self->{body} = $method_to_call
75 if ref $method_to_call;
76
77 my $accessor = $self->_get_delegate_accessor;
78
79 my $handle_name = $self->name;
80
81 # NOTE: we used to do a goto here, but the goto didn't handle
82 # failure correctly (it just returned nothing), so I took that
83 # out. However, the more I thought about it, the less I liked it
84 # doing the goto, and I preferred the act of delegation being
85 # actually represented in the stack trace. - SL
86 # not inlining this, since it won't really speed things up at
87 # all... the only thing that would end up different would be
88 # interpolating in $method_to_call, and a bunch of things in the
89 # error handling that mostly never gets called - doy
90 $self->{body} = sub {
91 my $instance = shift;
92 my $proxy = $instance->$accessor();
93
94 my $error
95 = !defined $proxy ? ' is not defined'
96 : ref($proxy) && !blessed($proxy) ? qq{ is not an object (got '$proxy')}
97 : undef;
98
99 if ($error) {
100 $self->throw_error(
101 "Cannot delegate $handle_name to $method_to_call because "
102 . "the value of "
103 . $self->associated_attribute->name
104 . $error,
105 method_name => $method_to_call,
106 object => $instance
107 );
108 }
109 unshift @_, @{ $self->curried_arguments };
110 $proxy->$method_to_call(@_);
111 };
112}
113
114sub _get_delegate_accessor {
115 my $self = shift;
116 my $attr = $self->associated_attribute;
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 my $accessor = $attr->has_read_method
128 ? $attr->get_read_method
129 : $attr->get_read_method_ref;
130
131 $accessor = $accessor->body if Scalar::Util::blessed $accessor;
132
133 return $accessor;
134}
135
13612µs1;
137
138# ABSTRACT: A Moose Method metaclass for delegation methods
139
- -
142=pod
143
144=head1 NAME
145
146Moose::Meta::Method::Delegation - A Moose Method metaclass for delegation methods
147
148=head1 VERSION
149
150version 2.0602
151
152=head1 DESCRIPTION
153
154This is a subclass of L<Moose::Meta::Method> for delegation
155methods.
156
157=head1 METHODS
158
159=over 4
160
161=item B<< Moose::Meta::Method::Delegation->new(%options) >>
162
163This creates the delegation methods based on the provided C<%options>.
164
165=over 4
166
167=item I<attribute>
168
169This must be an instance of C<Moose::Meta::Attribute> which this
170accessor is being generated for. This options is B<required>.
171
172=item I<delegate_to_method>
173
174The method in the associated attribute's value to which we
175delegate. This can be either a method name or a code reference.
176
177=item I<curried_arguments>
178
179An array reference of arguments that will be prepended to the argument list for
180any call to the delegating method.
181
182=back
183
184=item B<< $metamethod->associated_attribute >>
185
186Returns the attribute associated with this method.
187
188=item B<< $metamethod->curried_arguments >>
189
190Return any curried arguments that will be passed to the delegated method.
191
192=item B<< $metamethod->delegate_to_method >>
193
194Returns the method to which this method delegates, as passed to the
195constructor.
196
197=back
198
199=head1 BUGS
200
201See L<Moose/BUGS> for details on reporting bugs.
202
203=head1 AUTHOR
204
205Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details.
206
207=head1 COPYRIGHT AND LICENSE
208
209This software is copyright (c) 2012 by Infinity Interactive, Inc..
210
211This is free software; you can redistribute it and/or modify it under
212the same terms as the Perl 5 programming language system itself.
213
214=cut
215
216
217__END__