← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Wed Dec 14 15:33:55 2022
Reported on Wed Dec 14 15:40:04 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard/HashRef.pm
StatementsExecuted 303 statements in 1.24ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
3711481µs25.1msTypes::Standard::HashRef::::__ANON__[:76]Types::Standard::HashRef::__ANON__[:76]
811110µs10.8msTypes::Standard::HashRef::::__constraint_generatorTypes::Standard::HashRef::__constraint_generator
81170µs176µsTypes::Standard::HashRef::::__inline_generatorTypes::Standard::HashRef::__inline_generator
11129µs29µsTypes::Standard::HashRef::::BEGIN@5Types::Standard::HashRef::BEGIN@5
1117µs9µsTypes::Standard::HashRef::::BEGIN@6Types::Standard::HashRef::BEGIN@6
1117µs31µsTypes::Standard::HashRef::::BEGIN@7Types::Standard::HashRef::BEGIN@7
2116µs629µsTypes::Standard::HashRef::::__coercion_generatorTypes::Standard::HashRef::__coercion_generator
1114µs11µsTypes::Standard::HashRef::::BEGIN@22Types::Standard::HashRef::BEGIN@22
1113µs3µsTypes::Standard::HashRef::::BEGIN@17Types::Standard::HashRef::BEGIN@17
1112µs2µsTypes::Standard::HashRef::::BEGIN@18Types::Standard::HashRef::BEGIN@18
1111µs1µsTypes::Standard::HashRef::::BEGIN@16Types::Standard::HashRef::BEGIN@16
1111µs1µsTypes::Standard::HashRef::::BEGIN@9Types::Standard::HashRef::BEGIN@9
0000s0sTypes::Standard::HashRef::::__ANON__[:128]Types::Standard::HashRef::__ANON__[:128]
0000s0sTypes::Standard::HashRef::::__ANON__[:141]Types::Standard::HashRef::__ANON__[:141]
0000s0sTypes::Standard::HashRef::::__ANON__[:161]Types::Standard::HashRef::__ANON__[:161]
0000s0sTypes::Standard::HashRef::::__ANON__[:50]Types::Standard::HashRef::__ANON__[:50]
0000s0sTypes::Standard::HashRef::::__deep_explanationTypes::Standard::HashRef::__deep_explanation
0000s0sTypes::Standard::HashRef::::__hashref_allows_keyTypes::Standard::HashRef::__hashref_allows_key
0000s0sTypes::Standard::HashRef::::__hashref_allows_valueTypes::Standard::HashRef::__hashref_allows_value
0000s0sTypes::Standard::HashRef::::_croakTypes::Standard::HashRef::_croak
0000s0sTypes::Standard::HashRef::::my_hashref_allows_keyTypes::Standard::HashRef::my_hashref_allows_key
0000s0sTypes::Standard::HashRef::::my_hashref_allows_valueTypes::Standard::HashRef::my_hashref_allows_value
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# INTERNAL MODULE: guts for HashRef type from Types::Standard.
2
3package Types::Standard::HashRef;
4
5237µs129µ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
use 5.008001;
# spent 29µs making 1 call to Types::Standard::HashRef::BEGIN@5
6220µs211µ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
use strict;
# spent 9µs making 1 call to Types::Standard::HashRef::BEGIN@6 # spent 2µs making 1 call to strict::import
7230µs255µ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
use warnings;
# 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
BEGIN {
1010s $Types::Standard::HashRef::AUTHORITY = 'cpan:TOBYINK';
1112µs $Types::Standard::HashRef::VERSION = '2.000001';
12121µs11µs}
# spent 1µs making 1 call to Types::Standard::HashRef::BEGIN@9
13
1411µs$Types::Standard::HashRef::VERSION =~ tr/_//d;
15
16210µs11µ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
use Type::Tiny ();
# spent 1µs making 1 call to Types::Standard::HashRef::BEGIN@16
1728µs13µ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
use Types::Standard ();
# spent 3µs making 1 call to Types::Standard::HashRef::BEGIN@17
18228µs12µ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
use Types::TypeTiny ();
# spent 2µs making 1 call to Types::Standard::HashRef::BEGIN@18
19
20sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak }
21
222577µs218µ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
no warnings;
# 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
sub __constraint_generator {
2581µs return Types::Standard::HashRef unless @_;
26
2783µs my $param = shift;
2885µs895µ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
32810µs89.19ms my $param_compiled_check = $param->compiled_check;
# spent 9.19ms making 8 calls to Type::Tiny::compiled_check, avg 1.15ms/call
3382µs my $xsub;
34824µs822µ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 },
51839µ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
sub __inline_generator {
5680s my $param = shift;
57
58811µs86µs my $compiled = $param->compiled_check;
# spent 6µs making 8 calls to Type::Tiny::compiled_check, avg 750ns/call
5980s 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
6589µs8100µ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
return sub {
673714µs my $v = $_[1];
68378µs return "$xsubname\($v\)" if $xsubname && !$Type::Tiny::AvoidCallbacks;
693797µs74109µ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
703744µs370s 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
7237190µs "$p and do { "
73 . "my \$ok = 1; "
74 . "for my \$i (values \%{$v}) { "
75 . "(\$ok = 0, last) unless $param_check " . "}; " . "\$ok " . "}";
76839µs };
77} #/ sub __inline_generator
78
79sub __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
sub __coercion_generator {
10220s my ( $parent, $child, $param ) = @_;
10327µs20s 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
148sub __hashref_allows_key {
149 my $self = shift;
150 Types::Standard::is_Str( $_[0] );
151}
152
153sub __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
16712µs1;