← 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
StatementsExecuted 764 statements in 3.01ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
86212.04ms8.92msClass::MOP::Method::Inlined::::can_be_inlinedClass::MOP::Method::Inlined::can_be_inlined
2811332µs1.55msClass::MOP::Method::Inlined::::_uninlined_bodyClass::MOP::Method::Inlined::_uninlined_body
1118µs17µsClass::MOP::Method::Inlined::::BEGIN@4Class::MOP::Method::Inlined::BEGIN@4
1116µs9µsClass::MOP::Method::Inlined::::BEGIN@5Class::MOP::Method::Inlined::BEGIN@5
1116µs24µsClass::MOP::Method::Inlined::::BEGIN@7Class::MOP::Method::Inlined::BEGIN@7
1115µs23µsClass::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
1package Class::MOP::Method::Inlined;
21500nsour $VERSION = '2.1604';
3
4221µs226µ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
5219µs212µ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
7220µs242µ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
92290µs223µ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 {
12288µs my $self = shift;
13
1428132µs1121.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
182890µs2833µ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 {
2228116µs2818µ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 {
278625µs my $self = shift;
288692µs8675µ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
2986271µs8678µ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
3486320µs1724.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
3786393µs168200µ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
4786420µs8672µ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
5228170µs5647µ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
54286µ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
6428267µs5662µ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)
6828178µs5642µ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
7314167µs701.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
10612µs1;
107
108# ABSTRACT: Method base class for methods which have been inlined
109
110__END__