← Index
NYTProf Performance Profile   « block view • line view • sub view »
For script/nytprof.pl
  Run on Thu May 31 16:49:15 2012
Reported on Thu May 31 16:51:11 2012

Filename/Users/edenc/perl5/lib/perl5/darwin-multi-2level/Class/MOP/Method/Accessor.pm
StatementsExecuted 23625 statements in 103ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
9852235.6ms1.32sClass::MOP::Method::Accessor::::newClass::MOP::Method::Accessor::new
9501116.3ms964msClass::MOP::Method::Accessor::::_initialize_bodyClass::MOP::Method::Accessor::_initialize_body
10073311.9ms239msClass::MOP::Method::Accessor::::_newClass::MOP::Method::Accessor::_new
424227.85ms555msClass::MOP::Method::Accessor::::_generate_reader_method_inlineClass::MOP::Method::Accessor::_generate_reader_method_inline
424117.04ms533msClass::MOP::Method::Accessor::::__ANON__[:154]Class::MOP::Method::Accessor::__ANON__[:154]
163223.02ms202msClass::MOP::Method::Accessor::::_generate_accessor_method_inlineClass::MOP::Method::Accessor::_generate_accessor_method_inline
163112.72ms193msClass::MOP::Method::Accessor::::__ANON__[:120]Class::MOP::Method::Accessor::__ANON__[:120]
140222.57ms85.4msClass::MOP::Method::Accessor::::_generate_predicate_method_inlineClass::MOP::Method::Accessor::_generate_predicate_method_inline
140111.46ms79.0msClass::MOP::Method::Accessor::::__ANON__[:209]Class::MOP::Method::Accessor::__ANON__[:209]
85111.44ms45.0msClass::MOP::Method::Accessor::::_generate_clearer_method_inlineClass::MOP::Method::Accessor::_generate_clearer_method_inline
8511847µs41.3msClass::MOP::Method::Accessor::::__ANON__[:234]Class::MOP::Method::Accessor::__ANON__[:234]
3322593µs33.4msClass::MOP::Method::Accessor::::_generate_writer_method_inlineClass::MOP::Method::Accessor::_generate_writer_method_inline
5311589µs708µsClass::MOP::Method::Accessor::::_generate_reader_methodClass::MOP::Method::Accessor::_generate_reader_method
3311409µs31.8msClass::MOP::Method::Accessor::::__ANON__[:184]Class::MOP::Method::Accessor::__ANON__[:184]
2211209µs244µsClass::MOP::Method::Accessor::::_generate_accessor_methodClass::MOP::Method::Accessor::_generate_accessor_method
5311179µs179µsClass::MOP::Method::Accessor::::_inline_throw_errorClass::MOP::Method::Accessor::_inline_throw_error
1611153µs177µsClass::MOP::Method::Accessor::::_generate_predicate_methodClass::MOP::Method::Accessor::_generate_predicate_method
31136µs43µsClass::MOP::Method::Accessor::::_generate_writer_methodClass::MOP::Method::Accessor::_generate_writer_method
11112µs12µsClass::MOP::Method::Accessor::::BEGIN@3Class::MOP::Method::Accessor::BEGIN@3
11112µs22µsClass::MOP::Method::Accessor::::BEGIN@11Class::MOP::Method::Accessor::BEGIN@11
11111µs18µsClass::MOP::Method::Accessor::::BEGIN@10Class::MOP::Method::Accessor::BEGIN@10
11110µs55µsClass::MOP::Method::Accessor::::BEGIN@13Class::MOP::Method::Accessor::BEGIN@13
1119µs45µsClass::MOP::Method::Accessor::::BEGIN@15Class::MOP::Method::Accessor::BEGIN@15
1119µs8.33msClass::MOP::Method::Accessor::::BEGIN@17Class::MOP::Method::Accessor::BEGIN@17
1118µs38µsClass::MOP::Method::Accessor::::BEGIN@14Class::MOP::Method::Accessor::BEGIN@14
0000s0sClass::MOP::Method::Accessor::::__ANON__[:104]Class::MOP::Method::Accessor::__ANON__[:104]
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__[:157]Class::MOP::Method::Accessor::__ANON__[:157]
0000s0sClass::MOP::Method::Accessor::::__ANON__[:171]Class::MOP::Method::Accessor::__ANON__[:171]
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__[:212]Class::MOP::Method::Accessor::__ANON__[:212]
0000s0sClass::MOP::Method::Accessor::::__ANON__[:221]Class::MOP::Method::Accessor::__ANON__[:221]
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
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 12µs within Class::MOP::Method::Accessor::BEGIN@3 which was called: # once (12µs+0s) by Class::MOP::Class::BEGIN@15 at line 5
BEGIN {
416µs $Class::MOP::Method::Accessor::AUTHORITY = 'cpan:STEVAN';
5131µs112µs}
# spent 12µs making 1 call to Class::MOP::Method::Accessor::BEGIN@3
6{
722µs $Class::MOP::Method::Accessor::VERSION = '2.0602';
8}
9
10227µs225µs
# spent 18µs (11+7) within Class::MOP::Method::Accessor::BEGIN@10 which was called: # once (11µs+7µs) by Class::MOP::Class::BEGIN@15 at line 10
use strict;
# spent 18µs making 1 call to Class::MOP::Method::Accessor::BEGIN@10 # spent 7µs making 1 call to strict::import
11228µs232µs
# spent 22µs (12+10) within Class::MOP::Method::Accessor::BEGIN@11 which was called: # once (12µs+10µs) by Class::MOP::Class::BEGIN@15 at line 11
use warnings;
# spent 22µs making 1 call to Class::MOP::Method::Accessor::BEGIN@11 # spent 10µs making 1 call to warnings::import
12
13231µs2101µs
# spent 55µs (10+46) within Class::MOP::Method::Accessor::BEGIN@13 which was called: # once (10µs+46µs) by Class::MOP::Class::BEGIN@15 at line 13
use Carp 'confess';
# spent 55µs making 1 call to Class::MOP::Method::Accessor::BEGIN@13 # spent 46µs making 1 call to Exporter::import
14230µs268µs
# spent 38µs (8+30) within Class::MOP::Method::Accessor::BEGIN@14 which was called: # once (8µs+30µs) by Class::MOP::Class::BEGIN@15 at line 14
use Scalar::Util 'blessed', 'weaken';
# spent 38µs making 1 call to Class::MOP::Method::Accessor::BEGIN@14 # spent 30µs making 1 call to Exporter::import
15225µs282µs
# spent 45µs (9+36) within Class::MOP::Method::Accessor::BEGIN@15 which was called: # once (9µs+36µs) by Class::MOP::Class::BEGIN@15 at line 15
use Try::Tiny;
# spent 45µs making 1 call to Class::MOP::Method::Accessor::BEGIN@15 # spent 36µs making 1 call to Exporter::import
16
1721.14ms216.6ms
# spent 8.33ms (9µs+8.32) within Class::MOP::Method::Accessor::BEGIN@17 which was called: # once (9µs+8.32ms) by Class::MOP::Class::BEGIN@15 at line 17
use base 'Class::MOP::Method::Generated';
# spent 8.33ms making 1 call to Class::MOP::Method::Accessor::BEGIN@17 # spent 8.32ms making 1 call to base::import
18
19
# spent 1.32s (35.6ms+1.28) within Class::MOP::Method::Accessor::new which was called 985 times, avg 1.34ms/call: # 797 times (29.3ms+1.23s) by Class::MOP::Attribute::__ANON__[/Users/edenc/perl5/lib/perl5/darwin-multi-2level/Class/MOP/Attribute.pm:398] or Class::MOP::Class:::around at line 20 of Moose/Meta/Method/Accessor.pm, avg 1.58ms/call # 188 times (6.37ms+50.0ms) by Class::MOP::Attribute::__ANON__[/Users/edenc/perl5/lib/perl5/darwin-multi-2level/Class/MOP/Attribute.pm:398] at line 389 of Class/MOP/Attribute.pm, avg 300µs/call
sub new {
20985036.0ms my $class = shift;
21 my %options = @_;
22
23 (exists $options{attribute})
24 || confess "You must supply an attribute to construct with";
25
26 (exists $options{accessor_type})
27 || confess "You must supply an accessor_type to construct with";
28
2919702.95ms (blessed($options{attribute}) && $options{attribute}->isa('Class::MOP::Attribute'))
# spent 1.50ms making 985 calls to UNIVERSAL::isa, avg 2µs/call # spent 1.45ms making 985 calls to Scalar::Util::blessed, avg 1µs/call
30 || confess "You must supply an attribute which is a 'Class::MOP::Attribute' instance";
31
32 ($options{package_name} && $options{name})
33 || confess "You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT";
34
3598513.5ms my $self = $class->_new(\%options);
# spent 8.81ms making 35 calls to Moose::Meta::Method::Accessor::Native::_new, avg 252µs/call # spent 3.00ms making 188 calls to Class::MOP::Method::Accessor::_new, avg 16µs/call # spent 1.65ms making 762 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
409851.98ms weaken($self->{'attribute'});
# spent 1.98ms making 985 calls to Scalar::Util::weaken, avg 2µs/call
41
429851.03s $self->_initialize_body;
# spent 964ms making 950 calls to Class::MOP::Method::Accessor::_initialize_body, avg 1.01ms/call # spent 65.4ms making 35 calls to Moose::Meta::Method::Accessor::Native::_initialize_body, avg 1.87ms/call
43
44 return $self;
45}
46
47
# spent 239ms (11.9+227) within Class::MOP::Method::Accessor::_new which was called 1007 times, avg 237µs/call: # 762 times (7.22ms+227ms) by Class::MOP::Method::Accessor::new at line 24 of Moose/Meta/Method/Accessor.pm, avg 308µs/call # 188 times (3.00ms+0s) by Class::MOP::Method::Accessor::new at line 35, avg 16µs/call # 57 times (1.70ms+0s) by Class::MOP::Method::wrap at line 46 of Class/MOP/Method.pm, avg 30µs/call
sub _new {
48250411.3ms my $class = shift;
49
501524227ms return Class::MOP::Class->initialize($class)->new_object(@_)
# spent 213ms making 751 calls to Class::MOP::Class::new_object, avg 283µs/call # spent 9.14ms making 762 calls to Class::MOP::Class::initialize, avg 12µs/call # spent 5.54ms making 11 calls to Moose::Meta::Class::new_object, avg 504µs/call
51 if $class ne __PACKAGE__;
52
53 my $params = @_ == 1 ? $_[0] : {@_};
54
55 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
75365112.1mssub associated_attribute { (shift)->{'attribute'} }
769503.41mssub accessor_type { (shift)->{'accessor_type'} }
77
78## factory
79
80
# spent 964ms (16.3+948) within Class::MOP::Method::Accessor::_initialize_body which was called 950 times, avg 1.01ms/call: # 950 times (16.3ms+948ms) by Class::MOP::Method::Accessor::new at line 42, avg 1.01ms/call
sub _initialize_body {
81285015.5ms my $self = shift;
82
8319003.26ms my $method_name = join "_" => (
# spent 1.98ms making 950 calls to Class::MOP::Method::Accessor::accessor_type, avg 2µs/call # spent 1.28ms making 950 calls to Class::MOP::Method::Generated::is_inline, avg 1µs/call
84 '_generate',
85 $self->accessor_type,
86 'method',
87 ($self->is_inline ? 'inline' : ())
88 );
89
90950944ms $self->{'body'} = $self->$method_name();
# spent 541ms making 370 calls to Moose::Meta::Method::Accessor::_generate_reader_method, avg 1.46ms/call # spent 195ms making 141 calls to Moose::Meta::Method::Accessor::_generate_accessor_method, avg 1.38ms/call # spent 84.1ms making 124 calls to Moose::Meta::Method::Accessor::_generate_predicate_method, avg 678µs/call # spent 47.3ms making 85 calls to Moose::Meta::Method::Accessor::_generate_clearer_method, avg 557µs/call # spent 33.4ms making 30 calls to Moose::Meta::Method::Accessor::_generate_writer_method, avg 1.11ms/call # spent 24.7ms making 54 calls to Class::MOP::Method::Accessor::_generate_reader_method_inline, avg 458µs/call # spent 11.8ms making 22 calls to Class::MOP::Method::Accessor::_generate_accessor_method_inline, avg 536µs/call # spent 5.13ms making 16 calls to Class::MOP::Method::Accessor::_generate_predicate_method_inline, avg 321µs/call # spent 909µs making 3 calls to Class::MOP::Method::Accessor::_generate_writer_method_inline, avg 303µs/call # spent 708µs making 53 calls to Class::MOP::Method::Accessor::_generate_reader_method, avg 13µs/call # spent 244µs making 22 calls to Class::MOP::Method::Accessor::_generate_accessor_method, avg 11µs/call # spent 177µs making 16 calls to Class::MOP::Method::Accessor::_generate_predicate_method, avg 11µs/call # spent 123µs making 11 calls to MooseX::Emulate::Class::Accessor::Fast::Meta::Accessor::_generate_accessor_method, avg 11µs/call # spent 43µs making 3 calls to Class::MOP::Method::Accessor::_generate_writer_method, avg 14µs/call
91}
92
93## generators
94
95
# spent 244µs (209+35) within Class::MOP::Method::Accessor::_generate_accessor_method which was called 22 times, avg 11µs/call: # 22 times (209µs+35µs) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 11µs/call
sub _generate_accessor_method {
9666194µs my $self = shift;
972235µs my $attr = $self->associated_attribute;
# spent 35µs making 22 calls to Class::MOP::Method::Accessor::associated_attribute, avg 2µs/call
98
99 return sub {
100 if (@_ >= 2) {
101 $attr->set_value($_[0], $_[1]);
102 }
103 $attr->get_value($_[0]);
104 };
105}
106
107
# spent 202ms (3.02+199) within Class::MOP::Method::Accessor::_generate_accessor_method_inline which was called 163 times, avg 1.24ms/call: # 141 times (2.54ms+187ms) by Moose::Meta::Method::Accessor::_generate_accessor_method at line 74 of Moose/Meta/Method/Accessor.pm, avg 1.35ms/call # 22 times (475µs+11.3ms) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 536µs/call
sub _generate_accessor_method_inline {
1084892.38ms my $self = shift;
109163243µs my $attr = $self->associated_attribute;
# spent 243µs making 163 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
110
111
# spent 193ms (2.72+191) within Class::MOP::Method::Accessor::__ANON__[/Users/edenc/perl5/lib/perl5/darwin-multi-2level/Class/MOP/Method/Accessor.pm:120] which was called 163 times, avg 1.19ms/call: # 163 times (2.72ms+191ms) by Try::Tiny::try at line 71 of Try/Tiny.pm, avg 1.19ms/call
return try {
1121632.20ms489191ms $self->_compile_code([
# spent 85.9ms making 141 calls to Moose::Meta::Attribute::_inline_set_value, avg 609µs/call # spent 78.4ms making 141 calls to Moose::Meta::Method::Accessor::_compile_code, avg 556µs/call # spent 16.1ms making 141 calls to Moose::Meta::Attribute::_inline_get_value, avg 114µs/call # spent 6.41ms making 22 calls to Class::MOP::Method::Generated::_compile_code, avg 291µs/call # spent 3.16ms making 22 calls to Class::MOP::Attribute::_inline_set_value, avg 144µs/call # spent 755µs making 22 calls to Class::MOP::Attribute::_inline_get_value, avg 34µs/call
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 : $_";
123326779µs };
# spent 779µs making 163 calls to Try::Tiny::catch, avg 5µs/call # spent 198ms making 163 calls to Try::Tiny::try, avg 1.21ms/call, recursion: max depth 3, sum of overlapping time 198ms
124}
125
126
# spent 708µs (589+119) within Class::MOP::Method::Accessor::_generate_reader_method which was called 53 times, avg 13µs/call: # 53 times (589µs+119µs) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 13µs/call
sub _generate_reader_method {
127159544µs my $self = shift;
12853119µs my $attr = $self->associated_attribute;
# spent 119µs making 53 calls to Class::MOP::Method::Accessor::associated_attribute, avg 2µs/call
129
130 return sub {
1312458µs confess "Cannot assign a value to a read-only accessor"
132 if @_ > 1;
13312489µs $attr->get_value($_[0]);
# spent 489µs making 12 calls to Class::MOP::Attribute::get_value, avg 41µs/call
134 };
135}
136
137
# spent 555ms (7.85+547) within Class::MOP::Method::Accessor::_generate_reader_method_inline which was called 424 times, avg 1.31ms/call: # 370 times (6.76ms+523ms) by Moose::Meta::Method::Accessor::_generate_reader_method at line 62 of Moose/Meta/Method/Accessor.pm, avg 1.43ms/call # 54 times (1.09ms+23.6ms) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 458µs/call
sub _generate_reader_method_inline {
13812726.18ms my $self = shift;
139424654µs my $attr = $self->associated_attribute;
# spent 654µs making 424 calls to Class::MOP::Method::Accessor::associated_attribute, avg 2µs/call
140
141
# spent 533ms (7.04+526) within Class::MOP::Method::Accessor::__ANON__[/Users/edenc/perl5/lib/perl5/darwin-multi-2level/Class/MOP/Method/Accessor.pm:154] which was called 424 times, avg 1.26ms/call: # 424 times (7.04ms+526ms) by Try::Tiny::try at line 71 of Try/Tiny.pm, avg 1.26ms/call
return try {
1424245.87ms1272526ms $self->_compile_code([
# spent 266ms making 371 calls to Moose::Meta::Method::Accessor::_compile_code, avg 718µs/call # spent 147ms making 371 calls to Moose::Meta::Attribute::_inline_get_value, avg 395µs/call # spent 93.0ms making 371 calls to Moose::Meta::Method::_inline_throw_error, avg 251µs/call # spent 14.9ms making 53 calls to Class::MOP::Method::Generated::_compile_code, avg 280µs/call # spent 4.79ms making 53 calls to Class::MOP::Attribute::_inline_get_value, avg 90µs/call # spent 179µs making 53 calls to Class::MOP::Method::Accessor::_inline_throw_error, avg 3µ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 : $_";
1578481.94ms };
# spent 1.94ms making 424 calls to Try::Tiny::catch, avg 5µs/call # spent 544ms making 424 calls to Try::Tiny::try, avg 1.28ms/call, recursion: max depth 6, sum of overlapping time 544ms
158}
159
160
# spent 179µs within Class::MOP::Method::Accessor::_inline_throw_error which was called 53 times, avg 3µs/call: # 53 times (179µs+0s) by Class::MOP::Method::Accessor::__ANON__[/Users/edenc/perl5/lib/perl5/darwin-multi-2level/Class/MOP/Method/Accessor.pm:154] at line 142, avg 3µs/call
sub _inline_throw_error {
161106251µs my $self = shift;
162 return 'Carp::confess ' . $_[0];
163}
164
165
# spent 43µs (36+7) within Class::MOP::Method::Accessor::_generate_writer_method which was called 3 times, avg 14µs/call: # 3 times (36µs+7µs) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 14µs/call
sub _generate_writer_method {
166928µs my $self = shift;
16737µs my $attr = $self->associated_attribute;
# spent 7µs making 3 calls to Class::MOP::Method::Accessor::associated_attribute, avg 2µs/call
168
169 return sub {
170 $attr->set_value($_[0], $_[1]);
171 };
172}
173
174
# spent 33.4ms (593µs+32.8) within Class::MOP::Method::Accessor::_generate_writer_method_inline which was called 33 times, avg 1.01ms/call: # 30 times (536µs+31.9ms) by Moose::Meta::Method::Accessor::_generate_writer_method at line 68 of Moose/Meta/Method/Accessor.pm, avg 1.08ms/call # 3 times (58µs+851µs) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 303µs/call
sub _generate_writer_method_inline {
17599461µs my $self = shift;
1763344µs my $attr = $self->associated_attribute;
# spent 44µs making 33 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
177
178
# spent 31.8ms (409µs+31.4) within Class::MOP::Method::Accessor::__ANON__[/Users/edenc/perl5/lib/perl5/darwin-multi-2level/Class/MOP/Method/Accessor.pm:184] which was called 33 times, avg 964µs/call: # 33 times (409µs+31.4ms) by Try::Tiny::try at line 71 of Try/Tiny.pm, avg 964µs/call
return try {
17933336µs6631.4ms $self->_compile_code([
# spent 16.6ms making 30 calls to Moose::Meta::Method::Accessor::_compile_code, avg 552µs/call # spent 14.1ms making 30 calls to Moose::Meta::Attribute::_inline_set_value, avg 470µs/call # spent 639µs making 3 calls to Class::MOP::Method::Generated::_compile_code, avg 213µs/call # spent 111µs making 3 calls to Class::MOP::Attribute::_inline_set_value, avg 37µs/call
180 'sub {',
181 $attr->_inline_set_value('$_[0]', '$_[1]'),
182 '}',
183 ]);
184 }
185 catch {
186 confess "Could not generate inline writer because : $_";
18766142µs };
# spent 142µs making 33 calls to Try::Tiny::catch, avg 4µs/call # spent 32.6ms making 33 calls to Try::Tiny::try, avg 988µs/call, recursion: max depth 5, sum of overlapping time 32.6ms
188}
189
190
# spent 177µs (153+25) within Class::MOP::Method::Accessor::_generate_predicate_method which was called 16 times, avg 11µs/call: # 16 times (153µs+25µs) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 11µs/call
sub _generate_predicate_method {
19148134µs my $self = shift;
1921625µs my $attr = $self->associated_attribute;
# spent 25µs making 16 calls to Class::MOP::Method::Accessor::associated_attribute, avg 2µs/call
193
194 return sub {
1951253µs12406µs $attr->has_value($_[0])
# spent 406µs making 12 calls to Class::MOP::Attribute::has_value, avg 34µs/call
196 };
197}
198
199
# spent 85.4ms (2.57+82.9) within Class::MOP::Method::Accessor::_generate_predicate_method_inline which was called 140 times, avg 610µs/call: # 124 times (2.28ms+78.0ms) by Moose::Meta::Method::Accessor::_generate_predicate_method at line 80 of Moose/Meta/Method/Accessor.pm, avg 648µs/call # 16 times (286µs+4.84ms) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 321µs/call
sub _generate_predicate_method_inline {
2004201.94ms my $self = shift;
201140209µs my $attr = $self->associated_attribute;
# spent 209µs making 140 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
202
203
# spent 79.0ms (1.46+77.5) within Class::MOP::Method::Accessor::__ANON__[/Users/edenc/perl5/lib/perl5/darwin-multi-2level/Class/MOP/Method/Accessor.pm:209] which was called 140 times, avg 564µs/call: # 140 times (1.46ms+77.5ms) by Try::Tiny::try at line 71 of Try/Tiny.pm, avg 564µs/call
return try {
2041401.25ms28077.5ms $self->_compile_code([
# spent 68.5ms making 124 calls to Moose::Meta::Method::Accessor::_compile_code, avg 552µs/call # spent 5.36ms making 140 calls to Class::MOP::Attribute::_inline_has_value, avg 38µs/call # spent 3.65ms making 16 calls to Class::MOP::Method::Generated::_compile_code, avg 228µs/call
205 'sub {',
206 $attr->_inline_has_value('$_[0]'),
207 '}',
208 ]);
209 }
210 catch {
211 confess "Could not generate inline predicate because : $_";
212280603µs };
# spent 603µs making 140 calls to Try::Tiny::catch, avg 4µs/call # spent 82.1ms making 140 calls to Try::Tiny::try, avg 586µs/call, recursion: max depth 6, sum of overlapping time 82.1ms
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
224
# spent 45.0ms (1.44+43.6) within Class::MOP::Method::Accessor::_generate_clearer_method_inline which was called 85 times, avg 529µs/call: # 85 times (1.44ms+43.6ms) by Moose::Meta::Method::Accessor::_generate_clearer_method at line 86 of Moose/Meta/Method/Accessor.pm, avg 529µs/call
sub _generate_clearer_method_inline {
2252551.12ms my $self = shift;
22685110µs my $attr = $self->associated_attribute;
# spent 110µs making 85 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
227
228
# spent 41.3ms (847µs+40.4) within Class::MOP::Method::Accessor::__ANON__[/Users/edenc/perl5/lib/perl5/darwin-multi-2level/Class/MOP/Method/Accessor.pm:234] which was called 85 times, avg 485µs/call: # 85 times (847µs+40.4ms) by Try::Tiny::try at line 71 of Try/Tiny.pm, avg 485µs/call
return try {
22985692µs17040.4ms $self->_compile_code([
# spent 37.1ms making 85 calls to Moose::Meta::Method::Accessor::_compile_code, avg 437µs/call # spent 3.30ms making 85 calls to Class::MOP::Attribute::_inline_clear_value, avg 39µs/call
230 'sub {',
231 $attr->_inline_clear_value('$_[0]'),
232 '}',
233 ]);
234 }
235 catch {
236 confess "Could not generate inline clearer because : $_";
237170354µs };
# spent 354µs making 85 calls to Try::Tiny::catch, avg 4µs/call # spent 43.1ms making 85 calls to Try::Tiny::try, avg 507µs/call, recursion: max depth 6, sum of overlapping time 43.1ms
238}
239
24015µs1;
241
242# ABSTRACT: Method Meta Object for accessors
243
- -
246=pod
247
248=head1 NAME
249
250Class::MOP::Method::Accessor - Method Meta Object for accessors
251
252=head1 VERSION
253
254version 2.0602
255
256=head1 SYNOPSIS
257
258 use Class::MOP::Method::Accessor;
259
260 my $reader = Class::MOP::Method::Accessor->new(
261 attribute => $attribute,
262 is_inline => 1,
263 accessor_type => 'reader',
264 );
265
266 $reader->body->execute($instance); # call the reader method
267
268=head1 DESCRIPTION
269
270This is a subclass of C<Class::MOP::Method> which is used by
271C<Class::MOP::Attribute> to generate accessor code. It handles
272generation of readers, writers, predicates and clearers. For each type
273of method, it can either create a subroutine reference, or actually
274inline code by generating a string and C<eval>'ing it.
275
276=head1 METHODS
277
278=over 4
279
280=item B<< Class::MOP::Method::Accessor->new(%options) >>
281
282This returns a new C<Class::MOP::Method::Accessor> based on the
283C<%options> provided.
284
285=over 4
286
287=item * attribute
288
289This is the C<Class::MOP::Attribute> for which accessors are being
290generated. This option is required.
291
292=item * accessor_type
293
294This is a string which should be one of "reader", "writer",
295"accessor", "predicate", or "clearer". This is the type of method
296being generated. This option is required.
297
298=item * is_inline
299
300This indicates whether or not the accessor should be inlined. This
301defaults to false.
302
303=item * name
304
305The method name (without a package name). This is required.
306
307=item * package_name
308
309The package name for the method. This is required.
310
311=back
312
313=item B<< $metamethod->accessor_type >>
314
315Returns the accessor type which was passed to C<new>.
316
317=item B<< $metamethod->is_inline >>
318
319Returns a boolean indicating whether or not the accessor is inlined.
320
321=item B<< $metamethod->associated_attribute >>
322
323This returns the L<Class::MOP::Attribute> object which was passed to
324C<new>.
325
326=item B<< $metamethod->body >>
327
328The method itself is I<generated> when the accessor object is
329constructed.
330
331=back
332
333=head1 AUTHOR
334
335Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details.
336
337=head1 COPYRIGHT AND LICENSE
338
339This software is copyright (c) 2012 by Infinity Interactive, Inc..
340
341This is free software; you can redistribute it and/or modify it under
342the same terms as the Perl 5 programming language system itself.
343
344=cut
345
346
347__END__