| Filename | /home/doy/coding/src/Moose/blib/lib//Moose/Meta/Method/Accessor/Native/Writer.pm |
| Statements | Executed 95 statements in 6.13ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 2 | 1 | 1 | 720µs | 3.67ms | Moose::Meta::Method::Accessor::Native::Writer::_inline_writer_core |
| 2 | 1 | 1 | 209µs | 527µs | Moose::Meta::Method::Accessor::Native::Writer::_constraint_must_be_checked |
| 2 | 1 | 1 | 159µs | 780µs | Moose::Meta::Method::Accessor::Native::Writer::_inline_set_new_value |
| 2 | 1 | 1 | 147µs | 4.84ms | Moose::Meta::Method::Accessor::Native::Writer::_generate_method |
| 2 | 1 | 1 | 143µs | 228µs | Moose::Meta::Method::Accessor::Native::Writer::_is_root_type |
| 2 | 1 | 1 | 129µs | 179µs | Moose::Meta::Method::Accessor::Native::Writer::_get_is_lvalue |
| 2 | 1 | 1 | 105µs | 277µs | Moose::Meta::Method::Accessor::Native::Writer::_inline_copy_native_value |
| 1 | 1 | 1 | 74µs | 93µs | Moose::Meta::Method::Accessor::Native::Writer::BEGIN@3 |
| 1 | 1 | 1 | 62µs | 959µs | Moose::Meta::Method::Accessor::Native::Writer::BEGIN@177 |
| 1 | 1 | 1 | 47µs | 18.4ms | Moose::Meta::Method::Accessor::Native::Writer::BEGIN@12 |
| 1 | 1 | 1 | 39µs | 212µs | Moose::Meta::Method::Accessor::Native::Writer::BEGIN@6 |
| 1 | 1 | 1 | 39µs | 106µs | Moose::Meta::Method::Accessor::Native::Writer::BEGIN@4 |
| 2 | 1 | 1 | 17µs | 17µs | Moose::Meta::Method::Accessor::Native::Writer::_inline_capture_return_value |
| 2 | 1 | 1 | 15µs | 15µs | Moose::Meta::Method::Accessor::Native::Writer::_inline_process_arguments |
| 2 | 1 | 1 | 13µs | 13µs | Moose::Meta::Method::Accessor::Native::Writer::_inline_check_arguments |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::Native::Writer::__ANON__[:121] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::Native::Writer::__ANON__[:143] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::Native::Writer::__ANON__[:97] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::Native::Writer::_inline_check_coercion |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::Native::Writer::_inline_coerce_new_values |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::Native::Writer::_inline_optimized_set_new_value |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::Native::Writer::_return_value |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Accessor::Native::Writer::_writer_value_needs_copy |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moose::Meta::Method::Accessor::Native::Writer; | ||||
| 2 | |||||
| 3 | 3 | 98µs | 2 | 111µs | # spent 93µs (74+18) within Moose::Meta::Method::Accessor::Native::Writer::BEGIN@3 which was called:
# once (74µs+18µs) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 3 # spent 93µs making 1 call to Moose::Meta::Method::Accessor::Native::Writer::BEGIN@3
# spent 18µs making 1 call to strict::import |
| 4 | 3 | 105µs | 2 | 173µs | # spent 106µs (39+67) within Moose::Meta::Method::Accessor::Native::Writer::BEGIN@4 which was called:
# once (39µs+67µs) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 4 # spent 106µs making 1 call to Moose::Meta::Method::Accessor::Native::Writer::BEGIN@4
# spent 67µs making 1 call to warnings::import |
| 5 | |||||
| 6 | 3 | 217µs | 2 | 386µs | # spent 212µs (39+173) within Moose::Meta::Method::Accessor::Native::Writer::BEGIN@6 which was called:
# once (39µs+173µs) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 6 # spent 212µs making 1 call to Moose::Meta::Method::Accessor::Native::Writer::BEGIN@6
# spent 173µs making 1 call to Exporter::import |
| 7 | |||||
| 8 | 1 | 5µs | our $VERSION = '1.19'; | ||
| 9 | 1 | 109µs | $VERSION = eval $VERSION; # spent 14µs executing statements in string eval | ||
| 10 | 1 | 4µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 11 | |||||
| 12 | 3 | 3.79ms | 2 | 36.7ms | # spent 18.4ms (47µs+18.3) within Moose::Meta::Method::Accessor::Native::Writer::BEGIN@12 which was called:
# once (47µs+18.3ms) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 12 # spent 18.4ms making 1 call to Moose::Meta::Method::Accessor::Native::Writer::BEGIN@12
# spent 18.3ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:456] |
| 13 | |||||
| 14 | 1 | 22µs | 1 | 11.5ms | with 'Moose::Meta::Method::Accessor::Native'; # spent 11.5ms making 1 call to Moose::Role::with |
| 15 | |||||
| 16 | 1 | 12µs | 1 | 538µs | requires '_potential_value'; # spent 538µs making 1 call to Moose::Role::requires |
| 17 | |||||
| 18 | # spent 4.84ms (147µs+4.69) within Moose::Meta::Method::Accessor::Native::Writer::_generate_method which was called 2 times, avg 2.42ms/call:
# 2 times (147µs+4.69ms) by Moose::Meta::Method::Accessor::Native::_initialize_body at line 46 of Moose/Meta/Method/Accessor/Native.pm, avg 2.42ms/call | ||||
| 19 | 2 | 6µs | my $self = shift; | ||
| 20 | |||||
| 21 | 2 | 7µs | my $inv = '$self'; | ||
| 22 | 2 | 26µs | 2 | 901µs | my $slot_access = $self->_get_value($inv); # spent 459µs making 1 call to Class::MOP::Class::__ANON__::SERIAL::6::_get_value
# spent 442µs making 1 call to Class::MOP::Class::__ANON__::SERIAL::8::_get_value |
| 23 | |||||
| 24 | return ( | ||||
| 25 | 2 | 81µs | 4 | 3.79ms | 'sub {', # spent 3.67ms making 2 calls to Moose::Meta::Method::Accessor::Native::Writer::_inline_writer_core, avg 1.84ms/call
# spent 116µs making 2 calls to Moose::Meta::Method::Accessor::Native::_inline_curried_arguments, avg 58µs/call |
| 26 | 'my ' . $inv . ' = shift;', | ||||
| 27 | $self->_inline_curried_arguments, | ||||
| 28 | $self->_inline_writer_core($inv, $slot_access), | ||||
| 29 | '}', | ||||
| 30 | ); | ||||
| 31 | } | ||||
| 32 | |||||
| 33 | # spent 3.67ms (720µs+2.95) within Moose::Meta::Method::Accessor::Native::Writer::_inline_writer_core which was called 2 times, avg 1.84ms/call:
# 2 times (720µs+2.95ms) by Moose::Meta::Method::Accessor::Native::Writer::_generate_method at line 25, avg 1.84ms/call | ||||
| 34 | 2 | 6µs | my $self = shift; | ||
| 35 | 2 | 9µs | my ($inv, $slot_access) = @_; | ||
| 36 | |||||
| 37 | 2 | 24µs | 2 | 29µs | my $potential = $self->_potential_value($slot_access); # spent 20µs making 1 call to Moose::Meta::Method::Accessor::Native::Array::push::_potential_value
# spent 9µs making 1 call to Moose::Meta::Method::Accessor::Native::Array::clear::_potential_value |
| 38 | 2 | 6µs | my $old = '@old'; | ||
| 39 | |||||
| 40 | 2 | 5µs | my @code; | ||
| 41 | 2 | 172µs | 8 | 473µs | push @code, ( # spent 231µs making 2 calls to Moose::Meta::Method::Accessor::Native::_inline_check_argument_count, avg 116µs/call
# spent 213µs making 2 calls to Moose::Meta::Method::Accessor::_inline_check_lazy, avg 106µs/call
# spent 15µs making 2 calls to Moose::Meta::Method::Accessor::Native::Writer::_inline_process_arguments, avg 8µs/call
# spent 13µs making 2 calls to Moose::Meta::Method::Accessor::Native::Writer::_inline_check_arguments, avg 7µs/call |
| 42 | $self->_inline_check_argument_count, | ||||
| 43 | $self->_inline_process_arguments($inv, $slot_access), | ||||
| 44 | $self->_inline_check_arguments('for writer'), | ||||
| 45 | $self->_inline_check_lazy($inv, '$type_constraint', '$type_constraint_obj'), | ||||
| 46 | ); | ||||
| 47 | |||||
| 48 | 2 | 29µs | 2 | 30µs | if ($self->_return_value($slot_access)) { # spent 20µs making 1 call to Moose::Meta::Method::Accessor::Native::Array::push::_return_value
# spent 10µs making 1 call to Moose::Meta::Method::Accessor::Native::Array::clear::_return_value |
| 49 | # some writers will save the return value in this variable when they | ||||
| 50 | # generate the potential value. | ||||
| 51 | push @code, 'my @return;' | ||||
| 52 | } | ||||
| 53 | |||||
| 54 | 2 | 258µs | 16 | 2.42ms | push @code, ( # spent 780µs making 2 calls to Moose::Meta::Method::Accessor::Native::Writer::_inline_set_new_value, avg 390µs/call
# spent 402µs making 1 call to Class::MOP::Class::__ANON__::SERIAL::6::_inline_tc_code
# spent 300µs making 1 call to Class::MOP::Class::__ANON__::SERIAL::8::_inline_tc_code
# spent 277µs making 2 calls to Moose::Meta::Method::Accessor::Native::Writer::_inline_copy_native_value, avg 139µs/call
# spent 217µs making 2 calls to Moose::Meta::Method::Accessor::Native::Collection::_inline_get_old_value_for_trigger, avg 108µs/call
# spent 181µs making 2 calls to Moose::Meta::Method::Accessor::_inline_trigger, avg 91µs/call
# spent 157µs making 2 calls to Moose::Meta::Method::Accessor::Native::Collection::_inline_coerce_new_values, avg 78µs/call
# spent 91µs making 2 calls to Moose::Meta::Method::Accessor::Native::_inline_return_value, avg 46µs/call
# spent 17µs making 2 calls to Moose::Meta::Method::Accessor::Native::Writer::_inline_capture_return_value, avg 8µs/call |
| 55 | $self->_inline_coerce_new_values, | ||||
| 56 | $self->_inline_copy_native_value(\$potential), | ||||
| 57 | $self->_inline_tc_code($potential, '$type_constraint', '$type_constraint_obj'), | ||||
| 58 | $self->_inline_get_old_value_for_trigger($inv, $old), | ||||
| 59 | $self->_inline_capture_return_value($slot_access), | ||||
| 60 | $self->_inline_set_new_value($inv, $potential, $slot_access), | ||||
| 61 | $self->_inline_trigger($inv, $slot_access, $old), | ||||
| 62 | $self->_inline_return_value($slot_access, 'for writer'), | ||||
| 63 | ); | ||||
| 64 | |||||
| 65 | 2 | 43µs | return @code; | ||
| 66 | } | ||||
| 67 | |||||
| 68 | 2 | 26µs | # spent 15µs within Moose::Meta::Method::Accessor::Native::Writer::_inline_process_arguments which was called 2 times, avg 8µs/call:
# 2 times (15µs+0s) by Moose::Meta::Method::Accessor::Native::Writer::_inline_writer_core at line 41, avg 8µs/call | ||
| 69 | |||||
| 70 | 2 | 24µs | # spent 13µs within Moose::Meta::Method::Accessor::Native::Writer::_inline_check_arguments which was called 2 times, avg 7µs/call:
# 2 times (13µs+0s) by Moose::Meta::Method::Accessor::Native::Writer::_inline_writer_core at line 41, avg 7µs/call | ||
| 71 | |||||
| 72 | sub _inline_coerce_new_values { return } | ||||
| 73 | |||||
| 74 | sub _writer_value_needs_copy { | ||||
| 75 | my $self = shift; | ||||
| 76 | |||||
| 77 | return $self->_constraint_must_be_checked; | ||||
| 78 | } | ||||
| 79 | |||||
| 80 | # spent 527µs (209+318) within Moose::Meta::Method::Accessor::Native::Writer::_constraint_must_be_checked which was called 2 times, avg 263µs/call:
# 2 times (209µs+318µs) by Class::MOP::Class:::around at line 118, avg 263µs/call | ||||
| 81 | 2 | 5µs | my $self = shift; | ||
| 82 | |||||
| 83 | 2 | 20µs | 2 | 16µs | my $attr = $self->associated_attribute; # spent 16µs making 2 calls to Class::MOP::Method::Accessor::associated_attribute, avg 8µs/call |
| 84 | |||||
| 85 | 2 | 123µs | 8 | 302µs | return $attr->has_type_constraint # spent 228µs making 2 calls to Moose::Meta::Method::Accessor::Native::Writer::_is_root_type, avg 114µs/call
# spent 27µs making 2 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 14µs/call
# spent 25µs making 2 calls to Moose::Meta::Mixin::AttributeCore::has_type_constraint, avg 13µs/call
# spent 22µs making 2 calls to Moose::Meta::Mixin::AttributeCore::should_coerce, avg 11µs/call |
| 86 | && (!$self->_is_root_type( $attr->type_constraint ) | ||||
| 87 | || ( $attr->should_coerce && $attr->type_constraint->has_coercion) | ||||
| 88 | ); | ||||
| 89 | } | ||||
| 90 | |||||
| 91 | # spent 228µs (143+85) within Moose::Meta::Method::Accessor::Native::Writer::_is_root_type which was called 2 times, avg 114µs/call:
# 2 times (143µs+85µs) by Moose::Meta::Method::Accessor::Native::Writer::_constraint_must_be_checked at line 85, avg 114µs/call | ||||
| 92 | 2 | 6µs | my $self = shift; | ||
| 93 | 2 | 6µs | my ($type) = @_; | ||
| 94 | |||||
| 95 | 2 | 28µs | 2 | 30µs | my $name = $type->name; # spent 30µs making 2 calls to Moose::Meta::TypeConstraint::name, avg 15µs/call |
| 96 | |||||
| 97 | 4 | 119µs | 4 | 55µs | return any { $name eq $_ } @{ $self->root_types }; # spent 34µs making 2 calls to List::MoreUtils::any, avg 17µs/call
# spent 21µs making 2 calls to Moose::Meta::Method::Accessor::Native::root_types, avg 10µs/call |
| 98 | } | ||||
| 99 | |||||
| 100 | # spent 277µs (105+172) within Moose::Meta::Method::Accessor::Native::Writer::_inline_copy_native_value which was called 2 times, avg 139µs/call:
# 2 times (105µs+172µs) by Moose::Meta::Method::Accessor::Native::Writer::_inline_writer_core at line 54, avg 139µs/call | ||||
| 101 | 2 | 6µs | my $self = shift; | ||
| 102 | 2 | 6µs | my ($potential_ref) = @_; | ||
| 103 | |||||
| 104 | 2 | 90µs | 2 | 172µs | return unless $self->_writer_value_needs_copy; # spent 172µs making 2 calls to Moose::Meta::Method::Accessor::_writer_value_needs_copy, avg 86µs/call |
| 105 | |||||
| 106 | my $code = 'my $potential = ' . ${$potential_ref} . ';'; | ||||
| 107 | |||||
| 108 | ${$potential_ref} = '$potential'; | ||||
| 109 | |||||
| 110 | return $code; | ||||
| 111 | } | ||||
| 112 | |||||
| 113 | around _inline_tc_code => sub { | ||||
| 114 | 2 | 6µs | my $orig = shift; | ||
| 115 | 2 | 4µs | my $self = shift; | ||
| 116 | 2 | 10µs | my ($value, $tc, $tc_obj, $for_lazy) = @_; | ||
| 117 | |||||
| 118 | 2 | 42µs | 2 | 527µs | return unless $for_lazy || $self->_constraint_must_be_checked; # spent 527µs making 2 calls to Moose::Meta::Method::Accessor::Native::Writer::_constraint_must_be_checked, avg 263µs/call |
| 119 | |||||
| 120 | return $self->$orig(@_); | ||||
| 121 | 1 | 24µs | 1 | 322µs | }; # spent 322µs making 1 call to Moose::Role::around |
| 122 | |||||
| 123 | sub _inline_check_coercion { | ||||
| 124 | my $self = shift; | ||||
| 125 | my ($value, $tc, $tc_obj) = @_; | ||||
| 126 | |||||
| 127 | my $attr = $self->associated_attribute; | ||||
| 128 | return unless $attr->should_coerce && $attr->type_constraint->has_coercion; | ||||
| 129 | |||||
| 130 | # We want to break the aliasing in @_ in case the coercion tries to make a | ||||
| 131 | # destructive change to an array member. | ||||
| 132 | return $value . ' = ' . $tc_obj . '->coerce(' . $value . ');'; | ||||
| 133 | } | ||||
| 134 | |||||
| 135 | around _inline_check_constraint => sub { | ||||
| 136 | my $orig = shift; | ||||
| 137 | my $self = shift; | ||||
| 138 | my ($value, $tc, $tc_obj, $for_lazy) = @_; | ||||
| 139 | |||||
| 140 | return unless $for_lazy || $self->_constraint_must_be_checked; | ||||
| 141 | |||||
| 142 | return $self->$orig(@_); | ||||
| 143 | 1 | 22µs | 1 | 278µs | }; # spent 278µs making 1 call to Moose::Role::around |
| 144 | |||||
| 145 | 2 | 27µs | # spent 17µs within Moose::Meta::Method::Accessor::Native::Writer::_inline_capture_return_value which was called 2 times, avg 8µs/call:
# 2 times (17µs+0s) by Moose::Meta::Method::Accessor::Native::Writer::_inline_writer_core at line 54, avg 8µs/call | ||
| 146 | |||||
| 147 | # spent 780µs (159+621) within Moose::Meta::Method::Accessor::Native::Writer::_inline_set_new_value which was called 2 times, avg 390µs/call:
# 2 times (159µs+621µs) by Moose::Meta::Method::Accessor::Native::Writer::_inline_writer_core at line 54, avg 390µs/call | ||||
| 148 | 2 | 6µs | my $self = shift; | ||
| 149 | |||||
| 150 | 2 | 60µs | 6 | 574µs | return $self->_inline_store_value(@_) # spent 254µs making 2 calls to Moose::Meta::Method::Accessor::Native::_slot_access_can_be_inlined, avg 127µs/call
# spent 179µs making 2 calls to Moose::Meta::Method::Accessor::Native::Writer::_get_is_lvalue, avg 90µs/call
# spent 140µs making 2 calls to Moose::Meta::Method::Accessor::_writer_value_needs_copy, avg 70µs/call |
| 151 | if $self->_writer_value_needs_copy | ||||
| 152 | || !$self->_slot_access_can_be_inlined | ||||
| 153 | || !$self->_get_is_lvalue; | ||||
| 154 | |||||
| 155 | 2 | 73µs | 2 | 48µs | return $self->_inline_optimized_set_new_value(@_); # spent 24µs making 1 call to Moose::Meta::Method::Accessor::Native::Array::push::_inline_optimized_set_new_value
# spent 23µs making 1 call to Moose::Meta::Method::Accessor::Native::Array::clear::_inline_optimized_set_new_value |
| 156 | } | ||||
| 157 | |||||
| 158 | # spent 179µs (129+51) within Moose::Meta::Method::Accessor::Native::Writer::_get_is_lvalue which was called 2 times, avg 90µs/call:
# 2 times (129µs+51µs) by Moose::Meta::Method::Accessor::Native::Writer::_inline_set_new_value at line 150, avg 90µs/call | ||||
| 159 | 2 | 5µs | my $self = shift; | ||
| 160 | |||||
| 161 | 2 | 128µs | 8 | 51µs | return $self->associated_attribute->associated_class->instance_metaclass->inline_get_is_lvalue; # spent 16µs making 2 calls to Class::MOP::Instance::inline_get_is_lvalue, avg 8µs/call
# spent 16µs making 2 calls to Class::MOP::Method::Accessor::associated_attribute, avg 8µs/call
# spent 10µs making 2 calls to Class::MOP::Attribute::associated_class, avg 5µs/call
# spent 9µs making 2 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call |
| 162 | } | ||||
| 163 | |||||
| 164 | sub _inline_optimized_set_new_value { | ||||
| 165 | my $self = shift; | ||||
| 166 | |||||
| 167 | return $self->_inline_store_value(@_); | ||||
| 168 | } | ||||
| 169 | |||||
| 170 | sub _return_value { | ||||
| 171 | my $self = shift; | ||||
| 172 | my ($slot_access) = @_; | ||||
| 173 | |||||
| 174 | return $slot_access; | ||||
| 175 | } | ||||
| 176 | |||||
| 177 | 3 | 164µs | 2 | 1.86ms | # spent 959µs (62+897) within Moose::Meta::Method::Accessor::Native::Writer::BEGIN@177 which was called:
# once (62µs+897µs) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 177 # spent 959µs making 1 call to Moose::Meta::Method::Accessor::Native::Writer::BEGIN@177
# spent 897µs making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:557] |
| 178 | |||||
| 179 | 1 | 63µs | 1; |