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 |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
276 | 1 | 1 | 10.5ms | 76.2ms | new | Class::MOP::Method::Accessor::
276 | 1 | 1 | 2.58ms | 59.5ms | _initialize_body | Class::MOP::Method::Accessor::
223 | 2 | 2 | 2.09ms | 2.09ms | _new | Class::MOP::Method::Accessor::
52 | 1 | 1 | 918µs | 4.39ms | _generate_reader_method_inline | Class::MOP::Method::Accessor::
880 | 27 | 3 | 816µs | 816µs | associated_attribute | Class::MOP::Method::Accessor::
31 | 2 | 2 | 631µs | 2.44ms | _generate_predicate_method_inline | Class::MOP::Method::Accessor::
15 | 1 | 1 | 308µs | 1.47ms | _generate_accessor_method_inline | Class::MOP::Method::Accessor::
52 | 1 | 1 | 306µs | 353µs | _generate_reader_method | Class::MOP::Method::Accessor::
276 | 1 | 1 | 296µs | 296µs | accessor_type | Class::MOP::Method::Accessor::
3 | 1 | 1 | 102µs | 295µs | _generate_clearer_method_inline | Class::MOP::Method::Accessor::
15 | 1 | 1 | 86µs | 98µs | _generate_accessor_method | Class::MOP::Method::Accessor::
3 | 1 | 1 | 68µs | 258µs | _generate_writer_method_inline | Class::MOP::Method::Accessor::
13 | 1 | 1 | 63µs | 73µs | _generate_predicate_method | Class::MOP::Method::Accessor::
3 | 1 | 1 | 20µs | 22µs | _generate_writer_method | Class::MOP::Method::Accessor::
1 | 1 | 1 | 14µs | 17µs | BEGIN@4 | Class::MOP::Method::Accessor::
1 | 1 | 1 | 7µs | 17µs | BEGIN@5 | Class::MOP::Method::Accessor::
1 | 1 | 1 | 7µs | 37µs | BEGIN@8 | Class::MOP::Method::Accessor::
1 | 1 | 1 | 6µs | 1.64ms | BEGIN@14 | Class::MOP::Method::Accessor::
1 | 1 | 1 | 6µs | 32µs | BEGIN@7 | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:105] | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:113] | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:120] | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:127] | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:97] | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | _generate_clearer_method | Class::MOP::Method::Accessor::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | package Class::MOP::Method::Accessor; | ||||
3 | |||||
4 | 3 | 26µs | 2 | 20µ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 # spent 17µs making 1 call to Class::MOP::Method::Accessor::BEGIN@4
# spent 3µs making 1 call to strict::import |
5 | 3 | 22µs | 2 | 27µ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 # spent 17µs making 1 call to Class::MOP::Method::Accessor::BEGIN@5
# spent 10µs making 1 call to warnings::import |
6 | |||||
7 | 3 | 24µs | 2 | 58µ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 # spent 32µs making 1 call to Class::MOP::Method::Accessor::BEGIN@7
# spent 26µs making 1 call to Exporter::import |
8 | 3 | 43µs | 2 | 67µ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 # spent 37µs making 1 call to Class::MOP::Method::Accessor::BEGIN@8
# spent 30µs making 1 call to Exporter::import |
9 | |||||
10 | 1 | 700ns | our $VERSION = '0.98'; | ||
11 | 1 | 14µs | $VERSION = eval $VERSION; | ||
12 | 1 | 300ns | our $AUTHORITY = 'cpan:STEVAN'; | ||
13 | |||||
14 | 3 | 888µs | 2 | 3.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 # 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 | ||||
17 | 276 | 108µs | my $class = shift; | ||
18 | 276 | 679µs | my %options = @_; | ||
19 | |||||
20 | 276 | 99µs | (exists $options{attribute}) | ||
21 | || confess "You must supply an attribute to construct with"; | ||||
22 | |||||
23 | 276 | 69µs | (exists $options{accessor_type}) | ||
24 | || confess "You must supply an accessor_type to construct with"; | ||||
25 | |||||
26 | 276 | 1.46ms | 552 | 437µ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 | |||||
29 | 276 | 114µs | ($options{package_name} && $options{name}) | ||
30 | || confess "You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT"; | ||||
31 | |||||
32 | 276 | 6.09ms | 276 | 5.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 | ||||
37 | 276 | 883µs | 276 | 344µs | weaken($self->{'attribute'}); # spent 344µs making 276 calls to Scalar::Util::weaken, avg 1µs/call |
38 | |||||
39 | 276 | 411µs | 276 | 59.5ms | $self->_initialize_body; # spent 59.5ms making 276 calls to Class::MOP::Method::Accessor::_initialize_body, avg 216µs/call |
40 | |||||
41 | 276 | 804µ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 | ||||
45 | 223 | 108µs | my $class = shift; | ||
46 | |||||
47 | 223 | 47µs | return Class::MOP::Class->initialize($class)->new_object(@_) | ||
48 | if $class ne __PACKAGE__; | ||||
49 | |||||
50 | 223 | 87µs | my $params = @_ == 1 ? $_[0] : {@_}; | ||
51 | |||||
52 | 223 | 2.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 | |||||
72 | 880 | 1.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 | ||
73 | 276 | 535µ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 | ||
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 | ||||
78 | 276 | 49µs | my $self = shift; | ||
79 | |||||
80 | 276 | 792µs | 552 | 611µ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 | |||||
87 | 276 | 1.08ms | 276 | 56.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 | ||||
93 | 15 | 17µs | 15 | 13µ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]); | ||||
97 | 15 | 62µ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 | ||||
101 | 52 | 60µs | 52 | 47µ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 { | ||||
103 | 6 | 3µs | confess "Cannot assign a value to a read-only accessor" if @_ > 1; | ||
104 | 6 | 25µs | 6 | 161µs | $attr->get_value($_[0]); # spent 161µs making 6 calls to Class::MOP::Attribute::get_value, avg 27µs/call |
105 | 52 | 221µ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 | ||||
110 | 3 | 4µs | 3 | 2µ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]); | ||||
113 | 3 | 12µ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 | ||||
117 | 13 | 15µs | 13 | 10µ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 { | ||||
119 | 2 | 9µs | 2 | 57µs | $attr->has_value($_[0]) # spent 57µs making 2 calls to Class::MOP::Attribute::has_value, avg 29µs/call |
120 | 13 | 39µs | }; | ||
121 | } | ||||
122 | |||||
123 | sub _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 | ||||
133 | 15 | 4µs | my $self = shift; | ||
134 | 15 | 15µs | 15 | 13µs | my $attr = $self->associated_attribute; # spent 13µs making 15 calls to Class::MOP::Method::Accessor::associated_attribute, avg 873ns/call |
135 | 15 | 41µs | 15 | 10µs | my $attr_name = $attr->name; # spent 10µs making 15 calls to Class::MOP::Mixin::AttributeCore::name, avg 673ns/call |
136 | 15 | 27µs | 30 | 43µ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 | |||||
138 | 15 | 85µs | 45 | 1.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 | ); | ||||
146 | 15 | 2µs | confess "Could not generate inline accessor because : $e" if $e; | ||
147 | |||||
148 | 15 | 35µ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 | ||||
152 | 52 | 11µs | my $self = shift; | ||
153 | 52 | 49µs | 52 | 46µs | my $attr = $self->associated_attribute; # spent 46µs making 52 calls to Class::MOP::Method::Accessor::associated_attribute, avg 877ns/call |
154 | 52 | 145µs | 52 | 36µs | my $attr_name = $attr->name; # spent 36µs making 52 calls to Class::MOP::Mixin::AttributeCore::name, avg 687ns/call |
155 | 52 | 94µs | 104 | 101µ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 | |||||
157 | 52 | 199µs | 104 | 3.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 | ); | ||||
164 | 52 | 6µs | confess "Could not generate inline reader because : $e" if $e; | ||
165 | |||||
166 | 52 | 119µ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 | ||||
170 | 3 | 1µs | my $self = shift; | ||
171 | 3 | 4µs | 3 | 3µs | my $attr = $self->associated_attribute; # spent 3µs making 3 calls to Class::MOP::Method::Accessor::associated_attribute, avg 867ns/call |
172 | 3 | 10µs | 3 | 2µs | my $attr_name = $attr->name; # spent 2µs making 3 calls to Class::MOP::Mixin::AttributeCore::name, avg 600ns/call |
173 | 3 | 7µs | 6 | 5µ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 | |||||
175 | 3 | 14µs | 6 | 180µ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 | ); | ||||
181 | 3 | 900ns | confess "Could not generate inline writer because : $e" if $e; | ||
182 | |||||
183 | 3 | 9µ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 | ||||
187 | 31 | 10µs | my $self = shift; | ||
188 | 31 | 37µs | 31 | 27µs | my $attr = $self->associated_attribute; # spent 27µs making 31 calls to Class::MOP::Method::Accessor::associated_attribute, avg 868ns/call |
189 | 31 | 92µs | 31 | 19µs | my $attr_name = $attr->name; # spent 19µs making 31 calls to Class::MOP::Mixin::AttributeCore::name, avg 629ns/call |
190 | 31 | 69µs | 62 | 63µ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 | |||||
192 | 31 | 144µs | 62 | 1.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 | ); | ||||
198 | 31 | 7µs | confess "Could not generate inline predicate because : $e" if $e; | ||
199 | |||||
200 | 31 | 89µ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 | ||||
204 | 3 | 2µs | my $self = shift; | ||
205 | 3 | 4µs | 3 | 3µs | my $attr = $self->associated_attribute; # spent 3µs making 3 calls to Class::MOP::Method::Accessor::associated_attribute, avg 867ns/call |
206 | 3 | 10µs | 3 | 2µs | my $attr_name = $attr->name; # spent 2µs making 3 calls to Class::MOP::Mixin::AttributeCore::name, avg 633ns/call |
207 | 3 | 8µs | 6 | 6µ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 | |||||
209 | 3 | 24µs | 6 | 182µ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 | ); | ||||
215 | 3 | 800ns | confess "Could not generate inline clearer because : $e" if $e; | ||
216 | |||||
217 | 3 | 18µs | return $code; | ||
218 | } | ||||
219 | |||||
220 | 1 | 4µs | 1; | ||
221 | |||||
222 | __END__ | ||||
223 | |||||
224 | =pod | ||||
225 | |||||
226 | =head1 NAME | ||||
227 | |||||
228 | Class::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 | |||||
244 | This is a subclass of <Class::MOP::Method> which is used by | ||||
245 | C<Class::MOP::Attribute> to generate accessor code. It handles | ||||
246 | generation of readers, writers, predicates and clearers. For each type | ||||
247 | of method, it can either create a subroutine reference, or actually | ||||
248 | inline 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 | |||||
256 | This returns a new C<Class::MOP::Method::Accessor> based on the | ||||
257 | C<%options> provided. | ||||
258 | |||||
259 | =over 4 | ||||
260 | |||||
261 | =item * attribute | ||||
262 | |||||
263 | This is the C<Class::MOP::Attribute> for which accessors are being | ||||
264 | generated. This option is required. | ||||
265 | |||||
266 | =item * accessor_type | ||||
267 | |||||
268 | This is a string which should be one of "reader", "writer", | ||||
269 | "accessor", "predicate", or "clearer". This is the type of method | ||||
270 | being generated. This option is required. | ||||
271 | |||||
272 | =item * is_inline | ||||
273 | |||||
274 | This indicates whether or not the accessor should be inlined. This | ||||
275 | defaults to false. | ||||
276 | |||||
277 | =item * name | ||||
278 | |||||
279 | The method name (without a package name). This is required. | ||||
280 | |||||
281 | =item * package_name | ||||
282 | |||||
283 | The package name for the method. This is required. | ||||
284 | |||||
285 | =back | ||||
286 | |||||
287 | =item B<< $metamethod->accessor_type >> | ||||
288 | |||||
289 | Returns the accessor type which was passed to C<new>. | ||||
290 | |||||
291 | =item B<< $metamethod->is_inline >> | ||||
292 | |||||
293 | Returns a boolean indicating whether or not the accessor is inlined. | ||||
294 | |||||
295 | =item B<< $metamethod->associated_attribute >> | ||||
296 | |||||
297 | This returns the L<Class::MOP::Attribute> object which was passed to | ||||
298 | C<new>. | ||||
299 | |||||
300 | =item B<< $metamethod->body >> | ||||
301 | |||||
302 | The method itself is I<generated> when the accessor object is | ||||
303 | constructed. | ||||
304 | |||||
305 | =back | ||||
306 | |||||
307 | =head1 AUTHORS | ||||
308 | |||||
309 | Stevan Little E<lt>stevan@iinteractive.comE<gt> | ||||
310 | |||||
311 | =head1 COPYRIGHT AND LICENSE | ||||
312 | |||||
313 | Copyright 2006-2010 by Infinity Interactive, Inc. | ||||
314 | |||||
315 | L<http://www.iinteractive.com> | ||||
316 | |||||
317 | This library is free software; you can redistribute it and/or modify | ||||
318 | it under the same terms as Perl itself. | ||||
319 | |||||
320 | =cut | ||||
321 |