← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Thu Dec 15 15:23:56 2022
Reported on Thu Dec 15 15:27:03 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard/HashRef.pm
StatementsExecuted 303 statements in 1.09ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
3711334µs16.5msTypes::Standard::HashRef::::__ANON__[:76]Types::Standard::HashRef::__ANON__[:76]
811104µs8.03msTypes::Standard::HashRef::::__constraint_generatorTypes::Standard::HashRef::__constraint_generator
81156µs159µsTypes::Standard::HashRef::::__inline_generatorTypes::Standard::HashRef::__inline_generator
11128µs28µsTypes::Standard::HashRef::::BEGIN@5Types::Standard::HashRef::BEGIN@5
21111µs368µsTypes::Standard::HashRef::::__coercion_generatorTypes::Standard::HashRef::__coercion_generator
1116µs14µsTypes::Standard::HashRef::::BEGIN@22Types::Standard::HashRef::BEGIN@22
1116µs9µsTypes::Standard::HashRef::::BEGIN@6Types::Standard::HashRef::BEGIN@6
1114µs29µsTypes::Standard::HashRef::::BEGIN@7Types::Standard::HashRef::BEGIN@7
1113µs3µsTypes::Standard::HashRef::::BEGIN@16Types::Standard::HashRef::BEGIN@16
1112µs2µsTypes::Standard::HashRef::::BEGIN@17Types::Standard::HashRef::BEGIN@17
1111µs1µsTypes::Standard::HashRef::::BEGIN@18Types::Standard::HashRef::BEGIN@18
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µs128µs
# spent 28µs within Types::Standard::HashRef::BEGIN@5 which was called: # once (28µ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 28µs making 1 call to Types::Standard::HashRef::BEGIN@5
6218µs212µs
# spent 9µs (6+3) within Types::Standard::HashRef::BEGIN@6 which was called: # once (6µs+3µ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 3µs making 1 call to strict::import
7225µs254µs
# spent 29µs (4+25) within Types::Standard::HashRef::BEGIN@7 which was called: # once (4µs+25µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 7
use warnings;
# spent 29µs making 1 call to Types::Standard::HashRef::BEGIN@7 # spent 25µ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';
12122µs11µs}
# spent 1µs making 1 call to Types::Standard::HashRef::BEGIN@9
13
1411µs$Types::Standard::HashRef::VERSION =~ tr/_//d;
15
16211µs13µs
# spent 3µs within Types::Standard::HashRef::BEGIN@16 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 16
use Type::Tiny ();
# spent 3µs making 1 call to Types::Standard::HashRef::BEGIN@16
1729µs12µs
# spent 2µs within Types::Standard::HashRef::BEGIN@17 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 17
use Types::Standard ();
# spent 2µs making 1 call to Types::Standard::HashRef::BEGIN@17
18233µs11µs
# spent 1µs within Types::Standard::HashRef::BEGIN@18 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 18
use Types::TypeTiny ();
# spent 1µs making 1 call to Types::Standard::HashRef::BEGIN@18
19
20sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak }
21
222582µs222µs
# spent 14µs (6+8) within Types::Standard::HashRef::BEGIN@22 which was called: # once (6µs+8µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 22
no warnings;
# spent 14µs making 1 call to Types::Standard::HashRef::BEGIN@22 # spent 8µs making 1 call to warnings::unimport
23
24
# spent 8.03ms (104µs+7.93) within Types::Standard::HashRef::__constraint_generator which was called 8 times, avg 1.00ms/call: # 8 times (104µs+7.93ms) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm, avg 1.00ms/call
sub __constraint_generator {
2581µs return Types::Standard::HashRef unless @_;
26
2783µs my $param = shift;
2887µs872µs Types::TypeTiny::is_TypeTiny( $param )
# spent 72µs making 8 calls to Types::TypeTiny::is_TypeTiny, avg 9µs/call
29 or _croak(
30 "Parameter to HashRef[`a] expected to be a type constraint; got $param" );
31
32810µs86.40ms my $param_compiled_check = $param->compiled_check;
# spent 6.40ms making 8 calls to Type::Tiny::compiled_check, avg 800µs/call
3382µs my $xsub;
34818µs820µs if ( Type::Tiny::_USE_XS ) {
# spent 20µs making 8 calls to Type::Tiny::__ANON__[Type/Tiny.pm:55], avg 2µ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 },
51835µs $xsub,
52 );
53} #/ sub __constraint_generator
54
55
# spent 159µs (56+103) within Types::Standard::HashRef::__inline_generator which was called 8 times, avg 20µs/call: # 8 times (56µs+103µs) by Type::Tiny::parameterize at line 1057 of Type/Tiny.pm, avg 20µs/call
sub __inline_generator {
5683µs my $param = shift;
57
5887µs87µs my $compiled = $param->compiled_check;
# spent 7µs making 8 calls to Type::Tiny::compiled_check, avg 875ns/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
65811µs896µs return unless $param->can_be_inlined;
# spent 96µs making 8 calls to Type::Tiny::can_be_inlined, avg 12µs/call
66
# spent 16.5ms (334µs+16.2) 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 447µs/call: # 37 times (334µs+16.2ms) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 447µs/call
return sub {
67378µs my $v = $_[1];
683710µs return "$xsubname\($v\)" if $xsubname && !$Type::Tiny::AvoidCallbacks;
693758µs7473µs my $p = Types::Standard::HashRef->inline_check( $v );
# spent 73µs making 37 calls to Types::Standard::HashRef, avg 2µs/call # spent 852µs making 37 calls to Type::Tiny::inline_check, avg 23µs/call, recursion: max depth 2, sum of overlapping time 852µs
703728µs370s my $param_check = $param->inline_check( '$i' );
# spent 15.3ms making 37 calls to Type::Tiny::inline_check, avg 413µs/call, recursion: max depth 2, sum of overlapping time 15.3ms
71
7237113µs "$p and do { "
73 . "my \$ok = 1; "
74 . "for my \$i (values \%{$v}) { "
75 . "(\$ok = 0, last) unless $param_check " . "}; " . "\$ok " . "}";
76828µ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 368µs (11+357) within Types::Standard::HashRef::__coercion_generator which was called 2 times, avg 184µs/call: # 2 times (11µs+357µ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 184µs/call
sub __coercion_generator {
10222µs my ( $parent, $child, $param ) = @_;
10326µs20s return unless $param->has_coercion;
# spent 357µs making 2 calls to Type::Tiny::has_coercion, avg 178µs/call, recursion: max depth 1, sum of overlapping time 357µ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;