Profile of Class/MOP/Method.pm

← 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
Statements | Executed 14043 statements in 33.4ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
733 | 3 | 3 | 10.7ms | 12.3ms | Class::MOP::Method::::cloneClass::MOP::Method::clone
479 | 5 | 5 | 6.91ms | 26.7ms | Class::MOP::Method::::wrapClass::MOP::Method::wrap
1240 | 1 | 1 | 3.67ms | 4.41ms | Class::MOP::Method::::attach_to_classClass::MOP::Method::attach_to_class
1072 | 15 | 8 | 735µs | 735µs | Class::MOP::Method::::__ANON__[:16]Class::MOP::Method::__ANON__[:16]
95 | 1 | 1 | 408µs | 4.56ms | Class::MOP::Method::::_newClass::MOP::Method::_new
1 | 1 | 1 | 10µs | 40µs | Class::MOP::Method::::BEGIN@15Class::MOP::Method::BEGIN@15
1 | 1 | 1 | 8µs | 17µs | Class::MOP::Method::::BEGIN@4Class::MOP::Method::BEGIN@4
1 | 1 | 1 | 7µs | 1.17ms | Class::MOP::Method::::BEGIN@9Class::MOP::Method::BEGIN@9
1 | 1 | 1 | 6µs | 30µs | Class::MOP::Method::::BEGIN@7Class::MOP::Method::BEGIN@7
1 | 1 | 1 | 5µs | 8µs | Class::MOP::Method::::BEGIN@5Class::MOP::Method::BEGIN@5
1 | 1 | 1 | 3µs | 3µs | Class::MOP::Method::::is_stubClass::MOP::Method::is_stub (xsub)
1 | 1 | 1 | 2µs | 2µs | Class::MOP::Method::::detach_from_classClass::MOP::Method::detach_from_class
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::::__ANON__[:15]Class::MOP::Method::__ANON__[:15]
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::::__ANON__[:17]Class::MOP::Method::__ANON__[:17]
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::::executeClass::MOP::Method::execute
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::::fully_qualified_nameClass::MOP::Method::fully_qualified_name
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::::original_fully_qualified_nameClass::MOP::Method::original_fully_qualified_name
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::::original_nameClass::MOP::Method::original_name
0 | 0 | 0 | 0s | 0s | Class::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 |  |  |  |  | package Class::MOP::Method;
2 | 1 | 400ns |  |  | our $VERSION = '2.1604';
3 |  |  |  |  |
4 | 2 | 20µs | 2 | 26µ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
5 | 2 | 20µs | 2 | 11µ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 |  |  |  |  |
7 | 2 | 20µs | 2 | 55µ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 |  |  |  |  |
9 | 2 | 74µs | 2 | 1.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.
14 |  |  |  |  | use 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 },
16 | 1072 | 6.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]) },
18 | 2 | 432µs | 2 | 70µ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 {
23 | 479 | 579µs |  |  | my ( $class, @args ) = @_;
24 |  |  |  |  |
25 | 479 | 326µs |  |  | unshift @args, 'body' if @args % 2 == 1;
26 |  |  |  |  |
27 | 479 | 532µs |  |  | my %params = @args;
28 | 479 | 124µs |  |  | my $code = $params{body};
29 |  |  |  |  |
30 | 479 | 1.85ms | 958 | 353µ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 |  |  |  |  |
43 | 479 | 177µs |  |  | ($params{package_name} && $params{name})
44 |  |  |  |  | || $class->_throw_exception( PackageNameAndNameParamsNotGivenToWrap => params => \%params,
45 |  |  |  |  | class => $class,
46 |  |  |  |  | code => $code
47 |  |  |  |  | );
48 |  |  |  |  |
49 | 479 | 663µs | 479 | 19.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 |  |  |  |  |
51 | 479 | 2.12ms | 388 | 324µs | weaken($self->{associated_metaclass}) if $self->{associated_metaclass}; # spent 324µs making 388 calls to Scalar::Util::weaken, avg 836ns/call
52 |  |  |  |  |
53 | 479 | 1.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 {
57 | 95 | 23µs |  |  | my $class = shift;
58 |  |  |  |  |
59 | 95 | 108µs | 48 | 4.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 |  |  |  |  |
62 | 71 | 22µs |  |  | my $params = @_ == 1 ? $_[0] : {@_};
63 |  |  |  |  |
64 | 71 | 302µ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 |  |  |  |  |
75 | 196 | 426µs |  |  | sub 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 {
78 | 1240 | 314µs |  |  | my ( $self, $class ) = @_;
79 | 1240 | 654µs |  |  | $self->{associated_metaclass} = $class;
80 | 1240 | 4.14ms | 1240 | 745µ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 {
84 | 1 | 400ns |  |  | my $self = shift;
85 | 1 | 4µs |  |  | delete $self->{associated_metaclass};
86 |  |  |  |  | }
87 |  |  |  |  |
88 |  |  |  |  | sub fully_qualified_name {
89 |  |  |  |  | my $self = shift;
90 |  |  |  |  | $self->package_name . '::' . $self->name;
91 |  |  |  |  | }
92 |  |  |  |  |
93 |  |  |  |  | sub original_method { (shift)->{'original_method'} }
94 |  |  |  |  |
95 | 733 | 5.30ms |  |  | sub _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.
102 |  |  |  |  | sub 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 |  |  |  |  |
110 |  |  |  |  | sub original_name {
111 |  |  |  |  | my $self = shift;
112 |  |  |  |  |
113 |  |  |  |  | $self->original_method
114 |  |  |  |  | ? $self->original_method->original_name
115 |  |  |  |  | : $self->name;
116 |  |  |  |  | }
117 |  |  |  |  |
118 |  |  |  |  | sub 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 |  |  |  |  |
126 |  |  |  |  | sub 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 {
136 | 733 | 124µs |  |  | my $self = shift;
137 |  |  |  |  |
138 | 733 | 4.07ms | 733 | 439µs | my $clone = bless { %{$self}, @_ }, blessed($self); # spent 439µs making 733 calls to Scalar::Util::blessed, avg 599ns/call
139 | 733 | 1.65ms | 733 | 379µs | weaken($clone->{associated_metaclass}) if $clone->{associated_metaclass}; # spent 379µs making 733 calls to Scalar::Util::weaken, avg 517ns/call
140 |  |  |  |  |
141 | 733 | 587µs | 733 | 734µs | $clone->_set_original_method($self); # spent 734µs making 733 calls to Class::MOP::Method::_set_original_method, avg 1µs/call
142 |  |  |  |  |
143 | 733 | 1.15ms |  |  | return $clone;
144 |  |  |  |  | }
145 |  |  |  |  |
146 | 1 | 2µs |  |  | 1;
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