Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Method/Accessor.pm |
Statements | Executed 4835 statements in 15.1ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
197 | 2 | 2 | 4.38ms | 47.5ms | new | Class::MOP::Method::Accessor::
254 | 3 | 3 | 3.53ms | 7.28ms | _new | Class::MOP::Method::Accessor::
197 | 1 | 1 | 1.93ms | 36.8ms | _initialize_body | Class::MOP::Method::Accessor::
56 | 2 | 2 | 694µs | 16.2ms | _generate_reader_method_inline | Class::MOP::Method::Accessor::
56 | 1 | 1 | 640µs | 14.6ms | __ANON__[:154] | Class::MOP::Method::Accessor::
28 | 2 | 2 | 414µs | 13.8ms | _generate_accessor_method_inline | Class::MOP::Method::Accessor::
53 | 1 | 1 | 332µs | 387µs | _generate_reader_method | Class::MOP::Method::Accessor::
28 | 1 | 1 | 328µs | 12.9ms | __ANON__[:120] | Class::MOP::Method::Accessor::
16 | 1 | 1 | 188µs | 2.97ms | _generate_predicate_method_inline | Class::MOP::Method::Accessor::
22 | 1 | 1 | 140µs | 163µs | _generate_accessor_method | Class::MOP::Method::Accessor::
16 | 1 | 1 | 119µs | 2.54ms | __ANON__[:209] | Class::MOP::Method::Accessor::
53 | 1 | 1 | 106µs | 106µs | _inline_throw_error | Class::MOP::Method::Accessor::
16 | 1 | 1 | 95µs | 109µs | _generate_predicate_method | Class::MOP::Method::Accessor::
3 | 1 | 1 | 40µs | 564µs | _generate_writer_method_inline | Class::MOP::Method::Accessor::
3 | 1 | 1 | 25µs | 480µs | __ANON__[:184] | Class::MOP::Method::Accessor::
3 | 1 | 1 | 21µs | 24µs | _generate_writer_method | Class::MOP::Method::Accessor::
1 | 1 | 1 | 8µs | 4.62ms | BEGIN@17 | Class::MOP::Method::Accessor::
1 | 1 | 1 | 8µs | 8µs | BEGIN@3 | Class::MOP::Method::Accessor::
1 | 1 | 1 | 7µs | 44µs | BEGIN@15 | Class::MOP::Method::Accessor::
1 | 1 | 1 | 7µs | 18µs | BEGIN@11 | Class::MOP::Method::Accessor::
1 | 1 | 1 | 7µs | 10µs | BEGIN@10 | Class::MOP::Method::Accessor::
1 | 1 | 1 | 6µs | 28µs | BEGIN@13 | Class::MOP::Method::Accessor::
1 | 1 | 1 | 6µs | 30µs | BEGIN@14 | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:104] | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:123] | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:134] | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:157] | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:171] | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:187] | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:196] | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:212] | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:221] | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:234] | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:237] | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | _generate_clearer_method | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | _generate_clearer_method_inline | Class::MOP::Method::Accessor::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | package Class::MOP::Method::Accessor; | ||||
3 | # spent 8µs within Class::MOP::Method::Accessor::BEGIN@3 which was called:
# once (8µs+0s) by Class::MOP::Class::BEGIN@15 at line 5 | ||||
4 | 1 | 5µs | $Class::MOP::Method::Accessor::AUTHORITY = 'cpan:STEVAN'; | ||
5 | 1 | 21µs | 1 | 8µs | } # spent 8µs making 1 call to Class::MOP::Method::Accessor::BEGIN@3 |
6 | { | ||||
7 | 2 | 2µs | $Class::MOP::Method::Accessor::VERSION = '2.0602'; | ||
8 | } | ||||
9 | |||||
10 | 3 | 20µs | 2 | 12µs | # spent 10µs (7+2) within Class::MOP::Method::Accessor::BEGIN@10 which was called:
# once (7µs+2µs) by Class::MOP::Class::BEGIN@15 at line 10 # spent 10µs making 1 call to Class::MOP::Method::Accessor::BEGIN@10
# spent 2µs making 1 call to strict::import |
11 | 3 | 18µs | 2 | 28µs | # spent 18µs (7+10) within Class::MOP::Method::Accessor::BEGIN@11 which was called:
# once (7µs+10µs) by Class::MOP::Class::BEGIN@15 at line 11 # spent 18µs making 1 call to Class::MOP::Method::Accessor::BEGIN@11
# spent 10µs making 1 call to warnings::import |
12 | |||||
13 | 3 | 19µs | 2 | 50µs | # spent 28µs (6+22) within Class::MOP::Method::Accessor::BEGIN@13 which was called:
# once (6µs+22µs) by Class::MOP::Class::BEGIN@15 at line 13 # spent 28µs making 1 call to Class::MOP::Method::Accessor::BEGIN@13
# spent 22µs making 1 call to Exporter::import |
14 | 3 | 16µs | 2 | 54µs | # spent 30µs (6+24) within Class::MOP::Method::Accessor::BEGIN@14 which was called:
# once (6µs+24µs) by Class::MOP::Class::BEGIN@15 at line 14 # spent 30µs making 1 call to Class::MOP::Method::Accessor::BEGIN@14
# spent 24µs making 1 call to Exporter::import |
15 | 3 | 21µs | 2 | 80µs | # spent 44µs (7+37) within Class::MOP::Method::Accessor::BEGIN@15 which was called:
# once (7µs+37µs) by Class::MOP::Class::BEGIN@15 at line 15 # spent 44µs making 1 call to Class::MOP::Method::Accessor::BEGIN@15
# spent 36µs making 1 call to Exporter::import |
16 | |||||
17 | 3 | 992µs | 2 | 9.23ms | # spent 4.62ms (8µs+4.61) within Class::MOP::Method::Accessor::BEGIN@17 which was called:
# once (8µs+4.61ms) by Class::MOP::Class::BEGIN@15 at line 17 # spent 4.62ms making 1 call to Class::MOP::Method::Accessor::BEGIN@17
# spent 4.61ms making 1 call to base::import |
18 | |||||
19 | # spent 47.5ms (4.38+43.1) within Class::MOP::Method::Accessor::new which was called 197 times, avg 241µs/call:
# 188 times (4.06ms+29.2ms) by Class::MOP::Attribute::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Attribute.pm:398] at line 389 of Class/MOP/Attribute.pm, avg 177µs/call
# 9 times (313µs+13.9ms) by Class::MOP::Attribute::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Attribute.pm:398] at line 20 of Moose/Meta/Method/Accessor.pm, avg 1.58ms/call | ||||
20 | 197 | 99µs | my $class = shift; | ||
21 | 197 | 1.10ms | my %options = @_; | ||
22 | |||||
23 | 197 | 116µs | (exists $options{attribute}) | ||
24 | || confess "You must supply an attribute to construct with"; | ||||
25 | |||||
26 | 197 | 89µs | (exists $options{accessor_type}) | ||
27 | || confess "You must supply an accessor_type to construct with"; | ||||
28 | |||||
29 | 197 | 1.12ms | 394 | 344µs | (blessed($options{attribute}) && $options{attribute}->isa('Class::MOP::Attribute')) # spent 172µs making 197 calls to UNIVERSAL::isa, avg 876ns/call
# spent 172µs making 197 calls to Scalar::Util::blessed, avg 873ns/call |
30 | || confess "You must supply an attribute which is a 'Class::MOP::Attribute' instance"; | ||||
31 | |||||
32 | 197 | 96µs | ($options{package_name} && $options{name}) | ||
33 | || confess "You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT"; | ||||
34 | |||||
35 | 197 | 366µs | 197 | 1.90ms | my $self = $class->_new(\%options); # spent 1.88ms making 188 calls to Class::MOP::Method::Accessor::_new, avg 10µs/call
# spent 18µs making 9 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 | ||||
40 | 197 | 580µs | 197 | 219µs | weaken($self->{'attribute'}); # spent 219µs making 197 calls to Scalar::Util::weaken, avg 1µs/call |
41 | |||||
42 | 197 | 562µs | 197 | 36.8ms | $self->_initialize_body; # spent 36.8ms making 197 calls to Class::MOP::Method::Accessor::_initialize_body, avg 187µs/call |
43 | |||||
44 | 197 | 614µs | return $self; | ||
45 | } | ||||
46 | |||||
47 | # spent 7.28ms (3.53+3.75) within Class::MOP::Method::Accessor::_new which was called 254 times, avg 29µs/call:
# 188 times (1.88ms+0s) by Class::MOP::Method::Accessor::new at line 35, avg 10µs/call
# 57 times (1.57ms+0s) by Class::MOP::Method::wrap at line 46 of Class/MOP/Method.pm, avg 27µs/call
# 9 times (82µs+3.75ms) by Class::MOP::Method::Accessor::new at line 24 of Moose/Meta/Method/Accessor.pm, avg 426µs/call | ||||
48 | 254 | 105µs | my $class = shift; | ||
49 | |||||
50 | 254 | 161µs | 18 | 3.75ms | return Class::MOP::Class->initialize($class)->new_object(@_) # spent 3.20ms making 9 calls to Class::MOP::Class::new_object, avg 355µs/call
# spent 555µs making 9 calls to Class::MOP::Class::initialize, avg 62µs/call |
51 | if $class ne __PACKAGE__; | ||||
52 | |||||
53 | 245 | 143µs | my $params = @_ == 1 ? $_[0] : {@_}; | ||
54 | |||||
55 | 245 | 3.35ms | 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 | |||||
75 | 221 | 545µs | sub associated_attribute { (shift)->{'attribute'} } | ||
76 | 197 | 422µs | sub accessor_type { (shift)->{'accessor_type'} } | ||
77 | |||||
78 | ## factory | ||||
79 | |||||
80 | # spent 36.8ms (1.93+34.9) within Class::MOP::Method::Accessor::_initialize_body which was called 197 times, avg 187µs/call:
# 197 times (1.93ms+34.9ms) by Class::MOP::Method::Accessor::new at line 42, avg 187µs/call | ||||
81 | 197 | 55µs | my $self = shift; | ||
82 | |||||
83 | 197 | 991µs | 394 | 395µs | my $method_name = join "_" => ( # spent 239µs making 197 calls to Class::MOP::Method::Accessor::accessor_type, avg 1µs/call
# spent 156µs making 197 calls to Class::MOP::Method::Generated::is_inline, avg 791ns/call |
84 | '_generate', | ||||
85 | $self->accessor_type, | ||||
86 | 'method', | ||||
87 | ($self->is_inline ? 'inline' : ()) | ||||
88 | ); | ||||
89 | |||||
90 | 197 | 820µs | 197 | 34.5ms | $self->{'body'} = $self->$method_name(); # spent 14.3ms making 54 calls to Class::MOP::Method::Accessor::_generate_reader_method_inline, avg 264µs/call
# spent 7.09ms making 6 calls to Moose::Meta::Method::Accessor::_generate_accessor_method, avg 1.18ms/call
# spent 6.90ms making 22 calls to Class::MOP::Method::Accessor::_generate_accessor_method_inline, avg 314µs/call
# spent 2.97ms making 16 calls to Class::MOP::Method::Accessor::_generate_predicate_method_inline, avg 185µs/call
# spent 2.00ms making 2 calls to Moose::Meta::Method::Accessor::_generate_reader_method, avg 1.00ms/call
# spent 564µs making 3 calls to Class::MOP::Method::Accessor::_generate_writer_method_inline, avg 188µs/call
# spent 387µs making 53 calls to Class::MOP::Method::Accessor::_generate_reader_method, avg 7µs/call
# spent 163µs making 22 calls to Class::MOP::Method::Accessor::_generate_accessor_method, avg 7µs/call
# spent 109µs making 16 calls to Class::MOP::Method::Accessor::_generate_predicate_method, avg 7µs/call
# spent 24µs making 3 calls to Class::MOP::Method::Accessor::_generate_writer_method, avg 8µs/call |
91 | } | ||||
92 | |||||
93 | ## generators | ||||
94 | |||||
95 | # spent 163µs (140+23) within Class::MOP::Method::Accessor::_generate_accessor_method which was called 22 times, avg 7µs/call:
# 22 times (140µs+23µs) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 7µs/call | ||||
96 | 22 | 7µs | my $self = shift; | ||
97 | 22 | 29µs | 22 | 23µ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]); | ||||
104 | 22 | 99µs | }; | ||
105 | } | ||||
106 | |||||
107 | # spent 13.8ms (414µs+13.4) within Class::MOP::Method::Accessor::_generate_accessor_method_inline which was called 28 times, avg 493µs/call:
# 22 times (319µs+6.59ms) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 314µs/call
# 6 times (96µs+6.81ms) by Moose::Meta::Method::Accessor::_generate_accessor_method at line 74 of Moose/Meta/Method/Accessor.pm, avg 1.15ms/call | ||||
108 | 28 | 13µs | my $self = shift; | ||
109 | 28 | 39µs | 28 | 30µs | my $attr = $self->associated_attribute; # spent 30µs making 28 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call |
110 | |||||
111 | # spent 12.9ms (328µs+12.6) within Class::MOP::Method::Accessor::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Method/Accessor.pm:120] which was called 28 times, avg 461µs/call:
# 28 times (328µs+12.6ms) by Try::Tiny::try at line 71 of Try/Tiny.pm, avg 461µs/call | ||||
112 | 28 | 246µs | 84 | 12.6ms | $self->_compile_code([ # spent 3.71ms making 22 calls to Class::MOP::Method::Generated::_compile_code, avg 169µs/call
# spent 3.09ms making 6 calls to Moose::Meta::Attribute::_inline_set_value, avg 514µs/call
# spent 2.83ms making 6 calls to Moose::Meta::Method::Accessor::_compile_code, avg 472µs/call
# spent 1.83ms making 22 calls to Class::MOP::Attribute::_inline_set_value, avg 83µs/call
# spent 668µs making 6 calls to Moose::Meta::Attribute::_inline_get_value, avg 111µs/call
# spent 447µs making 22 calls to Class::MOP::Attribute::_inline_get_value, avg 20µ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 : $_"; | ||||
123 | 28 | 244µs | 56 | 68µs | }; # spent 68µs making 28 calls to Try::Tiny::catch, avg 2µs/call
# spent 13.3ms making 28 calls to Try::Tiny::try, avg 475µs/call, recursion: max depth 2, sum of overlapping time 13.3ms |
124 | } | ||||
125 | |||||
126 | # spent 387µs (332+55) within Class::MOP::Method::Accessor::_generate_reader_method which was called 53 times, avg 7µs/call:
# 53 times (332µs+55µs) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 7µs/call | ||||
127 | 53 | 14µs | my $self = shift; | ||
128 | 53 | 66µs | 53 | 55µs | my $attr = $self->associated_attribute; # spent 55µs making 53 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call |
129 | |||||
130 | return sub { | ||||
131 | 12 | 6µs | confess "Cannot assign a value to a read-only accessor" | ||
132 | if @_ > 1; | ||||
133 | 12 | 46µs | 12 | 339µs | $attr->get_value($_[0]); # spent 339µs making 12 calls to Class::MOP::Attribute::get_value, avg 28µs/call |
134 | 53 | 237µs | }; | ||
135 | } | ||||
136 | |||||
137 | # spent 16.2ms (694µs+15.5) within Class::MOP::Method::Accessor::_generate_reader_method_inline which was called 56 times, avg 289µs/call:
# 54 times (642µs+13.6ms) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 264µs/call
# 2 times (52µs+1.88ms) by Moose::Meta::Method::Accessor::_generate_reader_method at line 62 of Moose/Meta/Method/Accessor.pm, avg 967µs/call | ||||
138 | 56 | 24µs | my $self = shift; | ||
139 | 56 | 71µs | 56 | 58µs | my $attr = $self->associated_attribute; # spent 58µs making 56 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call |
140 | |||||
141 | # spent 14.6ms (640µs+14.0) within Class::MOP::Method::Accessor::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Method/Accessor.pm:154] which was called 56 times, avg 261µs/call:
# 56 times (640µs+14.0ms) by Try::Tiny::try at line 71 of Try/Tiny.pm, avg 261µs/call | ||||
142 | 56 | 444µs | 168 | 14.0ms | $self->_compile_code([ # spent 8.35ms making 53 calls to Class::MOP::Method::Generated::_compile_code, avg 158µs/call
# spent 3.00ms making 53 calls to Class::MOP::Attribute::_inline_get_value, avg 57µs/call
# spent 1.19ms making 3 calls to Moose::Meta::Method::Accessor::_compile_code, avg 398µs/call
# spent 722µs making 3 calls to Moose::Meta::Method::_inline_throw_error, avg 241µs/call
# spent 583µs making 3 calls to Moose::Meta::Attribute::_inline_get_value, avg 194µs/call
# spent 106µ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 : $_"; | ||||
157 | 56 | 430µs | 112 | 130µs | }; # spent 130µs making 56 calls to Try::Tiny::catch, avg 2µs/call
# spent 15.3ms making 56 calls to Try::Tiny::try, avg 273µs/call, recursion: max depth 2, sum of overlapping time 15.3ms |
158 | } | ||||
159 | |||||
160 | # spent 106µs within Class::MOP::Method::Accessor::_inline_throw_error which was called 53 times, avg 2µs/call:
# 53 times (106µs+0s) by Class::MOP::Method::Accessor::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Method/Accessor.pm:154] at line 142, avg 2µs/call | ||||
161 | 53 | 20µs | my $self = shift; | ||
162 | 53 | 198µs | return 'Carp::confess ' . $_[0]; | ||
163 | } | ||||
164 | |||||
165 | # spent 24µs (21+3) within Class::MOP::Method::Accessor::_generate_writer_method which was called 3 times, avg 8µs/call:
# 3 times (21µs+3µs) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 8µs/call | ||||
166 | 3 | 2µs | my $self = shift; | ||
167 | 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 |
168 | |||||
169 | return sub { | ||||
170 | $attr->set_value($_[0], $_[1]); | ||||
171 | 3 | 13µs | }; | ||
172 | } | ||||
173 | |||||
174 | # spent 564µs (40+524) within Class::MOP::Method::Accessor::_generate_writer_method_inline which was called 3 times, avg 188µs/call:
# 3 times (40µs+524µs) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 188µs/call | ||||
175 | 3 | 2µs | my $self = shift; | ||
176 | 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 900ns/call |
177 | |||||
178 | # spent 480µs (25+455) within Class::MOP::Method::Accessor::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Method/Accessor.pm:184] which was called 3 times, avg 160µs/call:
# 3 times (25µs+455µs) by Try::Tiny::try at line 71 of Try/Tiny.pm, avg 160µs/call | ||||
179 | 3 | 21µs | 6 | 455µs | $self->_compile_code([ # spent 375µs making 3 calls to Class::MOP::Method::Generated::_compile_code, avg 125µs/call
# spent 79µs making 3 calls to Class::MOP::Attribute::_inline_set_value, avg 26µs/call |
180 | 'sub {', | ||||
181 | $attr->_inline_set_value('$_[0]', '$_[1]'), | ||||
182 | '}', | ||||
183 | ]); | ||||
184 | } | ||||
185 | catch { | ||||
186 | confess "Could not generate inline writer because : $_"; | ||||
187 | 3 | 23µs | 6 | 6µs | }; # spent 6µs making 3 calls to Try::Tiny::catch, avg 2µs/call
# spent 515µs making 3 calls to Try::Tiny::try, avg 172µs/call, recursion: max depth 1, sum of overlapping time 515µs |
188 | } | ||||
189 | |||||
190 | # spent 109µs (95+14) within Class::MOP::Method::Accessor::_generate_predicate_method which was called 16 times, avg 7µs/call:
# 16 times (95µs+14µs) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 7µs/call | ||||
191 | 16 | 5µs | my $self = shift; | ||
192 | 16 | 17µs | 16 | 14µs | my $attr = $self->associated_attribute; # spent 14µs making 16 calls to Class::MOP::Method::Accessor::associated_attribute, avg 894ns/call |
193 | |||||
194 | return sub { | ||||
195 | 12 | 54µs | 12 | 274µs | $attr->has_value($_[0]) # spent 274µs making 12 calls to Class::MOP::Attribute::has_value, avg 23µs/call |
196 | 16 | 68µs | }; | ||
197 | } | ||||
198 | |||||
199 | # spent 2.97ms (188µs+2.78) within Class::MOP::Method::Accessor::_generate_predicate_method_inline which was called 16 times, avg 185µs/call:
# 16 times (188µs+2.78ms) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 185µs/call | ||||
200 | 16 | 6µs | my $self = shift; | ||
201 | 16 | 21µs | 16 | 17µ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 | # spent 2.54ms (119µs+2.42) within Class::MOP::Method::Accessor::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Method/Accessor.pm:209] which was called 16 times, avg 159µs/call:
# 16 times (119µs+2.42ms) by Try::Tiny::try at line 71 of Try/Tiny.pm, avg 159µs/call | ||||
204 | 16 | 96µs | 32 | 2.42ms | $self->_compile_code([ # spent 2.03ms making 16 calls to Class::MOP::Method::Generated::_compile_code, avg 127µs/call
# spent 392µs making 16 calls to Class::MOP::Attribute::_inline_has_value, avg 24µs/call |
205 | 'sub {', | ||||
206 | $attr->_inline_has_value('$_[0]'), | ||||
207 | '}', | ||||
208 | ]); | ||||
209 | } | ||||
210 | catch { | ||||
211 | confess "Could not generate inline predicate because : $_"; | ||||
212 | 16 | 116µs | 32 | 36µs | }; # spent 36µs making 16 calls to Try::Tiny::catch, avg 2µs/call
# spent 2.73ms making 16 calls to Try::Tiny::try, avg 170µs/call, recursion: max depth 1, sum of overlapping time 2.73ms |
213 | } | ||||
214 | |||||
215 | sub _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 | sub _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 | |||||
240 | 1 | 5µs | 1; | ||
241 | |||||
242 | # ABSTRACT: Method Meta Object for accessors | ||||
243 | |||||
- - | |||||
246 | =pod | ||||
247 | |||||
248 | =head1 NAME | ||||
249 | |||||
250 | Class::MOP::Method::Accessor - Method Meta Object for accessors | ||||
251 | |||||
252 | =head1 VERSION | ||||
253 | |||||
254 | version 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 | |||||
270 | This is a subclass of C<Class::MOP::Method> which is used by | ||||
271 | C<Class::MOP::Attribute> to generate accessor code. It handles | ||||
272 | generation of readers, writers, predicates and clearers. For each type | ||||
273 | of method, it can either create a subroutine reference, or actually | ||||
274 | inline 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 | |||||
282 | This returns a new C<Class::MOP::Method::Accessor> based on the | ||||
283 | C<%options> provided. | ||||
284 | |||||
285 | =over 4 | ||||
286 | |||||
287 | =item * attribute | ||||
288 | |||||
289 | This is the C<Class::MOP::Attribute> for which accessors are being | ||||
290 | generated. This option is required. | ||||
291 | |||||
292 | =item * accessor_type | ||||
293 | |||||
294 | This is a string which should be one of "reader", "writer", | ||||
295 | "accessor", "predicate", or "clearer". This is the type of method | ||||
296 | being generated. This option is required. | ||||
297 | |||||
298 | =item * is_inline | ||||
299 | |||||
300 | This indicates whether or not the accessor should be inlined. This | ||||
301 | defaults to false. | ||||
302 | |||||
303 | =item * name | ||||
304 | |||||
305 | The method name (without a package name). This is required. | ||||
306 | |||||
307 | =item * package_name | ||||
308 | |||||
309 | The package name for the method. This is required. | ||||
310 | |||||
311 | =back | ||||
312 | |||||
313 | =item B<< $metamethod->accessor_type >> | ||||
314 | |||||
315 | Returns the accessor type which was passed to C<new>. | ||||
316 | |||||
317 | =item B<< $metamethod->is_inline >> | ||||
318 | |||||
319 | Returns a boolean indicating whether or not the accessor is inlined. | ||||
320 | |||||
321 | =item B<< $metamethod->associated_attribute >> | ||||
322 | |||||
323 | This returns the L<Class::MOP::Attribute> object which was passed to | ||||
324 | C<new>. | ||||
325 | |||||
326 | =item B<< $metamethod->body >> | ||||
327 | |||||
328 | The method itself is I<generated> when the accessor object is | ||||
329 | constructed. | ||||
330 | |||||
331 | =back | ||||
332 | |||||
333 | =head1 AUTHOR | ||||
334 | |||||
335 | Moose 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 | |||||
339 | This software is copyright (c) 2012 by Infinity Interactive, Inc.. | ||||
340 | |||||
341 | This is free software; you can redistribute it and/or modify it under | ||||
342 | the same terms as the Perl 5 programming language system itself. | ||||
343 | |||||
344 | =cut | ||||
345 | |||||
346 | |||||
347 | __END__ |