← Index
NYTProf Performance Profile   « block view • line view • sub view »
For 05.Domain_and_Item.t
  Run on Tue May 4 17:21:41 2010
Reported on Tue May 4 17:23:03 2010

File /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP/Method/Accessor.pm
Statements Executed 6563
Statement Execution Time 20.1ms
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
2761110.5ms76.2msClass::MOP::Method::Accessor::::newClass::MOP::Method::Accessor::new
276112.58ms59.5msClass::MOP::Method::Accessor::::_initialize_bodyClass::MOP::Method::Accessor::_initialize_body
223222.09ms2.09msClass::MOP::Method::Accessor::::_newClass::MOP::Method::Accessor::_new
5211918µs4.39msClass::MOP::Method::Accessor::::_generate_reader_method_inlineClass::MOP::Method::Accessor::_generate_reader_method_inline
880273816µs816µsClass::MOP::Method::Accessor::::associated_attributeClass::MOP::Method::Accessor::associated_attribute
3122631µs2.44msClass::MOP::Method::Accessor::::_generate_predicate_method_inlineClass::MOP::Method::Accessor::_generate_predicate_method_inline
1511308µs1.47msClass::MOP::Method::Accessor::::_generate_accessor_method_inlineClass::MOP::Method::Accessor::_generate_accessor_method_inline
5211306µs353µsClass::MOP::Method::Accessor::::_generate_reader_methodClass::MOP::Method::Accessor::_generate_reader_method
27611296µs296µsClass::MOP::Method::Accessor::::accessor_typeClass::MOP::Method::Accessor::accessor_type
311102µs295µsClass::MOP::Method::Accessor::::_generate_clearer_method_inlineClass::MOP::Method::Accessor::_generate_clearer_method_inline
151186µs98µsClass::MOP::Method::Accessor::::_generate_accessor_methodClass::MOP::Method::Accessor::_generate_accessor_method
31168µs258µsClass::MOP::Method::Accessor::::_generate_writer_method_inlineClass::MOP::Method::Accessor::_generate_writer_method_inline
131163µs73µsClass::MOP::Method::Accessor::::_generate_predicate_methodClass::MOP::Method::Accessor::_generate_predicate_method
31120µs22µsClass::MOP::Method::Accessor::::_generate_writer_methodClass::MOP::Method::Accessor::_generate_writer_method
11114µs17µsClass::MOP::Method::Accessor::::BEGIN@4Class::MOP::Method::Accessor::BEGIN@4
1117µs17µsClass::MOP::Method::Accessor::::BEGIN@5Class::MOP::Method::Accessor::BEGIN@5
1117µs37µsClass::MOP::Method::Accessor::::BEGIN@8Class::MOP::Method::Accessor::BEGIN@8
1116µs1.64msClass::MOP::Method::Accessor::::BEGIN@14Class::MOP::Method::Accessor::BEGIN@14
1116µs32µsClass::MOP::Method::Accessor::::BEGIN@7Class::MOP::Method::Accessor::BEGIN@7
0000s0sClass::MOP::Method::Accessor::::__ANON__[:105]Class::MOP::Method::Accessor::__ANON__[:105]
0000s0sClass::MOP::Method::Accessor::::__ANON__[:113]Class::MOP::Method::Accessor::__ANON__[:113]
0000s0sClass::MOP::Method::Accessor::::__ANON__[:120]Class::MOP::Method::Accessor::__ANON__[:120]
0000s0sClass::MOP::Method::Accessor::::__ANON__[:127]Class::MOP::Method::Accessor::__ANON__[:127]
0000s0sClass::MOP::Method::Accessor::::__ANON__[:97]Class::MOP::Method::Accessor::__ANON__[:97]
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
4326µs220µs
# spent 17µs (14+3) within Class::MOP::Method::Accessor::BEGIN@4 which was called # once (14µs+3µs) by Class::MOP::Class::BEGIN@9 at line 4
use strict;
# spent 17µs making 1 call to Class::MOP::Method::Accessor::BEGIN@4 # spent 3µs making 1 call to strict::import
5322µs227µs
# spent 17µs (7+10) within Class::MOP::Method::Accessor::BEGIN@5 which was called # once (7µs+10µs) by Class::MOP::Class::BEGIN@9 at line 5
use warnings;
# spent 17µs making 1 call to Class::MOP::Method::Accessor::BEGIN@5 # spent 10µs making 1 call to warnings::import
6
7324µs258µs
# spent 32µs (6+26) within Class::MOP::Method::Accessor::BEGIN@7 which was called # once (6µs+26µs) by Class::MOP::Class::BEGIN@9 at line 7
use Carp 'confess';
# spent 32µs making 1 call to Class::MOP::Method::Accessor::BEGIN@7 # spent 26µs making 1 call to Exporter::import
8343µs267µs
# spent 37µs (7+30) within Class::MOP::Method::Accessor::BEGIN@8 which was called # once (7µs+30µs) by Class::MOP::Class::BEGIN@9 at line 8
use Scalar::Util 'blessed', 'weaken';
# spent 37µs making 1 call to Class::MOP::Method::Accessor::BEGIN@8 # spent 30µs making 1 call to Exporter::import
9
101700nsour $VERSION = '0.98';
11114µs$VERSION = eval $VERSION;
121300nsour $AUTHORITY = 'cpan:STEVAN';
13
143888µs23.27ms
# spent 1.64ms (6µs+1.63) within Class::MOP::Method::Accessor::BEGIN@14 which was called # once (6µs+1.63ms) by Class::MOP::Class::BEGIN@9 at line 14
use base 'Class::MOP::Method::Generated';
# spent 1.64ms making 1 call to Class::MOP::Method::Accessor::BEGIN@14 # spent 1.63ms making 1 call to base::import
15
16
# spent 76.2ms (10.5+65.7) within Class::MOP::Method::Accessor::new which was called 276 times, avg 276µs/call: # 276 times (10.5ms+65.7ms) by Class::MOP::Attribute::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP/Attribute.pm:340] at line 332 of Class/MOP/Attribute.pm, avg 276µs/call
sub new {
17276108µs my $class = shift;
18276679µs my %options = @_;
19
2027699µs (exists $options{attribute})
21 || confess "You must supply an attribute to construct with";
22
2327669µs (exists $options{accessor_type})
24 || confess "You must supply an accessor_type to construct with";
25
262761.46ms552437µs (blessed($options{attribute}) && $options{attribute}->isa('Class::MOP::Attribute'))
# spent 229µs making 276 calls to UNIVERSAL::isa, avg 832ns/call # spent 208µs making 276 calls to Scalar::Util::blessed, avg 754ns/call
27 || confess "You must supply an attribute which is a 'Class::MOP::Attribute' instance";
28
29276114µs ($options{package_name} && $options{name})
30 || confess "You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT";
31
322766.09ms2765.45ms my $self = $class->_new(\%options);
# spent 2.97ms making 108 calls to Moose::Meta::Method::Accessor::_new, avg 27µs/call # spent 1.45ms making 166 calls to Class::MOP::Method::Accessor::_new, avg 9µs/call # spent 1.04ms making 2 calls to Class::MOP::Method::_new, avg 520µs/call
33
34 # we don't want this creating
35 # a cycle in the code, if not
36 # needed
37276883µs276344µs weaken($self->{'attribute'});
# spent 344µs making 276 calls to Scalar::Util::weaken, avg 1µs/call
38
39276411µs27659.5ms $self->_initialize_body;
# spent 59.5ms making 276 calls to Class::MOP::Method::Accessor::_initialize_body, avg 216µs/call
40
41276804µs return $self;
42}
43
44
# spent 2.09ms within Class::MOP::Method::Accessor::_new which was called 223 times, avg 9µs/call: # 166 times (1.45ms+0s) by Class::MOP::Method::Accessor::new at line 32, avg 9µs/call # 57 times (649µs+0s) by Class::MOP::Method::wrap at line 44 of Class/MOP/Method.pm, avg 11µs/call
sub _new {
45223108µs my $class = shift;
46
4722347µs return Class::MOP::Class->initialize($class)->new_object(@_)
48 if $class ne __PACKAGE__;
49
5022387µs my $params = @_ == 1 ? $_[0] : {@_};
51
522232.00ms return bless {
53 # inherited from Class::MOP::Method
54 body => $params->{body},
55 associated_metaclass => $params->{associated_metaclass},
56 package_name => $params->{package_name},
57 name => $params->{name},
58 original_method => $params->{original_method},
59
60 # inherit from Class::MOP::Generated
61 is_inline => $params->{is_inline} || 0,
62 definition_context => $params->{definition_context},
63
64 # defined in this class
65 attribute => $params->{attribute},
66 accessor_type => $params->{accessor_type},
67 } => $class;
68}
69
70## accessors
71
728801.77ms
# spent 816µs within Class::MOP::Method::Accessor::associated_attribute which was called 880 times, avg 928ns/call: # 89 times (106µs+0s) by Moose::Meta::Method::Accessor::_inline_check_lazy at line 158 of Moose/Meta/Method/Accessor.pm, avg 1µs/call # 89 times (80µs+0s) by Moose::Meta::Method::Accessor::_inline_auto_deref at line 277 of Moose/Meta/Method/Accessor.pm, avg 902ns/call # 89 times (75µs+0s) by Moose::Meta::Method::Accessor::_eval_code at line 24 of Moose/Meta/Method/Accessor.pm, avg 837ns/call # 89 times (68µs+0s) by Moose::Meta::Method::Accessor::_inline_get at line 250 of Moose/Meta/Method/Accessor.pm, avg 761ns/call # 68 times (77µs+0s) by Moose::Meta::Method::Accessor::_generate_reader_method_inline at line 91 of Moose/Meta/Method/Accessor.pm, avg 1µs/call # 52 times (47µs+0s) by Class::MOP::Method::Accessor::_generate_reader_method at line 101, avg 902ns/call # 52 times (46µs+0s) by Class::MOP::Method::Accessor::_generate_reader_method_inline at line 153, avg 877ns/call # 42 times (39µs+0s) by Moose::Meta::Method::Accessor::_inline_store at line 216 of Moose/Meta/Method/Accessor.pm, avg 921ns/call # 42 times (33µs+0s) by Moose::Meta::Method::Accessor::_value_needs_copy at line 110 of Moose/Meta/Method/Accessor.pm, avg 795ns/call # 38 times (36µs+0s) by Moose::Meta::Method::Accessor::_inline_check_coercion at line 138 of Moose/Meta/Method/Accessor.pm, avg 937ns/call # 38 times (34µs+0s) by Moose::Meta::Method::Accessor::_inline_check_constraint at line 126 of Moose/Meta/Method/Accessor.pm, avg 887ns/call # 31 times (27µs+0s) by Class::MOP::Method::Accessor::_generate_predicate_method_inline at line 188, avg 868ns/call # 22 times (18µs+0s) by Moose::Meta::Method::Accessor::_inline_has at line 268 of Moose/Meta/Method/Accessor.pm, avg 841ns/call # 21 times (26µs+0s) by Moose::Meta::Method::Accessor::_inline_trigger at line 243 of Moose/Meta/Method/Accessor.pm, avg 1µs/call # 21 times (22µs+0s) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 48 of Moose/Meta/Method/Accessor.pm, avg 1µs/call # 21 times (17µs+0s) by Moose::Meta::Method::Accessor::_inline_check_required at line 146 of Moose/Meta/Method/Accessor.pm, avg 819ns/call # 20 times (19µs+0s) by Moose::Meta::Method::Accessor::_inline_get_old_value_for_trigger at line 229 of Moose/Meta/Method/Accessor.pm, avg 945ns/call # 15 times (13µs+0s) by Class::MOP::Method::Accessor::_generate_accessor_method_inline at line 134, avg 873ns/call # 15 times (13µs+0s) by Class::MOP::Method::Accessor::_generate_accessor_method at line 93, avg 840ns/call # 13 times (10µs+0s) by Class::MOP::Method::Accessor::_generate_predicate_method at line 117, avg 808ns/call # 3 times (3µs+0s) by Class::MOP::Method::Accessor::_generate_clearer_method_inline at line 205, avg 867ns/call # 3 times (3µs+0s) by Class::MOP::Method::Accessor::_generate_writer_method_inline at line 171, avg 867ns/call # 3 times (2µs+0s) by Class::MOP::Method::Accessor::_generate_writer_method at line 110, avg 800ns/call # once (1µs+0s) by MooseX::ClassAttribute::Meta::Method::Accessor::_inline_get at line 61 of MooseX/ClassAttribute/Meta/Method/Accessor.pm # once (1µs+0s) by MooseX::ClassAttribute::Meta::Method::Accessor::_inline_get_old_value_for_trigger at line 107 of MooseX/ClassAttribute/Meta/Method/Accessor.pm # once (900ns+0s) by MooseX::ClassAttribute::Meta::Method::Accessor::_inline_store at line 46 of MooseX/ClassAttribute/Meta/Method/Accessor.pm # once (800ns+0s) by MooseX::ClassAttribute::Meta::Method::Accessor::_inline_check_lazy at line 99 of MooseX/ClassAttribute/Meta/Method/Accessor.pm
sub associated_attribute { (shift)->{'attribute'} }
73276535µs
# spent 296µs within Class::MOP::Method::Accessor::accessor_type which was called 276 times, avg 1µs/call: # 276 times (296µs+0s) by Class::MOP::Method::Accessor::_initialize_body at line 80, avg 1µs/call
sub accessor_type { (shift)->{'accessor_type'} }
74
75## factory
76
77
# spent 59.5ms (2.58+56.9) within Class::MOP::Method::Accessor::_initialize_body which was called 276 times, avg 216µs/call: # 276 times (2.58ms+56.9ms) by Class::MOP::Method::Accessor::new at line 39, avg 216µs/call
sub _initialize_body {
7827649µs my $self = shift;
79
80276792µs552611µs my $method_name = join "_" => (
# spent 315µs making 276 calls to Class::MOP::Method::Generated::is_inline, avg 1µs/call # spent 296µs making 276 calls to Class::MOP::Method::Accessor::accessor_type, avg 1µs/call
81 '_generate',
82 $self->accessor_type,
83 'method',
84 ($self->is_inline ? 'inline' : ())
85 );
86
872761.08ms27656.3ms $self->{'body'} = $self->$method_name();
# spent 33.8ms making 67 calls to Moose::Meta::Method::Accessor::_generate_reader_method, avg 505µs/call # spent 12.5ms making 21 calls to Moose::Meta::Method::Accessor::_generate_accessor_method, avg 596µs/call # spent 4.39ms making 52 calls to Class::MOP::Method::Accessor::_generate_reader_method_inline, avg 84µs/call # spent 1.55ms making 18 calls to Moose::Meta::Method::Accessor::_generate_predicate_method, avg 86µs/call # spent 1.47ms making 15 calls to Class::MOP::Method::Accessor::_generate_accessor_method_inline, avg 98µs/call # spent 999µs making 13 calls to Class::MOP::Method::Accessor::_generate_predicate_method_inline, avg 77µs/call # spent 430µs making 1 call to Moose::Meta::Method::Accessor::_generate_reader_method_inline # spent 353µs making 52 calls to Class::MOP::Method::Accessor::_generate_reader_method, avg 7µs/call # spent 324µs making 3 calls to Moose::Meta::Method::Accessor::_generate_clearer_method, avg 108µs/call # spent 258µs making 3 calls to Class::MOP::Method::Accessor::_generate_writer_method_inline, avg 86µs/call # spent 98µs making 15 calls to Class::MOP::Method::Accessor::_generate_accessor_method, avg 7µs/call # spent 73µs making 13 calls to Class::MOP::Method::Accessor::_generate_predicate_method, avg 6µs/call # spent 22µs making 3 calls to Class::MOP::Method::Accessor::_generate_writer_method, avg 7µs/call
88}
89
90## generators
91
92
# spent 98µs (86+13) within Class::MOP::Method::Accessor::_generate_accessor_method which was called 15 times, avg 7µs/call: # 15 times (86µs+13µs) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 7µs/call
sub _generate_accessor_method {
931517µs1513µs my $attr = (shift)->associated_attribute;
# spent 13µs making 15 calls to Class::MOP::Method::Accessor::associated_attribute, avg 840ns/call
94 return sub {
95 $attr->set_value($_[0], $_[1]) if scalar(@_) == 2;
96 $attr->get_value($_[0]);
971562µs };
98}
99
100
# spent 353µs (306+47) within Class::MOP::Method::Accessor::_generate_reader_method which was called 52 times, avg 7µs/call: # 52 times (306µs+47µs) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 7µs/call
sub _generate_reader_method {
1015260µs5247µs my $attr = (shift)->associated_attribute;
# spent 47µs making 52 calls to Class::MOP::Method::Accessor::associated_attribute, avg 902ns/call
102 return sub {
10363µs confess "Cannot assign a value to a read-only accessor" if @_ > 1;
104625µs6161µs $attr->get_value($_[0]);
# spent 161µs making 6 calls to Class::MOP::Attribute::get_value, avg 27µs/call
10552221µs };
106}
107
108
109
# spent 22µs (20+2) within Class::MOP::Method::Accessor::_generate_writer_method which was called 3 times, avg 7µs/call: # 3 times (20µs+2µs) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 7µs/call
sub _generate_writer_method {
11034µs32µs my $attr = (shift)->associated_attribute;
# spent 2µs making 3 calls to Class::MOP::Method::Accessor::associated_attribute, avg 800ns/call
111 return sub {
112 $attr->set_value($_[0], $_[1]);
113312µs };
114}
115
116
# spent 73µs (63+10) within Class::MOP::Method::Accessor::_generate_predicate_method which was called 13 times, avg 6µs/call: # 13 times (63µs+10µs) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 6µs/call
sub _generate_predicate_method {
1171315µs1310µs my $attr = (shift)->associated_attribute;
# spent 10µs making 13 calls to Class::MOP::Method::Accessor::associated_attribute, avg 808ns/call
118 return sub {
11929µs257µs $attr->has_value($_[0])
# spent 57µs making 2 calls to Class::MOP::Attribute::has_value, avg 29µs/call
1201339µs };
121}
122
123sub _generate_clearer_method {
124 my $attr = (shift)->associated_attribute;
125 return sub {
126 $attr->clear_value($_[0])
127 };
128}
129
130## Inline methods
131
132
# spent 1.47ms (308µs+1.16) within Class::MOP::Method::Accessor::_generate_accessor_method_inline which was called 15 times, avg 98µs/call: # 15 times (308µs+1.16ms) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 98µs/call
sub _generate_accessor_method_inline {
133154µs my $self = shift;
1341515µs1513µs my $attr = $self->associated_attribute;
# spent 13µs making 15 calls to Class::MOP::Method::Accessor::associated_attribute, avg 873ns/call
1351541µs1510µs my $attr_name = $attr->name;
# spent 10µs making 15 calls to Class::MOP::Mixin::AttributeCore::name, avg 673ns/call
1361527µs3043µs my $meta_instance = $attr->associated_class->instance_metaclass;
# spent 29µs making 15 calls to Class::MOP::Class::instance_metaclass, avg 2µs/call # spent 14µs making 15 calls to Class::MOP::Attribute::associated_class, avg 907ns/call
137
1381585µs451.09ms my ( $code, $e ) = $self->_eval_closure(
# spent 912µs making 15 calls to Class::MOP::Method::Generated::_eval_closure, avg 61µs/call # spent 104µs making 15 calls to Class::MOP::Instance::inline_set_slot_value, avg 7µs/call # spent 75µs making 15 calls to Class::MOP::Instance::inline_get_slot_value, avg 5µs/call
139 {},
140 'sub {'
141 . $meta_instance->inline_set_slot_value('$_[0]', $attr_name, '$_[1]')
142 . ' if scalar(@_) == 2; '
143 . $meta_instance->inline_get_slot_value('$_[0]', $attr_name)
144 . '}'
145 );
146152µs confess "Could not generate inline accessor because : $e" if $e;
147
1481535µs return $code;
149}
150
151
# spent 4.39ms (918µs+3.47) within Class::MOP::Method::Accessor::_generate_reader_method_inline which was called 52 times, avg 84µs/call: # 52 times (918µs+3.47ms) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 84µs/call
sub _generate_reader_method_inline {
1525211µs my $self = shift;
1535249µs5246µs my $attr = $self->associated_attribute;
# spent 46µs making 52 calls to Class::MOP::Method::Accessor::associated_attribute, avg 877ns/call
15452145µs5236µs my $attr_name = $attr->name;
# spent 36µs making 52 calls to Class::MOP::Mixin::AttributeCore::name, avg 687ns/call
1555294µs104101µs my $meta_instance = $attr->associated_class->instance_metaclass;
# spent 53µs making 52 calls to Class::MOP::Class::instance_metaclass, avg 1µs/call # spent 48µs making 52 calls to Class::MOP::Attribute::associated_class, avg 921ns/call
156
15752199µs1043.29ms my ( $code, $e ) = $self->_eval_closure(
# spent 2.98ms making 52 calls to Class::MOP::Method::Generated::_eval_closure, avg 57µs/call # spent 309µs making 52 calls to Class::MOP::Instance::inline_get_slot_value, avg 6µs/call
158 {},
159 'sub {'
160 . 'confess "Cannot assign a value to a read-only accessor" if @_ > 1;'
161 . $meta_instance->inline_get_slot_value('$_[0]', $attr_name)
162 . '}'
163 );
164526µs confess "Could not generate inline reader because : $e" if $e;
165
16652119µs return $code;
167}
168
169
# spent 258µs (68+189) within Class::MOP::Method::Accessor::_generate_writer_method_inline which was called 3 times, avg 86µs/call: # 3 times (68µs+189µs) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 86µs/call
sub _generate_writer_method_inline {
17031µs my $self = shift;
17134µs33µs my $attr = $self->associated_attribute;
# spent 3µs making 3 calls to Class::MOP::Method::Accessor::associated_attribute, avg 867ns/call
172310µs32µs my $attr_name = $attr->name;
# spent 2µs making 3 calls to Class::MOP::Mixin::AttributeCore::name, avg 600ns/call
17337µs65µs my $meta_instance = $attr->associated_class->instance_metaclass;
# spent 3µs making 3 calls to Class::MOP::Class::instance_metaclass, avg 967ns/call # spent 2µs making 3 calls to Class::MOP::Attribute::associated_class, avg 833ns/call
174
175314µs6180µs my ( $code, $e ) = $self->_eval_closure(
# spent 160µs making 3 calls to Class::MOP::Method::Generated::_eval_closure, avg 53µs/call # spent 19µs making 3 calls to Class::MOP::Instance::inline_set_slot_value, avg 6µs/call
176 {},
177 'sub {'
178 . $meta_instance->inline_set_slot_value('$_[0]', $attr_name, '$_[1]')
179 . '}'
180 );
1813900ns confess "Could not generate inline writer because : $e" if $e;
182
18339µs return $code;
184}
185
186
# spent 2.44ms (631µs+1.81) within Class::MOP::Method::Accessor::_generate_predicate_method_inline which was called 31 times, avg 79µs/call: # 18 times (388µs+1.06ms) by Moose::Meta::Method::Accessor::_generate_predicate_method at line 117 of Moose/Meta/Method/Accessor.pm, avg 80µs/call # 13 times (243µs+756µs) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 77µs/call
sub _generate_predicate_method_inline {
1873110µs my $self = shift;
1883137µs3127µs my $attr = $self->associated_attribute;
# spent 27µs making 31 calls to Class::MOP::Method::Accessor::associated_attribute, avg 868ns/call
1893192µs3119µs my $attr_name = $attr->name;
# spent 19µs making 31 calls to Class::MOP::Mixin::AttributeCore::name, avg 629ns/call
1903169µs6263µs my $meta_instance = $attr->associated_class->instance_metaclass;
# spent 34µs making 31 calls to Class::MOP::Class::instance_metaclass, avg 1µs/call # spent 29µs making 31 calls to Class::MOP::Attribute::associated_class, avg 932ns/call
191
19231144µs621.70ms my ( $code, $e ) = $self->_eval_closure(
# spent 1.49ms making 31 calls to Class::MOP::Method::Generated::_eval_closure, avg 48µs/call # spent 209µs making 31 calls to Class::MOP::Instance::inline_is_slot_initialized, avg 7µs/call
193 {},
194 'sub {'
195 . $meta_instance->inline_is_slot_initialized('$_[0]', $attr_name)
196 . '}'
197 );
198317µs confess "Could not generate inline predicate because : $e" if $e;
199
2003189µs return $code;
201}
202
203
# spent 295µs (102+193) within Class::MOP::Method::Accessor::_generate_clearer_method_inline which was called 3 times, avg 98µs/call: # 3 times (102µs+193µs) by Moose::Meta::Method::Accessor::_generate_clearer_method at line 118 of Moose/Meta/Method/Accessor.pm, avg 98µs/call
sub _generate_clearer_method_inline {
20432µs my $self = shift;
20534µs33µs my $attr = $self->associated_attribute;
# spent 3µs making 3 calls to Class::MOP::Method::Accessor::associated_attribute, avg 867ns/call
206310µs32µs my $attr_name = $attr->name;
# spent 2µs making 3 calls to Class::MOP::Mixin::AttributeCore::name, avg 633ns/call
20738µs66µs my $meta_instance = $attr->associated_class->instance_metaclass;
# spent 3µs making 3 calls to Class::MOP::Class::instance_metaclass, avg 1µs/call # spent 3µs making 3 calls to Class::MOP::Attribute::associated_class, avg 1µs/call
208
209324µs6182µs my ( $code, $e ) = $self->_eval_closure(
# spent 155µs making 3 calls to Class::MOP::Method::Generated::_eval_closure, avg 52µs/call # spent 27µs making 3 calls to Class::MOP::Instance::inline_deinitialize_slot, avg 9µs/call
210 {},
211 'sub {'
212 . $meta_instance->inline_deinitialize_slot('$_[0]', $attr_name)
213 . '}'
214 );
2153800ns confess "Could not generate inline clearer because : $e" if $e;
216
217318µs return $code;
218}
219
22014µs1;
221
222__END__
223
224=pod
225
226=head1 NAME
227
228Class::MOP::Method::Accessor - Method Meta Object for accessors
229
230=head1 SYNOPSIS
231
232 use Class::MOP::Method::Accessor;
233
234 my $reader = Class::MOP::Method::Accessor->new(
235 attribute => $attribute,
236 is_inline => 1,
237 accessor_type => 'reader',
238 );
239
240 $reader->body->execute($instance); # call the reader method
241
242=head1 DESCRIPTION
243
244This is a subclass of <Class::MOP::Method> which is used by
245C<Class::MOP::Attribute> to generate accessor code. It handles
246generation of readers, writers, predicates and clearers. For each type
247of method, it can either create a subroutine reference, or actually
248inline code by generating a string and C<eval>'ing it.
249
250=head1 METHODS
251
252=over 4
253
254=item B<< Class::MOP::Method::Accessor->new(%options) >>
255
256This returns a new C<Class::MOP::Method::Accessor> based on the
257C<%options> provided.
258
259=over 4
260
261=item * attribute
262
263This is the C<Class::MOP::Attribute> for which accessors are being
264generated. This option is required.
265
266=item * accessor_type
267
268This is a string which should be one of "reader", "writer",
269"accessor", "predicate", or "clearer". This is the type of method
270being generated. This option is required.
271
272=item * is_inline
273
274This indicates whether or not the accessor should be inlined. This
275defaults to false.
276
277=item * name
278
279The method name (without a package name). This is required.
280
281=item * package_name
282
283The package name for the method. This is required.
284
285=back
286
287=item B<< $metamethod->accessor_type >>
288
289Returns the accessor type which was passed to C<new>.
290
291=item B<< $metamethod->is_inline >>
292
293Returns a boolean indicating whether or not the accessor is inlined.
294
295=item B<< $metamethod->associated_attribute >>
296
297This returns the L<Class::MOP::Attribute> object which was passed to
298C<new>.
299
300=item B<< $metamethod->body >>
301
302The method itself is I<generated> when the accessor object is
303constructed.
304
305=back
306
307=head1 AUTHORS
308
309Stevan Little E<lt>stevan@iinteractive.comE<gt>
310
311=head1 COPYRIGHT AND LICENSE
312
313Copyright 2006-2010 by Infinity Interactive, Inc.
314
315L<http://www.iinteractive.com>
316
317This library is free software; you can redistribute it and/or modify
318it under the same terms as Perl itself.
319
320=cut
321