| Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny/Role/GenerateAccessor.pm |
| Statements | Executed 897 statements in 3.25ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 73 | 1 | 1 | 1.98ms | 33.6ms | MooX::TypeTiny::Role::GenerateAccessor::__ANON__[:33] |
| 17 | 1 | 1 | 330µs | 1.81ms | MooX::TypeTiny::Role::GenerateAccessor::__ANON__[:63] |
| 73 | 1 | 1 | 225µs | 225µs | MooX::TypeTiny::Role::GenerateAccessor::CORE:subst (opcode) |
| 214 | 2 | 1 | 134µs | 134µs | MooX::TypeTiny::Role::GenerateAccessor::CORE:match (opcode) |
| 1 | 1 | 1 | 56µs | 613µs | MooX::TypeTiny::Role::GenerateAccessor::BEGIN@2 |
| 1 | 1 | 1 | 11µs | 51µs | MooX::TypeTiny::Role::GenerateAccessor::BEGIN@3 |
| 1 | 1 | 1 | 7µs | 26µ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 | 59µs | 2 | 653µs | # spent 613µs (56+557) within MooX::TypeTiny::Role::GenerateAccessor::BEGIN@2 which was called:
# once (56µs+557µs) by Moo::_Utils::_require at line 2 # spent 613µs making 1 call to MooX::TypeTiny::Role::GenerateAccessor::BEGIN@2
# spent 40µs making 1 call to Moo::Role::import |
| 3 | 2 | 35µs | 2 | 91µs | # spent 51µs (11+40) within MooX::TypeTiny::Role::GenerateAccessor::BEGIN@3 which was called:
# once (11µs+40µs) by Moo::_Utils::_require at line 3 # spent 51µs making 1 call to MooX::TypeTiny::Role::GenerateAccessor::BEGIN@3
# spent 40µs making 1 call to Exporter::import |
| 4 | 2 | 552µs | 2 | 45µs | # spent 26µs (7+19) within MooX::TypeTiny::Role::GenerateAccessor::BEGIN@4 which was called:
# once (7µs+19µs) by Moo::_Utils::_require at line 4 # spent 26µs making 1 call to MooX::TypeTiny::Role::GenerateAccessor::BEGIN@4
# spent 19µs making 1 call to Exporter::import |
| 5 | |||||
| 6 | # spent 33.6ms (1.98+31.6) within MooX::TypeTiny::Role::GenerateAccessor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny/Role/GenerateAccessor.pm:33] which was called 73 times, avg 461µs/call:
# 73 times (1.98ms+31.6ms) 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 461µs/call | ||||
| 7 | $Error::TypeTiny::CarpInternal{$_} = 1 | ||||
| 8 | 73 | 517µs | 146 | 58µs | for grep /\A(?:MooX?|Method::Generate)::/, keys %Carp::CarpInternal; # spent 58µs making 146 calls to MooX::TypeTiny::Role::GenerateAccessor::CORE:match, avg 397ns/call |
| 9 | |||||
| 10 | 73 | 20µs | my $orig = shift; | ||
| 11 | 73 | 17µs | my $self = shift; | ||
| 12 | 73 | 48µs | my ($name, $value, $check, $init_arg) = @_; | ||
| 13 | 73 | 362µs | 146 | 478µs | return $self->$orig(@_) # spent 402µs making 73 calls to Type::Tiny::isa, avg 6µs/call
# spent 76µs making 73 calls to Scalar::Util::blessed, avg 1µs/call |
| 14 | unless blessed $check && $check->isa('Type::Tiny'); | ||||
| 15 | |||||
| 16 | 73 | 119µs | 73 | 763µs | my $var = '$isa_check_for_'.sanitize_identifier($name); # spent 763µs making 73 calls to Sub::Quote::sanitize_identifier, avg 10µs/call |
| 17 | 73 | 88µs | $self->{captures}->{$var} = \$check; | ||
| 18 | |||||
| 19 | 73 | 158µs | 73 | 500µs | my $varname = defined $init_arg # spent 500µs making 73 calls to Sub::Quote::quotify, avg 7µs/call |
| 20 | ? sprintf('$args->{%s}', quotify($init_arg)) | ||||
| 21 | : sprintf('$self->{%s}', quotify($name)); | ||||
| 22 | |||||
| 23 | 73 | 184µs | 73 | 29.6ms | my $assertion = $check->inline_assert( # spent 29.6ms making 73 calls to Type::Tiny::inline_assert, avg 406µs/call |
| 24 | $value, | ||||
| 25 | $var, | ||||
| 26 | mgaca => 0, | ||||
| 27 | attribute_name => $name, | ||||
| 28 | attribute_step => 'isa check', | ||||
| 29 | varname => $varname, | ||||
| 30 | ); | ||||
| 31 | 73 | 381µs | 73 | 225µs | $assertion =~ s/;\z//; # spent 225µs making 73 calls to MooX::TypeTiny::Role::GenerateAccessor::CORE:subst, avg 3µs/call |
| 32 | 73 | 261µs | return $assertion; | ||
| 33 | 1 | 4µs | 1 | 13µs | }; # spent 13µs making 1 call to Moo::Role::around |
| 34 | |||||
| 35 | # spent 1.81ms (330µs+1.48) within MooX::TypeTiny::Role::GenerateAccessor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny/Role/GenerateAccessor.pm:63] which was called 17 times, avg 106µs/call:
# 17 times (330µs+1.48ms) 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 106µs/call | ||||
| 36 | $Error::TypeTiny::CarpInternal{$_} = 1 | ||||
| 37 | 17 | 278µs | 68 | 76µs | for grep /\A(?:MooX?|Method::Generate)::/, keys %Carp::Internal; # spent 76µs making 68 calls to MooX::TypeTiny::Role::GenerateAccessor::CORE:match, avg 1µs/call |
| 38 | |||||
| 39 | 17 | 7µs | my $orig = shift; | ||
| 40 | 17 | 4µs | my $self = shift; | ||
| 41 | 17 | 14µs | my ($name, $value, $coerce, $init_arg) = @_; | ||
| 42 | 17 | 138µs | 34 | 1.40ms | return $self->$orig(@_) # spent 1.39ms making 17 calls to Method::Generate::Accessor::_generate_coerce, avg 82µs/call
# spent 14µs making 17 calls to Scalar::Util::blessed, avg 824ns/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 | 1µs | 1 | 2µs | }; # spent 2µ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 134µs within MooX::TypeTiny::Role::GenerateAccessor::CORE:match which was called 214 times, avg 626ns/call:
# 146 times (58µ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 397ns/call
# 68 times (76µ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 1µs/call | |||||
# spent 225µs within MooX::TypeTiny::Role::GenerateAccessor::CORE:subst which was called 73 times, avg 3µs/call:
# 73 times (225µ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 3µs/call |