← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:39:01 2010
Reported on Wed Nov 17 22:05:15 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 15534 statements in 209ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
10653365.6ms83.6msClass::MOP::Method::::cloneClass::MOP::Method::clone
5325551.7ms263msClass::MOP::Method::::wrapClass::MOP::Method::wrap
16191142.7ms53.0msClass::MOP::Method::::attach_to_classClass::MOP::Method::attach_to_class
94223.90ms45.5msClass::MOP::Method::::_newClass::MOP::Method::_new
11168µs85µsClass::MOP::Method::::BEGIN@4Class::MOP::Method::BEGIN@4
11154µs242µsClass::MOP::Method::::BEGIN@8Class::MOP::Method::BEGIN@8
11149µs205µsClass::MOP::Method::::BEGIN@19Class::MOP::Method::BEGIN@19
11143µs213µsClass::MOP::Method::::BEGIN@7Class::MOP::Method::BEGIN@7
11141µs3.18msClass::MOP::Method::::BEGIN@14Class::MOP::Method::BEGIN@14
11138µs105µsClass::MOP::Method::::BEGIN@5Class::MOP::Method::BEGIN@5
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
4393µs2102µs
# spent 85µs (68+17) within Class::MOP::Method::BEGIN@4 which was called: # once (68µs+17µs) by base::import at line 4
use strict;
# spent 85µs making 1 call to Class::MOP::Method::BEGIN@4 # spent 17µs making 1 call to strict::import
5398µs2173µs
# spent 105µs (38+67) within Class::MOP::Method::BEGIN@5 which was called: # once (38µs+67µs) by base::import at line 5
use warnings;
# spent 105µs making 1 call to Class::MOP::Method::BEGIN@5 # spent 67µs making 1 call to warnings::import
6
73130µs2382µs
# spent 213µs (43+169) within Class::MOP::Method::BEGIN@7 which was called: # once (43µs+169µs) by base::import at line 7
use Carp 'confess';
# spent 213µs making 1 call to Class::MOP::Method::BEGIN@7 # spent 169µs making 1 call to Exporter::import
83221µs2429µs
# spent 242µs (54+188) within Class::MOP::Method::BEGIN@8 which was called: # once (54µs+188µs) by base::import at line 8
use Scalar::Util 'weaken', 'reftype', 'blessed';
# spent 242µs making 1 call to Class::MOP::Method::BEGIN@8 # spent 188µs making 1 call to Exporter::import
9
1014µsour $VERSION = '1.11';
11162µs$VERSION = eval $VERSION;
# spent 14µs executing statements in string eval
1215µsour $AUTHORITY = 'cpan:STEVAN';
13
143208µs23.18ms
# spent 3.18ms (41µs+3.14) within Class::MOP::Method::BEGIN@14 which was called: # once (41µs+3.14ms) by base::import at line 14
use base 'Class::MOP::Object';
# spent 3.18ms making 1 call to Class::MOP::Method::BEGIN@14 # spent 3.14ms making 1 call to base::import, recursion: max depth 1, sum of overlapping time 3.14ms
15
16# NOTE:
17# if poked in the right way,
18# they should act like CODE refs.
1931.93ms2362µs
# spent 205µs (49+157) within Class::MOP::Method::BEGIN@19 which was called: # once (49µs+157µs) by base::import at line 19
use overload '&{}' => sub { $_[0]->body }, fallback => 1;
# spent 205µs making 1 call to Class::MOP::Method::BEGIN@19 # spent 156µs making 1 call to overload::import
20
21# construction
22
23
# spent 263ms (51.7+212) within Class::MOP::Method::wrap which was called 532 times, avg 495µs/call: # 257 times (24.9ms+20.1ms) by Class::MOP::Mixin::HasMethods::wrap_method_body at line 51 of Class/MOP/Mixin/HasMethods.pm, avg 175µs/call # 126 times (13.2ms+181ms) by Class::MOP::Method::Meta::wrap at line 58 of Class/MOP/Method/Meta.pm, avg 1.54ms/call # 75 times (7.13ms+4.95ms) by Class::MOP::Method::Wrapped::wrap at line 92 of Class/MOP/Method/Wrapped.pm, avg 161µs/call # 57 times (5.02ms+3.54ms) by Class::MOP::Attribute::_process_accessors at line 312 of Class/MOP/Attribute.pm, avg 150µs/call # 17 times (1.45ms+1.87ms) by Moose::Meta::Method::Overridden::new at line 43 of Moose/Meta/Method/Overridden.pm, avg 195µs/call
sub wrap {
24478859.9ms my ( $class, @args ) = @_;
25
26 unshift @args, 'body' if @args % 2 == 1;
27
28 my %params = @args;
29 my $code = $params{body};
30
3110645.76ms if (blessed($code) && $code->isa(__PACKAGE__)) {
# spent 2.91ms making 532 calls to Scalar::Util::blessed, avg 5µs/call # spent 2.85ms making 532 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
41 ($params{package_name} && $params{name})
42 || confess "You must supply the package_name and name parameters";
43
44532203ms my $self = $class->_new(\%params);
# spent 148ms making 147 calls to Moose::Meta::Method::_new, avg 1.01ms/call # spent 36.4ms making 92 calls to Class::MOP::Method::_new, avg 396µs/call # spent 9.33ms making 144 calls to Moose::Meta::Role::Method::_new, avg 65µs/call # spent 4.12ms making 75 calls to Class::MOP::Method::Wrapped::_new, avg 55µs/call # spent 2.89ms making 57 calls to Class::MOP::Method::Accessor::_new, avg 51µs/call # spent 1.69ms making 17 calls to Moose::Meta::Method::Overridden::_new, avg 100µs/call
45
463833.21ms weaken($self->{associated_metaclass}) if $self->{associated_metaclass};
# spent 3.21ms making 383 calls to Scalar::Util::weaken, avg 8µs/call
47
48 return $self;
49}
50
51
# spent 45.5ms (3.90+41.6) within Class::MOP::Method::_new which was called 94 times, avg 484µs/call: # 92 times (3.82ms+32.6ms) by Class::MOP::Method::wrap at line 44, avg 396µs/call # 2 times (73µs+8.99ms) by Class::MOP::Method::Accessor::new at line 32 of Class/MOP/Method/Accessor.pm, avg 4.53ms/call
sub _new {
523244.10ms my $class = shift;
53
545241.6ms return Class::MOP::Class->initialize($class)->new_object(@_)
# spent 32.3ms making 26 calls to Class::MOP::Class::new_object, avg 1.24ms/call # spent 9.32ms making 26 calls to Class::MOP::Class::initialize, avg 358µs/call
55 if $class ne __PACKAGE__;
56
57 my $params = @_ == 1 ? $_[0] : {@_};
58
59 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
702183.11mssub associated_metaclass { shift->{'associated_metaclass'} }
71
72
# spent 53.0ms (42.7+10.3) within Class::MOP::Method::attach_to_class which was called 1619 times, avg 33µs/call: # 1619 times (42.7ms+10.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 {
73485753.8ms my ( $self, $class ) = @_;
74 $self->{associated_metaclass} = $class;
75161910.3ms weaken($self->{associated_metaclass});
# spent 10.3ms making 1619 calls to Scalar::Util::weaken, avg 6µ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
90106515.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 83.6ms (65.6+18.0) within Class::MOP::Method::clone which was called 1065 times, avg 79µs/call: # 876 times (54.8ms+15.0ms) by Class::MOP::Mixin::HasMethods::add_method at line 67 of Class/MOP/Mixin/HasMethods.pm, avg 80µs/call # 179 times (10.1ms+2.90ms) by Moose::Meta::Role::Composite::add_method at line 83 of Moose/Meta/Role/Composite.pm, avg 72µs/call # 10 times (732µs+166µs) by Class::MOP::MiniTrait::apply at line 25 of Class/MOP/MiniTrait.pm, avg 90µs/call
sub clone {
131426070.7ms my $self = shift;
132
13310656.16ms my $clone = bless { %{$self}, @_ }, blessed($self);
# spent 6.16ms making 1065 calls to Scalar::Util::blessed, avg 6µs/call
134
135106511.9ms $clone->_set_original_method($self);
# spent 11.9ms making 1065 calls to Class::MOP::Method::_set_original_method, avg 11µs/call
136
137 return $clone;
138}
139
140115µs1;
141
142__END__