← Index
NYTProf Performance Profile   « line view »
For script/ponapi
  Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:10 2016

Filename/usr/local/lib/perl/5.18.2/Class/MOP/Method.pm
StatementsExecuted 14043 statements in 33.4ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
7333310.7ms12.3msClass::MOP::Method::::cloneClass::MOP::Method::clone
479556.91ms26.7msClass::MOP::Method::::wrapClass::MOP::Method::wrap
1240113.67ms4.41msClass::MOP::Method::::attach_to_classClass::MOP::Method::attach_to_class
1072158735µs735µsClass::MOP::Method::::__ANON__[:16]Class::MOP::Method::__ANON__[:16]
9511408µs4.56msClass::MOP::Method::::_newClass::MOP::Method::_new
11110µs40µsClass::MOP::Method::::BEGIN@15Class::MOP::Method::BEGIN@15
1118µs17µsClass::MOP::Method::::BEGIN@4Class::MOP::Method::BEGIN@4
1117µs1.17msClass::MOP::Method::::BEGIN@9Class::MOP::Method::BEGIN@9
1116µs30µsClass::MOP::Method::::BEGIN@7Class::MOP::Method::BEGIN@7
1115µs8µsClass::MOP::Method::::BEGIN@5Class::MOP::Method::BEGIN@5
1113µs3µsClass::MOP::Method::::is_stubClass::MOP::Method::is_stub (xsub)
1112µs2µsClass::MOP::Method::::detach_from_classClass::MOP::Method::detach_from_class
0000s0sClass::MOP::Method::::__ANON__[:15]Class::MOP::Method::__ANON__[:15]
0000s0sClass::MOP::Method::::__ANON__[:17]Class::MOP::Method::__ANON__[:17]
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
1package Class::MOP::Method;
21400nsour $VERSION = '2.1604';
3
4220µs226µs
# spent 17µs (8+9) within Class::MOP::Method::BEGIN@4 which was called: # once (8µs+9µs) by parent::import at line 4
use strict;
# spent 17µs making 1 call to Class::MOP::Method::BEGIN@4 # spent 9µs making 1 call to strict::import
5220µs211µs
# spent 8µs (5+3) within Class::MOP::Method::BEGIN@5 which was called: # once (5µs+3µs) by parent::import at line 5
use warnings;
# spent 8µs making 1 call to Class::MOP::Method::BEGIN@5 # spent 3µs making 1 call to warnings::import
6
7220µs255µs
# spent 30µs (6+25) within Class::MOP::Method::BEGIN@7 which was called: # once (6µs+25µs) by parent::import at line 7
use Scalar::Util 'weaken', 'reftype', 'blessed';
# spent 30µs making 1 call to Class::MOP::Method::BEGIN@7 # spent 25µs making 1 call to Exporter::import
8
9274µs21.17ms
# spent 1.17ms (7µs+1.16) within Class::MOP::Method::BEGIN@9 which was called: # once (7µs+1.16ms) by parent::import at line 9
use parent 'Class::MOP::Object';
# spent 1.17ms making 1 call to Class::MOP::Method::BEGIN@9 # spent 1.16ms making 1 call to parent::import, recursion: max depth 1, sum of overlapping time 1.16ms
10
11# NOTE:
12# if poked in the right way,
13# they should act like CODE refs.
14use overload
15
# spent 40µs (10+30) within Class::MOP::Method::BEGIN@15 which was called: # once (10µs+30µs) by parent::import at line 18
'&{}' => sub { $_[0]->body },
1610726.37ms
# spent 735µs within Class::MOP::Method::__ANON__[/usr/local/lib/perl/5.18.2/Class/MOP/Method.pm:16] which was called 1072 times, avg 686ns/call: # 776 times (515µs+0s) by Class::MOP::Mixin::HasMethods::get_method at line 112 of Class/MOP/Mixin/HasMethods.pm, avg 664ns/call # 84 times (54µs+0s) by Class::MOP::Method::Inlined::can_be_inlined at line 37 of Class/MOP/Method/Inlined.pm, avg 637ns/call # 43 times (29µs+0s) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 672ns/call # 28 times (28µs+0s) by Class::MOP::Method::Inlined::_uninlined_body at line 14 of Class/MOP/Method/Inlined.pm, avg 1µs/call # 28 times (21µs+0s) by Moose::Meta::Class::_inline_BUILDARGS at line 327 of Moose/Meta/Class.pm, avg 736ns/call # 28 times (16µs+0s) by Class::MOP::Class::_inline_destructor at line 1494 of Class/MOP/Class.pm, avg 579ns/call # 26 times (20µs+0s) by Moose::Meta::Role::Application::ToClass::check_required_methods at line 69 of Moose/Meta/Role/Application/ToClass.pm, avg 762ns/call # 20 times (14µs+0s) by Moose::Meta::Role::Application::ToRole::apply_methods at line 86 of Moose/Meta/Role/Application/ToRole.pm, avg 710ns/call # 14 times (14µs+0s) by Moose::Meta::Role::Application::ToRole::check_required_methods at line 43 of Moose/Meta/Role/Application/ToRole.pm, avg 1µs/call # 11 times (13µs+0s) by Class::MOP::Mixin::HasMethods::has_method at line 100 of Class/MOP/Mixin/HasMethods.pm, avg 1µs/call # 5 times (6µs+0s) by Moose::Meta::Role::Application::ToClass::apply_methods at line 145 of Moose/Meta/Role/Application/ToClass.pm, avg 1µs/call # 5 times (3µs+0s) by Class::MOP::Class::__ANON__[/usr/local/lib/perl/5.18.2/Class/MOP/Class.pm:1082] at line 1057 of Class/MOP/Class.pm, avg 520ns/call # 2 times (2µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 22 of Class/MOP/Mixin/HasMethods.pm, avg 900ns/call # once (500ns+0s) by Moose::Meta::Attribute::_process_accessors at line 1035 of Moose/Meta/Attribute.pm # once (500ns+0s) by Moose::Meta::Attribute::_process_accessors at line 1023 of Moose/Meta/Attribute.pm
'bool' => sub { 1 },
17 '""' => sub { overload::StrVal($_[0]) },
182432µs270µs fallback => 1;
# spent 40µs making 1 call to Class::MOP::Method::BEGIN@15 # spent 30µs making 1 call to overload::import
19
20# construction
21
22
# spent 26.7ms (6.91+19.8) within Class::MOP::Method::wrap which was called 479 times, avg 56µs/call: # 221 times (2.64ms+1.89ms) by Class::MOP::Mixin::HasMethods::wrap_method_body at line 40 of Class/MOP/Mixin/HasMethods.pm, avg 20µs/call # 97 times (1.48ms+16.8ms) by Class::MOP::Method::Meta::wrap at line 58 of Class/MOP/Method/Meta.pm, avg 189µs/call # 70 times (1.71ms+432µs) by Class::MOP::Attribute::_process_accessors at line 390 of Class/MOP/Attribute.pm, avg 31µs/call # 66 times (827µs+338µs) by Class::MOP::Method::Wrapped::wrap at line 97 of Class/MOP/Method/Wrapped.pm, avg 18µs/call # 25 times (259µs+328µs) by Moose::Meta::Method::Overridden::new at line 45 of Moose/Meta/Method/Overridden.pm, avg 23µs/call
sub wrap {
23479579µs my ( $class, @args ) = @_;
24
25479326µs unshift @args, 'body' if @args % 2 == 1;
26
27479532µs my %params = @args;
28479124µs my $code = $params{body};
29
304791.85ms958353µs if (blessed($code) && $code->isa(__PACKAGE__)) {
# spent 194µs making 479 calls to Scalar::Util::blessed, avg 404ns/call # spent 160µs making 479 calls to Scalar::Util::reftype, avg 333ns/call
31 my $method = $code->clone;
32 delete $params{body};
33 Class::MOP::class_of($class)->rebless_instance($method, %params);
34 return $method;
35 }
36 elsif (!ref $code || 'CODE' ne reftype($code)) {
37 $class->_throw_exception( WrapTakesACodeRefToBless => params => \%params,
38 class => $class,
39 code => $code
40 );
41 }
42
43479177µs ($params{package_name} && $params{name})
44 || $class->_throw_exception( PackageNameAndNameParamsNotGivenToWrap => params => \%params,
45 class => $class,
46 code => $code
47 );
48
49479663µs47919.1ms my $self = $class->_new(\%params);
# spent 12.7ms making 113 calls to Moose::Meta::Method::_new, avg 113µs/call # spent 4.56ms making 95 calls to Class::MOP::Method::_new, avg 48µs/call # spent 902µs making 110 calls to Moose::Meta::Role::Method::_new, avg 8µs/call # spent 320µs making 70 calls to Class::MOP::Method::Accessor::_new, avg 5µs/call # spent 309µs making 25 calls to Moose::Meta::Method::Overridden::_new, avg 12µs/call # spent 289µs making 66 calls to Class::MOP::Method::Wrapped::_new, avg 4µs/call
50
514792.12ms388324µs weaken($self->{associated_metaclass}) if $self->{associated_metaclass};
# spent 324µs making 388 calls to Scalar::Util::weaken, avg 836ns/call
52
534791.20ms return $self;
54}
55
56
# spent 4.56ms (408µs+4.16) within Class::MOP::Method::_new which was called 95 times, avg 48µs/call: # 95 times (408µs+4.16ms) by Class::MOP::Method::wrap at line 49, avg 48µs/call
sub _new {
579523µs my $class = shift;
58
5995108µs484.16ms return Class::MOP::Class->initialize($class)->new_object(@_)
# spent 3.57ms making 24 calls to Class::MOP::Class::new_object, avg 149µs/call # spent 586µs making 24 calls to Class::MOP::Class::initialize, avg 24µs/call
60 if $class ne __PACKAGE__;
61
627122µs my $params = @_ == 1 ? $_[0] : {@_};
63
6471302µs return bless {
65 'body' => $params->{body},
66 'associated_metaclass' => $params->{associated_metaclass},
67 'package_name' => $params->{package_name},
68 'name' => $params->{name},
69 'original_method' => $params->{original_method},
70 } => $class;
71}
72
73## accessors
74
75196426µssub associated_metaclass { shift->{'associated_metaclass'} }
76
77
# spent 4.41ms (3.67+745µs) within Class::MOP::Method::attach_to_class which was called 1240 times, avg 4µs/call: # 1240 times (3.67ms+745µs) by Class::MOP::Mixin::HasMethods::add_method at line 63 of Class/MOP/Mixin/HasMethods.pm, avg 4µs/call
sub attach_to_class {
781240314µs my ( $self, $class ) = @_;
791240654µs $self->{associated_metaclass} = $class;
8012404.14ms1240745µs weaken($self->{associated_metaclass});
# spent 745µs making 1240 calls to Scalar::Util::weaken, avg 601ns/call
81}
82
83
# spent 2µs within Class::MOP::Method::detach_from_class which was called: # once (2µs+0s) by Class::MOP::Mixin::HasMethods::remove_method at line 146 of Class/MOP/Mixin/HasMethods.pm
sub detach_from_class {
841400ns my $self = shift;
8514µs delete $self->{associated_metaclass};
86}
87
88sub fully_qualified_name {
89 my $self = shift;
90 $self->package_name . '::' . $self->name;
91}
92
93sub original_method { (shift)->{'original_method'} }
94
957335.30mssub _set_original_method { $_[0]->{'original_method'} = $_[1] }
96
97# It's possible that this could cause a loop if there is a circular
98# reference in here. That shouldn't ever happen in normal
99# circumstances, since original method only gets set when clone is
100# called. We _could_ check for such a loop, but it'd involve some sort
101# of package-lexical variable, and wouldn't be terribly subclassable.
102sub original_package_name {
103 my $self = shift;
104
105 $self->original_method
106 ? $self->original_method->original_package_name
107 : $self->package_name;
108}
109
110sub original_name {
111 my $self = shift;
112
113 $self->original_method
114 ? $self->original_method->original_name
115 : $self->name;
116}
117
118sub original_fully_qualified_name {
119 my $self = shift;
120
121 $self->original_method
122 ? $self->original_method->original_fully_qualified_name
123 : $self->fully_qualified_name;
124}
125
126sub execute {
127 my $self = shift;
128 $self->body->(@_);
129}
130
131# We used to go through use Class::MOP::Class->clone_instance to do this, but
132# this was awfully slow. This method may be called a number of times when
133# classes are loaded (especially during Moose role application), so it is
134# worth optimizing. - DR
135
# spent 12.3ms (10.7+1.55) within Class::MOP::Method::clone which was called 733 times, avg 17µs/call: # 507 times (4.77ms+1.06ms) by Class::MOP::Mixin::HasMethods::add_method at line 56 of Class/MOP/Mixin/HasMethods.pm, avg 11µs/call # 213 times (5.81ms+458µs) by Moose::Meta::Role::Composite::add_method at line 104 of Moose/Meta/Role/Composite.pm, avg 29µs/call # 13 times (144µs+39µs) by Class::MOP::MiniTrait::apply at line 25 of Class/MOP/MiniTrait.pm, avg 14µs/call
sub clone {
136733124µs my $self = shift;
137
1387334.07ms733439µs my $clone = bless { %{$self}, @_ }, blessed($self);
# spent 439µs making 733 calls to Scalar::Util::blessed, avg 599ns/call
1397331.65ms733379µs weaken($clone->{associated_metaclass}) if $clone->{associated_metaclass};
# spent 379µs making 733 calls to Scalar::Util::weaken, avg 517ns/call
140
141733587µs733734µs $clone->_set_original_method($self);
# spent 734µs making 733 calls to Class::MOP::Method::_set_original_method, avg 1µs/call
142
1437331.15ms return $clone;
144}
145
14612µs1;
147
148# ABSTRACT: Method Meta Object
149
150__END__
 
# spent 3µs within Class::MOP::Method::is_stub which was called: # once (3µs+0s) by Moose::Meta::Attribute::_process_accessors at line 1035 of Moose/Meta/Attribute.pm
sub Class::MOP::Method::is_stub; # xsub