← 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/ArrayRef.pm
StatementsExecuted 282 statements in 2.28ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
2411437µs3.40msTypes::Standard::ArrayRef::::__ANON__[:121]Types::Standard::ArrayRef::__ANON__[:121]
411112µs3.99msTypes::Standard::ArrayRef::::__constraint_generatorTypes::Standard::ArrayRef::__constraint_generator
11190µs90µsTypes::Standard::ArrayRef::::BEGIN@5Types::Standard::ArrayRef::BEGIN@5
41164µs139µsTypes::Standard::ArrayRef::::__inline_generatorTypes::Standard::ArrayRef::__inline_generator
11133µs86µsTypes::Standard::ArrayRef::::BEGIN@7Types::Standard::ArrayRef::BEGIN@7
11118µs53µsTypes::Standard::ArrayRef::::BEGIN@22Types::Standard::ArrayRef::BEGIN@22
11110µs14µsTypes::Standard::ArrayRef::::BEGIN@6Types::Standard::ArrayRef::BEGIN@6
1113µs3µsTypes::Standard::ArrayRef::::BEGIN@16Types::Standard::ArrayRef::BEGIN@16
1113µs3µsTypes::Standard::ArrayRef::::BEGIN@18Types::Standard::ArrayRef::BEGIN@18
1113µs3µsTypes::Standard::ArrayRef::::BEGIN@9Types::Standard::ArrayRef::BEGIN@9
1112µs2µsTypes::Standard::ArrayRef::::BEGIN@17Types::Standard::ArrayRef::BEGIN@17
0000s0sTypes::Standard::ArrayRef::::__ANON__[:186]Types::Standard::ArrayRef::__ANON__[:186]
0000s0sTypes::Standard::ArrayRef::::__ANON__[:199]Types::Standard::ArrayRef::__ANON__[:199]
0000s0sTypes::Standard::ArrayRef::::__ANON__[:58]Types::Standard::ArrayRef::__ANON__[:58]
0000s0sTypes::Standard::ArrayRef::::__ANON__[:67]Types::Standard::ArrayRef::__ANON__[:67]
0000s0sTypes::Standard::ArrayRef::::__ANON__[:75]Types::Standard::ArrayRef::__ANON__[:75]
0000s0sTypes::Standard::ArrayRef::::__ANON__[:84]Types::Standard::ArrayRef::__ANON__[:84]
0000s0sTypes::Standard::ArrayRef::::__coercion_generatorTypes::Standard::ArrayRef::__coercion_generator
0000s0sTypes::Standard::ArrayRef::::__deep_explanationTypes::Standard::ArrayRef::__deep_explanation
0000s0sTypes::Standard::ArrayRef::::_croakTypes::Standard::ArrayRef::_croak
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 ArrayRef type from Types::Standard.
2
3package Types::Standard::ArrayRef;
4
5286µs190µs
# spent 90µs within Types::Standard::ArrayRef::BEGIN@5 which was called: # once (90µ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 90µs making 1 call to Types::Standard::ArrayRef::BEGIN@5
6255µs218µs
# spent 14µs (10+4) within Types::Standard::ArrayRef::BEGIN@6 which was called: # once (10µ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 14µs making 1 call to Types::Standard::ArrayRef::BEGIN@6 # spent 4µs making 1 call to strict::import
7248µs2139µs
# spent 86µs (33+53) within Types::Standard::ArrayRef::BEGIN@7 which was called: # once (33µs+53µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 7
use warnings;
# spent 86µs making 1 call to Types::Standard::ArrayRef::BEGIN@7 # spent 53µs making 1 call to warnings::import
8
9
# spent 3µs within Types::Standard::ArrayRef::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 {
1011µs $Types::Standard::ArrayRef::AUTHORITY = 'cpan:TOBYINK';
1113µs $Types::Standard::ArrayRef::VERSION = '2.000001';
12139µs13µs}
# spent 3µs making 1 call to Types::Standard::ArrayRef::BEGIN@9
13
1412µs$Types::Standard::ArrayRef::VERSION =~ tr/_//d;
15
16215µs13µs
# spent 3µs within Types::Standard::ArrayRef::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::ArrayRef::BEGIN@16
17213µs12µs
# spent 2µs within Types::Standard::ArrayRef::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::ArrayRef::BEGIN@17
18296µs13µs
# spent 3µs within Types::Standard::ArrayRef::BEGIN@18 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 18
use Types::TypeTiny ();
# spent 3µs making 1 call to Types::Standard::ArrayRef::BEGIN@18
19
20sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak }
21
2221.40ms288µs
# spent 53µs (18+35) within Types::Standard::ArrayRef::BEGIN@22 which was called: # once (18µs+35µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 22
no warnings;
# spent 53µs making 1 call to Types::Standard::ArrayRef::BEGIN@22 # spent 35µs making 1 call to warnings::unimport
23
24
# spent 3.99ms (112µs+3.88) within Types::Standard::ArrayRef::__constraint_generator which was called 4 times, avg 997µs/call: # 4 times (112µs+3.88ms) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm, avg 997µs/call
sub __constraint_generator {
2542µs return Types::Standard::ArrayRef unless @_;
26
2743µs my $param = shift;
2849µs4112µs Types::TypeTiny::is_TypeTiny( $param )
# spent 112µs making 4 calls to Types::TypeTiny::is_TypeTiny, avg 28µs/call
29 or _croak(
30 "Parameter to ArrayRef[`a] expected to be a type constraint; got $param" );
31
3244µs my ( $min, $max ) = ( 0, -1 );
3342µs $min = Types::Standard::assert_Int( shift ) if @_;
3441µs $max = Types::Standard::assert_Int( shift ) if @_;
35
36410µs4963µs my $param_compiled_check = $param->compiled_check;
# spent 963µs making 4 calls to Type::Tiny::compiled_check, avg 241µs/call
3741µs my $xsub;
3849µs49µs if ( Type::Tiny::_USE_XS and $min == 0 and $max == -1 ) {
# spent 9µs making 4 calls to Type::Tiny::__ANON__[Type/Tiny.pm:55], avg 2µs/call
39 my $paramname = Type::Tiny::XS::is_known( $param_compiled_check );
40 $xsub = Type::Tiny::XS::get_coderef_for( "ArrayRef[$paramname]" )
41 if $paramname;
42 }
43 elsif ( Type::Tiny::_USE_MOUSE
44 and $param->_has_xsub
45 and $min == 0
46 and $max == -1 )
47 {
48 require Mouse::Util::TypeConstraints;
49 my $maker = "Mouse::Util::TypeConstraints"->can( "_parameterize_ArrayRef_for" );
50 $xsub = $maker->( $param ) if $maker;
51 }
52
53 return (
54 sub {
55 my $array = shift;
56 $param->check( $_ ) || return for @$array;
57 return !!1;
58 },
59428µs $xsub,
60 ) if $min == 0 and $max == -1;
61
62 return sub {
63 my $array = shift;
64 return if @$array < $min;
65 $param->check( $_ ) || return for @$array;
66 return !!1;
67 }
68 if $max == -1;
69
70 return sub {
71 my $array = shift;
72 return if @$array > $max;
73 $param->check( $_ ) || return for @$array;
74 return !!1;
75 }
76 if $min == 0;
77
78 return sub {
79 my $array = shift;
80 return if @$array < $min;
81 return if @$array > $max;
82 $param->check( $_ ) || return for @$array;
83 return !!1;
84 };
85} #/ sub __constraint_generator
86
87
# spent 139µs (64+75) within Types::Standard::ArrayRef::__inline_generator which was called 4 times, avg 35µs/call: # 4 times (64µs+75µs) by Type::Tiny::parameterize at line 1057 of Type/Tiny.pm, avg 35µs/call
sub __inline_generator {
8849µs my $param = shift;
8942µs my ( $min, $max ) = ( 0, -1 );
9043µs $min = shift if @_;
9141µs $max = shift if @_;
92
9345µs41µs my $param_compiled_check = $param->compiled_check;
# spent 1µs making 4 calls to Type::Tiny::compiled_check, avg 250ns/call
9440s my $xsubname;
95 if ( Type::Tiny::_USE_XS and $min == 0 and $max == -1 ) {
96 my $paramname = Type::Tiny::XS::is_known( $param_compiled_check );
97 $xsubname = Type::Tiny::XS::get_subname_for( "ArrayRef[$paramname]" );
98 }
99
10048µs474µs return unless $param->can_be_inlined;
# spent 74µs making 4 calls to Type::Tiny::can_be_inlined, avg 18µs/call
101
102
# spent 3.40ms (437µs+2.97) within Types::Standard::ArrayRef::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard/ArrayRef.pm:121] which was called 24 times, avg 142µs/call: # 24 times (437µs+2.97ms) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 142µs/call
return sub {
1032417µs my $v = $_[1];
1042415µs return "$xsubname\($v\)" if $xsubname && !$Type::Tiny::AvoidCallbacks;
10524108µs48117µs my $p = Types::Standard::ArrayRef->inline_check( $v );
# spent 117µs making 24 calls to Types::Standard::ArrayRef, avg 5µs/call # spent 880µs making 24 calls to Type::Tiny::inline_check, avg 37µs/call, recursion: max depth 3, sum of overlapping time 880µs
106
1072425µs if ( $min != 0 ) {
108 $p .= sprintf( ' and @{%s} >= %d', $v, $min );
109 }
1102411µs if ( $max > 0 ) {
111 $p .= sprintf( ' and @{%s} <= %d', $v, $max );
112 }
113
1142431µs240s my $param_check = $param->inline_check( '$i' );
# spent 1.91ms making 24 calls to Type::Tiny::inline_check, avg 80µs/call, recursion: max depth 3, sum of overlapping time 1.91ms
1152486µs2457µs return $p if $param->{uniq} eq Types::Standard::Any->{uniq};
# spent 57µs making 24 calls to Types::Standard::Any, avg 2µs/call
116
11724101µs "$p and do { "
118 . "my \$ok = 1; "
119 . "for my \$i (\@{$v}) { "
120 . "(\$ok = 0, last) unless $param_check " . "}; " . "\$ok " . "}";
121427µs };
122} #/ sub __inline_generator
123
124sub __deep_explanation {
125 my ( $type, $value, $varname ) = @_;
126 my $param = $type->parameters->[0];
127 my ( $min, $max ) = ( 0, -1 );
128 $min = $type->parameters->[1] if @{ $type->parameters } > 1;
129 $max = $type->parameters->[2] if @{ $type->parameters } > 2;
130
131 if ( $min != 0 and @$value < $min ) {
132 return [
133 sprintf( '"%s" constrains array length at least %s', $type, $min ),
134 sprintf( '@{%s} is %d', $varname, scalar @$value ),
135 ];
136 }
137
138 if ( $max > 0 and @$value > $max ) {
139 return [
140 sprintf( '"%s" constrains array length at most %d', $type, $max ),
141 sprintf( '@{%s} is %d', $varname, scalar @$value ),
142 ];
143 }
144
145 for my $i ( 0 .. $#$value ) {
146 my $item = $value->[$i];
147 next if $param->check( $item );
148 return [
149 sprintf( '"%s" constrains each value in the array with "%s"', $type, $param ),
150 @{ $param->validate_explain( $item, sprintf( '%s->[%d]', $varname, $i ) ) },
151 ];
152 }
153
154 # This should never happen...
155 return; # uncoverable statement
156} #/ sub __deep_explanation
157
158# XXX: min and max need to be handled by coercion?
159sub __coercion_generator {
160 my ( $parent, $child, $param ) = @_;
161 return unless $param->has_coercion;
162
163 my $coercable_item = $param->coercion->_source_type_union;
164 my $C = "Type::Coercion"->new( type_constraint => $child );
165
166 if ( $param->coercion->can_be_inlined and $coercable_item->can_be_inlined ) {
167 $C->add_type_coercions(
168 $parent => Types::Standard::Stringable {
169 my @code;
170 push @code, 'do { my ($orig, $return_orig, @new) = ($_, 0);';
171 push @code, 'for (@$orig) {';
172 push @code,
173 sprintf(
174 '++$return_orig && last unless (%s);',
175 $coercable_item->inline_check( '$_' )
176 );
177 push @code,
178 sprintf(
179 'push @new, (%s);',
180 $param->coercion->inline_coercion( '$_' )
181 );
182 push @code, '}';
183 push @code, '$return_orig ? $orig : \\@new';
184 push @code, '}';
185 "@code";
186 }
187 );
188 } #/ if ( $param->coercion->...)
189 else {
190 $C->add_type_coercions(
191 $parent => sub {
192 my $value = @_ ? $_[0] : $_;
193 my @new;
194 for my $item ( @$value ) {
195 return $value unless $coercable_item->check( $item );
196 push @new, $param->coerce( $item );
197 }
198 return \@new;
199 },
200 );
201 } #/ else [ if ( $param->coercion->...)]
202
203 return $C;
204} #/ sub __coercion_generator
205
20615µs1;