← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:45:08 2010
Reported on Wed Nov 17 22:13:23 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP/Method/Inlined.pm
StatementsExecuted 958 statements in 23.0ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1112115.4ms100msClass::MOP::Method::Inlined::::can_be_inlinedClass::MOP::Method::Inlined::can_be_inlined
11171µs88µsClass::MOP::Method::Inlined::::BEGIN@3Class::MOP::Method::Inlined::BEGIN@3
11141µs291µsClass::MOP::Method::Inlined::::BEGIN@13Class::MOP::Method::Inlined::BEGIN@13
11138µs106µsClass::MOP::Method::Inlined::::BEGIN@4Class::MOP::Method::Inlined::BEGIN@4
11136µs260µsClass::MOP::Method::Inlined::::BEGIN@7Class::MOP::Method::Inlined::BEGIN@7
11136µs186µsClass::MOP::Method::Inlined::::BEGIN@6Class::MOP::Method::Inlined::BEGIN@6
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;
2
3398µs2105µs
# spent 88µs (71+17) within Class::MOP::Method::Inlined::BEGIN@3 which was called: # once (71µs+17µs) by base::import at line 3
use strict;
# spent 88µs making 1 call to Class::MOP::Method::Inlined::BEGIN@3 # spent 17µs making 1 call to strict::import
43100µs2173µs
# spent 106µs (38+67) within Class::MOP::Method::Inlined::BEGIN@4 which was called: # once (38µs+67µs) by base::import at line 4
use warnings;
# spent 106µs making 1 call to Class::MOP::Method::Inlined::BEGIN@4 # spent 67µs making 1 call to warnings::import
5
63108µs2337µs
# spent 186µs (36+151) within Class::MOP::Method::Inlined::BEGIN@6 which was called: # once (36µs+151µs) by base::import at line 6
use Carp 'confess';
# spent 186µs making 1 call to Class::MOP::Method::Inlined::BEGIN@6 # spent 151µs making 1 call to Exporter::import
73205µs2484µs
# spent 260µs (36+224) within Class::MOP::Method::Inlined::BEGIN@7 which was called: # once (36µs+224µs) by base::import at line 7
use Scalar::Util 'blessed', 'weaken', 'looks_like_number', 'refaddr';
# spent 260µs making 1 call to Class::MOP::Method::Inlined::BEGIN@7 # spent 224µs making 1 call to Exporter::import
8
914µsour $VERSION = '1.11';
10175µs$VERSION = eval $VERSION;
# spent 25µs executing statements in string eval
1113µsour $AUTHORITY = 'cpan:STEVAN';
12
1331.44ms2291µs
# spent 291µs (41+250) within Class::MOP::Method::Inlined::BEGIN@13 which was called: # once (41µs+250µs) by base::import at line 13
use base 'Class::MOP::Method::Generated';
# spent 291µs making 1 call to Class::MOP::Method::Inlined::BEGIN@13 # spent 250µs making 1 call to base::import, recursion: max depth 2, sum of overlapping time 250µs
14
151111.58mssub _expected_method_class { $_[0]{_expected_method_class} }
16
17sub _uninlined_body {
18 my $self = shift;
19
20 my $super_method
21 = $self->associated_metaclass->find_next_method_by_name( $self->name )
22 or return;
23
24 if ( $super_method->isa(__PACKAGE__) ) {
25 return $super_method->_uninlined_body;
26 }
27 else {
28 return $super_method->body;
29 }
30}
31
32
# spent 100ms (15.4+85.0) within Class::MOP::Method::Inlined::can_be_inlined which was called 111 times, avg 904µs/call: # 72 times (11.3ms+56.5ms) by Class::MOP::Class::_inline_constructor at line 1338 of Class/MOP/Class.pm, avg 943µs/call # 39 times (4.04ms+28.5ms) by Class::MOP::Class::_inline_destructor at line 1371 of Class/MOP/Class.pm, avg 834µs/call
sub can_be_inlined {
33111426µs my $self = shift;
341111.29ms1111.10ms my $metaclass = $self->associated_metaclass;
# spent 808µs making 80 calls to Class::MOP::Method::associated_metaclass, avg 10µs/call # spent 290µs making 31 calls to Class::MOP::Method::Constructor::associated_metaclass, avg 9µs/call
351112.57ms111863µs my $class = $metaclass->name;
# spent 863µs making 111 calls to Class::MOP::Package::name, avg 8µs/call
36
37 # If we don't find an inherited method, this is a rather weird
38 # case where we have no method in the inheritance chain even
39 # though we're expecting one to be there
401113.36ms22278.2ms my $inherited_method
# spent 77.6ms making 111 calls to Class::MOP::Class::find_next_method_by_name, avg 699µs/call # spent 629µs making 111 calls to Class::MOP::Method::name, avg 6µs/call
41 = $metaclass->find_next_method_by_name( $self->name );
42
431113.15ms1061.54ms if ( $inherited_method
# spent 1.54ms making 106 calls to UNIVERSAL::isa, avg 15µs/call
44 && $inherited_method->isa('Class::MOP::Method::Wrapped') ) {
45 warn "Not inlining '"
46 . $self->name
47 . "' for $class since it "
48 . "has method modifiers which would be lost if it were inlined\n";
49
50 return 0;
51 }
52
531112.50ms1111.40ms my $expected_class = $self->_expected_method_class
# spent 1.40ms making 111 calls to Class::MOP::Method::Inlined::_expected_method_class, avg 13µs/call
54 or return 1;
55
56 # if we are shadowing a method we first verify that it is
57 # compatible with the definition we are replacing it with
58411.66ms82656µs my $expected_method = $expected_class->can( $self->name );
# spent 428µs making 41 calls to UNIVERSAL::can, avg 10µs/call # spent 228µs making 41 calls to Class::MOP::Method::name, avg 6µs/call
59
6041102µs if ( ! $expected_method ) {
61 warn "Not inlining '"
62 . $self->name
63 . "' for $class since ${expected_class}::"
64 . $self->name
65 . " is not defined\n";
66
67 return 0;
68 }
69
70412.76ms82863µs my $actual_method = $class->can( $self->name )
# spent 658µs making 41 calls to UNIVERSAL::can, avg 16µs/call # spent 205µs making 41 calls to Class::MOP::Method::name, avg 5µs/call
71 or return 1;
72
73 # the method is what we wanted (probably Moose::Object::new)
74391.58ms78397µs return 1
# spent 397µs making 78 calls to Scalar::Util::refaddr, avg 5µs/call
75 if refaddr($expected_method) == refaddr($actual_method);
76
77 # otherwise we have to check that the actual method is an inlined
78 # version of what we're expecting
79 if ( $inherited_method->isa(__PACKAGE__) ) {
80 if ( $inherited_method->_uninlined_body
81 && refaddr( $inherited_method->_uninlined_body )
82 == refaddr($expected_method) ) {
83 return 1;
84 }
85 }
86 elsif ( refaddr( $inherited_method->body )
87 == refaddr($expected_method) ) {
88 return 1;
89 }
90
91 my $warning
92 = "Not inlining '"
93 . $self->name
94 . "' for $class since it is not"
95 . " inheriting the default ${expected_class}::"
96 . $self->name . "\n";
97
98 if ( $self->isa("Class::MOP::Method::Constructor") ) {
99
100 # FIXME kludge, refactor warning generation to a method
101 $warning
102 .= "If you are certain you don't need to inline your"
103 . " constructor, specify inline_constructor => 0 in your"
104 . " call to $class->meta->make_immutable\n";
105 }
106
107 warn $warning;
108
109 return 0;
110}
111
112111µs1;
113
114__END__