Profile of Class/MOP/Method/Inlined.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/Inlined.pm
Statements | Executed 764 statements in 3.01ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
86 | 2 | 1 | 2.04ms | 8.92ms | Class::MOP::Method::Inlined::::can_be_inlinedClass::MOP::Method::Inlined::can_be_inlined
28 | 1 | 1 | 332µs | 1.55ms | Class::MOP::Method::Inlined::::_uninlined_bodyClass::MOP::Method::Inlined::_uninlined_body
1 | 1 | 1 | 8µs | 17µs | Class::MOP::Method::Inlined::::BEGIN@4Class::MOP::Method::Inlined::BEGIN@4
1 | 1 | 1 | 6µs | 9µs | Class::MOP::Method::Inlined::::BEGIN@5Class::MOP::Method::Inlined::BEGIN@5
1 | 1 | 1 | 6µs | 24µs | Class::MOP::Method::Inlined::::BEGIN@7Class::MOP::Method::Inlined::BEGIN@7
1 | 1 | 1 | 5µs | 23µs | Class::MOP::Method::Inlined::::BEGIN@9Class::MOP::Method::Inlined::BEGIN@9

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::Inlined;
2 | 1 | 500ns |  |  | our $VERSION = '2.1604';
3 |  |  |  |  |
4 | 2 | 21µs | 2 | 26µs | # spent 17µs (8+9) within Class::MOP::Method::Inlined::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::Inlined::BEGIN@4 # spent 9µs making 1 call to strict::import
5 | 2 | 19µs | 2 | 12µs | # spent 9µs (6+3) within Class::MOP::Method::Inlined::BEGIN@5 which was called: # once (6µs+3µs) by parent::import at line 5 use warnings; # spent 9µs making 1 call to Class::MOP::Method::Inlined::BEGIN@5 # spent 3µs making 1 call to warnings::import
6 |  |  |  |  |
7 | 2 | 20µs | 2 | 42µs | # spent 24µs (6+18) within Class::MOP::Method::Inlined::BEGIN@7 which was called: # once (6µs+18µs) by parent::import at line 7 use Scalar::Util 'refaddr'; # spent 24µs making 1 call to Class::MOP::Method::Inlined::BEGIN@7 # spent 18µs making 1 call to Exporter::import
8 |  |  |  |  |
9 | 2 | 290µs | 2 | 23µs | # spent 23µs (5+18) within Class::MOP::Method::Inlined::BEGIN@9 which was called: # once (5µs+18µs) by parent::import at line 9 use parent 'Class::MOP::Method::Generated'; # spent 23µs making 1 call to Class::MOP::Method::Inlined::BEGIN@9 # spent 18µs making 1 call to parent::import, recursion: max depth 1, sum of overlapping time 18µs
10 |  |  |  |  |
11 |  |  |  |  | # spent 1.55ms (332µs+1.22) within Class::MOP::Method::Inlined::_uninlined_body which was called 28 times, avg 55µs/call: # 28 times (332µs+1.22ms) by Class::MOP::Method::Inlined::can_be_inlined at line 73, avg 55µs/call sub _uninlined_body {
12 | 28 | 8µs |  |  | my $self = shift;
13 |  |  |  |  |
14 | 28 | 132µs | 112 | 1.16ms | my $super_method # spent 1.10ms making 28 calls to Class::MOP::Class::find_next_method_by_name, avg 39µs/call # spent 28µs making 28 calls to Class::MOP::Method::__ANON__[Class/MOP/Method.pm:16], avg 1µs/call # spent 26µs making 28 calls to Class::MOP::Method::associated_metaclass, avg 914ns/call # spent 10µs making 28 calls to Class::MOP::Method::name, avg 361ns/call
15 |  |  |  |  | = $self->associated_metaclass->find_next_method_by_name( $self->name )
16 |  |  |  |  | or return;
17 |  |  |  |  |
18 | 28 | 90µs | 28 | 33µs | if ( $super_method->isa(__PACKAGE__) ) { # spent 33µs making 28 calls to UNIVERSAL::isa, avg 1µs/call
19 |  |  |  |  | return $super_method->_uninlined_body;
20 |  |  |  |  | }
21 |  |  |  |  | else {
22 | 28 | 116µs | 28 | 18µs | return $super_method->body; # spent 18µs making 28 calls to Class::MOP::Method::body, avg 657ns/call
23 |  |  |  |  | }
24 |  |  |  |  | }
25 |  |  |  |  |
26 |  |  |  |  | # spent 8.92ms (2.04+6.88) within Class::MOP::Method::Inlined::can_be_inlined which was called 86 times, avg 104µs/call: # 58 times (1.64ms+5.61ms) by Class::MOP::Class::_inline_constructor at line 1466 of Class/MOP/Class.pm, avg 125µs/call # 28 times (398µs+1.27ms) by Class::MOP::Class::_inline_destructor at line 1508 of Class/MOP/Class.pm, avg 60µs/call sub can_be_inlined {
27 | 86 | 25µs |  |  | my $self = shift;
28 | 86 | 92µs | 86 | 75µs | my $metaclass = $self->associated_metaclass; # spent 51µs making 56 calls to Class::MOP::Method::associated_metaclass, avg 914ns/call # spent 24µs making 30 calls to Class::MOP::Method::Constructor::associated_metaclass, avg 807ns/call
29 | 86 | 271µs | 86 | 78µs | my $class = $metaclass->name; # spent 78µs making 86 calls to Class::MOP::Package::name, avg 907ns/call
30 |  |  |  |  |
31 |  |  |  |  | # If we don't find an inherited method, this is a rather weird
32 |  |  |  |  | # case where we have no method in the inheritance chain even
33 |  |  |  |  | # though we're expecting one to be there
34 | 86 | 320µs | 172 | 4.74ms | my $inherited_method # spent 4.69ms making 86 calls to Class::MOP::Class::find_next_method_by_name, avg 55µs/call # spent 45µs making 86 calls to Class::MOP::Method::name, avg 527ns/call
35 |  |  |  |  | = $metaclass->find_next_method_by_name( $self->name );
36 |  |  |  |  |
37 | 86 | 393µs | 168 | 200µs | if ( $inherited_method # spent 146µs making 84 calls to UNIVERSAL::isa, avg 2µs/call # spent 54µs making 84 calls to Class::MOP::Method::__ANON__[Class/MOP/Method.pm:16], avg 637ns/call
38 |  |  |  |  | && $inherited_method->isa('Class::MOP::Method::Wrapped') ) {
39 |  |  |  |  | warn "Not inlining '"
40 |  |  |  |  | . $self->name
41 |  |  |  |  | . "' for $class since it "
42 |  |  |  |  | . "has method modifiers which would be lost if it were inlined\n";
43 |  |  |  |  |
44 |  |  |  |  | return 0;
45 |  |  |  |  | }
46 |  |  |  |  |
47 | 86 | 420µs | 86 | 72µs | my $expected_class = $self->_expected_method_class # spent 72µs making 86 calls to Class::MOP::Method::Inlined::_expected_method_class, avg 843ns/call
48 |  |  |  |  | or return 1;
49 |  |  |  |  |
50 |  |  |  |  | # if we are shadowing a method we first verify that it is
51 |  |  |  |  | # compatible with the definition we are replacing it with
52 | 28 | 170µs | 56 | 47µs | my $expected_method = $expected_class->can( $self->name ); # spent 37µs making 28 calls to UNIVERSAL::can, avg 1µs/call # spent 10µs making 28 calls to Class::MOP::Method::name, avg 354ns/call
53 |  |  |  |  |
54 | 28 | 6µs |  |  | if ( ! $expected_method ) {
55 |  |  |  |  | warn "Not inlining '"
56 |  |  |  |  | . $self->name
57 |  |  |  |  | . "' for $class since ${expected_class}::"
58 |  |  |  |  | . $self->name
59 |  |  |  |  | . " is not defined\n";
60 |  |  |  |  |
61 |  |  |  |  | return 0;
62 |  |  |  |  | }
63 |  |  |  |  |
64 | 28 | 267µs | 56 | 62µs | my $actual_method = $class->can( $self->name ) # spent 54µs making 28 calls to UNIVERSAL::can, avg 2µs/call # spent 8µs making 28 calls to Class::MOP::Method::name, avg 300ns/call
65 |  |  |  |  | or return 1;
66 |  |  |  |  |
67 |  |  |  |  | # the method is what we wanted (probably Moose::Object::new)
68 | 28 | 178µs | 56 | 42µs | return 1 # spent 42µs making 56 calls to Scalar::Util::refaddr, avg 741ns/call
69 |  |  |  |  | if refaddr($expected_method) == refaddr($actual_method);
70 |  |  |  |  |
71 |  |  |  |  | # otherwise we have to check that the actual method is an inlined
72 |  |  |  |  | # version of what we're expecting
73 | 14 | 167µs | 70 | 1.57ms | if ( $inherited_method->isa(__PACKAGE__) ) { # spent 1.55ms making 28 calls to Class::MOP::Method::Inlined::_uninlined_body, avg 55µs/call # spent 10µs making 28 calls to Scalar::Util::refaddr, avg 354ns/call # spent 8µs making 14 calls to UNIVERSAL::isa, avg 571ns/call
74 |  |  |  |  | if ( $inherited_method->_uninlined_body
75 |  |  |  |  | && refaddr( $inherited_method->_uninlined_body )
76 |  |  |  |  | == refaddr($expected_method) ) {
77 |  |  |  |  | return 1;
78 |  |  |  |  | }
79 |  |  |  |  | }
80 |  |  |  |  | elsif ( refaddr( $inherited_method->body )
81 |  |  |  |  | == refaddr($expected_method) ) {
82 |  |  |  |  | return 1;
83 |  |  |  |  | }
84 |  |  |  |  |
85 |  |  |  |  | my $warning
86 |  |  |  |  | = "Not inlining '"
87 |  |  |  |  | . $self->name
88 |  |  |  |  | . "' for $class since it is not"
89 |  |  |  |  | . " inheriting the default ${expected_class}::"
90 |  |  |  |  | . $self->name . "\n";
91 |  |  |  |  |
92 |  |  |  |  | if ( $self->isa("Class::MOP::Method::Constructor") ) {
93 |  |  |  |  |
94 |  |  |  |  | # FIXME kludge, refactor warning generation to a method
95 |  |  |  |  | $warning
96 |  |  |  |  | .= "If you are certain you don't need to inline your"
97 |  |  |  |  | . " constructor, specify inline_constructor => 0 in your"
98 |  |  |  |  | . " call to $class->meta->make_immutable\n";
99 |  |  |  |  | }
100 |  |  |  |  |
101 |  |  |  |  | warn $warning;
102 |  |  |  |  |
103 |  |  |  |  | return 0;
104 |  |  |  |  | }
105 |  |  |  |  |
106 | 1 | 2µs |  |  | 1;
107 |  |  |  |  |
108 |  |  |  |  | # ABSTRACT: Method base class for methods which have been inlined
109 |  |  |  |  |
110 |  |  |  |  | __END__