← 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:18 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP/Method.pm
StatementsExecuted 28803 statements in 390ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
220633133ms171msClass::MOP::Method::::cloneClass::MOP::Method::clone
9366687.9ms443msClass::MOP::Method::::wrapClass::MOP::Method::wrap
28771172.8ms96.1msClass::MOP::Method::::attach_to_classClass::MOP::Method::attach_to_class
95223.73ms45.6msClass::MOP::Method::::_newClass::MOP::Method::_new
11171µs90µsClass::MOP::Method::::BEGIN@4Class::MOP::Method::BEGIN@4
11147µs198µsClass::MOP::Method::::BEGIN@19Class::MOP::Method::BEGIN@19
11141µs3.10msClass::MOP::Method::::BEGIN@14Class::MOP::Method::BEGIN@14
11137µs105µsClass::MOP::Method::::BEGIN@5Class::MOP::Method::BEGIN@5
11137µs217µsClass::MOP::Method::::BEGIN@8Class::MOP::Method::BEGIN@8
11136µs272µsClass::MOP::Method::::BEGIN@7Class::MOP::Method::BEGIN@7
0000s0sClass::MOP::Method::::__ANON__[:19]Class::MOP::Method::__ANON__[:19]
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
43119µs2108µs
# spent 90µs (71+18) within Class::MOP::Method::BEGIN@4 which was called: # once (71µs+18µs) by base::import at line 4
use strict;
# spent 90µs making 1 call to Class::MOP::Method::BEGIN@4 # spent 18µs making 1 call to strict::import
5398µs2173µs
# spent 105µs (37+68) within Class::MOP::Method::BEGIN@5 which was called: # once (37µs+68µs) by base::import at line 5
use warnings;
# spent 105µs making 1 call to Class::MOP::Method::BEGIN@5 # spent 68µs making 1 call to warnings::import
6
73117µs2508µs
# spent 272µs (36+236) within Class::MOP::Method::BEGIN@7 which was called: # once (36µs+236µs) by base::import at line 7
use Carp 'confess';
# spent 272µs making 1 call to Class::MOP::Method::BEGIN@7 # spent 236µs making 1 call to Exporter::import
83205µs2398µs
# spent 217µs (37+180) within Class::MOP::Method::BEGIN@8 which was called: # once (37µs+180µs) by base::import at line 8
use Scalar::Util 'weaken', 'reftype', 'blessed';
# spent 217µs making 1 call to Class::MOP::Method::BEGIN@8 # spent 180µs making 1 call to Exporter::import
9
1014µsour $VERSION = '1.11';
111106µs$VERSION = eval $VERSION;
# spent 11µs executing statements in string eval
1214µsour $AUTHORITY = 'cpan:STEVAN';
13
143212µs23.10ms
# spent 3.10ms (41µs+3.06) within Class::MOP::Method::BEGIN@14 which was called: # once (41µs+3.06ms) by base::import at line 14
use base 'Class::MOP::Object';
# spent 3.10ms making 1 call to Class::MOP::Method::BEGIN@14 # spent 3.06ms making 1 call to base::import, recursion: max depth 2, sum of overlapping time 3.06ms
15
16# NOTE:
17# if poked in the right way,
18# they should act like CODE refs.
1931.99ms2349µs
# spent 198µs (47+151) within Class::MOP::Method::BEGIN@19 which was called: # once (47µs+151µs) by base::import at line 19
use overload '&{}' => sub { $_[0]->body }, fallback => 1;
# spent 198µs making 1 call to Class::MOP::Method::BEGIN@19 # spent 151µs making 1 call to overload::import
20
21# construction
22
23
# spent 443ms (87.9+355) within Class::MOP::Method::wrap which was called 936 times, avg 474µs/call: # 296 times (28.4ms+21.0ms) by Class::MOP::Mixin::HasMethods::wrap_method_body at line 51 of Class/MOP/Mixin/HasMethods.pm, avg 167µs/call # 216 times (22.4ms+307ms) by Class::MOP::Method::Meta::wrap at line 58 of Class/MOP/Method/Meta.pm, avg 1.53ms/call # 212 times (17.7ms+13.7ms) by MooseX::Role::Parameterized::method at line 71 of MooseX/Role/Parameterized.pm, avg 148µs/call # 110 times (10.5ms+6.32ms) by Class::MOP::Method::Wrapped::wrap at line 92 of Class/MOP/Method/Wrapped.pm, avg 153µs/call # 57 times (4.92ms+3.46ms) by Class::MOP::Attribute::_process_accessors at line 312 of Class/MOP/Attribute.pm, avg 147µs/call # 45 times (3.96ms+3.57ms) by Moose::Meta::Method::Overridden::new at line 43 of Moose/Meta/Method/Overridden.pm, avg 168µs/call
sub wrap {
2493610.1ms my ( $class, @args ) = @_;
25
269364.56ms unshift @args, 'body' if @args % 2 == 1;
27
289368.30ms my %params = @args;
299362.60ms my $code = $params{body};
30
3193631.2ms18729.96ms if (blessed($code) && $code->isa(__PACKAGE__)) {
# spent 5.11ms making 936 calls to Scalar::Util::blessed, avg 5µs/call # spent 4.84ms making 936 calls to Scalar::Util::reftype, avg 5µs/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
419362.93ms ($params{package_name} && $params{name})
42 || confess "You must supply the package_name and name parameters";
43
4493613.1ms936341ms my $self = $class->_new(\%params);
# spent 270ms making 208 calls to Moose::Meta::Method::_new, avg 1.30ms/call # spent 36.5ms making 93 calls to Class::MOP::Method::_new, avg 392µs/call # spent 23.5ms making 423 calls to Moose::Meta::Role::Method::_new, avg 56µs/call # spent 5.10ms making 110 calls to Class::MOP::Method::Wrapped::_new, avg 46µs/call # spent 3.07ms making 45 calls to Moose::Meta::Method::Overridden::_new, avg 68µs/call # spent 2.84ms making 57 calls to Class::MOP::Method::Accessor::_new, avg 50µs/call
45
4693612.8ms5124.44ms weaken($self->{associated_metaclass}) if $self->{associated_metaclass};
# spent 4.44ms making 512 calls to Scalar::Util::weaken, avg 9µs/call
47
4893615.8ms return $self;
49}
50
51
# spent 45.6ms (3.73+41.9) within Class::MOP::Method::_new which was called 95 times, avg 480µs/call: # 93 times (3.66ms+32.8ms) by Class::MOP::Method::wrap at line 44, avg 392µs/call # 2 times (74µs+9.05ms) by Class::MOP::Method::Accessor::new at line 32 of Class/MOP/Method/Accessor.pm, avg 4.56ms/call
sub _new {
5295329µs my $class = shift;
53
5495971µs5241.9ms return Class::MOP::Class->initialize($class)->new_object(@_)
# spent 32.6ms making 26 calls to Class::MOP::Class::new_object, avg 1.25ms/call # spent 9.30ms making 26 calls to Class::MOP::Class::initialize, avg 358µs/call
55 if $class ne __PACKAGE__;
56
5769225µs my $params = @_ == 1 ? $_[0] : {@_};
58
59692.46ms 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
703685.13mssub associated_metaclass { shift->{'associated_metaclass'} }
71
72
# spent 96.1ms (72.8+23.3) within Class::MOP::Method::attach_to_class which was called 2877 times, avg 33µs/call: # 2877 times (72.8ms+23.3ms) by Class::MOP::Mixin::HasMethods::add_method at line 74 of Class/MOP/Mixin/HasMethods.pm, avg 33µs/call
sub attach_to_class {
7328779.74ms my ( $self, $class ) = @_;
74287710.9ms $self->{associated_metaclass} = $class;
75287779.4ms287723.3ms weaken($self->{associated_metaclass});
# spent 23.3ms making 2877 calls to Scalar::Util::weaken, avg 8µs/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
90220632.2mssub _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# We used to go through use Class::MOP::Class->clone_instance to do this, but
127# this was awfully slow. This method may be called a number of times when
128# classes are loaded (especially during Moose role application), so it is
129# worth optimizing. - DR
130
# spent 171ms (133+38.5) within Class::MOP::Method::clone which was called 2206 times, avg 78µs/call: # 2018 times (121ms+35.3ms) by Class::MOP::Mixin::HasMethods::add_method at line 67 of Class/MOP/Mixin/HasMethods.pm, avg 78µs/call # 178 times (10.8ms+2.97ms) by Moose::Meta::Role::Composite::add_method at line 83 of Moose/Meta/Role/Composite.pm, avg 77µs/call # 10 times (801µs+177µs) by Class::MOP::MiniTrait::apply at line 25 of Class/MOP/MiniTrait.pm, avg 98µs/call
sub clone {
13122066.75ms my $self = shift;
132
133220689.7ms220612.9ms my $clone = bless { %{$self}, @_ }, blessed($self);
# spent 12.9ms making 2206 calls to Scalar::Util::blessed, avg 6µs/call
134
135220623.2ms220625.5ms $clone->_set_original_method($self);
# spent 25.5ms making 2206 calls to Class::MOP::Method::_set_original_method, avg 12µs/call
136
137220625.0ms return $clone;
138}
139
140111µs1;
141
142__END__