| Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny/Role/GenerateAccessor.pm |
| Statements | Executed 857 statements in 3.11ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 20 | 1 | 1 | 1.64ms | 3.34ms | MooX::TypeTiny::Role::GenerateAccessor::__ANON__[:63] |
| 68 | 1 | 1 | 1.28ms | 22.8ms | MooX::TypeTiny::Role::GenerateAccessor::__ANON__[:33] |
| 68 | 1 | 1 | 130µs | 130µs | MooX::TypeTiny::Role::GenerateAccessor::CORE:subst (opcode) |
| 216 | 2 | 1 | 123µs | 123µs | MooX::TypeTiny::Role::GenerateAccessor::CORE:match (opcode) |
| 1 | 1 | 1 | 33µs | 356µs | MooX::TypeTiny::Role::GenerateAccessor::BEGIN@2 |
| 1 | 1 | 1 | 6µs | 37µs | MooX::TypeTiny::Role::GenerateAccessor::BEGIN@3 |
| 1 | 1 | 1 | 4µs | 16µs | MooX::TypeTiny::Role::GenerateAccessor::BEGIN@4 |
| 0 | 0 | 0 | 0s | 0s | MooX::TypeTiny::Role::GenerateAccessor::_is_simple_value |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package MooX::TypeTiny::Role::GenerateAccessor; | ||||
| 2 | 2 | 35µs | 2 | 374µs | # spent 356µs (33+323) within MooX::TypeTiny::Role::GenerateAccessor::BEGIN@2 which was called:
# once (33µs+323µs) by Moo::_Utils::_require at line 2 # spent 356µs making 1 call to MooX::TypeTiny::Role::GenerateAccessor::BEGIN@2
# spent 18µs making 1 call to Moo::Role::import |
| 3 | 2 | 17µs | 2 | 68µs | # spent 37µs (6+31) within MooX::TypeTiny::Role::GenerateAccessor::BEGIN@3 which was called:
# once (6µs+31µs) by Moo::_Utils::_require at line 3 # spent 37µs making 1 call to MooX::TypeTiny::Role::GenerateAccessor::BEGIN@3
# spent 31µs making 1 call to Exporter::import |
| 4 | 2 | 476µs | 2 | 28µs | # spent 16µs (4+12) within MooX::TypeTiny::Role::GenerateAccessor::BEGIN@4 which was called:
# once (4µs+12µs) by Moo::_Utils::_require at line 4 # spent 16µs making 1 call to MooX::TypeTiny::Role::GenerateAccessor::BEGIN@4
# spent 12µs making 1 call to Exporter::import |
| 5 | |||||
| 6 | # spent 22.8ms (1.28+21.5) within MooX::TypeTiny::Role::GenerateAccessor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny/Role/GenerateAccessor.pm:33] which was called 68 times, avg 335µs/call:
# 68 times (1.28ms+21.5ms) by Method::Generate::Accessor__WITH__MooX::TypeTiny::Role::GenerateAccessor::__ANON__[(eval 200)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Class/Method/Modifiers.pm:89]:1] at line 1 of (eval 200)[Class/Method/Modifiers.pm:89], avg 335µs/call | ||||
| 7 | $Error::TypeTiny::CarpInternal{$_} = 1 | ||||
| 8 | 68 | 330µs | 136 | 48µs | for grep /\A(?:MooX?|Method::Generate)::/, keys %Carp::CarpInternal; # spent 48µs making 136 calls to MooX::TypeTiny::Role::GenerateAccessor::CORE:match, avg 353ns/call |
| 9 | |||||
| 10 | 68 | 11µs | my $orig = shift; | ||
| 11 | 68 | 9µs | my $self = shift; | ||
| 12 | 68 | 39µs | my ($name, $value, $check, $init_arg) = @_; | ||
| 13 | 68 | 251µs | 136 | 384µs | return $self->$orig(@_) # spent 348µs making 68 calls to Type::Tiny::isa, avg 5µs/call
# spent 36µs making 68 calls to Scalar::Util::blessed, avg 529ns/call |
| 14 | unless blessed $check && $check->isa('Type::Tiny'); | ||||
| 15 | |||||
| 16 | 68 | 60µs | 68 | 391µs | my $var = '$isa_check_for_'.sanitize_identifier($name); # spent 391µs making 68 calls to Sub::Quote::sanitize_identifier, avg 6µs/call |
| 17 | 68 | 56µs | $self->{captures}->{$var} = \$check; | ||
| 18 | |||||
| 19 | 68 | 103µs | 68 | 231µs | my $varname = defined $init_arg # spent 231µs making 68 calls to Sub::Quote::quotify, avg 3µs/call |
| 20 | ? sprintf('$args->{%s}', quotify($init_arg)) | ||||
| 21 | : sprintf('$self->{%s}', quotify($name)); | ||||
| 22 | |||||
| 23 | 68 | 97µs | 68 | 20.3ms | my $assertion = $check->inline_assert( # spent 20.3ms making 68 calls to Type::Tiny::inline_assert, avg 299µs/call |
| 24 | $value, | ||||
| 25 | $var, | ||||
| 26 | mgaca => 0, | ||||
| 27 | attribute_name => $name, | ||||
| 28 | attribute_step => 'isa check', | ||||
| 29 | varname => $varname, | ||||
| 30 | ); | ||||
| 31 | 68 | 206µs | 68 | 130µs | $assertion =~ s/;\z//; # spent 130µs making 68 calls to MooX::TypeTiny::Role::GenerateAccessor::CORE:subst, avg 2µs/call |
| 32 | 68 | 186µs | return $assertion; | ||
| 33 | 1 | 4µs | 1 | 14µs | }; # spent 14µs making 1 call to Moo::Role::around |
| 34 | |||||
| 35 | # spent 3.34ms (1.64+1.70) within MooX::TypeTiny::Role::GenerateAccessor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny/Role/GenerateAccessor.pm:63] which was called 20 times, avg 167µs/call:
# 20 times (1.64ms+1.70ms) by Method::Generate::Accessor__WITH__MooX::TypeTiny::Role::GenerateAccessor::__ANON__[(eval 204)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Class/Method/Modifiers.pm:89]:1] at line 1 of (eval 200)[Class/Method/Modifiers.pm:89], avg 167µs/call | ||||
| 36 | $Error::TypeTiny::CarpInternal{$_} = 1 | ||||
| 37 | 20 | 1.09ms | 80 | 75µs | for grep /\A(?:MooX?|Method::Generate)::/, keys %Carp::Internal; # spent 75µs making 80 calls to MooX::TypeTiny::Role::GenerateAccessor::CORE:match, avg 937ns/call |
| 38 | |||||
| 39 | 20 | 12µs | my $orig = shift; | ||
| 40 | 20 | 2µs | my $self = shift; | ||
| 41 | 20 | 23µs | my ($name, $value, $coerce, $init_arg) = @_; | ||
| 42 | 20 | 103µs | 40 | 1.63ms | return $self->$orig(@_) # spent 1.61ms making 20 calls to Method::Generate::Accessor::_generate_coerce, avg 80µs/call
# spent 15µs making 20 calls to Scalar::Util::blessed, avg 750ns/call |
| 43 | unless blessed $coerce && $coerce->isa('Type::Coercion'); | ||||
| 44 | |||||
| 45 | my $var = '$coercion_for_'.sanitize_identifier($name); | ||||
| 46 | $self->{captures}->{$var} = \$coerce; | ||||
| 47 | |||||
| 48 | my $need_temp = !$self->_is_simple_value($value); | ||||
| 49 | my $inline_value = $value; | ||||
| 50 | if ($need_temp) { | ||||
| 51 | $inline_value = $value; | ||||
| 52 | $value = '$tmp'; | ||||
| 53 | } | ||||
| 54 | |||||
| 55 | my $code = $coerce->can_be_inlined ? $coerce->inline_coercion($value) : "${var}->coerce(${value})"; | ||||
| 56 | |||||
| 57 | if ($need_temp) { | ||||
| 58 | return "do { my \$tmp = $inline_value; $code }"; | ||||
| 59 | } | ||||
| 60 | else { | ||||
| 61 | return $code; | ||||
| 62 | } | ||||
| 63 | 1 | 2µs | 1 | 3µs | }; # spent 3µs making 1 call to Moo::Role::around |
| 64 | |||||
| 65 | # this doesn't need to be perfect. false negatives are fine. | ||||
| 66 | sub _is_simple_value { | ||||
| 67 | my ($self, $value) = @_; | ||||
| 68 | return $value =~ /\A(?: | ||||
| 69 | \$\w+(?:(?:->)?(?:\[[0-9]+\]|\{\w+\}))? | ||||
| 70 | | | ||||
| 71 | [-0-9_.ex]+ | ||||
| 72 | | | ||||
| 73 | "[^\$\@"]*" | ||||
| 74 | | | ||||
| 75 | '[^']*' | ||||
| 76 | | | ||||
| 77 | undef\(\) | ||||
| 78 | | | ||||
| 79 | \(!1\) | ||||
| 80 | )\z/x; | ||||
| 81 | } | ||||
| 82 | |||||
| 83 | 1 | 3µs | 1; | ||
# spent 123µs within MooX::TypeTiny::Role::GenerateAccessor::CORE:match which was called 216 times, avg 569ns/call:
# 136 times (48µs+0s) by MooX::TypeTiny::Role::GenerateAccessor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny/Role/GenerateAccessor.pm:33] at line 8, avg 353ns/call
# 80 times (75µs+0s) by MooX::TypeTiny::Role::GenerateAccessor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny/Role/GenerateAccessor.pm:63] at line 37, avg 937ns/call | |||||
# spent 130µs within MooX::TypeTiny::Role::GenerateAccessor::CORE:subst which was called 68 times, avg 2µs/call:
# 68 times (130µs+0s) by MooX::TypeTiny::Role::GenerateAccessor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny/Role/GenerateAccessor.pm:33] at line 31, avg 2µs/call |