← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Wed Dec 14 15:57:08 2022
Reported on Wed Dec 14 16:00:34 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard/HashRef.pm
StatementsExecuted 303 statements in 1.56ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
3711556µs21.9msTypes::Standard::HashRef::::__ANON__[:76]Types::Standard::HashRef::__ANON__[:76]
811134µs11.0msTypes::Standard::HashRef::::__constraint_generatorTypes::Standard::HashRef::__constraint_generator
81186µs229µsTypes::Standard::HashRef::::__inline_generatorTypes::Standard::HashRef::__inline_generator
11143µs43µsTypes::Standard::HashRef::::BEGIN@5Types::Standard::HashRef::BEGIN@5
21115µs714µsTypes::Standard::HashRef::::__coercion_generatorTypes::Standard::HashRef::__coercion_generator
1118µs28µsTypes::Standard::HashRef::::BEGIN@22Types::Standard::HashRef::BEGIN@22
1117µs11µsTypes::Standard::HashRef::::BEGIN@6Types::Standard::HashRef::BEGIN@6
1117µs46µsTypes::Standard::HashRef::::BEGIN@7Types::Standard::HashRef::BEGIN@7
1115µs5µsTypes::Standard::HashRef::::BEGIN@16Types::Standard::HashRef::BEGIN@16
1113µs3µsTypes::Standard::HashRef::::BEGIN@9Types::Standard::HashRef::BEGIN@9
1112µs2µsTypes::Standard::HashRef::::BEGIN@17Types::Standard::HashRef::BEGIN@17
1111µs1µsTypes::Standard::HashRef::::BEGIN@18Types::Standard::HashRef::BEGIN@18
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
5255µs143µs
# spent 43µs within Types::Standard::HashRef::BEGIN@5 which was called: # once (43µ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 43µs making 1 call to Types::Standard::HashRef::BEGIN@5
6228µs215µs
# spent 11µs (7+4) within Types::Standard::HashRef::BEGIN@6 which was called: # once (7µs+4µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 6
use strict;
# spent 11µs making 1 call to Types::Standard::HashRef::BEGIN@6 # spent 4µs making 1 call to strict::import
7243µs285µs
# spent 46µs (7+39) within Types::Standard::HashRef::BEGIN@7 which was called: # once (7µs+39µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 7
use warnings;
# spent 46µs making 1 call to Types::Standard::HashRef::BEGIN@7 # spent 39µs making 1 call to warnings::import
8
9
# spent 3µs within Types::Standard::HashRef::BEGIN@9 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 12
BEGIN {
1010s $Types::Standard::HashRef::AUTHORITY = 'cpan:TOBYINK';
1114µs $Types::Standard::HashRef::VERSION = '2.000001';
12135µs13µs}
# spent 3µs making 1 call to Types::Standard::HashRef::BEGIN@9
13
1411µs$Types::Standard::HashRef::VERSION =~ tr/_//d;
15
16217µs15µs
# spent 5µs within Types::Standard::HashRef::BEGIN@16 which was called: # once (5µ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 5µs making 1 call to Types::Standard::HashRef::BEGIN@16
17212µ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
18245µ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
222827µs248µs
# spent 28µs (8+20) within Types::Standard::HashRef::BEGIN@22 which was called: # once (8µs+20µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 22
no warnings;
# spent 28µs making 1 call to Types::Standard::HashRef::BEGIN@22 # spent 20µs making 1 call to warnings::unimport
23
24
# spent 11.0ms (134µs+10.8) within Types::Standard::HashRef::__constraint_generator which was called 8 times, avg 1.37ms/call: # 8 times (134µs+10.8ms) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm, avg 1.37ms/call
sub __constraint_generator {
2585µs return Types::Standard::HashRef unless @_;
26
2781µs my $param = shift;
2887µs8109µs Types::TypeTiny::is_TypeTiny( $param )
# spent 109µs making 8 calls to Types::TypeTiny::is_TypeTiny, avg 14µs/call
29 or _croak(
30 "Parameter to HashRef[`a] expected to be a type constraint; got $param" );
31
32812µs88.59ms my $param_compiled_check = $param->compiled_check;
# spent 8.59ms making 8 calls to Type::Tiny::compiled_check, avg 1.07ms/call
3381µs my $xsub;
34823µs821µs if ( Type::Tiny::_USE_XS ) {
# spent 21µ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 },
51843µs $xsub,
52 );
53} #/ sub __constraint_generator
54
55
# spent 229µs (86+143) within Types::Standard::HashRef::__inline_generator which was called 8 times, avg 29µs/call: # 8 times (86µs+143µs) by Type::Tiny::parameterize at line 1057 of Type/Tiny.pm, avg 29µs/call
sub __inline_generator {
5684µs my $param = shift;
57
58812µ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
65812µs8136µs return unless $param->can_be_inlined;
# spent 136µs making 8 calls to Type::Tiny::can_be_inlined, avg 17µs/call
66
# spent 21.9ms (556µs+21.3) 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 591µs/call: # 37 times (556µs+21.3ms) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 591µs/call
return sub {
673716µs my $v = $_[1];
683713µs return "$xsubname\($v\)" if $xsubname && !$Type::Tiny::AvoidCallbacks;
6937104µs74104µs my $p = Types::Standard::HashRef->inline_check( $v );
# spent 104µs making 37 calls to Types::Standard::HashRef, avg 3µs/call # spent 1.21ms making 37 calls to Type::Tiny::inline_check, avg 33µs/call, recursion: max depth 2, sum of overlapping time 1.21ms
703744µs370s my $param_check = $param->inline_check( '$i' );
# spent 20.0ms making 37 calls to Type::Tiny::inline_check, avg 540µs/call, recursion: max depth 2, sum of overlapping time 20.0ms
71
7237139µs "$p and do { "
73 . "my \$ok = 1; "
74 . "for my \$i (values \%{$v}) { "
75 . "(\$ok = 0, last) unless $param_check " . "}; " . "\$ok " . "}";
76836µ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 714µs (15+699) within Types::Standard::HashRef::__coercion_generator which was called 2 times, avg 357µs/call: # 2 times (15µs+699µ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 357µs/call
sub __coercion_generator {
10222µs my ( $parent, $child, $param ) = @_;
103213µs20s return unless $param->has_coercion;
# spent 699µs making 2 calls to Type::Tiny::has_coercion, avg 350µs/call, recursion: max depth 1, sum of overlapping time 699µ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
16715µs1;