← Index
NYTProf Performance Profile   « line view »
For fastest.pl
  Run on Fri Jan 31 20:48:16 2014
Reported on Fri Jan 31 20:49:40 2014

Filename/opt/perl-5.18.1/lib/site_perl/5.18.1/darwin-thread-multi-2level/Class/MOP/Method/Accessor.pm
StatementsExecuted 4689 statements in 18.7ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
191116.93ms40.5msClass::MOP::Method::Accessor::::_initialize_bodyClass::MOP::Method::Accessor::_initialize_body
191224.28ms54.7msClass::MOP::Method::Accessor::::newClass::MOP::Method::Accessor::new
248332.13ms9.75msClass::MOP::Method::Accessor::::_newClass::MOP::Method::Accessor::_new
5522764µs18.8msClass::MOP::Method::Accessor::::_generate_reader_method_inlineClass::MOP::Method::Accessor::_generate_reader_method_inline
5311436µs492µsClass::MOP::Method::Accessor::::_generate_reader_methodClass::MOP::Method::Accessor::_generate_reader_method
2322328µs8.78msClass::MOP::Method::Accessor::::_generate_accessor_method_inlineClass::MOP::Method::Accessor::_generate_accessor_method_inline
1611222µs3.94msClass::MOP::Method::Accessor::::_generate_predicate_method_inlineClass::MOP::Method::Accessor::_generate_predicate_method_inline
2211160µs183µsClass::MOP::Method::Accessor::::_generate_accessor_methodClass::MOP::Method::Accessor::_generate_accessor_method
1611114µs136µsClass::MOP::Method::Accessor::::_generate_predicate_methodClass::MOP::Method::Accessor::_generate_predicate_method
5311104µs104µsClass::MOP::Method::Accessor::::_inline_throw_errorClass::MOP::Method::Accessor::_inline_throw_error
31152µs756µsClass::MOP::Method::Accessor::::_generate_writer_method_inlineClass::MOP::Method::Accessor::_generate_writer_method_inline
31129µs33µsClass::MOP::Method::Accessor::::_generate_writer_methodClass::MOP::Method::Accessor::_generate_writer_method
11111µs11µsClass::MOP::Method::Accessor::::BEGIN@3Class::MOP::Method::Accessor::BEGIN@3
11110µs48µsClass::MOP::Method::Accessor::::BEGIN@15Class::MOP::Method::Accessor::BEGIN@15
11110µs14µsClass::MOP::Method::Accessor::::BEGIN@11Class::MOP::Method::Accessor::BEGIN@11
11110µs46µsClass::MOP::Method::Accessor::::BEGIN@13Class::MOP::Method::Accessor::BEGIN@13
1119µs48µsClass::MOP::Method::Accessor::::BEGIN@14Class::MOP::Method::Accessor::BEGIN@14
1119µs2.76msClass::MOP::Method::Accessor::::BEGIN@17Class::MOP::Method::Accessor::BEGIN@17
1119µs25µsClass::MOP::Method::Accessor::::BEGIN@10Class::MOP::Method::Accessor::BEGIN@10
0000s0sClass::MOP::Method::Accessor::::__ANON__[:104]Class::MOP::Method::Accessor::__ANON__[:104]
0000s0sClass::MOP::Method::Accessor::::__ANON__[:120]Class::MOP::Method::Accessor::__ANON__[:120]
0000s0sClass::MOP::Method::Accessor::::__ANON__[:123]Class::MOP::Method::Accessor::__ANON__[:123]
0000s0sClass::MOP::Method::Accessor::::__ANON__[:134]Class::MOP::Method::Accessor::__ANON__[:134]
0000s0sClass::MOP::Method::Accessor::::__ANON__[:154]Class::MOP::Method::Accessor::__ANON__[:154]
0000s0sClass::MOP::Method::Accessor::::__ANON__[:157]Class::MOP::Method::Accessor::__ANON__[:157]
0000s0sClass::MOP::Method::Accessor::::__ANON__[:171]Class::MOP::Method::Accessor::__ANON__[:171]
0000s0sClass::MOP::Method::Accessor::::__ANON__[:184]Class::MOP::Method::Accessor::__ANON__[:184]
0000s0sClass::MOP::Method::Accessor::::__ANON__[:187]Class::MOP::Method::Accessor::__ANON__[:187]
0000s0sClass::MOP::Method::Accessor::::__ANON__[:196]Class::MOP::Method::Accessor::__ANON__[:196]
0000s0sClass::MOP::Method::Accessor::::__ANON__[:209]Class::MOP::Method::Accessor::__ANON__[:209]
0000s0sClass::MOP::Method::Accessor::::__ANON__[:212]Class::MOP::Method::Accessor::__ANON__[:212]
0000s0sClass::MOP::Method::Accessor::::__ANON__[:221]Class::MOP::Method::Accessor::__ANON__[:221]
0000s0sClass::MOP::Method::Accessor::::__ANON__[:234]Class::MOP::Method::Accessor::__ANON__[:234]
0000s0sClass::MOP::Method::Accessor::::__ANON__[:237]Class::MOP::Method::Accessor::__ANON__[:237]
0000s0sClass::MOP::Method::Accessor::::_generate_clearer_methodClass::MOP::Method::Accessor::_generate_clearer_method
0000s0sClass::MOP::Method::Accessor::::_generate_clearer_method_inlineClass::MOP::Method::Accessor::_generate_clearer_method_inline
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1
2package Class::MOP::Method::Accessor;
3
# spent 11µs within Class::MOP::Method::Accessor::BEGIN@3 which was called: # once (11µs+0s) by Class::MOP::Class::BEGIN@15 at line 5
BEGIN {
417µs $Class::MOP::Method::Accessor::AUTHORITY = 'cpan:STEVAN';
5141µs111µs}
# spent 11µs making 1 call to Class::MOP::Method::Accessor::BEGIN@3
6{
721µs $Class::MOP::Method::Accessor::VERSION = '2.1005';
8}
9
10238µs241µs
# spent 25µs (9+16) within Class::MOP::Method::Accessor::BEGIN@10 which was called: # once (9µs+16µs) by Class::MOP::Class::BEGIN@15 at line 10
use strict;
# spent 25µs making 1 call to Class::MOP::Method::Accessor::BEGIN@10 # spent 16µs making 1 call to strict::import
11233µs219µs
# spent 14µs (10+5) within Class::MOP::Method::Accessor::BEGIN@11 which was called: # once (10µs+5µs) by Class::MOP::Class::BEGIN@15 at line 11
use warnings;
# spent 14µs making 1 call to Class::MOP::Method::Accessor::BEGIN@11 # spent 5µs making 1 call to warnings::import
12
13237µs283µs
# spent 46µs (10+37) within Class::MOP::Method::Accessor::BEGIN@13 which was called: # once (10µs+37µs) by Class::MOP::Class::BEGIN@15 at line 13
use Carp 'confess';
# spent 46µs making 1 call to Class::MOP::Method::Accessor::BEGIN@13 # spent 37µs making 1 call to Exporter::import
14233µs287µs
# spent 48µs (9+39) within Class::MOP::Method::Accessor::BEGIN@14 which was called: # once (9µs+39µs) by Class::MOP::Class::BEGIN@15 at line 14
use Scalar::Util 'blessed', 'weaken';
# spent 48µs making 1 call to Class::MOP::Method::Accessor::BEGIN@14 # spent 39µs making 1 call to Exporter::import
15242µs286µs
# spent 48µs (10+38) within Class::MOP::Method::Accessor::BEGIN@15 which was called: # once (10µs+38µs) by Class::MOP::Class::BEGIN@15 at line 15
use Try::Tiny;
# spent 48µs making 1 call to Class::MOP::Method::Accessor::BEGIN@15 # spent 38µs making 1 call to Exporter::import
16
1721.42ms25.50ms
# spent 2.76ms (9µs+2.75) within Class::MOP::Method::Accessor::BEGIN@17 which was called: # once (9µs+2.75ms) by Class::MOP::Class::BEGIN@15 at line 17
use base 'Class::MOP::Method::Generated';
# spent 2.76ms making 1 call to Class::MOP::Method::Accessor::BEGIN@17 # spent 2.75ms making 1 call to base::import
18
19
# spent 54.7ms (4.28+50.4) within Class::MOP::Method::Accessor::new which was called 191 times, avg 286µs/call: # 188 times (4.18ms+39.2ms) by Class::MOP::Attribute::try {...} at line 389 of Class/MOP/Attribute.pm, avg 231µs/call # 3 times (99µs+11.2ms) by Class::MOP::Attribute::try {...} at line 20 of Moose/Meta/Method/Accessor.pm, avg 3.78ms/call
sub new {
2019143µs my $class = shift;
21191552µs my %options = @_;
22
2319179µs (exists $options{attribute})
24 || confess "You must supply an attribute to construct with";
25
2619140µs (exists $options{accessor_type})
27 || confess "You must supply an accessor_type to construct with";
28
291911.22ms382384µs (blessed($options{attribute}) && $options{attribute}->isa('Class::MOP::Attribute'))
# spent 204µs making 191 calls to Scalar::Util::blessed, avg 1µs/call # spent 180µs making 191 calls to UNIVERSAL::isa, avg 942ns/call
30 || confess "You must supply an attribute which is a 'Class::MOP::Attribute' instance";
31
3219179µs ($options{package_name} && $options{name})
33 || confess "You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT";
34
35191306µs1911.63ms my $self = $class->_new(\%options);
# spent 1.63ms making 188 calls to Class::MOP::Method::Accessor::_new, avg 9µs/call # spent 6µs making 3 calls to Moose::Meta::Method::Accessor::_new, avg 2µs/call
36
37 # we don't want this creating
38 # a cycle in the code, if not
39 # needed
40191663µs191235µs weaken($self->{'attribute'});
# spent 235µs making 191 calls to Scalar::Util::weaken, avg 1µs/call
41
42191770µs19140.5ms $self->_initialize_body;
# spent 40.5ms making 191 calls to Class::MOP::Method::Accessor::_initialize_body, avg 212µs/call
43
44191639µs return $self;
45}
46
47
# spent 9.75ms (2.13+7.61) within Class::MOP::Method::Accessor::_new which was called 248 times, avg 39µs/call: # 188 times (1.63ms+0s) by Class::MOP::Method::Accessor::new at line 35, avg 9µs/call # 57 times (481µs+0s) by Class::MOP::Method::wrap at line 46 of Class/MOP/Method.pm, avg 8µs/call # 3 times (25µs+7.61ms) by Class::MOP::Method::Accessor::new at line 24 of Moose/Meta/Method/Accessor.pm, avg 2.55ms/call
sub _new {
4824854µs my $class = shift;
49
5024877µs67.61ms return Class::MOP::Class->initialize($class)->new_object(@_)
# spent 7.12ms making 3 calls to Class::MOP::Class::new_object, avg 2.37ms/call # spent 492µs making 3 calls to Class::MOP::Class::initialize, avg 164µs/call
51 if $class ne __PACKAGE__;
52
53245125µs my $params = @_ == 1 ? $_[0] : {@_};
54
552452.12ms return bless {
56 # inherited from Class::MOP::Method
57 body => $params->{body},
58 associated_metaclass => $params->{associated_metaclass},
59 package_name => $params->{package_name},
60 name => $params->{name},
61 original_method => $params->{original_method},
62
63 # inherit from Class::MOP::Generated
64 is_inline => $params->{is_inline} || 0,
65 definition_context => $params->{definition_context},
66
67 # defined in this class
68 attribute => $params->{attribute},
69 accessor_type => $params->{accessor_type},
70 } => $class;
71}
72
73## accessors
74
75201502µssub associated_attribute { (shift)->{'attribute'} }
761915.42mssub accessor_type { (shift)->{'accessor_type'} }
77
78## factory
79
80
# spent 40.5ms (6.93+33.6) within Class::MOP::Method::Accessor::_initialize_body which was called 191 times, avg 212µs/call: # 191 times (6.93ms+33.6ms) by Class::MOP::Method::Accessor::new at line 42, avg 212µs/call
sub _initialize_body {
8119139µs my $self = shift;
82
83191868µs382360µs my $method_name = join "_" => (
# spent 230µs making 191 calls to Class::MOP::Method::Accessor::accessor_type, avg 1µs/call # spent 130µs making 191 calls to Class::MOP::Method::Generated::is_inline, avg 682ns/call
84 '_generate',
85 $self->accessor_type,
86 'method',
87 ($self->is_inline ? 'inline' : ())
88 );
89
90191775µs19133.2ms $self->{'body'} = $self->$method_name();
# spent 17.7ms making 54 calls to Class::MOP::Method::Accessor::_generate_reader_method_inline, avg 328µs/call # spent 7.37ms making 22 calls to Class::MOP::Method::Accessor::_generate_accessor_method_inline, avg 335µs/call # spent 3.94ms making 16 calls to Class::MOP::Method::Accessor::_generate_predicate_method_inline, avg 246µs/call # spent 1.44ms making 1 call to Moose::Meta::Method::Accessor::_generate_accessor_method # spent 1.17ms making 1 call to Moose::Meta::Method::Accessor::_generate_reader_method # spent 756µs making 3 calls to Class::MOP::Method::Accessor::_generate_writer_method_inline, avg 252µs/call # spent 492µs making 53 calls to Class::MOP::Method::Accessor::_generate_reader_method, avg 9µs/call # spent 183µs making 22 calls to Class::MOP::Method::Accessor::_generate_accessor_method, avg 8µs/call # spent 136µs making 16 calls to Class::MOP::Method::Accessor::_generate_predicate_method, avg 8µs/call # spent 33µs making 3 calls to Class::MOP::Method::Accessor::_generate_writer_method, avg 11µs/call
91}
92
93## generators
94
95
# spent 183µs (160+23) within Class::MOP::Method::Accessor::_generate_accessor_method which was called 22 times, avg 8µs/call: # 22 times (160µs+23µs) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 8µs/call
sub _generate_accessor_method {
96224µs my $self = shift;
972223µs2223µs my $attr = $self->associated_attribute;
# spent 23µs making 22 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
98
99 return sub {
100 if (@_ >= 2) {
101 $attr->set_value($_[0], $_[1]);
102 }
103 $attr->get_value($_[0]);
10422123µs };
105}
106
107
# spent 8.78ms (328µs+8.45) within Class::MOP::Method::Accessor::_generate_accessor_method_inline which was called 23 times, avg 382µs/call: # 22 times (310µs+7.06ms) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 335µs/call # once (17µs+1.39ms) by Moose::Meta::Method::Accessor::_generate_accessor_method at line 74 of Moose/Meta/Method/Accessor.pm
sub _generate_accessor_method_inline {
108235µs my $self = shift;
1092323µs2324µs my $attr = $self->associated_attribute;
# spent 24µs making 23 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
110
111 return try {
11223152µs697.57ms $self->_compile_code([
# spent 4.23ms making 22 calls to Class::MOP::Method::Generated::_compile_code, avg 192µs/call # spent 1.55ms making 22 calls to Class::MOP::Attribute::_inline_set_value, avg 70µs/call # spent 694µs making 1 call to Moose::Meta::Attribute::_inline_set_value # spent 571µs making 1 call to Moose::Meta::Method::Accessor::_compile_code # spent 460µs making 22 calls to Class::MOP::Attribute::_inline_get_value, avg 21µs/call # spent 67µs making 1 call to Moose::Meta::Attribute::_inline_get_value
113 'sub {',
114 'if (@_ > 1) {',
115 $attr->_inline_set_value('$_[0]', '$_[1]'),
116 '}',
117 $attr->_inline_get_value('$_[0]'),
118 '}',
119 ]);
120 }
121 catch {
122 confess "Could not generate inline accessor because : $_";
12323205µs4672µs };
# spent 72µs making 23 calls to Try::Tiny::catch, avg 3µs/call # spent 8.35ms making 23 calls to Try::Tiny::try, avg 363µs/call, recursion: max depth 2, sum of overlapping time 8.35ms
124}
125
126
# spent 492µs (436+56) within Class::MOP::Method::Accessor::_generate_reader_method which was called 53 times, avg 9µs/call: # 53 times (436µs+56µs) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 9µs/call
sub _generate_reader_method {
1275310µs my $self = shift;
1285352µs5356µs my $attr = $self->associated_attribute;
# spent 56µs making 53 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
129
130 return sub {
131124µs confess "Cannot assign a value to a read-only accessor"
132 if @_ > 1;
1331245µs12359µs $attr->get_value($_[0]);
# spent 359µs making 12 calls to Class::MOP::Attribute::get_value, avg 30µs/call
13453347µs };
135}
136
137
# spent 18.8ms (764µs+18.1) within Class::MOP::Method::Accessor::_generate_reader_method_inline which was called 55 times, avg 343µs/call: # 54 times (743µs+17.0ms) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 328µs/call # once (20µs+1.12ms) by Moose::Meta::Method::Accessor::_generate_reader_method at line 62 of Moose/Meta/Method/Accessor.pm
sub _generate_reader_method_inline {
1385512µs my $self = shift;
1395554µs5558µs my $attr = $self->associated_attribute;
# spent 58µs making 55 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
140
141 return try {
14255464µs16515.8ms $self->_compile_code([
# spent 10.6ms making 53 calls to Class::MOP::Method::Generated::_compile_code, avg 199µs/call # spent 3.24ms making 53 calls to Class::MOP::Attribute::_inline_get_value, avg 61µs/call # spent 857µs making 2 calls to Moose::Meta::Method::Accessor::_compile_code, avg 429µs/call # spent 573µs making 2 calls to Moose::Meta::Method::_inline_throw_error, avg 287µs/call # spent 459µs making 2 calls to Moose::Meta::Attribute::_inline_get_value, avg 230µs/call # spent 104µs making 53 calls to Class::MOP::Method::Accessor::_inline_throw_error, avg 2µs/call
143 'sub {',
144 'if (@_ > 1) {',
145 # XXX: this is a hack, but our error stuff is terrible
146 $self->_inline_throw_error(
147 '"Cannot assign a value to a read-only accessor"',
148 'data => \@_'
149 ) . ';',
150 '}',
151 $attr->_inline_get_value('$_[0]'),
152 '}',
153 ]);
154 }
155 catch {
156 confess "Could not generate inline reader because : $_";
15755479µs110173µs };
# spent 173µs making 55 calls to Try::Tiny::catch, avg 3µs/call # spent 17.9ms making 55 calls to Try::Tiny::try, avg 325µs/call, recursion: max depth 2, sum of overlapping time 17.9ms
158}
159
160
# spent 104µs within Class::MOP::Method::Accessor::_inline_throw_error which was called 53 times, avg 2µs/call: # 53 times (104µs+0s) by Class::MOP::Method::Accessor::try {...} at line 142, avg 2µs/call
sub _inline_throw_error {
1615315µs my $self = shift;
16253151µs return 'Carp::confess ' . $_[0];
163}
164
165
# spent 33µs (29+3) within Class::MOP::Method::Accessor::_generate_writer_method which was called 3 times, avg 11µs/call: # 3 times (29µs+3µs) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 11µs/call
sub _generate_writer_method {
1663800ns my $self = shift;
16734µs33µs my $attr = $self->associated_attribute;
# spent 3µs making 3 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
168
169 return sub {
170 $attr->set_value($_[0], $_[1]);
171323µs };
172}
173
174
# spent 756µs (52+703) within Class::MOP::Method::Accessor::_generate_writer_method_inline which was called 3 times, avg 252µs/call: # 3 times (52µs+703µs) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 252µs/call
sub _generate_writer_method_inline {
1753900ns my $self = shift;
17634µs33µs my $attr = $self->associated_attribute;
# spent 3µs making 3 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
177
178 return try {
179316µs6597µs $self->_compile_code([
# spent 522µs making 3 calls to Class::MOP::Method::Generated::_compile_code, avg 174µs/call # spent 75µs making 3 calls to Class::MOP::Attribute::_inline_set_value, avg 25µs/call
180 'sub {',
181 $attr->_inline_set_value('$_[0]', '$_[1]'),
182 '}',
183 ]);
184 }
185 catch {
186 confess "Could not generate inline writer because : $_";
187330µs69µs };
# spent 9µs making 3 calls to Try::Tiny::catch, avg 3µs/call # spent 691µs making 3 calls to Try::Tiny::try, avg 230µs/call, recursion: max depth 1, sum of overlapping time 691µs
188}
189
190
# spent 136µs (114+22) within Class::MOP::Method::Accessor::_generate_predicate_method which was called 16 times, avg 8µs/call: # 16 times (114µs+22µs) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 8µs/call
sub _generate_predicate_method {
191163µs my $self = shift;
1921620µs1622µs my $attr = $self->associated_attribute;
# spent 22µs making 16 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
193
194 return sub {
1951252µs12316µs $attr->has_value($_[0])
# spent 316µs making 12 calls to Class::MOP::Attribute::has_value, avg 26µs/call
1961686µs };
197}
198
199
# spent 3.94ms (222µs+3.72) within Class::MOP::Method::Accessor::_generate_predicate_method_inline which was called 16 times, avg 246µs/call: # 16 times (222µs+3.72ms) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 246µs/call
sub _generate_predicate_method_inline {
200164µs my $self = shift;
2011617µs1617µs my $attr = $self->associated_attribute;
# spent 17µs making 16 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
202
203 return try {
2041682µs323.16ms $self->_compile_code([
# spent 2.74ms making 16 calls to Class::MOP::Method::Generated::_compile_code, avg 171µs/call # spent 426µs making 16 calls to Class::MOP::Attribute::_inline_has_value, avg 27µs/call
205 'sub {',
206 $attr->_inline_has_value('$_[0]'),
207 '}',
208 ]);
209 }
210 catch {
211 confess "Could not generate inline predicate because : $_";
21216135µs3249µs };
# spent 49µs making 16 calls to Try::Tiny::catch, avg 3µs/call # spent 3.66ms making 16 calls to Try::Tiny::try, avg 228µs/call, recursion: max depth 1, sum of overlapping time 3.66ms
213}
214
215sub _generate_clearer_method {
216 my $self = shift;
217 my $attr = $self->associated_attribute;
218
219 return sub {
220 $attr->clear_value($_[0])
221 };
222}
223
224sub _generate_clearer_method_inline {
225 my $self = shift;
226 my $attr = $self->associated_attribute;
227
228 return try {
229 $self->_compile_code([
230 'sub {',
231 $attr->_inline_clear_value('$_[0]'),
232 '}',
233 ]);
234 }
235 catch {
236 confess "Could not generate inline clearer because : $_";
237 };
238}
239
24014µs1;
241
242# ABSTRACT: Method Meta Object for accessors
243
244__END__