| Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard/HashRef.pm |
| Statements | Executed 303 statements in 1.24ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 37 | 1 | 1 | 481µs | 25.1ms | Types::Standard::HashRef::__ANON__[:76] |
| 8 | 1 | 1 | 110µs | 10.8ms | Types::Standard::HashRef::__constraint_generator |
| 8 | 1 | 1 | 70µs | 176µs | Types::Standard::HashRef::__inline_generator |
| 1 | 1 | 1 | 29µs | 29µs | Types::Standard::HashRef::BEGIN@5 |
| 1 | 1 | 1 | 7µs | 9µs | Types::Standard::HashRef::BEGIN@6 |
| 1 | 1 | 1 | 7µs | 31µs | Types::Standard::HashRef::BEGIN@7 |
| 2 | 1 | 1 | 6µs | 629µs | Types::Standard::HashRef::__coercion_generator |
| 1 | 1 | 1 | 4µs | 11µs | Types::Standard::HashRef::BEGIN@22 |
| 1 | 1 | 1 | 3µs | 3µs | Types::Standard::HashRef::BEGIN@17 |
| 1 | 1 | 1 | 2µs | 2µs | Types::Standard::HashRef::BEGIN@18 |
| 1 | 1 | 1 | 1µs | 1µs | Types::Standard::HashRef::BEGIN@16 |
| 1 | 1 | 1 | 1µs | 1µs | Types::Standard::HashRef::BEGIN@9 |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::HashRef::__ANON__[:128] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::HashRef::__ANON__[:141] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::HashRef::__ANON__[:161] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::HashRef::__ANON__[:50] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::HashRef::__deep_explanation |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::HashRef::__hashref_allows_key |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::HashRef::__hashref_allows_value |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::HashRef::_croak |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::HashRef::my_hashref_allows_key |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::HashRef::my_hashref_allows_value |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | # INTERNAL MODULE: guts for HashRef type from Types::Standard. | ||||
| 2 | |||||
| 3 | package Types::Standard::HashRef; | ||||
| 4 | |||||
| 5 | 2 | 37µs | 1 | 29µs | # spent 29µs within Types::Standard::HashRef::BEGIN@5 which was called:
# once (29µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 5 # spent 29µs making 1 call to Types::Standard::HashRef::BEGIN@5 |
| 6 | 2 | 20µs | 2 | 11µs | # spent 9µs (7+2) within Types::Standard::HashRef::BEGIN@6 which was called:
# once (7µs+2µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 6 # spent 9µs making 1 call to Types::Standard::HashRef::BEGIN@6
# spent 2µs making 1 call to strict::import |
| 7 | 2 | 30µs | 2 | 55µs | # spent 31µs (7+24) within Types::Standard::HashRef::BEGIN@7 which was called:
# once (7µs+24µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 7 # spent 31µs making 1 call to Types::Standard::HashRef::BEGIN@7
# spent 24µs making 1 call to warnings::import |
| 8 | |||||
| 9 | # spent 1µs within Types::Standard::HashRef::BEGIN@9 which was called:
# once (1µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 12 | ||||
| 10 | 1 | 0s | $Types::Standard::HashRef::AUTHORITY = 'cpan:TOBYINK'; | ||
| 11 | 1 | 2µs | $Types::Standard::HashRef::VERSION = '2.000001'; | ||
| 12 | 1 | 21µs | 1 | 1µs | } # spent 1µs making 1 call to Types::Standard::HashRef::BEGIN@9 |
| 13 | |||||
| 14 | 1 | 1µs | $Types::Standard::HashRef::VERSION =~ tr/_//d; | ||
| 15 | |||||
| 16 | 2 | 10µs | 1 | 1µs | # spent 1µs within Types::Standard::HashRef::BEGIN@16 which was called:
# once (1µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 16 # spent 1µs making 1 call to Types::Standard::HashRef::BEGIN@16 |
| 17 | 2 | 8µs | 1 | 3µs | # spent 3µs within Types::Standard::HashRef::BEGIN@17 which was called:
# once (3µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 17 # spent 3µs making 1 call to Types::Standard::HashRef::BEGIN@17 |
| 18 | 2 | 28µs | 1 | 2µs | # spent 2µs within Types::Standard::HashRef::BEGIN@18 which was called:
# once (2µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 18 # spent 2µs making 1 call to Types::Standard::HashRef::BEGIN@18 |
| 19 | |||||
| 20 | sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak } | ||||
| 21 | |||||
| 22 | 2 | 577µs | 2 | 18µs | # spent 11µs (4+7) within Types::Standard::HashRef::BEGIN@22 which was called:
# once (4µs+7µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 22 # spent 11µs making 1 call to Types::Standard::HashRef::BEGIN@22
# spent 7µs making 1 call to warnings::unimport |
| 23 | |||||
| 24 | # spent 10.8ms (110µs+10.7) within Types::Standard::HashRef::__constraint_generator which was called 8 times, avg 1.35ms/call:
# 8 times (110µs+10.7ms) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm, avg 1.35ms/call | ||||
| 25 | 8 | 1µs | return Types::Standard::HashRef unless @_; | ||
| 26 | |||||
| 27 | 8 | 3µs | my $param = shift; | ||
| 28 | 8 | 5µs | 8 | 95µs | Types::TypeTiny::is_TypeTiny( $param ) # spent 95µs making 8 calls to Types::TypeTiny::is_TypeTiny, avg 12µs/call |
| 29 | or _croak( | ||||
| 30 | "Parameter to HashRef[`a] expected to be a type constraint; got $param" ); | ||||
| 31 | |||||
| 32 | 8 | 10µs | 8 | 9.19ms | my $param_compiled_check = $param->compiled_check; # spent 9.19ms making 8 calls to Type::Tiny::compiled_check, avg 1.15ms/call |
| 33 | 8 | 2µs | my $xsub; | ||
| 34 | 8 | 24µs | 8 | 22µs | if ( Type::Tiny::_USE_XS ) { # spent 22µs making 8 calls to Type::Tiny::__ANON__[Type/Tiny.pm:55], avg 3µs/call |
| 35 | my $paramname = Type::Tiny::XS::is_known( $param_compiled_check ); | ||||
| 36 | $xsub = Type::Tiny::XS::get_coderef_for( "HashRef[$paramname]" ) | ||||
| 37 | if $paramname; | ||||
| 38 | } | ||||
| 39 | elsif ( Type::Tiny::_USE_MOUSE and $param->_has_xsub ) { | ||||
| 40 | require Mouse::Util::TypeConstraints; | ||||
| 41 | my $maker = "Mouse::Util::TypeConstraints"->can( "_parameterize_HashRef_for" ); | ||||
| 42 | $xsub = $maker->( $param ) if $maker; | ||||
| 43 | } | ||||
| 44 | |||||
| 45 | return ( | ||||
| 46 | sub { | ||||
| 47 | my $hash = shift; | ||||
| 48 | $param->check( $_ ) || return for values %$hash; | ||||
| 49 | return !!1; | ||||
| 50 | }, | ||||
| 51 | 8 | 39µs | $xsub, | ||
| 52 | ); | ||||
| 53 | } #/ sub __constraint_generator | ||||
| 54 | |||||
| 55 | # spent 176µs (70+106) within Types::Standard::HashRef::__inline_generator which was called 8 times, avg 22µs/call:
# 8 times (70µs+106µs) by Type::Tiny::parameterize at line 1057 of Type/Tiny.pm, avg 22µs/call | ||||
| 56 | 8 | 0s | my $param = shift; | ||
| 57 | |||||
| 58 | 8 | 11µs | 8 | 6µs | my $compiled = $param->compiled_check; # spent 6µs making 8 calls to Type::Tiny::compiled_check, avg 750ns/call |
| 59 | 8 | 0s | my $xsubname; | ||
| 60 | if ( Type::Tiny::_USE_XS and not $Type::Tiny::AvoidCallbacks ) { | ||||
| 61 | my $paramname = Type::Tiny::XS::is_known( $compiled ); | ||||
| 62 | $xsubname = Type::Tiny::XS::get_subname_for( "HashRef[$paramname]" ); | ||||
| 63 | } | ||||
| 64 | |||||
| 65 | 8 | 9µs | 8 | 100µs | return unless $param->can_be_inlined; # spent 100µs making 8 calls to Type::Tiny::can_be_inlined, avg 12µs/call |
| 66 | # spent 25.1ms (481µs+24.6) within Types::Standard::HashRef::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard/HashRef.pm:76] which was called 37 times, avg 677µs/call:
# 37 times (481µs+24.6ms) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 677µs/call | ||||
| 67 | 37 | 14µs | my $v = $_[1]; | ||
| 68 | 37 | 8µs | return "$xsubname\($v\)" if $xsubname && !$Type::Tiny::AvoidCallbacks; | ||
| 69 | 37 | 97µs | 74 | 109µs | my $p = Types::Standard::HashRef->inline_check( $v ); # spent 109µs making 37 calls to Types::Standard::HashRef, avg 3µs/call
# spent 1.22ms making 37 calls to Type::Tiny::inline_check, avg 33µs/call, recursion: max depth 2, sum of overlapping time 1.22ms |
| 70 | 37 | 44µs | 37 | 0s | my $param_check = $param->inline_check( '$i' ); # spent 23.2ms making 37 calls to Type::Tiny::inline_check, avg 628µs/call, recursion: max depth 2, sum of overlapping time 23.2ms |
| 71 | |||||
| 72 | 37 | 190µs | "$p and do { " | ||
| 73 | . "my \$ok = 1; " | ||||
| 74 | . "for my \$i (values \%{$v}) { " | ||||
| 75 | . "(\$ok = 0, last) unless $param_check " . "}; " . "\$ok " . "}"; | ||||
| 76 | 8 | 39µs | }; | ||
| 77 | } #/ sub __inline_generator | ||||
| 78 | |||||
| 79 | sub __deep_explanation { | ||||
| 80 | require B; | ||||
| 81 | my ( $type, $value, $varname ) = @_; | ||||
| 82 | my $param = $type->parameters->[0]; | ||||
| 83 | |||||
| 84 | for my $k ( sort keys %$value ) { | ||||
| 85 | my $item = $value->{$k}; | ||||
| 86 | next if $param->check( $item ); | ||||
| 87 | return [ | ||||
| 88 | sprintf( '"%s" constrains each value in the hash with "%s"', $type, $param ), | ||||
| 89 | @{ | ||||
| 90 | $param->validate_explain( | ||||
| 91 | $item, sprintf( '%s->{%s}', $varname, B::perlstring( $k ) ) | ||||
| 92 | ) | ||||
| 93 | }, | ||||
| 94 | ]; | ||||
| 95 | } #/ for my $k ( sort keys %$value) | ||||
| 96 | |||||
| 97 | # This should never happen... | ||||
| 98 | return; # uncoverable statement | ||||
| 99 | } #/ sub __deep_explanation | ||||
| 100 | |||||
| 101 | # spent 629µs (6+623) within Types::Standard::HashRef::__coercion_generator which was called 2 times, avg 314µs/call:
# 2 times (6µs+623µs) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:1073] at line 1070 of Type/Tiny.pm, avg 314µs/call | ||||
| 102 | 2 | 0s | my ( $parent, $child, $param ) = @_; | ||
| 103 | 2 | 7µs | 2 | 0s | return unless $param->has_coercion; # spent 623µs making 2 calls to Type::Tiny::has_coercion, avg 312µs/call, recursion: max depth 1, sum of overlapping time 623µs |
| 104 | |||||
| 105 | my $coercable_item = $param->coercion->_source_type_union; | ||||
| 106 | my $C = "Type::Coercion"->new( type_constraint => $child ); | ||||
| 107 | |||||
| 108 | if ( $param->coercion->can_be_inlined and $coercable_item->can_be_inlined ) { | ||||
| 109 | $C->add_type_coercions( | ||||
| 110 | $parent => Types::Standard::Stringable { | ||||
| 111 | my @code; | ||||
| 112 | push @code, 'do { my ($orig, $return_orig, %new) = ($_, 0);'; | ||||
| 113 | push @code, 'for (keys %$orig) {'; | ||||
| 114 | push @code, | ||||
| 115 | sprintf( | ||||
| 116 | '$return_orig++ && last unless (%s);', | ||||
| 117 | $coercable_item->inline_check( '$orig->{$_}' ) | ||||
| 118 | ); | ||||
| 119 | push @code, | ||||
| 120 | sprintf( | ||||
| 121 | '$new{$_} = (%s);', | ||||
| 122 | $param->coercion->inline_coercion( '$orig->{$_}' ) | ||||
| 123 | ); | ||||
| 124 | push @code, '}'; | ||||
| 125 | push @code, '$return_orig ? $orig : \\%new'; | ||||
| 126 | push @code, '}'; | ||||
| 127 | "@code"; | ||||
| 128 | } | ||||
| 129 | ); | ||||
| 130 | } #/ if ( $param->coercion->...) | ||||
| 131 | else { | ||||
| 132 | $C->add_type_coercions( | ||||
| 133 | $parent => sub { | ||||
| 134 | my $value = @_ ? $_[0] : $_; | ||||
| 135 | my %new; | ||||
| 136 | for my $k ( keys %$value ) { | ||||
| 137 | return $value unless $coercable_item->check( $value->{$k} ); | ||||
| 138 | $new{$k} = $param->coerce( $value->{$k} ); | ||||
| 139 | } | ||||
| 140 | return \%new; | ||||
| 141 | }, | ||||
| 142 | ); | ||||
| 143 | } #/ else [ if ( $param->coercion->...)] | ||||
| 144 | |||||
| 145 | return $C; | ||||
| 146 | } #/ sub __coercion_generator | ||||
| 147 | |||||
| 148 | sub __hashref_allows_key { | ||||
| 149 | my $self = shift; | ||||
| 150 | Types::Standard::is_Str( $_[0] ); | ||||
| 151 | } | ||||
| 152 | |||||
| 153 | sub __hashref_allows_value { | ||||
| 154 | my $self = shift; | ||||
| 155 | my ( $key, $value ) = @_; | ||||
| 156 | |||||
| 157 | return !!0 unless $self->my_hashref_allows_key( $key ); | ||||
| 158 | return !!1 if $self == Types::Standard::HashRef(); | ||||
| 159 | |||||
| 160 | my $href = $self->find_parent( | ||||
| 161 | sub { $_->has_parent && $_->parent == Types::Standard::HashRef() } ); | ||||
| 162 | my $param = $href->type_parameter; | ||||
| 163 | |||||
| 164 | Types::Standard::is_Str( $key ) and $param->check( $value ); | ||||
| 165 | } #/ sub __hashref_allows_value | ||||
| 166 | |||||
| 167 | 1 | 2µs | 1; |