← 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:22:34 2012

Filename/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Method.pm
StatementsExecuted 3215 statements in 7.31ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
181443.11ms16.9msClass::MOP::Method::::wrapClass::MOP::Method::wrap
367111.39ms1.66msClass::MOP::Method::::attach_to_classClass::MOP::Method::attach_to_class
3522531µs645µsClass::MOP::Method::::cloneClass::MOP::Method::clone
7411508µs6.03msClass::MOP::Method::::_newClass::MOP::Method::_new
1119µs46µsClass::MOP::Method::::BEGIN@21Class::MOP::Method::BEGIN@21
1118µs8µsClass::MOP::Method::::BEGIN@3Class::MOP::Method::BEGIN@3
1117µs619µsClass::MOP::Method::::BEGIN@16Class::MOP::Method::BEGIN@16
1117µs22µsClass::MOP::Method::::BEGIN@11Class::MOP::Method::BEGIN@11
1117µs36µsClass::MOP::Method::::BEGIN@14Class::MOP::Method::BEGIN@14
1116µs9µsClass::MOP::Method::::BEGIN@10Class::MOP::Method::BEGIN@10
1116µs39µsClass::MOP::Method::::BEGIN@13Class::MOP::Method::BEGIN@13
1111µs1µsClass::MOP::Method::::is_stubClass::MOP::Method::is_stub (xsub)
0000s0sClass::MOP::Method::::__ANON__[:21]Class::MOP::Method::__ANON__[:21]
0000s0sClass::MOP::Method::::detach_from_classClass::MOP::Method::detach_from_class
0000s0sClass::MOP::Method::::executeClass::MOP::Method::execute
0000s0sClass::MOP::Method::::fully_qualified_nameClass::MOP::Method::fully_qualified_name
0000s0sClass::MOP::Method::::original_fully_qualified_nameClass::MOP::Method::original_fully_qualified_name
0000s0sClass::MOP::Method::::original_nameClass::MOP::Method::original_name
0000s0sClass::MOP::Method::::original_package_nameClass::MOP::Method::original_package_name
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1
2package Class::MOP::Method;
3
# spent 8µs within Class::MOP::Method::BEGIN@3 which was called: # once (8µs+0s) by base::import at line 5
BEGIN {
414µs $Class::MOP::Method::AUTHORITY = 'cpan:STEVAN';
5122µs18µs}
# spent 8µs making 1 call to Class::MOP::Method::BEGIN@3
6{
721µs $Class::MOP::Method::VERSION = '2.0602';
8}
9
10316µs212µs
# spent 9µs (6+3) within Class::MOP::Method::BEGIN@10 which was called: # once (6µs+3µs) by base::import at line 10
use strict;
# spent 9µs making 1 call to Class::MOP::Method::BEGIN@10 # spent 3µs making 1 call to strict::import
11318µs238µs
# spent 22µs (7+15) within Class::MOP::Method::BEGIN@11 which was called: # once (7µs+15µs) by base::import at line 11
use warnings;
# spent 22µs making 1 call to Class::MOP::Method::BEGIN@11 # spent 15µs making 1 call to warnings::import
12
13320µs272µs
# spent 39µs (6+33) within Class::MOP::Method::BEGIN@13 which was called: # once (6µs+33µs) by base::import at line 13
use Carp 'confess';
# spent 39µs making 1 call to Class::MOP::Method::BEGIN@13 # spent 33µs making 1 call to Exporter::import
14318µs266µs
# spent 36µs (7+30) within Class::MOP::Method::BEGIN@14 which was called: # once (7µs+30µs) by base::import at line 14
use Scalar::Util 'weaken', 'reftype', 'blessed';
# spent 36µs making 1 call to Class::MOP::Method::BEGIN@14 # spent 30µs making 1 call to Exporter::import
15
16338µs2619µs
# spent 619µs (7+612) within Class::MOP::Method::BEGIN@16 which was called: # once (7µs+612µs) by base::import at line 16
use base 'Class::MOP::Object';
# spent 619µs making 1 call to Class::MOP::Method::BEGIN@16 # spent 612µs making 1 call to base::import, recursion: max depth 1, sum of overlapping time 612µs
17
18# NOTE:
19# if poked in the right way,
20# they should act like CODE refs.
213505µs283µs
# spent 46µs (9+37) within Class::MOP::Method::BEGIN@21 which was called: # once (9µs+37µs) by base::import at line 21
use overload '&{}' => sub { $_[0]->body }, fallback => 1;
# spent 46µs making 1 call to Class::MOP::Method::BEGIN@21 # spent 37µs making 1 call to overload::import
22
23# construction
24
25
# spent 16.9ms (3.11+13.8) within Class::MOP::Method::wrap which was called 181 times, avg 94µs/call: # 66 times (1.07ms+1.39ms) by Class::MOP::Mixin::HasMethods::wrap_method_body at line 48 of Class/MOP/Mixin/HasMethods.pm, avg 37µs/call # 57 times (914µs+1.73ms) by Class::MOP::Attribute::_process_accessors at line 372 of Class/MOP/Attribute.pm, avg 46µs/call # 35 times (776µs+10.3ms) by Class::MOP::Method::Meta::wrap at line 62 of Class/MOP/Method/Meta.pm, avg 316µs/call # 23 times (348µs+424µs) by Class::MOP::Method::Wrapped::wrap at line 94 of Class/MOP/Method/Wrapped.pm, avg 34µs/call
sub wrap {
2616293.57ms my ( $class, @args ) = @_;
27
28 unshift @args, 'body' if @args % 2 == 1;
29
30 my %params = @args;
31 my $code = $params{body};
32
33362258µs if (blessed($code) && $code->isa(__PACKAGE__)) {
# spent 133µs making 181 calls to Scalar::Util::blessed, avg 735ns/call # spent 125µs making 181 calls to Scalar::Util::reftype, avg 691ns/call
34 my $method = $code->clone;
35 delete $params{body};
36 Class::MOP::class_of($class)->rebless_instance($method, %params);
37 return $method;
38 }
39 elsif (!ref $code || 'CODE' ne reftype($code)) {
40 confess "You must supply a CODE reference to bless, not (" . ($code || 'undef') . ")";
41 }
42
43 ($params{package_name} && $params{name})
44 || confess "You must supply the package_name and name parameters";
45
4618113.4ms my $self = $class->_new(\%params);
# spent 6.03ms making 74 calls to Class::MOP::Method::_new, avg 81µs/call # spent 4.47ms making 12 calls to Moose::Meta::Method::_new, avg 373µs/call # spent 1.57ms making 57 calls to Class::MOP::Method::Accessor::_new, avg 27µs/call # spent 899µs making 15 calls to Moose::Meta::Role::Method::_new, avg 60µs/call # spent 395µs making 23 calls to Class::MOP::Method::Wrapped::_new, avg 17µs/call
47
48158206µs weaken($self->{associated_metaclass}) if $self->{associated_metaclass};
# spent 206µs making 158 calls to Scalar::Util::weaken, avg 1µs/call
49
50 return $self;
51}
52
53
# spent 6.03ms (508µs+5.52) within Class::MOP::Method::_new which was called 74 times, avg 81µs/call: # 74 times (508µs+5.52ms) by Class::MOP::Method::wrap at line 46, avg 81µs/call
sub _new {
54250534µs my $class = shift;
55
56465.52ms return Class::MOP::Class->initialize($class)->new_object(@_)
# spent 4.63ms making 23 calls to Class::MOP::Class::new_object, avg 201µs/call # spent 893µs making 23 calls to Class::MOP::Class::initialize, avg 39µs/call
57 if $class ne __PACKAGE__;
58
59 my $params = @_ == 1 ? $_[0] : {@_};
60
61 return bless {
62 'body' => $params->{body},
63 'associated_metaclass' => $params->{associated_metaclass},
64 'package_name' => $params->{package_name},
65 'name' => $params->{name},
66 'original_method' => $params->{original_method},
67 } => $class;
68}
69
70## accessors
71
7238µssub associated_metaclass { shift->{'associated_metaclass'} }
73
74
# spent 1.66ms (1.39+270µs) within Class::MOP::Method::attach_to_class which was called 367 times, avg 5µs/call: # 367 times (1.39ms+270µs) by Class::MOP::Mixin::HasMethods::add_method at line 71 of Class/MOP/Mixin/HasMethods.pm, avg 5µs/call
sub attach_to_class {
7511011.88ms my ( $self, $class ) = @_;
76 $self->{associated_metaclass} = $class;
77367270µs weaken($self->{associated_metaclass});
# spent 270µs making 367 calls to Scalar::Util::weaken, avg 736ns/call
78}
79
80sub detach_from_class {
81 my $self = shift;
82 delete $self->{associated_metaclass};
83}
84
85sub fully_qualified_name {
86 my $self = shift;
87 $self->package_name . '::' . $self->name;
88}
89
90sub original_method { (shift)->{'original_method'} }
91
923591µssub _set_original_method { $_[0]->{'original_method'} = $_[1] }
93
94# It's possible that this could cause a loop if there is a circular
95# reference in here. That shouldn't ever happen in normal
96# circumstances, since original method only gets set when clone is
97# called. We _could_ check for such a loop, but it'd involve some sort
98# of package-lexical variable, and wouldn't be terribly subclassable.
99sub original_package_name {
100 my $self = shift;
101
102 $self->original_method
103 ? $self->original_method->original_package_name
104 : $self->package_name;
105}
106
107sub original_name {
108 my $self = shift;
109
110 $self->original_method
111 ? $self->original_method->original_name
112 : $self->name;
113}
114
115sub original_fully_qualified_name {
116 my $self = shift;
117
118 $self->original_method
119 ? $self->original_method->original_fully_qualified_name
120 : $self->fully_qualified_name;
121}
122
123sub execute {
124 my $self = shift;
125 $self->body->(@_);
126}
127
128# We used to go through use Class::MOP::Class->clone_instance to do this, but
129# this was awfully slow. This method may be called a number of times when
130# classes are loaded (especially during Moose role application), so it is
131# worth optimizing. - DR
132
# spent 645µs (531+115) within Class::MOP::Method::clone which was called 35 times, avg 18µs/call: # 25 times (348µs+83µs) by Class::MOP::Mixin::HasMethods::add_method at line 64 of Class/MOP/Mixin/HasMethods.pm, avg 17µs/call # 10 times (183µs+32µs) by Class::MOP::MiniTrait::apply at line 29 of Class/MOP/MiniTrait.pm, avg 21µs/call
sub clone {
133175584µs my $self = shift;
134
1353529µs my $clone = bless { %{$self}, @_ }, blessed($self);
# spent 29µs making 35 calls to Scalar::Util::blessed, avg 823ns/call
1363528µs weaken($clone->{associated_metaclass}) if $clone->{associated_metaclass};
# spent 28µs making 35 calls to Scalar::Util::weaken, avg 789ns/call
137
1383558µs $clone->_set_original_method($self);
# spent 58µs making 35 calls to Class::MOP::Method::_set_original_method, avg 2µs/call
139
140 return $clone;
141}
142
14312µs1;
144
145# ABSTRACT: Method Meta Object
146
- -
149=pod
150
151=head1 NAME
152
153Class::MOP::Method - Method Meta Object
154
155=head1 VERSION
156
157version 2.0602
158
159=head1 DESCRIPTION
160
161The Method Protocol is very small, since methods in Perl 5 are just
162subroutines in a specific package. We provide a very basic
163introspection interface.
164
165=head1 METHODS
166
167=over 4
168
169=item B<< Class::MOP::Method->wrap($code, %options) >>
170
171This is the constructor. It accepts a method body in the form of
172either a code reference or a L<Class::MOP::Method> instance, followed
173by a hash of options.
174
175The options are:
176
177=over 8
178
179=item * name
180
181The method name (without a package name). This is required if C<$code>
182is a coderef.
183
184=item * package_name
185
186The package name for the method. This is required if C<$code> is a
187coderef.
188
189=item * associated_metaclass
190
191An optional L<Class::MOP::Class> object. This is the metaclass for the
192method's class.
193
194=back
195
196=item B<< $metamethod->clone(%params) >>
197
198This makes a shallow clone of the method object. In particular,
199subroutine reference itself is shared between all clones of a given
200method.
201
202When a method is cloned, the original method object will be available
203by calling C<original_method> on the clone.
204
205=item B<< $metamethod->body >>
206
207This returns a reference to the method's subroutine.
208
209=item B<< $metamethod->name >>
210
211This returns the method's name
212
213=item B<< $metamethod->package_name >>
214
215This returns the method's package name.
216
217=item B<< $metamethod->fully_qualified_name >>
218
219This returns the method's fully qualified name (package name and
220method name).
221
222=item B<< $metamethod->associated_metaclass >>
223
224This returns the L<Class::MOP::Class> object for the method, if one
225exists.
226
227=item B<< $metamethod->original_method >>
228
229If this method object was created as a clone of some other method
230object, this returns the object that was cloned.
231
232=item B<< $metamethod->original_name >>
233
234This returns the method's original name, wherever it was first
235defined.
236
237If this method is a clone of a clone (of a clone, etc.), this method
238returns the name from the I<first> method in the chain of clones.
239
240=item B<< $metamethod->original_package_name >>
241
242This returns the method's original package name, wherever it was first
243defined.
244
245If this method is a clone of a clone (of a clone, etc.), this method
246returns the package name from the I<first> method in the chain of
247clones.
248
249=item B<< $metamethod->original_fully_qualified_name >>
250
251This returns the method's original fully qualified name, wherever it
252was first defined.
253
254If this method is a clone of a clone (of a clone, etc.), this method
255returns the fully qualified name from the I<first> method in the chain
256of clones.
257
258=item B<< $metamethod->is_stub >>
259
260Returns true if the method is just a stub:
261
262 sub foo;
263
264=item B<< $metamethod->attach_to_class($metaclass) >>
265
266Given a L<Class::MOP::Class> object, this method sets the associated
267metaclass for the method. This will overwrite any existing associated
268metaclass.
269
270=item B<< $metamethod->detach_from_class >>
271
272Removes any associated metaclass object for the method.
273
274=item B<< $metamethod->execute(...) >>
275
276This executes the method. Any arguments provided will be passed on to
277the method itself.
278
279=item B<< Class::MOP::Method->meta >>
280
281This will return a L<Class::MOP::Class> instance for this class.
282
283It should also be noted that L<Class::MOP> will actually bootstrap
284this module by installing a number of attribute meta-objects into its
285metaclass.
286
287=back
288
289=head1 AUTHOR
290
291Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details.
292
293=head1 COPYRIGHT AND LICENSE
294
295This software is copyright (c) 2012 by Infinity Interactive, Inc..
296
297This is free software; you can redistribute it and/or modify it under
298the same terms as the Perl 5 programming language system itself.
299
300=cut
301
302
303__END__
 
# spent 1µs within Class::MOP::Method::is_stub which was called: # once (1µs+0s) by Moose::Meta::Attribute::_process_accessors at line 1053 of Moose/Meta/Attribute.pm
sub Class::MOP::Method::is_stub; # xsub