Profile of /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Meta/Method/Accessor.pm

← 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:12 2010

File | /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Meta/Method/Accessor.pm
Statements Executed | 3488
Statement Execution Time | 9.12ms

Subroutines — ordered by exclusive time
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
68 | 2 | 2 | 1.54ms | 34.0ms | Moose::Meta::Method::Accessor::::_generate_reader_method_inlineMoose::Meta::Method::Accessor::_generate_reader_method_inline
89 | 2 | 1 | 1.49ms | 17.5ms | Moose::Meta::Method::Accessor::::_eval_codeMoose::Meta::Method::Accessor::_eval_code
89 | 3 | 2 | 1.27ms | 3.82ms | Moose::Meta::Method::Accessor::::_inline_check_lazyMoose::Meta::Method::Accessor::_inline_check_lazy
89 | 3 | 1 | 1.10ms | 16.3ms | Moose::Meta::Method::Accessor::::_inline_getMoose::Meta::Method::Accessor::_inline_get
21 | 1 | 1 | 910µs | 12.4ms | Moose::Meta::Method::Accessor::::_generate_accessor_method_inlineMoose::Meta::Method::Accessor::_generate_accessor_method_inline
42 | 2 | 1 | 720µs | 3.88ms | Moose::Meta::Method::Accessor::::_inline_storeMoose::Meta::Method::Accessor::_inline_store
89 | 2 | 1 | 567µs | 843µs | Moose::Meta::Method::Accessor::::_inline_auto_derefMoose::Meta::Method::Accessor::_inline_auto_deref
38 | 2 | 1 | 478µs | 669µs | Moose::Meta::Method::Accessor::::_inline_check_constraintMoose::Meta::Method::Accessor::_inline_check_constraint
22 | 1 | 1 | 323µs | 606µs | Moose::Meta::Method::Accessor::::_inline_hasMoose::Meta::Method::Accessor::_inline_has
38 | 2 | 1 | 284µs | 382µs | Moose::Meta::Method::Accessor::::_inline_check_coercionMoose::Meta::Method::Accessor::_inline_check_coercion
67 | 1 | 1 | 226µs | 33.8ms | Moose::Meta::Method::Accessor::::_generate_reader_methodMoose::Meta::Method::Accessor::_generate_reader_method
42 | 2 | 1 | 217µs | 316µs | Moose::Meta::Method::Accessor::::_value_needs_copyMoose::Meta::Method::Accessor::_value_needs_copy
22 | 2 | 1 | 196µs | 970µs | Moose::Meta::Method::Accessor::::_inline_init_slotMoose::Meta::Method::Accessor::_inline_init_slot
20 | 1 | 1 | 159µs | 355µs | Moose::Meta::Method::Accessor::::_inline_get_old_value_for_triggerMoose::Meta::Method::Accessor::_inline_get_old_value_for_trigger
21 | 1 | 1 | 151µs | 206µs | Moose::Meta::Method::Accessor::::_inline_triggerMoose::Meta::Method::Accessor::_inline_trigger
21 | 1 | 1 | 140µs | 199µs | Moose::Meta::Method::Accessor::::_inline_check_requiredMoose::Meta::Method::Accessor::_inline_check_required
89 | 2 | 1 | 106µs | 106µs | Moose::Meta::Method::Accessor::::_inline_pre_bodyMoose::Meta::Method::Accessor::_inline_pre_body
18 | 1 | 1 | 101µs | 1.55ms | Moose::Meta::Method::Accessor::::_generate_predicate_methodMoose::Meta::Method::Accessor::_generate_predicate_method
89 | 2 | 1 | 100µs | 100µs | Moose::Meta::Method::Accessor::::_inline_post_bodyMoose::Meta::Method::Accessor::_inline_post_body
21 | 1 | 1 | 79µs | 12.5ms | Moose::Meta::Method::Accessor::::_generate_accessor_methodMoose::Meta::Method::Accessor::_generate_accessor_method
21 | 1 | 1 | 72µs | 200µs | Moose::Meta::Method::Accessor::::_inline_copy_valueMoose::Meta::Method::Accessor::_inline_copy_value
3 | 1 | 1 | 29µs | 324µs | Moose::Meta::Method::Accessor::::_generate_clearer_methodMoose::Meta::Method::Accessor::_generate_clearer_method
1 | 1 | 1 | 14µs | 17µs | Moose::Meta::Method::Accessor::::BEGIN@4Moose::Meta::Method::Accessor::BEGIN@4
1 | 1 | 1 | 8µs | 17µs | Moose::Meta::Method::Accessor::::BEGIN@5Moose::Meta::Method::Accessor::BEGIN@5
1 | 1 | 1 | 7µs | 79µs | Moose::Meta::Method::Accessor::::BEGIN@11Moose::Meta::Method::Accessor::BEGIN@11
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::::_error_throwerMoose::Meta::Method::Accessor::_error_thrower
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::::_generate_writer_methodMoose::Meta::Method::Accessor::_generate_writer_method
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::::_generate_writer_method_inlineMoose::Meta::Method::Accessor::_generate_writer_method_inline
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::::_inline_accessMoose::Meta::Method::Accessor::_inline_access

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  |
2 |  |  |  |  | package Moose::Meta::Method::Accessor;
3 |  |  |  |  |
4 | 3 | 22µs | 2 | 20µs | # spent 17µs (14+3) within Moose::Meta::Method::Accessor::BEGIN@4 which was called # once (14µs+3µs) by Moose::Meta::Attribute::BEGIN@15 at line 4 use strict; # spent 17µs making 1 call to Moose::Meta::Method::Accessor::BEGIN@4 # spent 3µs making 1 call to strict::import
5 | 3 | 57µs | 2 | 26µs | # spent 17µs (8+9) within Moose::Meta::Method::Accessor::BEGIN@5 which was called # once (8µs+9µs) by Moose::Meta::Attribute::BEGIN@15 at line 5 use warnings; # spent 17µs making 1 call to Moose::Meta::Method::Accessor::BEGIN@5 # spent 9µs making 1 call to warnings::import
6 |  |  |  |  |
7 | 1 | 700ns |  |  | our $VERSION = '0.98';
8 | 1 | 19µs |  |  | $VERSION = eval $VERSION;
9 | 1 | 400ns |  |  | our $AUTHORITY = 'cpan:STEVAN';
10 |  |  |  |  |
11 | 1 | 4µs | 1 | 71µs | # spent 79µs (7+71) within Moose::Meta::Method::Accessor::BEGIN@11 which was called # once (7µs+71µs) by Moose::Meta::Attribute::BEGIN@15 at line 12 use base 'Moose::Meta::Method', # spent 71µs making 1 call to base::import
12 | 2 | 1.38ms | 1 | 79µs | 'Class::MOP::Method::Accessor'; # spent 79µs making 1 call to Moose::Meta::Method::Accessor::BEGIN@11
13 |  |  |  |  |
14 |  |  |  |  | sub _error_thrower {
15 |  |  |  |  | my $self = shift;
16 |  |  |  |  | ( ref $self && $self->associated_attribute ) || $self->SUPER::_error_thrower();
17 |  |  |  |  | }
18 |  |  |  |  |
19 |  |  |  |  | # spent 17.5ms (1.49+16.0) within Moose::Meta::Method::Accessor::_eval_code which was called 89 times, avg 197µs/call: # 68 times (1.12ms+11.6ms) by Moose::Meta::Method::Accessor::_generate_reader_method_inline at line 95, avg 187µs/call # 21 times (369µs+4.46ms) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 230µs/call sub _eval_code {
20 | 89 | 56µs |  |  | my ( $self, $source ) = @_;
21 |  |  |  |  |
22 |  |  |  |  | # NOTE:
23 |  |  |  |  | # set up the environment
24 | 89 | 87µs | 89 | 75µs | my $attr = $self->associated_attribute; # spent 75µs making 89 calls to Class::MOP::Method::Accessor::associated_attribute, avg 837ns/call
25 | 89 | 141µs | 89 | 204µs | my $type_constraint_obj = $attr->type_constraint; # spent 204µs making 89 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 2µs/call
26 | 89 | 409µs | 124 | 485µs | my $environment = { # spent 319µs making 61 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:8], avg 5µs/call # spent 116µs making 61 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 2µs/call # spent 32µs making 1 call to MooseX::Types::TypeDecorator::AUTOLOAD # spent 18µs making 1 call to MooseX::Types::TypeDecorator::__ANON__[MooseX/Types/TypeDecorator.pm:20]
27 |  |  |  |  | '$attr' => \$attr,
28 |  |  |  |  | '$meta' => \$self,
29 |  |  |  |  | '$type_constraint_obj' => \$type_constraint_obj,
30 |  |  |  |  | '$type_constraint' => \($type_constraint_obj
31 |  |  |  |  | ? $type_constraint_obj->_compiled_type_constraint
32 |  |  |  |  | : undef),
33 |  |  |  |  | };
34 |  |  |  |  |
35 |  |  |  |  | #warn "code for " . $attr->name . " =>\n" . $source . "\n";
36 | 89 | 202µs | 89 | 15.3ms | my ( $code, $e ) = $self->_compile_code( environment => $environment, code => $source ); # spent 15.3ms making 89 calls to Class::MOP::Method::Generated::_compile_code, avg 172µs/call
37 |  |  |  |  |
38 |  |  |  |  | $self->throw_error(
39 | 89 | 20µs |  |  | "Could not create writer for '${\$self->associated_attribute->name}' because $e \n code: $source",
40 |  |  |  |  | error => $e, data => $source )
41 |  |  |  |  | if $e;
42 |  |  |  |  |
43 | 89 | 231µs |  |  | return $code;
44 |  |  |  |  | }
45 |  |  |  |  |
46 |  |  |  |  | # spent 12.4ms (910µs+11.5) within Moose::Meta::Method::Accessor::_generate_accessor_method_inline which was called 21 times, avg 592µs/call: # 21 times (910µs+11.5ms) by Moose::Meta::Method::Accessor::_generate_accessor_method at line 116, avg 592µs/call sub _generate_accessor_method_inline {
47 | 21 | 6µs |  |  | my $self = $_[0];
48 | 21 | 28µs | 21 | 22µs | my $attr = $self->associated_attribute; # spent 22µs making 21 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
49 | 21 | 7µs |  |  | my $inv = '$_[0]';
50 | 21 | 38µs | 21 | 188µs | my $value_name = $self->_value_needs_copy ? '$val' : '$_[1]'; # spent 188µs making 21 calls to Moose::Meta::Method::Accessor::_value_needs_copy, avg 9µs/call
51 |  |  |  |  |
52 | 21 | 493µs | 273 | 11.3ms | $self->_eval_code('sub { ' . "\n" # spent 4.83ms making 21 calls to Moose::Meta::Method::Accessor::_eval_code, avg 230µs/call # spent 3.14ms making 20 calls to Moose::Meta::Method::Accessor::_inline_store, avg 157µs/call # spent 959µs making 20 calls to Moose::Meta::Method::Accessor::_inline_check_lazy, avg 48µs/call # spent 443µs making 20 calls to Moose::Meta::Method::Accessor::_inline_get, avg 22µs/call # spent 362µs making 21 calls to Moose::Meta::Method::Accessor::_inline_check_constraint, avg 17µs/call # spent 355µs making 20 calls to Moose::Meta::Method::Accessor::_inline_get_old_value_for_trigger, avg 18µs/call # spent 206µs making 21 calls to Moose::Meta::Method::Accessor::_inline_trigger, avg 10µs/call # spent 200µs making 21 calls to Moose::Meta::Method::Accessor::_inline_copy_value, avg 10µs/call # spent 199µs making 21 calls to Moose::Meta::Method::Accessor::_inline_check_required, avg 9µs/call # spent 195µs making 21 calls to Moose::Meta::Method::Accessor::_inline_auto_deref, avg 9µs/call # spent 193µs making 21 calls to Moose::Meta::Method::Accessor::_inline_check_coercion, avg 9µs/call # spent 66µs making 1 call to MooseX::ClassAttribute::Meta::Method::Accessor::_inline_store # spent 61µs making 1 call to MooseX::ClassAttribute::Meta::Method::Accessor::_inline_check_lazy # spent 36µs making 1 call to MooseX::ClassAttribute::Meta::Method::Accessor::_inline_get # spent 23µs making 1 call to MooseX::ClassAttribute::Meta::Method::Accessor::_inline_get_old_value_for_trigger # spent 21µs making 21 calls to Moose::Meta::Method::Accessor::_inline_post_body, avg 1µs/call # spent 20µs making 21 calls to Moose::Meta::Method::Accessor::_inline_pre_body, avg 962ns/call
53 |  |  |  |  | . $self->_inline_pre_body(@_) . "\n"
54 |  |  |  |  | . 'if (scalar(@_) >= 2) {' . "\n"
55 |  |  |  |  | . $self->_inline_copy_value . "\n"
56 |  |  |  |  | . $self->_inline_check_required . "\n"
57 |  |  |  |  | . $self->_inline_check_coercion($value_name) . "\n"
58 |  |  |  |  | . $self->_inline_check_constraint($value_name) . "\n"
59 |  |  |  |  | . $self->_inline_get_old_value_for_trigger($inv, $value_name) . "\n"
60 |  |  |  |  | . $self->_inline_store($inv, $value_name) . "\n"
61 |  |  |  |  | . $self->_inline_trigger($inv, $value_name, '@old') . "\n"
62 |  |  |  |  | . ' }' . "\n"
63 |  |  |  |  | . $self->_inline_check_lazy($inv) . "\n"
64 |  |  |  |  | . $self->_inline_post_body(@_) . "\n"
65 |  |  |  |  | . 'return ' . $self->_inline_auto_deref($self->_inline_get($inv)) . "\n"
66 |  |  |  |  | . ' }');
67 |  |  |  |  | }
68 |  |  |  |  |
69 |  |  |  |  | sub _generate_writer_method_inline {
70 |  |  |  |  | my $self = $_[0];
71 |  |  |  |  | my $attr = $self->associated_attribute;
72 |  |  |  |  | my $inv = '$_[0]';
73 |  |  |  |  | my $slot_access = $self->_inline_get($inv);
74 |  |  |  |  | my $value_name = $self->_value_needs_copy ? '$val' : '$_[1]';
75 |  |  |  |  |
76 |  |  |  |  | $self->_eval_code('sub { '
77 |  |  |  |  | . $self->_inline_pre_body(@_)
78 |  |  |  |  | . $self->_inline_copy_value
79 |  |  |  |  | . $self->_inline_check_required
80 |  |  |  |  | . $self->_inline_check_coercion($value_name)
81 |  |  |  |  | . $self->_inline_check_constraint($value_name)
82 |  |  |  |  | . $self->_inline_get_old_value_for_trigger($inv, $value_name) . "\n"
83 |  |  |  |  | . $self->_inline_store($inv, $value_name)
84 |  |  |  |  | . $self->_inline_post_body(@_)
85 |  |  |  |  | . $self->_inline_trigger($inv, $value_name, '@old')
86 |  |  |  |  | . ' }');
87 |  |  |  |  | }
88 |  |  |  |  |
89 |  |  |  |  | # spent 34.0ms (1.54+32.5) within Moose::Meta::Method::Accessor::_generate_reader_method_inline which was called 68 times, avg 501µs/call: # 67 times (1.51ms+32.1ms) by Moose::Meta::Method::Accessor::_generate_reader_method at line 114, avg 502µs/call # once (28µs+402µs) by Class::MOP::Method::Accessor::_initialize_body at line 87 of Class/MOP/Method/Accessor.pm sub _generate_reader_method_inline {
90 | 68 | 20µs |  |  | my $self = $_[0];
91 | 68 | 98µs | 68 | 77µs | my $attr = $self->associated_attribute; # spent 77µs making 68 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
92 | 68 | 20µs |  |  | my $inv = '$_[0]';
93 | 68 | 123µs | 68 | 15.9ms | my $slot_access = $self->_inline_get($inv); # spent 15.9ms making 68 calls to Moose::Meta::Method::Accessor::_inline_get, avg 233µs/call
94 |  |  |  |  |
95 | 68 | 775µs | 408 | 16.6ms | $self->_eval_code('sub {' # spent 12.7ms making 68 calls to Moose::Meta::Method::Accessor::_eval_code, avg 187µs/call # spent 2.85ms making 68 calls to Moose::Meta::Method::Accessor::_inline_check_lazy, avg 42µs/call # spent 648µs making 68 calls to Moose::Meta::Method::Accessor::_inline_auto_deref, avg 10µs/call # spent 196µs making 68 calls to Moose::Meta::Method::_inline_throw_error, avg 3µs/call # spent 86µs making 68 calls to Moose::Meta::Method::Accessor::_inline_pre_body, avg 1µs/call # spent 79µs making 68 calls to Moose::Meta::Method::Accessor::_inline_post_body, avg 1µs/call
96 |  |  |  |  | . $self->_inline_pre_body(@_)
97 |  |  |  |  | . $self->_inline_throw_error('"Cannot assign a value to a read-only accessor"', 'data => \@_') . ' if @_ > 1;'
98 |  |  |  |  | . $self->_inline_check_lazy($inv)
99 |  |  |  |  | . $self->_inline_post_body(@_)
100 |  |  |  |  | . 'return ' . $self->_inline_auto_deref( $slot_access ) . ';'
101 |  |  |  |  | . '}');
102 |  |  |  |  | }
103 |  |  |  |  |
104 |  |  |  |  | # spent 200µs (72+129) within Moose::Meta::Method::Accessor::_inline_copy_value which was called 21 times, avg 10µs/call: # 21 times (72µs+129µs) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 10µs/call sub _inline_copy_value {
105 | 21 | 37µs | 21 | 129µs | return '' unless shift->_value_needs_copy; # spent 129µs making 21 calls to Moose::Meta::Method::Accessor::_value_needs_copy, avg 6µs/call
106 | 13 | 24µs |  |  | return 'my $val = $_[1];'
107 |  |  |  |  | }
108 |  |  |  |  |
109 |  |  |  |  | # spent 316µs (217+99) within Moose::Meta::Method::Accessor::_value_needs_copy which was called 42 times, avg 8µs/call: # 21 times (129µs+58µs) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 50, avg 9µs/call # 21 times (88µs+41µs) by Moose::Meta::Method::Accessor::_inline_copy_value at line 105, avg 6µs/call sub _value_needs_copy {
110 | 42 | 36µs | 42 | 33µs | my $attr = (shift)->associated_attribute; # spent 33µs making 42 calls to Class::MOP::Method::Accessor::associated_attribute, avg 795ns/call
111 | 42 | 135µs | 42 | 65µs | return $attr->should_coerce; # spent 65µs making 42 calls to Moose::Meta::Mixin::AttributeCore::should_coerce, avg 2µs/call
112 |  |  |  |  | }
113 |  |  |  |  |
114 | 67 | 218µs | 67 | 33.6ms | # spent 33.8ms (226µs+33.6) within Moose::Meta::Method::Accessor::_generate_reader_method which was called 67 times, avg 505µs/call: # 67 times (226µs+33.6ms) by Class::MOP::Method::Accessor::_initialize_body at line 87 of Class/MOP/Method/Accessor.pm, avg 505µs/call sub _generate_reader_method { shift->_generate_reader_method_inline(@_) } # spent 33.6ms making 67 calls to Moose::Meta::Method::Accessor::_generate_reader_method_inline, avg 502µs/call
115 |  |  |  |  | sub _generate_writer_method { shift->_generate_writer_method_inline(@_) }
116 | 21 | 72µs | 21 | 12.4ms | # spent 12.5ms (79µs+12.4) within Moose::Meta::Method::Accessor::_generate_accessor_method which was called 21 times, avg 596µs/call: # 21 times (79µs+12.4ms) by Class::MOP::Method::Accessor::_initialize_body at line 87 of Class/MOP/Method/Accessor.pm, avg 596µs/call sub _generate_accessor_method { shift->_generate_accessor_method_inline(@_) } # spent 12.4ms making 21 calls to Moose::Meta::Method::Accessor::_generate_accessor_method_inline, avg 592µs/call
117 | 18 | 95µs | 18 | 1.44ms | # spent 1.55ms (101µs+1.44) within Moose::Meta::Method::Accessor::_generate_predicate_method which was called 18 times, avg 86µs/call: # 18 times (101µs+1.44ms) by Class::MOP::Method::Accessor::_initialize_body at line 87 of Class/MOP/Method/Accessor.pm, avg 86µs/call sub _generate_predicate_method { shift->_generate_predicate_method_inline(@_) } # spent 1.44ms making 18 calls to Class::MOP::Method::Accessor::_generate_predicate_method_inline, avg 80µs/call
118 | 3 | 26µs | 3 | 295µs | # spent 324µs (29+295) within Moose::Meta::Method::Accessor::_generate_clearer_method which was called 3 times, avg 108µs/call: # 3 times (29µs+295µs) by Class::MOP::Method::Accessor::_initialize_body at line 87 of Class/MOP/Method/Accessor.pm, avg 108µs/call sub _generate_clearer_method { shift->_generate_clearer_method_inline(@_) } # spent 295µs making 3 calls to Class::MOP::Method::Accessor::_generate_clearer_method_inline, avg 98µs/call
119 |  |  |  |  |
120 | 89 | 173µs |  |  | # spent 106µs within Moose::Meta::Method::Accessor::_inline_pre_body which was called 89 times, avg 1µs/call: # 68 times (86µs+0s) by Moose::Meta::Method::Accessor::_generate_reader_method_inline at line 95, avg 1µs/call # 21 times (20µs+0s) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 962ns/call sub _inline_pre_body { '' }
121 | 89 | 159µs |  |  | # spent 100µs within Moose::Meta::Method::Accessor::_inline_post_body which was called 89 times, avg 1µs/call: # 68 times (79µs+0s) by Moose::Meta::Method::Accessor::_generate_reader_method_inline at line 95, avg 1µs/call # 21 times (21µs+0s) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 1µs/call sub _inline_post_body { '' }
122 |  |  |  |  |
123 |  |  |  |  | # spent 669µs (478+190) within Moose::Meta::Method::Accessor::_inline_check_constraint which was called 38 times, avg 18µs/call: # 21 times (249µs+114µs) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 17µs/call # 17 times (230µs+77µs) by Moose::Meta::Method::Accessor::_inline_check_lazy at line 178, avg 18µs/call sub _inline_check_constraint {
124 | 38 | 21µs |  |  | my ($self, $value) = @_;
125 |  |  |  |  |
126 | 38 | 39µs | 38 | 34µs | my $attr = $self->associated_attribute; # spent 34µs making 38 calls to Class::MOP::Method::Accessor::associated_attribute, avg 887ns/call
127 |  |  |  |  |
128 | 38 | 55µs | 38 | 52µs | return '' unless $attr->has_type_constraint; # spent 52µs making 38 calls to Moose::Meta::Mixin::AttributeCore::has_type_constraint, avg 1µs/call
129 |  |  |  |  |
130 | 35 | 102µs | 35 | 23µs | my $attr_name = quotemeta( $attr->name ); # spent 23µs making 35 calls to Class::MOP::Mixin::AttributeCore::name, avg 654ns/call
131 |  |  |  |  |
132 | 35 | 177µs | 35 | 82µs | qq{\$type_constraint->($value) || } . $self->_inline_throw_error(qq{"Attribute ($attr_name) does not pass the type constraint because: " . \$type_constraint_obj->get_message($value)}, "data => $value") . ";"; # spent 82µs making 35 calls to Moose::Meta::Method::_inline_throw_error, avg 2µs/call
133 |  |  |  |  | }
134 |  |  |  |  |
135 |  |  |  |  | # spent 382µs (284+98) within Moose::Meta::Method::Accessor::_inline_check_coercion which was called 38 times, avg 10µs/call: # 21 times (147µs+45µs) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 9µs/call # 17 times (137µs+53µs) by Moose::Meta::Method::Accessor::_inline_check_lazy at line 177, avg 11µs/call sub _inline_check_coercion {
136 | 38 | 26µs |  |  | my ($self, $value) = @_;
137 |  |  |  |  |
138 | 38 | 40µs | 38 | 36µs | my $attr = $self->associated_attribute; # spent 36µs making 38 calls to Class::MOP::Method::Accessor::associated_attribute, avg 937ns/call
139 |  |  |  |  |
140 | 38 | 98µs | 38 | 62µs | return '' unless $attr->should_coerce; # spent 62µs making 38 calls to Moose::Meta::Mixin::AttributeCore::should_coerce, avg 2µs/call
141 | 18 | 48µs |  |  | return "$value = \$attr->type_constraint->coerce($value);";
142 |  |  |  |  | }
143 |  |  |  |  |
144 |  |  |  |  | # spent 199µs (140+59) within Moose::Meta::Method::Accessor::_inline_check_required which was called 21 times, avg 9µs/call: # 21 times (140µs+59µs) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 9µs/call sub _inline_check_required {
145 | 21 | 6µs |  |  | my $self = shift;
146 | 21 | 20µs | 21 | 17µs | my $attr = $self->associated_attribute; # spent 17µs making 21 calls to Class::MOP::Method::Accessor::associated_attribute, avg 819ns/call
147 |  |  |  |  |
148 | 21 | 85µs | 21 | 42µs | return '' unless $attr->is_required; # spent 42µs making 21 calls to Moose::Meta::Mixin::AttributeCore::is_required, avg 2µs/call
149 |  |  |  |  |
150 |  |  |  |  | my $attr_name = quotemeta( $attr->name );
151 |  |  |  |  |
152 |  |  |  |  | return qq{(\@_ >= 2) || } . $self->_inline_throw_error(qq{"Attribute ($attr_name) is required, so cannot be set to undef"}) . ';' # defined $_[1] is not good enough
153 |  |  |  |  | }
154 |  |  |  |  |
155 |  |  |  |  | # spent 3.82ms (1.27+2.55) within Moose::Meta::Method::Accessor::_inline_check_lazy which was called 89 times, avg 43µs/call: # 68 times (971µs+1.88ms) by Moose::Meta::Method::Accessor::_generate_reader_method_inline at line 95, avg 42µs/call # 20 times (290µs+669µs) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 48µs/call # once (11µs+3µs) by MooseX::ClassAttribute::Meta::Method::Accessor::_inline_check_lazy at line 99 of MooseX/ClassAttribute/Meta/Method/Accessor.pm sub _inline_check_lazy {
156 | 89 | 42µs |  |  | my ($self, $instance) = @_;
157 |  |  |  |  |
158 | 89 | 107µs | 89 | 106µs | my $attr = $self->associated_attribute; # spent 106µs making 89 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
159 |  |  |  |  |
160 | 89 | 291µs | 89 | 266µs | return '' unless $attr->is_lazy; # spent 266µs making 89 calls to Moose::Meta::Mixin::AttributeCore::is_lazy, avg 3µs/call
161 |  |  |  |  |
162 | 22 | 56µs | 22 | 606µs | my $slot_exists = $self->_inline_has($instance); # spent 606µs making 22 calls to Moose::Meta::Method::Accessor::_inline_has, avg 28µs/call
163 |  |  |  |  |
164 | 22 | 20µs |  |  | my $code = 'unless (' . $slot_exists . ') {' . "\n";
165 | 22 | 72µs | 22 | 43µs | if ($attr->has_type_constraint) { # spent 43µs making 22 calls to Moose::Meta::Mixin::AttributeCore::has_type_constraint, avg 2µs/call
166 | 17 | 52µs | 18 | 34µs | if ($attr->has_default || $attr->has_builder) { # spent 32µs making 17 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 2µs/call # spent 2µs making 1 call to Class::MOP::Mixin::AttributeCore::has_builder
167 | 17 | 39µs | 19 | 18µs | if ($attr->has_default) { # spent 16µs making 17 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 912ns/call # spent 2µs making 1 call to Moose::Meta::Method::_inline_throw_error # spent 800ns making 1 call to Class::MOP::Mixin::AttributeCore::has_builder
168 |  |  |  |  | $code .= ' my $default = $attr->default(' . $instance . ');'."\n";
169 |  |  |  |  | }
170 |  |  |  |  | elsif ($attr->has_builder) {
171 |  |  |  |  | $code .= ' my $default;'."\n".
172 |  |  |  |  | ' if(my $builder = '.$instance.'->can($attr->builder)){ '."\n".
173 |  |  |  |  | ' $default = '.$instance.'->$builder; '. "\n } else {\n" .
174 |  |  |  |  | ' ' . $self->_inline_throw_error(q{sprintf "%s does not support builder method '%s' for attribute '%s'", ref(} . $instance . ') || '.$instance.', $attr->builder, $attr->name') .
175 |  |  |  |  | ';'. "\n }";
176 |  |  |  |  | }
177 | 17 | 40µs | 17 | 190µs | $code .= $self->_inline_check_coercion('$default') . "\n"; # spent 190µs making 17 calls to Moose::Meta::Method::Accessor::_inline_check_coercion, avg 11µs/call
178 | 17 | 96µs | 17 | 306µs | $code .= $self->_inline_check_constraint('$default') . "\n"; # spent 306µs making 17 calls to Moose::Meta::Method::Accessor::_inline_check_constraint, avg 18µs/call
179 | 17 | 45µs | 17 | 757µs | $code .= ' ' . $self->_inline_init_slot($attr, $instance, '$default') . "\n"; # spent 757µs making 17 calls to Moose::Meta::Method::Accessor::_inline_init_slot, avg 45µs/call
180 |  |  |  |  | }
181 |  |  |  |  | else {
182 |  |  |  |  | $code .= ' ' . $self->_inline_init_slot($attr, $instance, 'undef') . "\n";
183 |  |  |  |  | }
184 |  |  |  |  |
185 |  |  |  |  | } else {
186 | 5 | 30µs | 10 | 223µs | if ($attr->has_default) { # spent 213µs making 5 calls to Moose::Meta::Method::Accessor::_inline_init_slot, avg 43µs/call # spent 10µs making 5 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 2µs/call
187 |  |  |  |  | $code .= ' ' . $self->_inline_init_slot($attr, $instance, ('$attr->default(' . $instance . ')')) . "\n";
188 |  |  |  |  | }
189 |  |  |  |  | elsif ($attr->has_builder) {
190 |  |  |  |  | $code .= ' if (my $builder = '.$instance.'->can($attr->builder)) { ' . "\n"
191 |  |  |  |  | . ' ' . $self->_inline_init_slot($attr, $instance, ($instance . '->$builder'))
192 |  |  |  |  | . "\n } else {\n"
193 |  |  |  |  | . ' ' . $self->_inline_throw_error(q{sprintf "%s does not support builder method '%s' for attribute '%s'", ref(} . $instance . ') || '.$instance.', $attr->builder, $attr->name')
194 |  |  |  |  | . ';'. "\n }";
195 |  |  |  |  | }
196 |  |  |  |  | else {
197 |  |  |  |  | $code .= ' ' . $self->_inline_init_slot($attr, $instance, 'undef') . "\n";
198 |  |  |  |  | }
199 |  |  |  |  | }
200 | 22 | 7µs |  |  | $code .= "}\n";
201 | 22 | 51µs |  |  | return $code;
202 |  |  |  |  | }
203 |  |  |  |  |
204 |  |  |  |  | # spent 970µs (196+774) within Moose::Meta::Method::Accessor::_inline_init_slot which was called 22 times, avg 44µs/call: # 17 times (152µs+604µs) by Moose::Meta::Method::Accessor::_inline_check_lazy at line 179, avg 45µs/call # 5 times (43µs+170µs) by Moose::Meta::Method::Accessor::_inline_check_lazy at line 186, avg 43µs/call sub _inline_init_slot {
205 | 22 | 21µs |  |  | my ($self, $attr, $inv, $value) = @_;
206 | 22 | 50µs | 22 | 36µs | if ($attr->has_initializer) { # spent 36µs making 22 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 2µs/call
207 |  |  |  |  | return ('$attr->set_initial_value(' . $inv . ', ' . $value . ');');
208 |  |  |  |  | }
209 |  |  |  |  | else {
210 | 22 | 87µs | 22 | 739µs | return $self->_inline_store($inv, $value); # spent 739µs making 22 calls to Moose::Meta::Method::Accessor::_inline_store, avg 34µs/call
211 |  |  |  |  | }
212 |  |  |  |  | }
213 |  |  |  |  |
214 |  |  |  |  | # spent 3.88ms (720µs+3.16) within Moose::Meta::Method::Accessor::_inline_store which was called 42 times, avg 92µs/call: # 22 times (404µs+334µs) by Moose::Meta::Method::Accessor::_inline_init_slot at line 210, avg 34µs/call # 20 times (315µs+2.83ms) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 157µs/call sub _inline_store {
215 | 42 | 28µs |  |  | my ($self, $instance, $value) = @_;
216 | 42 | 46µs | 42 | 39µs | my $attr = $self->associated_attribute; # spent 39µs making 42 calls to Class::MOP::Method::Accessor::associated_attribute, avg 921ns/call
217 |  |  |  |  |
218 | 42 | 95µs | 84 | 2.60ms | my $mi = $attr->associated_class->get_meta_instance; # spent 2.55ms making 42 calls to Class::MOP::Class::get_meta_instance, avg 61µs/call # spent 50µs making 42 calls to Class::MOP::Attribute::associated_class, avg 1µs/call
219 |  |  |  |  |
220 | 42 | 136µs | 84 | 436µs | my $code = $mi->inline_set_slot_value($instance, $attr->slots, $value) . ";"; # spent 302µs making 42 calls to Class::MOP::Instance::inline_set_slot_value, avg 7µs/call # spent 134µs making 42 calls to Class::MOP::Attribute::slots, avg 3µs/call
221 | 42 | 83µs | 42 | 87µs | $code .= $mi->inline_weaken_slot_value($instance, $attr->slots, $value) . ";" # spent 87µs making 42 calls to Moose::Meta::Mixin::AttributeCore::is_weak_ref, avg 2µs/call
222 |  |  |  |  | if $attr->is_weak_ref;
223 | 42 | 111µs |  |  | return $code;
224 |  |  |  |  | }
225 |  |  |  |  |
226 |  |  |  |  | # spent 355µs (159+195) within Moose::Meta::Method::Accessor::_inline_get_old_value_for_trigger which was called 20 times, avg 18µs/call: # 20 times (159µs+195µs) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 18µs/call sub _inline_get_old_value_for_trigger {
227 | 20 | 10µs |  |  | my ( $self, $instance ) = @_;
228 |  |  |  |  |
229 | 20 | 19µs | 20 | 19µs | my $attr = $self->associated_attribute; # spent 19µs making 20 calls to Class::MOP::Method::Accessor::associated_attribute, avg 945ns/call
230 | 20 | 70µs | 20 | 36µs | return '' unless $attr->has_trigger; # spent 36µs making 20 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 2µs/call
231 |  |  |  |  |
232 | 1 | 2µs | 2 | 113µs | my $mi = $attr->associated_class->get_meta_instance; # spent 112µs making 1 call to Class::MOP::Class::get_meta_instance # spent 1µs making 1 call to Class::MOP::Attribute::associated_class
233 | 1 | 6µs | 2 | 7µs | my $pred = $mi->inline_is_slot_initialized($instance, $attr->name); # spent 6µs making 1 call to Class::MOP::Instance::inline_is_slot_initialized # spent 500ns making 1 call to Class::MOP::Mixin::AttributeCore::name
234 |  |  |  |  |
235 |  |  |  |  | return
236 | 1 | 5µs | 1 | 21µs | 'my @old = ' # spent 21µs making 1 call to Moose::Meta::Method::Accessor::_inline_get
237 |  |  |  |  | . $pred . q{ ? }
238 |  |  |  |  | . $self->_inline_get($instance) . q{ : ()} . ";\n";
239 |  |  |  |  | }
240 |  |  |  |  |
241 |  |  |  |  | # spent 206µs (151+54) within Moose::Meta::Method::Accessor::_inline_trigger which was called 21 times, avg 10µs/call: # 21 times (151µs+54µs) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 10µs/call sub _inline_trigger {
242 | 21 | 18µs |  |  | my ($self, $instance, $value, $old_value) = @_;
243 | 21 | 24µs | 21 | 26µs | my $attr = $self->associated_attribute; # spent 26µs making 21 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
244 | 21 | 64µs | 21 | 28µs | return '' unless $attr->has_trigger; # spent 28µs making 21 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 1µs/call
245 | 1 | 4µs |  |  | return sprintf('$attr->trigger->(%s, %s, %s);', $instance, $value, $old_value);
246 |  |  |  |  | }
247 |  |  |  |  |
248 |  |  |  |  | # spent 16.3ms (1.10+15.2) within Moose::Meta::Method::Accessor::_inline_get which was called 89 times, avg 184µs/call: # 68 times (873µs+15.0ms) by Moose::Meta::Method::Accessor::_generate_reader_method_inline at line 93, avg 233µs/call # 20 times (217µs+226µs) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 22µs/call # once (10µs+11µs) by Moose::Meta::Method::Accessor::_inline_get_old_value_for_trigger at line 236 sub _inline_get {
249 | 89 | 46µs |  |  | my ($self, $instance) = @_;
250 | 89 | 79µs | 89 | 68µs | my $attr = $self->associated_attribute; # spent 68µs making 89 calls to Class::MOP::Method::Accessor::associated_attribute, avg 761ns/call
251 |  |  |  |  |
252 | 89 | 193µs | 178 | 14.3ms | my $mi = $attr->associated_class->get_meta_instance; # spent 14.2ms making 89 calls to Class::MOP::Class::get_meta_instance, avg 159µs/call # spent 81µs making 89 calls to Class::MOP::Attribute::associated_class, avg 910ns/call
253 |  |  |  |  |
254 | 89 | 381µs | 178 | 902µs | return $mi->inline_get_slot_value($instance, $attr->slots); # spent 619µs making 89 calls to Class::MOP::Instance::inline_get_slot_value, avg 7µs/call # spent 284µs making 89 calls to Class::MOP::Attribute::slots, avg 3µs/call
255 |  |  |  |  | }
256 |  |  |  |  |
257 |  |  |  |  | sub _inline_access {
258 |  |  |  |  | my ($self, $instance) = @_;
259 |  |  |  |  | my $attr = $self->associated_attribute;
260 |  |  |  |  |
261 |  |  |  |  | my $mi = $attr->associated_class->get_meta_instance;
262 |  |  |  |  |
263 |  |  |  |  | return $mi->inline_slot_access($instance, $attr->slots);
264 |  |  |  |  | }
265 |  |  |  |  |
266 |  |  |  |  | # spent 606µs (323+283) within Moose::Meta::Method::Accessor::_inline_has which was called 22 times, avg 28µs/call: # 22 times (323µs+283µs) by Moose::Meta::Method::Accessor::_inline_check_lazy at line 162, avg 28µs/call sub _inline_has {
267 | 22 | 14µs |  |  | my ($self, $instance) = @_;
268 | 22 | 26µs | 22 | 18µs | my $attr = $self->associated_attribute; # spent 18µs making 22 calls to Class::MOP::Method::Accessor::associated_attribute, avg 841ns/call
269 |  |  |  |  |
270 | 22 | 52µs | 44 | 55µs | my $mi = $attr->associated_class->get_meta_instance; # spent 28µs making 22 calls to Class::MOP::Class::get_meta_instance, avg 1µs/call # spent 26µs making 22 calls to Class::MOP::Attribute::associated_class, avg 1µs/call
271 |  |  |  |  |
272 | 22 | 114µs | 44 | 209µs | return $mi->inline_is_slot_initialized($instance, $attr->slots); # spent 142µs making 22 calls to Class::MOP::Instance::inline_is_slot_initialized, avg 6µs/call # spent 67µs making 22 calls to Class::MOP::Attribute::slots, avg 3µs/call
273 |  |  |  |  | }
274 |  |  |  |  |
275 |  |  |  |  | # spent 843µs (567+276) within Moose::Meta::Method::Accessor::_inline_auto_deref which was called 89 times, avg 9µs/call: # 68 times (429µs+219µs) by Moose::Meta::Method::Accessor::_generate_reader_method_inline at line 95, avg 10µs/call # 21 times (137µs+57µs) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 52, avg 9µs/call sub _inline_auto_deref {
276 | 89 | 43µs |  |  | my ( $self, $ref_value ) = @_;
277 | 89 | 89µs | 89 | 80µs | my $attr = $self->associated_attribute; # spent 80µs making 89 calls to Class::MOP::Method::Accessor::associated_attribute, avg 902ns/call
278 |  |  |  |  |
279 | 89 | 317µs | 89 | 196µs | return $ref_value unless $attr->should_auto_deref; # spent 196µs making 89 calls to Moose::Meta::Mixin::AttributeCore::should_auto_deref, avg 2µs/call
280 |  |  |  |  |
281 |  |  |  |  | my $type_constraint = $attr->type_constraint;
282 |  |  |  |  |
283 |  |  |  |  | my $sigil;
284 |  |  |  |  | if ($type_constraint->is_a_type_of('ArrayRef')) {
285 |  |  |  |  | $sigil = '@';
286 |  |  |  |  | }
287 |  |  |  |  | elsif ($type_constraint->is_a_type_of('HashRef')) {
288 |  |  |  |  | $sigil = '%';
289 |  |  |  |  | }
290 |  |  |  |  | else {
291 |  |  |  |  | $self->throw_error( "Can not auto de-reference the type constraint '"
292 |  |  |  |  | . quotemeta( $type_constraint->name )
293 |  |  |  |  | . "'", type_constraint => $type_constraint );
294 |  |  |  |  | }
295 |  |  |  |  |
296 |  |  |  |  | "(wantarray() ? $sigil\{ ( $ref_value ) || return } : ( $ref_value ) )";
297 |  |  |  |  | }
298 |  |  |  |  |
299 | 1 | 7µs |  |  | 1;
300 |  |  |  |  |
301 |  |  |  |  | __END__
302 |  |  |  |  |
303 |  |  |  |  | =pod
304 |  |  |  |  |
305 |  |  |  |  | =head1 NAME
306 |  |  |  |  |
307 |  |  |  |  | Moose::Meta::Method::Accessor - A Moose Method metaclass for accessors
308 |  |  |  |  |
309 |  |  |  |  | =head1 DESCRIPTION
310 |  |  |  |  |
311 |  |  |  |  | This class is a subclass of L<Class::MOP::Method::Accessor> that
312 |  |  |  |  | provides additional Moose-specific functionality, all of which is
313 |  |  |  |  | private.
314 |  |  |  |  |
315 |  |  |  |  | To understand this class, you should read the the
316 |  |  |  |  | L<Class::MOP::Method::Accessor> documentation.
317 |  |  |  |  |
318 |  |  |  |  | =head1 BUGS
319 |  |  |  |  |
320 |  |  |  |  | See L<Moose/BUGS> for details on reporting bugs.
321 |  |  |  |  |
322 |  |  |  |  | =head1 AUTHOR
323 |  |  |  |  |
324 |  |  |  |  | Stevan Little E<lt>stevan@iinteractive.comE<gt>
325 |  |  |  |  |
326 |  |  |  |  | Yuval Kogman E<lt>nothingmuch@woobling.comE<gt>
327 |  |  |  |  |
328 |  |  |  |  | =head1 COPYRIGHT AND LICENSE
329 |  |  |  |  |
330 |  |  |  |  | Copyright 2006-2010 by Infinity Interactive, Inc.
331 |  |  |  |  |
332 |  |  |  |  | L<http://www.iinteractive.com>
333 |  |  |  |  |
334 |  |  |  |  | This library is free software; you can redistribute it and/or modify
335 |  |  |  |  | it under the same terms as Perl itself.
336 |  |  |  |  |
337 |  |  |  |  | =cut