← Index
NYTProf Performance Profile   « block view • line view • sub view »
For bin/pan_genome_post_analysis
  Run on Fri Mar 27 11:43:32 2015
Reported on Fri Mar 27 11:45:34 2015

Filename/Users/ap13/perl5/lib/perl5/darwin-2level/Class/MOP/Method/Inlined.pm
StatementsExecuted 446 statements in 2.58ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
62211.60ms6.90msClass::MOP::Method::Inlined::::can_be_inlinedClass::MOP::Method::Inlined::can_be_inlined
11119µs37µsClass::MOP::Method::Inlined::::BEGIN@4Class::MOP::Method::Inlined::BEGIN@4
11112µs56µsClass::MOP::Method::Inlined::::BEGIN@9Class::MOP::Method::Inlined::BEGIN@9
11111µs18µsClass::MOP::Method::Inlined::::BEGIN@5Class::MOP::Method::Inlined::BEGIN@5
11111µs44µsClass::MOP::Method::Inlined::::BEGIN@7Class::MOP::Method::Inlined::BEGIN@7
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;
211µsour $VERSION = '2.1403';
3
4236µs256µs
# spent 37µs (19+19) within Class::MOP::Method::Inlined::BEGIN@4 which was called: # once (19µs+19µs) by parent::import at line 4
use strict;
# spent 37µs making 1 call to Class::MOP::Method::Inlined::BEGIN@4 # spent 19µs making 1 call to strict::import
5237µs224µs
# spent 18µs (11+6) within Class::MOP::Method::Inlined::BEGIN@5 which was called: # once (11µs+6µs) by parent::import at line 5
use warnings;
# spent 18µs making 1 call to Class::MOP::Method::Inlined::BEGIN@5 # spent 6µs making 1 call to warnings::import
6
7237µs277µs
# spent 44µs (11+33) within Class::MOP::Method::Inlined::BEGIN@7 which was called: # once (11µs+33µs) by parent::import at line 7
use Scalar::Util 'refaddr';
# spent 44µs making 1 call to Class::MOP::Method::Inlined::BEGIN@7 # spent 33µs making 1 call to Exporter::import
8
92577µs256µs
# spent 56µs (12+44) within Class::MOP::Method::Inlined::BEGIN@9 which was called: # once (12µs+44µs) by parent::import at line 9
use parent 'Class::MOP::Method::Generated';
# spent 56µs making 1 call to Class::MOP::Method::Inlined::BEGIN@9 # spent 44µs making 1 call to parent::import, recursion: max depth 1, sum of overlapping time 44µ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 6.90ms (1.60+5.30) within Class::MOP::Method::Inlined::can_be_inlined which was called 62 times, avg 111µs/call: # 46 times (1.32ms+4.43ms) by Class::MOP::Class::_inline_constructor at line 1466 of Class/MOP/Class.pm, avg 125µs/call # 16 times (273µs+872µs) by Class::MOP::Class::_inline_destructor at line 1508 of Class/MOP/Class.pm, avg 72µs/call
sub can_be_inlined {
274361.88ms my $self = shift;
286289µs my $metaclass = $self->associated_metaclass;
# spent 55µs making 32 calls to Class::MOP::Method::associated_metaclass, avg 2µs/call # spent 34µs making 30 calls to Class::MOP::Method::Constructor::associated_metaclass, avg 1µs/call
296269µs my $class = $metaclass->name;
# spent 69µs making 62 calls to Class::MOP::Package::name, avg 1µs/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
341244.83ms my $inherited_method
# spent 4.78ms making 62 calls to Class::MOP::Class::find_next_method_by_name, avg 77µs/call # spent 53µs making 62 calls to Class::MOP::Method::name, avg 860ns/call
35 = $metaclass->find_next_method_by_name( $self->name );
36
3760134µs if ( $inherited_method
# spent 134µs making 60 calls to UNIVERSAL::isa, avg 2µs/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
476264µs my $expected_class = $self->_expected_method_class
# spent 64µs making 62 calls to Class::MOP::Method::Inlined::_expected_method_class, avg 1µs/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
523236µs my $expected_method = $expected_class->can( $self->name );
# spent 26µs making 16 calls to UNIVERSAL::can, avg 2µs/call # spent 10µs making 16 calls to Class::MOP::Method::name, avg 656ns/call
53
54 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
643254µs my $actual_method = $class->can( $self->name )
# spent 45µs making 16 calls to UNIVERSAL::can, avg 3µs/call # spent 10µs making 16 calls to Class::MOP::Method::name, avg 600ns/call
65 or return 1;
66
67 # the method is what we wanted (probably Moose::Object::new)
683226µs return 1
# spent 26µs making 32 calls to Scalar::Util::refaddr, avg 825ns/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
10615µs1;
107
108# ABSTRACT: Method base class for methods which have been inlined
109
110__END__