← Index
NYTProf Performance Profile   « block view • line view • sub view »
For 05.Domain_and_Item.t
  Run on Tue May 4 17:21:41 2010
Reported on Tue May 4 17:23:08 2010

File /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP/Method.pm
Statements Executed 5221
Statement Execution Time 9.93ms
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
309544.86ms10.9msClass::MOP::Method::::wrapClass::MOP::Method::wrap
630112.28ms2.77msClass::MOP::Method::::attach_to_classClass::MOP::Method::attach_to_class
153687937µs937µsClass::MOP::Method::::bodyClass::MOP::Method::body (xsub)
6222513µs1.54msClass::MOP::Method::::_newClass::MOP::Method::_new
8254331µs370µsClass::MOP::Method::::__ANON__[:19]Class::MOP::Method::__ANON__[:19]
63012311µs311µsClass::MOP::Method::::package_nameClass::MOP::Method::package_name (xsub)
15411235µs235µsClass::MOP::Method::::_set_original_methodClass::MOP::Method::_set_original_method
1194380µs80µsClass::MOP::Method::::nameClass::MOP::Method::name (xsub)
487458µs58µsClass::MOP::Method::::associated_metaclassClass::MOP::Method::associated_metaclass
11113µs16µsClass::MOP::Method::::BEGIN@4Class::MOP::Method::BEGIN@4
11110µs48µsClass::MOP::Method::::BEGIN@19Class::MOP::Method::BEGIN@19
1116µs45µsClass::MOP::Method::::BEGIN@14Class::MOP::Method::BEGIN@14
1116µs15µsClass::MOP::Method::::BEGIN@5Class::MOP::Method::BEGIN@5
1116µs40µsClass::MOP::Method::::BEGIN@8Class::MOP::Method::BEGIN@8
1116µs28µsClass::MOP::Method::::BEGIN@7Class::MOP::Method::BEGIN@7
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_methodClass::MOP::Method::original_method
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
4320µs219µs
# spent 16µs (13+3) within Class::MOP::Method::BEGIN@4 which was called # once (13µs+3µs) by base::import at line 4
use strict;
# spent 16µs making 1 call to Class::MOP::Method::BEGIN@4 # spent 3µs making 1 call to strict::import
5320µs223µs
# spent 15µs (6+9) within Class::MOP::Method::BEGIN@5 which was called # once (6µs+9µs) by base::import at line 5
use warnings;
# spent 15µs making 1 call to Class::MOP::Method::BEGIN@5 # spent 8µs making 1 call to warnings::import
6
7322µs251µs
# spent 28µs (6+23) within Class::MOP::Method::BEGIN@7 which was called # once (6µs+23µs) by base::import at line 7
use Carp 'confess';
# spent 28µs making 1 call to Class::MOP::Method::BEGIN@7 # spent 23µs making 1 call to Exporter::import
8340µs274µs
# spent 40µs (6+34) within Class::MOP::Method::BEGIN@8 which was called # once (6µs+34µs) by base::import at line 8
use Scalar::Util 'weaken', 'reftype', 'blessed';
# spent 40µs making 1 call to Class::MOP::Method::BEGIN@8 # spent 34µs making 1 call to Exporter::import
9
101600nsour $VERSION = '0.98';
11113µs$VERSION = eval $VERSION;
121300nsour $AUTHORITY = 'cpan:STEVAN';
13
14347µs245µs
# spent 45µs (6+38) within Class::MOP::Method::BEGIN@14 which was called # once (6µs+38µs) by base::import at line 14
use base 'Class::MOP::Object';
# spent 45µs making 1 call to Class::MOP::Method::BEGIN@14 # spent 38µs making 1 call to base::import, recursion: max depth 1, time 38µs
15
16# NOTE:
17# if poked in the right way,
18# they should act like CODE refs.
1985821µs84126µs
# spent 48µs (10+38) within Class::MOP::Method::BEGIN@19 which was called # once (10µs+38µs) by base::import at line 19 # spent 370µs (331+40) within Class::MOP::Method::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP/Method.pm:19] which was called 82 times, avg 5µs/call: # 58 times (248µs+26µs) by Foo::Domain::size or Moose::Meta::Class::new_object at line 267 of Moose/Meta/Class.pm, avg 5µs/call # 18 times (56µs+9µs) by Class::MOP::Class:::after or MooseX::AttributeHelpers::MethodProvider::Hash::delete or MooseX::AttributeHelpers::MethodProvider::Hash::set or MooseX::AttributeHelpers::MethodProvider::ImmutableHash::exists or MooseX::AttributeHelpers::MethodProvider::ImmutableHash::get or MooseX::AttributeHelpers::MethodProvider::ImmutableHash::keys at line 181 of MooseX/AttributeHelpers/Trait/Base.pm, avg 4µs/call # 2 times (13µs+2µs) by Class::MOP::Class::__ANON__::SERIAL::1::get_class_attribute_map or Class::MOP::Class::__ANON__::SERIAL::1::has_class_attribute at line 10 of MooseX/AttributeHelpers/MethodProvider/ImmutableHash.pm, avg 8µs/call # 2 times (7µs+1µs) by Class::MOP::Class::__ANON__::SERIAL::1::_add_class_attribute or Class::MOP::Class::__ANON__::SERIAL::1::get_class_attribute_map at line 30 of MooseX/AttributeHelpers/MethodProvider/Hash.pm, avg 4µs/call # 2 times (7µs+1µs) by Class::MOP::Class::__ANON__::SERIAL::1::_class_attribute_values or Class::MOP::Class::__ANON__::SERIAL::1::set_class_attribute_value at line 36 of MooseX/AttributeHelpers/MethodProvider/Hash.pm, avg 4µs/call
use overload '&{}' => sub { $_[0]->body }, fallback => 1;
# spent 48µs making 1 call to Class::MOP::Method::BEGIN@19 # spent 40µs making 82 calls to Class::MOP::Method::body, avg 483ns/call # spent 38µs making 1 call to overload::import
20
21# construction
22
23
# spent 10.9ms (4.86+6.02) within Class::MOP::Method::wrap which was called 309 times, avg 35µs/call: # 141 times (2.24ms+1.79ms) by Class::MOP::Mixin::HasMethods::wrap_method_body at line 31 of Class/MOP/Mixin/HasMethods.pm, avg 29µs/call # 100 times (1.57ms+1.03ms) by Class::MOP::Method::Wrapped::wrap at line 92 of Class/MOP/Method/Wrapped.pm, avg 26µs/call # 57 times (881µs+743µs) by Class::MOP::Attribute::_process_accessors at line 310 of Class/MOP/Attribute.pm, avg 28µs/call # 9 times (127µs+2.44ms) by Class::MOP::Class:::after at line 181 of MooseX/AttributeHelpers/Trait/Base.pm, avg 285µs/call # 2 times (32µs+21µs) by Class::MOP::Attribute::get_write_method_ref at line 209 of Class/MOP/Attribute.pm, avg 27µs/call
sub wrap {
24309561µs my ( $class, @args ) = @_;
25
26309311µs unshift @args, 'body' if @args % 2 == 1;
27
28309493µs my %params = @args;
2930973µs my $code = $params{body};
30
313091.52ms618371µs if (blessed($code) && $code->isa(__PACKAGE__)) {
# spent 193µs making 309 calls to Scalar::Util::blessed, avg 623ns/call # spent 179µs making 309 calls to Scalar::Util::reftype, avg 579ns/call
32 my $method = $code->clone;
33 delete $params{body};
34 Class::MOP::class_of($class)->rebless_instance($method, %params);
35 return $method;
36 }
37 elsif (!ref $code || 'CODE' ne reftype($code)) {
38 confess "You must supply a CODE reference to bless, not (" . ($code || 'undef') . ")";
39 }
40
41309104µs ($params{package_name} && $params{name})
42 || confess "You must supply the package_name and name parameters";
43
44309479µs3095.52ms my $self = $class->_new(\%params);
# spent 2.70ms making 17 calls to Moose::Meta::Method::_new, avg 159µs/call # spent 921µs making 100 calls to Class::MOP::Method::Wrapped::_new, avg 9µs/call # spent 755µs making 75 calls to Moose::Meta::Role::Method::_new, avg 10µs/call # spent 649µs making 57 calls to Class::MOP::Method::Accessor::_new, avg 11µs/call # spent 498µs making 60 calls to Class::MOP::Method::_new, avg 8µs/call
45
46309489µs141127µs weaken($self->{associated_metaclass}) if $self->{associated_metaclass};
# spent 127µs making 141 calls to Scalar::Util::weaken, avg 901ns/call
47
48309983µs return $self;
49}
50
51
# spent 1.54ms (513µs+1.02) within Class::MOP::Method::_new which was called 62 times, avg 25µs/call: # 60 times (498µs+0s) by Class::MOP::Method::wrap at line 44, avg 8µs/call # 2 times (15µs+1.02ms) by Class::MOP::Method::Accessor::new at line 32 of Class/MOP/Method/Accessor.pm, avg 520µs/call
sub _new {
526217µs my $class = shift;
53
546220µs41.02ms return Class::MOP::Class->initialize($class)->new_object(@_)
# spent 976µs making 2 calls to Class::MOP::Class::new_object, avg 488µs/call # spent 48µs making 2 calls to Class::MOP::Class::initialize, avg 24µs/call
55 if $class ne __PACKAGE__;
56
576021µs my $params = @_ == 1 ? $_[0] : {@_};
58
5960482µs return bless {
60 'body' => $params->{body},
61 'associated_metaclass' => $params->{associated_metaclass},
62 'package_name' => $params->{package_name},
63 'name' => $params->{name},
64 'original_method' => $params->{original_method},
65 } => $class;
66}
67
68## accessors
69
7048119µs
# spent 58µs within Class::MOP::Method::associated_metaclass which was called 48 times, avg 1µs/call: # 12 times (14µs+0s) by Class::MOP::Method::Inlined::can_be_inlined at line 34 of Class/MOP/Method/Inlined.pm, avg 1µs/call # 6 times (15µs+0s) by Moose::Meta::Method::Constructor::_initialize_body at line 63 of Moose/Meta/Method/Constructor.pm, avg 2µs/call # 6 times (7µs+0s) by Moose::Meta::Method::Constructor::_generate_BUILDALL at line 153 of Moose/Meta/Method/Constructor.pm, avg 1µs/call # 6 times (6µs+0s) by Moose::Meta::Method::Destructor::_initialize_body at line 81 of Moose/Meta/Method/Destructor.pm, avg 1µs/call # 6 times (6µs+0s) by Class::MOP::Method::Constructor::_meta_instance at line 77 of Class/MOP/Method/Constructor.pm, avg 950ns/call # 6 times (5µs+0s) by Class::MOP::Method::Constructor::_attributes at line 82 of Class/MOP/Method/Constructor.pm, avg 767ns/call # 6 times (4µs+0s) by Moose::Meta::Method::Constructor::_generate_BUILDARGS at line 135 of Moose/Meta/Method/Constructor.pm, avg 750ns/call
sub associated_metaclass { shift->{'associated_metaclass'} }
71
72
# spent 2.77ms (2.28+493µs) within Class::MOP::Method::attach_to_class which was called 630 times, avg 4µs/call: # 630 times (2.28ms+493µs) by Class::MOP::Mixin::HasMethods::add_method at line 52 of Class/MOP/Mixin/HasMethods.pm, avg 4µs/call
sub attach_to_class {
73630220µs my ( $self, $class ) = @_;
74630325µs $self->{associated_metaclass} = $class;
756302.39ms630493µs weaken($self->{associated_metaclass});
# spent 493µs making 630 calls to Scalar::Util::weaken, avg 783ns/call
76}
77
78sub detach_from_class {
79 my $self = shift;
80 delete $self->{associated_metaclass};
81}
82
83sub fully_qualified_name {
84 my $self = shift;
85 $self->package_name . '::' . $self->name;
86}
87
88sub original_method { (shift)->{'original_method'} }
89
90154341µs
# spent 235µs within Class::MOP::Method::_set_original_method which was called 154 times, avg 2µs/call: # 154 times (235µs+0s) by Class::MOP::Method::clone at line 539 of Class/MOP.pm, avg 2µs/call
sub _set_original_method { $_[0]->{'original_method'} = $_[1] }
91
92# It's possible that this could cause a loop if there is a circular
93# reference in here. That shouldn't ever happen in normal
94# circumstances, since original method only gets set when clone is
95# called. We _could_ check for such a loop, but it'd involve some sort
96# of package-lexical variable, and wouldn't be terribly subclassable.
97sub original_package_name {
98 my $self = shift;
99
100 $self->original_method
101 ? $self->original_method->original_package_name
102 : $self->package_name;
103}
104
105sub original_name {
106 my $self = shift;
107
108 $self->original_method
109 ? $self->original_method->original_name
110 : $self->name;
111}
112
113sub original_fully_qualified_name {
114 my $self = shift;
115
116 $self->original_method
117 ? $self->original_method->original_fully_qualified_name
118 : $self->fully_qualified_name;
119}
120
121sub execute {
122 my $self = shift;
123 $self->body->(@_);
124}
125
126# NOTE:
127# the Class::MOP bootstrap
128# will create this for us
129# - SL
130# sub clone { ... }
131
13214µs1;
133
134__END__
135
136=pod
137
138=head1 NAME
139
140Class::MOP::Method - Method Meta Object
141
142=head1 DESCRIPTION
143
144The Method Protocol is very small, since methods in Perl 5 are just
145subroutines in a specific package. We provide a very basic
146introspection interface.
147
148=head1 METHODS
149
150=over 4
151
152=item B<< Class::MOP::Method->wrap($code, %options) >>
153
154This is the constructor. It accepts a method body in the form of
155either a code reference or a L<Class::MOP::Method> instance, followed
156by a hash of options.
157
158The options are:
159
160=over 8
161
162=item * name
163
164The method name (without a package name). This is required if C<$code>
165is a coderef.
166
167=item * package_name
168
169The package name for the method. This is required if C<$code> is a
170coderef.
171
172=item * associated_metaclass
173
174An optional L<Class::MOP::Class> object. This is the metaclass for the
175method's class.
176
177=back
178
179=item B<< $metamethod->clone(%params) >>
180
181This makes a shallow clone of the method object. In particular,
182subroutine reference itself is shared between all clones of a given
183method.
184
185When a method is cloned, the original method object will be available
186by calling C<original_method> on the clone.
187
188=item B<< $metamethod->body >>
189
190This returns a reference to the method's subroutine.
191
192=item B<< $metamethod->name >>
193
194This returns the method's name
195
196=item B<< $metamethod->package_name >>
197
198This returns the method's package name.
199
200=item B<< $metamethod->fully_qualified_name >>
201
202This returns the method's fully qualified name (package name and
203method name).
204
205=item B<< $metamethod->associated_metaclass >>
206
207This returns the L<Class::MOP::Class> object for the method, if one
208exists.
209
210=item B<< $metamethod->original_method >>
211
212If this method object was created as a clone of some other method
213object, this returns the object that was cloned.
214
215=item B<< $metamethod->original_name >>
216
217This returns the method's original name, wherever it was first
218defined.
219
220If this method is a clone of a clone (of a clone, etc.), this method
221returns the name from the I<first> method in the chain of clones.
222
223=item B<< $metamethod->original_package_name >>
224
225This returns the method's original package name, wherever it was first
226defined.
227
228If this method is a clone of a clone (of a clone, etc.), this method
229returns the package name from the I<first> method in the chain of
230clones.
231
232=item B<< $metamethod->original_fully_qualified_name >>
233
234This returns the method's original fully qualified name, wherever it
235was first defined.
236
237If this method is a clone of a clone (of a clone, etc.), this method
238returns the fully qualified name from the I<first> method in the chain
239of clones.
240
241=item B<< $metamethod->attach_to_class($metaclass) >>
242
243Given a L<Class::MOP::Class> object, this method sets the associated
244metaclass for the method. This will overwrite any existing associated
245metaclass.
246
247=item B<< $metamethod->detach_from_class >>
248
249Removes any associated metaclass object for the method.
250
251=item B<< $metamethod->execute(...) >>
252
253This executes the method. Any arguments provided will be passed on to
254the method itself.
255
256=item B<< Class::MOP::Method->meta >>
257
258This will return a L<Class::MOP::Class> instance for this class.
259
260It should also be noted that L<Class::MOP> will actually bootstrap
261this module by installing a number of attribute meta-objects into its
262metaclass.
263
264=back
265
266=head1 AUTHORS
267
268Stevan Little E<lt>stevan@iinteractive.comE<gt>
269
270=head1 COPYRIGHT AND LICENSE
271
272Copyright 2006-2010 by Infinity Interactive, Inc.
273
274L<http://www.iinteractive.com>
275
276This library is free software; you can redistribute it and/or modify
277it under the same terms as Perl itself.
278
279=cut
280
# spent 937µs within Class::MOP::Method::body which was called 1536 times, avg 610ns/call: # 630 times (379µs+0s) by Class::MOP::Mixin::HasMethods::add_method at line 44 of Class/MOP/Mixin/HasMethods.pm, avg 602ns/call # 596 times (402µs+0s) by Class::MOP::Mixin::HasMethods::get_method at line 115 of Class/MOP/Mixin/HasMethods.pm, avg 675ns/call # 100 times (42µs+0s) by Class::MOP::Method::Wrapped::wrap at line 77 of Class/MOP/Method/Wrapped.pm, avg 424ns/call # 82 times (40µs+0s) by Class::MOP::Method::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP/Method.pm:19] at line 19 of Class/MOP/Method.pm, avg 483ns/call # 65 times (31µs+0s) by Class::MOP::Method::Wrapped::add_around_modifier at line 168 of Class/MOP/Method/Wrapped.pm, avg 477ns/call # 55 times (38µs+0s) by Class::MOP::Class::_immutable_metaclass at line 970 of Class/MOP/Class.pm, avg 684ns/call # 6 times (4µs+0s) by Moose::Meta::Method::Constructor::_generate_BUILDARGS at line 137 of Moose/Meta/Method/Constructor.pm, avg 650ns/call # 2 times (1µs+0s) by Moose::Meta::Role::Application::ToRole::apply_methods at line 77 of Moose/Meta/Role/Application/ToRole.pm, avg 500ns/call
sub Class::MOP::Method::body; # xsub
# spent 80µs within Class::MOP::Method::name which was called 119 times, avg 672ns/call: # 64 times (47µs+0s) by Class::MOP::Class::_immutable_metaclass at line 968 of Class/MOP/Class.pm, avg 742ns/call # 43 times (26µs+0s) by Class::MOP::Method::Inlined::can_be_inlined at line 40 of Class/MOP/Method/Inlined.pm, avg 600ns/call # 6 times (4µs+0s) by Class::MOP::Method::Inlined::can_be_inlined at line 58 of Class/MOP/Method/Inlined.pm, avg 617ns/call # 6 times (3µs+0s) by Class::MOP::Method::Inlined::can_be_inlined at line 70 of Class/MOP/Method/Inlined.pm, avg 500ns/call
sub Class::MOP::Method::name; # xsub
# spent 311µs within Class::MOP::Method::package_name which was called 630 times, avg 493ns/call: # 630 times (311µs+0s) by Class::MOP::Mixin::HasMethods::add_method at line 45 of Class/MOP/Mixin/HasMethods.pm, avg 493ns/call
sub Class::MOP::Method::package_name; # xsub