← Index
NYTProf Performance Profile   « line view »
For /home/ss5/perl5/perlbrew/perls/perl-5.22.0/bin/benchmarkanything-storage
  Run on Mon Jan 29 16:55:34 2018
Reported on Mon Jan 29 16:57:06 2018

Filename/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Class/MOP/Method/Inlined.pm
StatementsExecuted 206 statements in 730µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
3221365µs2.10msClass::MOP::Method::Inlined::::can_be_inlinedClass::MOP::Method::Inlined::can_be_inlined
1118µs9µsClass::MOP::Method::Inlined::::BEGIN@4Class::MOP::Method::Inlined::BEGIN@4
1117µs33µsClass::MOP::Method::Inlined::::BEGIN@9Class::MOP::Method::Inlined::BEGIN@9
1114µs22µsClass::MOP::Method::Inlined::::BEGIN@7Class::MOP::Method::Inlined::BEGIN@7
1114µs7µsClass::MOP::Method::Inlined::::BEGIN@5Class::MOP::Method::Inlined::BEGIN@5
0000s0sClass::MOP::Method::Inlined::::_uninlined_bodyClass::MOP::Method::Inlined::_uninlined_body
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;
21200nsour $VERSION = '2.1605';
3
4212µs210µs
# spent 9µs (8+1) within Class::MOP::Method::Inlined::BEGIN@4 which was called: # once (8µs+1µs) by parent::import at line 4
use strict;
# spent 9µs making 1 call to Class::MOP::Method::Inlined::BEGIN@4 # spent 1µs making 1 call to strict::import
5211µs210µs
# spent 7µs (4+3) within Class::MOP::Method::Inlined::BEGIN@5 which was called: # once (4µs+3µs) by parent::import at line 5
use warnings;
# spent 7µs making 1 call to Class::MOP::Method::Inlined::BEGIN@5 # spent 3µs making 1 call to warnings::import
6
7275µs239µs
# spent 22µs (4+17) within Class::MOP::Method::Inlined::BEGIN@7 which was called: # once (4µs+17µs) by parent::import at line 7
use Scalar::Util 'refaddr';
# spent 22µs making 1 call to Class::MOP::Method::Inlined::BEGIN@7 # spent 17µs making 1 call to Exporter::import
8
92219µs233µs
# spent 33µs (7+26) within Class::MOP::Method::Inlined::BEGIN@9 which was called: # once (7µs+26µs) by parent::import at line 9
use parent 'Class::MOP::Method::Generated';
# spent 33µs making 1 call to Class::MOP::Method::Inlined::BEGIN@9 # spent 26µs making 1 call to parent::import, recursion: max depth 1, sum of overlapping time 26µs
10
11sub _uninlined_body {
12 my $self = shift;
13
14 my $super_method
15 = $self->associated_metaclass->find_next_method_by_name( $self->name )
16 or return;
17
18 if ( $super_method->isa(__PACKAGE__) ) {
19 return $super_method->_uninlined_body;
20 }
21 else {
22 return $super_method->body;
23 }
24}
25
26
# spent 2.10ms (365µs+1.74) within Class::MOP::Method::Inlined::can_be_inlined which was called 32 times, avg 66µs/call: # 31 times (352µs+1.68ms) by Class::MOP::Class::_inline_constructor at line 1466 of Class/MOP/Class.pm, avg 65µs/call # once (13µs+58µs) by Class::MOP::Class::_inline_destructor at line 1508 of Class/MOP/Class.pm
sub can_be_inlined {
27328µs my $self = shift;
283223µs3219µs my $metaclass = $self->associated_metaclass;
# spent 18µs making 30 calls to Class::MOP::Method::Constructor::associated_metaclass, avg 587ns/call # spent 1µs making 2 calls to Class::MOP::Method::associated_metaclass, avg 650ns/call
293263µs3218µs my $class = $metaclass->name;
# spent 18µs making 32 calls to Class::MOP::Package::name, avg 575ns/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
343284µs641.63ms my $inherited_method
# spent 1.62ms making 32 calls to Class::MOP::Class::find_next_method_by_name, avg 51µs/call # spent 11µs making 32 calls to Class::MOP::Method::name, avg 334ns/call
35 = $metaclass->find_next_method_by_name( $self->name );
36
3732102µs6054µs if ( $inherited_method
# spent 40µs making 30 calls to UNIVERSAL::isa, avg 1µs/call # spent 15µs making 30 calls to Class::MOP::Method::__ANON__[Class/MOP/Method.pm:16], avg 490ns/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
4732112µs3212µs my $expected_class = $self->_expected_method_class
# spent 12µs making 32 calls to Class::MOP::Method::Inlined::_expected_method_class, avg 391ns/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
5215µs21µs my $expected_method = $expected_class->can( $self->name );
# spent 1µs making 1 call to UNIVERSAL::can # spent 300ns making 1 call to Class::MOP::Method::name
53
541200ns 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
6416µs21µs my $actual_method = $class->can( $self->name )
# spent 1µs making 1 call to UNIVERSAL::can # spent 200ns making 1 call to Class::MOP::Method::name
65 or return 1;
66
67 # the method is what we wanted (probably Moose::Object::new)
6815µs2400ns return 1
# spent 400ns making 2 calls to Scalar::Util::refaddr, avg 200ns/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 if ( $inherited_method->isa(__PACKAGE__) ) {
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__