Profile of /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP/Method/Inlined.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For 01.HTTP.t
Run on Tue May 4 15:25:55 2010
Reported on Tue May 4 15:26:05 2010

File | /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP/Method/Inlined.pm
Statements Executed | 254
Statement Execution Time | 1.28ms

Subroutines — ordered by exclusive time
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
33 | 2 | 1 | 570µs | 3.08ms | Class::MOP::Method::Inlined::::can_be_inlinedClass::MOP::Method::Inlined::can_be_inlined
33 | 1 | 1 | 52µs | 52µs | Class::MOP::Method::Inlined::::_expected_method_classClass::MOP::Method::Inlined::_expected_method_class
1 | 1 | 1 | 19µs | 23µs | Class::MOP::Method::Inlined::::BEGIN@3Class::MOP::Method::Inlined::BEGIN@3
1 | 1 | 1 | 10µs | 66µs | Class::MOP::Method::Inlined::::BEGIN@13Class::MOP::Method::Inlined::BEGIN@13
1 | 1 | 1 | 9µs | 21µs | Class::MOP::Method::Inlined::::BEGIN@4Class::MOP::Method::Inlined::BEGIN@4
1 | 1 | 1 | 9µs | 56µs | Class::MOP::Method::Inlined::::BEGIN@7Class::MOP::Method::Inlined::BEGIN@7
1 | 1 | 1 | 8µs | 40µs | Class::MOP::Method::Inlined::::BEGIN@6Class::MOP::Method::Inlined::BEGIN@6
0 | 0 | 0 | 0s | 0s | Class::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
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package Class::MOP::Method::Inlined;
2 |  |  |  |  |
3 | 3 | 29µs | 2 | 26µs | # spent 23µs (19+4) within Class::MOP::Method::Inlined::BEGIN@3 which was called # once (19µs+4µs) by base::import at line 3 use strict; # spent 23µs making 1 call to Class::MOP::Method::Inlined::BEGIN@3 # spent 4µs making 1 call to strict::import
4 | 3 | 28µs | 2 | 33µs | # spent 21µs (9+12) within Class::MOP::Method::Inlined::BEGIN@4 which was called # once (9µs+12µs) by base::import at line 4 use warnings; # spent 21µs making 1 call to Class::MOP::Method::Inlined::BEGIN@4 # spent 12µs making 1 call to warnings::import
5 |  |  |  |  |
6 | 3 | 44µs | 2 | 72µs | # spent 40µs (8+32) within Class::MOP::Method::Inlined::BEGIN@6 which was called # once (8µs+32µs) by base::import at line 6 use Carp 'confess'; # spent 40µs making 1 call to Class::MOP::Method::Inlined::BEGIN@6 # spent 32µs making 1 call to Exporter::import
7 | 3 | 70µs | 2 | 104µs | # spent 56µs (9+48) within Class::MOP::Method::Inlined::BEGIN@7 which was called # once (9µs+48µs) by base::import at line 7 use Scalar::Util 'blessed', 'weaken', 'looks_like_number', 'refaddr'; # spent 56µs making 1 call to Class::MOP::Method::Inlined::BEGIN@7 # spent 47µs making 1 call to Exporter::import
8 |  |  |  |  |
9 | 1 | 900ns |  |  | our $VERSION = '0.98';
10 | 1 | 18µs |  |  | $VERSION = eval $VERSION;
11 | 1 | 400ns |  |  | our $AUTHORITY = 'cpan:STEVAN';
12 |  |  |  |  |
13 | 3 | 416µs | 2 | 66µs | # spent 66µs (10+57) within Class::MOP::Method::Inlined::BEGIN@13 which was called # once (10µs+57µs) by base::import at line 13 use base 'Class::MOP::Method::Generated'; # spent 66µs making 1 call to Class::MOP::Method::Inlined::BEGIN@13 # spent 57µs making 1 call to base::import, recursion: max depth 1, time 57µs
14 |  |  |  |  |
15 | 33 | 70µs |  |  | # spent 52µs within Class::MOP::Method::Inlined::_expected_method_class which was called 33 times, avg 2µs/call: # 33 times (52µs+0s) by Class::MOP::Method::Inlined::can_be_inlined at line 53, avg 2µs/call sub _expected_method_class { $_[0]{_expected_method_class} }
16 |  |  |  |  |
17 |  |  |  |  | sub _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 3.08ms (570µs+2.51) within Class::MOP::Method::Inlined::can_be_inlined which was called 33 times, avg 93µs/call: # 32 times (550µs+2.40ms) by Class::MOP::Class::_inline_constructor at line 1063 of Class/MOP/Class.pm, avg 92µs/call # once (20µs+106µs) by Class::MOP::Class::_inline_destructor at line 1096 of Class/MOP/Class.pm sub can_be_inlined {
33 | 202 | 595µs |  |  | my $self = shift;
34 |  |  |  |  | my $metaclass = $self->associated_metaclass; # spent 34µs making 31 calls to Class::MOP::Method::Constructor::associated_metaclass, avg 1µs/call # spent 2µs making 2 calls to Class::MOP::Method::associated_metaclass, avg 1µs/call
35 |  |  |  |  | my $class = $metaclass->name; # spent 28µs making 33 calls to Class::MOP::Package::name, avg 855ns/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
40 |  |  |  |  | my $inherited_method # spent 2.30ms making 33 calls to Class::MOP::Class::find_next_method_by_name, avg 70µs/call # spent 19µs making 33 calls to Class::MOP::Method::name, avg 585ns/call
41 |  |  |  |  | = $metaclass->find_next_method_by_name( $self->name );
42 |  |  |  |  |
43 |  |  |  |  | if ( $inherited_method # spent 64µs making 30 calls to UNIVERSAL::isa, avg 2µ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 |  |  |  |  |
53 |  |  |  |  | my $expected_class = $self->_expected_method_class # spent 52µs making 33 calls to Class::MOP::Method::Inlined::_expected_method_class, avg 2µ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
58 |  |  |  |  | my $expected_method = $expected_class->can( $self->name ); # spent 900ns making 1 call to UNIVERSAL::can # spent 600ns making 1 call to Class::MOP::Method::name
59 |  |  |  |  |
60 |  |  |  |  | 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 |  |  |  |  |
70 |  |  |  |  | my $actual_method = $class->can( $self->name ) # spent 2µs making 1 call to UNIVERSAL::can # spent 400ns making 1 call to Class::MOP::Method::name
71 |  |  |  |  | or return 1;
72 |  |  |  |  |
73 |  |  |  |  | # the method is what we wanted (probably Moose::Object::new)
74 |  |  |  |  | return 1 # spent 7µs making 2 calls to Scalar::Util::refaddr, avg 3µ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 |  |  |  |  |
112 | 1 | 11µs |  |  | 1;
113 |  |  |  |  |
114 |  |  |  |  | __END__
115 |  |  |  |  |
116 |  |  |  |  | =pod
117 |  |  |  |  |
118 |  |  |  |  | =head1 NAME
119 |  |  |  |  |
120 |  |  |  |  | Class::MOP::Method::Inlined - Method base class for methods which have been inlined
121 |  |  |  |  |
122 |  |  |  |  | =head1 DESCRIPTION
123 |  |  |  |  |
124 |  |  |  |  | This is a L<Class::MOP::Method::Generated> subclass for methods which
125 |  |  |  |  | can be inlined.
126 |  |  |  |  |
127 |  |  |  |  | =head1 METHODS
128 |  |  |  |  |
129 |  |  |  |  | =over 4
130 |  |  |  |  |
131 |  |  |  |  | =item B<< $metamethod->can_be_inlined >>
132 |  |  |  |  |
133 |  |  |  |  | This method returns true if the method in question can be inlined in
134 |  |  |  |  | the associated metaclass.
135 |  |  |  |  |
136 |  |  |  |  | If it cannot be inlined, it spits out a warning and returns false.
137 |  |  |  |  |
138 |  |  |  |  | =back
139 |  |  |  |  |
140 |  |  |  |  | =head1 AUTHORS
141 |  |  |  |  |
142 |  |  |  |  | Stevan Little E<lt>stevan@iinteractive.comE<gt>
143 |  |  |  |  |
144 |  |  |  |  | =head1 COPYRIGHT AND LICENSE
145 |  |  |  |  |
146 |  |  |  |  | Copyright 2006-2010 by Infinity Interactive, Inc.
147 |  |  |  |  |
148 |  |  |  |  | L<http://www.iinteractive.com>
149 |  |  |  |  |
150 |  |  |  |  | This library is free software; you can redistribute it and/or modify
151 |  |  |  |  | it under the same terms as Perl itself.
152 |  |  |  |  |
153 |  |  |  |  | =cut
154 |  |  |  |  |