← 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:32 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Eval/TypeTiny.pm
StatementsExecuted 4320 statements in 23.0ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1311117.6ms19.0msEval::TypeTiny::::_clean_evalEval::TypeTiny::_clean_eval
131533.60ms23.6msEval::TypeTiny::::eval_closureEval::TypeTiny::eval_closure
19854785µs1.46msEval::TypeTiny::::set_subnameEval::TypeTiny::set_subname
4022719µs8.52msEval::TypeTiny::::type_to_coderefEval::TypeTiny::type_to_coderef
13111291µs291µsEval::TypeTiny::::CORE:substEval::TypeTiny::CORE:subst (opcode)
4011273µs292µsEval::TypeTiny::::_make_lexical_assignmentEval::TypeTiny::_make_lexical_assignment
1311175µs75µsEval::TypeTiny::::CORE:sortEval::TypeTiny::CORE:sort (opcode)
11162µs62µsEval::TypeTiny::::_pick_alternativeEval::TypeTiny::_pick_alternative
11125µs335µsEval::TypeTiny::::importEval::TypeTiny::import
11120µs23µsEval::TypeTiny::::BEGIN@3Eval::TypeTiny::BEGIN@3
401119µs19µsEval::TypeTiny::::CORE:matchEval::TypeTiny::CORE:match (opcode)
1117µs39µsEval::TypeTiny::::BEGIN@13Eval::TypeTiny::BEGIN@13
1115µs5µsEval::TypeTiny::::BEGIN@61Eval::TypeTiny::BEGIN@61
1115µs19µsEval::TypeTiny::::BEGIN@81Eval::TypeTiny::BEGIN@81
1114µs4µsEval::TypeTiny::::BEGIN@15Eval::TypeTiny::BEGIN@15
0000s0sEval::TypeTiny::::ALIAS_IMPLEMENTATIONEval::TypeTiny::ALIAS_IMPLEMENTATION
0000s0sEval::TypeTiny::::__ANON__[:141]Eval::TypeTiny::__ANON__[:141]
0000s0sEval::TypeTiny::::_force_implementationEval::TypeTiny::_force_implementation
0000s0sEval::TypeTiny::::_manufacture_tiesEval::TypeTiny::_manufacture_ties
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Eval::TypeTiny;
2
3266µs226µs
# spent 23µs (20+3) within Eval::TypeTiny::BEGIN@3 which was called: # once (20µs+3µs) by Type::Library::BEGIN@14 at line 3
use strict;
# spent 23µs making 1 call to Eval::TypeTiny::BEGIN@3 # spent 3µs making 1 call to strict::import
4
5
# spent 19.0ms (17.6+1.46) within Eval::TypeTiny::_clean_eval which was called 131 times, avg 145µs/call: # 131 times (17.6ms+1.46ms) by Eval::TypeTiny::eval_closure at line 235, avg 145µs/call
sub _clean_eval {
613127µs local $@;
7131292µs local $SIG{__DIE__};
813113.7ms my $r = eval $_[0];
# spent 1.63ms executing statements in string eval
# includes 1.29ms spent executing 344 calls to 2 subs defined therein. # spent 1.21ms executing statements in 20 string evals (merged)
# includes 1.01ms spent executing 197 calls to 22 subs defined therein. # spent 458µs executing statements in 20 string evals (merged)
# includes 271µs spent executing 141 calls to 22 subs defined therein. # spent 187µs executing statements in string eval
# includes 25µs spent executing 2 calls to 4 subs defined therein. # spent 153µs executing statements in string eval
# includes 23µs spent executing 3 calls to 5 subs defined therein. # spent 136µs executing statements in string eval
# includes 13µs spent executing 2 calls to 4 subs defined therein. # spent 131µs executing statements in string eval
# includes 11µs spent executing 2 calls to 4 subs defined therein. # spent 131µs executing statements in string eval
# includes 16µs spent executing 2 calls to 4 subs defined therein. # spent 128µs executing statements in string eval
# includes 12µs spent executing 2 calls to 4 subs defined therein. # spent 124µs executing statements in string eval
# includes 16µs spent executing 2 calls to 4 subs defined therein. # spent 120µs executing statements in string eval
# includes 14µs spent executing 2 calls to 4 subs defined therein. # spent 119µs executing statements in string eval
# includes 21µs spent executing 2 calls to 4 subs defined therein. # spent 113µs executing statements in string eval
# includes 14µs spent executing 2 calls to 4 subs defined therein. # spent 106µs executing statements in string eval
# includes 61µs spent executing 2 calls to 4 subs defined therein. # spent 102µs executing statements in string eval
# includes 19µs spent executing 2 calls to 4 subs defined therein. # spent 100µs executing statements in string eval
# includes 31µs spent executing 2 calls to 4 subs defined therein. # spent 99µs executing statements in string eval
# includes 15µs spent executing 2 calls to 4 subs defined therein. # spent 93µs executing statements in string eval
# includes 14µs spent executing 2 calls to 4 subs defined therein. # spent 89µs executing statements in string eval
# includes 41µs spent executing 2 calls to 4 subs defined therein. # spent 86µs executing statements in string eval
# includes 23µs spent executing 2 calls to 4 subs defined therein. # spent 77µs executing statements in string eval
# includes 13µs spent executing 2 calls to 4 subs defined therein. # spent 77µs executing statements in string eval
# includes 13µs spent executing 2 calls to 4 subs defined therein. # spent 75µs executing statements in string eval
# includes 11µs spent executing 2 calls to 4 subs defined therein. # spent 74µs executing statements in string eval
# includes 66µs spent executing 2 calls to 4 subs defined therein. # spent 74µs executing statements in string eval
# includes 12µs spent executing 2 calls to 4 subs defined therein. # spent 73µs executing statements in string eval
# includes 15µs spent executing 2 calls to 4 subs defined therein. # spent 69µs executing statements in string eval
# includes 18µs spent executing 2 calls to 4 subs defined therein. # spent 67µs executing statements in string eval
# includes 14µs spent executing 2 calls to 4 subs defined therein. # spent 67µs executing statements in string eval
# includes 8µs spent executing 2 calls to 4 subs defined therein. # spent 66µs executing statements in string eval
# includes 15µs spent executing 2 calls to 4 subs defined therein. # spent 65µs executing statements in string eval
# includes 40µs spent executing 39 calls to 2 subs defined therein. # spent 63µs executing statements in string eval
# includes 8µs spent executing 2 calls to 4 subs defined therein. # spent 60µs executing statements in string eval
# includes 10µs spent executing 2 calls to 4 subs defined therein. # spent 58µs executing statements in string eval
# includes 7µs spent executing 2 calls to 4 subs defined therein. # spent 56µs executing statements in string eval
# includes 8µs spent executing 2 calls to 4 subs defined therein. # spent 55µs executing statements in string eval
# includes 8µs spent executing 2 calls to 4 subs defined therein. # spent 54µs executing statements in string eval
# includes 13µs spent executing 2 calls to 4 subs defined therein. # spent 53µs executing statements in string eval
# includes 13µs spent executing 2 calls to 4 subs defined therein. # spent 50µs executing statements in string eval
# includes 7µs spent executing 2 calls to 4 subs defined therein. # spent 48µs executing statements in string eval
# includes 8µs spent executing 2 calls to 4 subs defined therein. # spent 47µs executing statements in string eval
# includes 10µs spent executing 2 calls to 4 subs defined therein. # spent 47µs executing statements in string eval
# includes 35µs spent executing 1 call to 2 subs defined therein. # spent 42µs executing statements in string eval
# includes 6µs spent executing 2 calls to 4 subs defined therein. # spent 36µs executing statements in 2 string evals (merged)
# includes 6µs spent executing 2 calls to 2 subs defined therein. # spent 22µs executing statements in string eval
# includes 7µs spent executing 1 call to 2 subs defined therein. # spent 17µs executing statements in 2 string evals (merged)
# includes 4µs spent executing 2 calls to 2 subs defined therein. # spent 14µs executing statements in string eval
# includes 4µs spent executing 1 call to 2 subs defined therein. # spent 12µs executing statements in string eval
# includes 3µs spent executing 1 call to 2 subs defined therein. # spent 12µs executing statements in string eval
# includes 2µs spent executing 1 call to 3 subs defined therein. # spent 11µs executing statements in 2 string evals (merged)
# includes 3µs spent executing 2 calls to 4 subs defined therein. # spent 11µs executing statements in string eval
# includes 5µs spent executing 1 call to 2 subs defined therein. # spent 11µs executing statements in string eval
# includes 3µs spent executing 1 call to 2 subs defined therein. # spent 11µs executing statements in string eval
# includes 4µs spent executing 1 call to 2 subs defined therein. # spent 11µs executing statements in string eval
# includes 3µs spent executing 1 call to 2 subs defined therein. # spent 10µs executing statements in string eval
# includes 2µs spent executing 1 call to 2 subs defined therein. # spent 10µs executing statements in string eval
# includes 4µs spent executing 1 call to 3 subs defined therein. # spent 10µs executing statements in string eval
# includes 2µs spent executing 1 call to 3 subs defined therein. # spent 10µs executing statements in string eval
# includes 3µs spent executing 1 call to 2 subs defined therein. # spent 10µs executing statements in string eval
# includes 2µs spent executing 1 call to 3 subs defined therein. # spent 10µs executing statements in string eval
# includes 2µs spent executing 1 call to 3 subs defined therein. # spent 9µs executing statements in string eval
# includes 2µs spent executing 1 call to 3 subs defined therein. # spent 9µs executing statements in string eval
# includes 1µs spent executing 1 call to 2 subs defined therein. # spent 9µs executing statements in string eval
# includes 3µs spent executing 1 call to 2 subs defined therein. # spent 9µs executing statements in string eval
# includes 2µs spent executing 1 call to 2 subs defined therein. # spent 8µs executing statements in string eval
# includes 2µs spent executing 1 call to 2 subs defined therein. # spent 8µs executing statements in string eval
# includes 2µs spent executing 1 call to 2 subs defined therein. # spent 8µs executing statements in string eval
# includes 2µs spent executing 1 call to 2 subs defined therein. # spent 7µs executing statements in string eval
# includes 1µs spent executing 1 call to 3 subs defined therein. # spent 7µs executing statements in string eval
# includes 2µs spent executing 1 call to 2 subs defined therein. # spent 7µs executing statements in string eval
# includes 2µs spent executing 1 call to 2 subs defined therein. # spent 7µs executing statements in string eval
# includes 2µs spent executing 1 call to 2 subs defined therein. # spent 7µs executing statements in string eval
# includes 2µs spent executing 1 call to 3 subs defined therein. # spent 7µs executing statements in string eval
# includes 2µs spent executing 1 call to 3 subs defined therein. # spent 6µs executing statements in string eval
# includes 2µs spent executing 1 call to 2 subs defined therein. # spent 6µs executing statements in string eval
# includes 2µs spent executing 1 call to 2 subs defined therein. # spent 6µs executing statements in string eval
# includes 0s spent executing 1 call to 2 subs defined therein. # spent 6µs executing statements in string eval
# includes 2µs spent executing 1 call to 2 subs defined therein. # spent 6µs executing statements in string eval
# includes 2µs spent executing 1 call to 3 subs defined therein. # spent 6µs executing statements in string eval
# includes 3µs spent executing 1 call to 3 subs defined therein. # spent 6µs executing statements in string eval
# includes 2µs spent executing 1 call to 3 subs defined therein. # spent 6µs executing statements in string eval
# includes 2µs spent executing 1 call to 3 subs defined therein. # spent 5µs executing statements in string eval
# includes 1µs spent executing 1 call to 3 subs defined therein. # spent 5µs executing statements in string eval
# includes 0s spent executing 1 call to 3 subs defined therein. # spent 5µs executing statements in string eval
# includes 0s spent executing 1 call to 2 subs defined therein. # spent 5µs executing statements in string eval
# includes 1µs spent executing 1 call to 3 subs defined therein. # spent 4µs executing statements in string eval
# includes 2µs spent executing 1 call to 3 subs defined therein. # spent 4µs executing statements in string eval
# includes 0s spent executing 1 call to 3 subs defined therein. # spent 4µs executing statements in string eval
# includes 2µs spent executing 1 call to 3 subs defined therein. # spent 4µs executing statements in string eval
# includes 1µs spent executing 1 call to 3 subs defined therein. # spent 4µs executing statements in string eval
# includes 1µs spent executing 1 call to 3 subs defined therein.
913164µs my $e = $@;
10131664µs return ( $r, $e );
11}
12
13263µs271µs
# spent 39µs (7+32) within Eval::TypeTiny::BEGIN@13 which was called: # once (7µs+32µs) by Type::Library::BEGIN@14 at line 13
use warnings;
# spent 39µs making 1 call to Eval::TypeTiny::BEGIN@13 # spent 32µs making 1 call to warnings::import
14
15
# spent 4µs within Eval::TypeTiny::BEGIN@15 which was called: # once (4µs+0s) by Type::Library::BEGIN@14 at line 18
BEGIN {
1611µs *HAS_LEXICAL_SUBS = ( $] >= 5.018 ) ? sub () { !!1 } : sub () { !!0 };
1713µs *NICE_PROTOTYPES = ( $] >= 5.014 ) ? sub () { !!1 } : sub () { !!0 };
181174µs14µs}
# spent 4µs making 1 call to Eval::TypeTiny::BEGIN@15
19
20
# spent 62µs within Eval::TypeTiny::_pick_alternative which was called: # once (62µs+0s) by Eval::TypeTiny::set_subname at line 96
sub _pick_alternative {
2111µs my $ok = 0;
2210s while ( @_ ) {
2311µs my ( $type, $condition, $result ) = splice @_, 0, 3;
2412µs if ( $type eq 'needs' ) {
25126µs ++$ok if eval "require $condition; 1";
# spent 2µs executing statements in string eval
26 }
27 elsif ( $type eq 'if' ) {
28 ++$ok if $condition;
29 }
3010s next unless $ok;
31124µs return ref( $result ) eq 'CODE' ? $result->() : ref( $result ) eq 'SCALAR' ? eval( $$result ) : $result;
# spent 7µs executing statements in string eval
32 }
33 return;
34}
35
36{
37 sub IMPLEMENTATION_DEVEL_LEXALIAS () { 'Devel::LexAlias' }
38 sub IMPLEMENTATION_PADWALKER () { 'PadWalker' }
39 sub IMPLEMENTATION_TIE () { 'tie' }
40 sub IMPLEMENTATION_NATIVE () { 'perl' }
41
4211µs my $implementation;
43
44 #<<<
45 # uncoverable subroutine
46 sub ALIAS_IMPLEMENTATION () {
47 $implementation ||= _pick_alternative(
48 if => ( $] ge '5.022' ) => IMPLEMENTATION_NATIVE,
49 needs => 'Devel::LexAlias' => IMPLEMENTATION_DEVEL_LEXALIAS,
50 needs => 'PadWalker' => IMPLEMENTATION_PADWALKER,
51 if => !!1 => IMPLEMENTATION_TIE,
52 );
53 }
54 #>>>
55
56 sub _force_implementation {
57 $implementation = shift;
58 }
59}
60
6110s
# spent 5µs within Eval::TypeTiny::BEGIN@61 which was called: # once (5µs+0s) by Type::Library::BEGIN@14 at line 63
BEGIN {
6214µs *_EXTENDED_TESTING = $ENV{EXTENDED_TESTING} ? sub() { !!1 } : sub() { !!0 };
63160µs15µs}
# spent 5µs making 1 call to Eval::TypeTiny::BEGIN@61
64
6511µsour $AUTHORITY = 'cpan:TOBYINK';
6610sour $VERSION = '2.000001';
6711µsour @EXPORT = qw( eval_closure );
6810sour @EXPORT_OK = qw(
69 HAS_LEXICAL_SUBS HAS_LEXICAL_VARS ALIAS_IMPLEMENTATION
70 IMPLEMENTATION_DEVEL_LEXALIAS IMPLEMENTATION_PADWALKER
71 IMPLEMENTATION_NATIVE IMPLEMENTATION_TIE
72 set_subname type_to_coderef NICE_PROTOTYPES
73);
74
7512µs$VERSION =~ tr/_//d;
76
77# See Types::TypeTiny for an explanation of this import method.
78#
79# uncoverable subroutine
80
# spent 335µs (25+310) within Eval::TypeTiny::import which was called: # once (25µs+310µs) by Type::Library::BEGIN@14 at line 14 of Type/Library.pm
sub import {
8121.74ms233µs
# spent 19µs (5+14) within Eval::TypeTiny::BEGIN@81 which was called: # once (5µs+14µs) by Type::Library::BEGIN@14 at line 81
no warnings "redefine";
# spent 19µs making 1 call to Eval::TypeTiny::BEGIN@81 # spent 14µs making 1 call to warnings::unimport
8218µs our @ISA = qw( Exporter::Tiny );
8311µs require Exporter::Tiny;
8412µs my $next = \&Exporter::Tiny::import;
8511µs *import = $next;
8611µs my $class = shift;
8711µs my $opts = { ref( $_[0] ) ? %{ +shift } : () };
8812µs $opts->{into} ||= scalar( caller );
89114µs1310µs return $class->$next( $opts, @_ );
# spent 310µs making 1 call to Exporter::Tiny::import
90} #/ sub import
91
92{
9310s my $subname;
9411µs my %already; # prevent renaming established functions
95
# spent 1.46ms (785µs+678µs) within Eval::TypeTiny::set_subname which was called 198 times, avg 7µs/call: # 148 times (514µs+391µs) by Type::Library::add_type at line 239 of Type/Library.pm, avg 6µs/call # 40 times (212µs+227µs) by Eval::TypeTiny::type_to_coderef at line 177, avg 11µs/call # 7 times (45µs+37µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 186 of Types/Standard.pm, avg 12µs/call # 2 times (8µs+17µs) by Type::Tiny::new at line 364 of Type/Tiny.pm, avg 12µs/call # once (6µs+6µs) by Type::Library::make_immutable at line 322 of Type/Library.pm
sub set_subname ($$) {
9619840µs162µs $subname = _pick_alternative(
# spent 62µs making 1 call to Eval::TypeTiny::_pick_alternative
97 needs => 'Sub::Util' => \ q{ \&Sub::Util::set_subname },
98 needs => 'Sub::Name' => \ q{ \&Sub::Name::subname },
99 if => !!1 => 0,
100 ) unless defined $subname;
1011981.36ms147616µs $subname and !$already{$_[1]}++ and return &$subname;
# spent 616µs making 147 calls to Sub::Util::set_subname, avg 4µs/call
10251103µs $_[1];
103 } #/ sub set_subname ($$)
104}
105
10610s
# spent 8.52ms (719µs+7.80) within Eval::TypeTiny::type_to_coderef which was called 40 times, avg 213µs/call: # 37 times (660µs+7.13ms) by Type::Tiny::exportables at line 1197 of Type/Tiny.pm, avg 211µs/call # 3 times (59µs+664µs) by Type::Library::add_coercion at line 287 of Type/Library.pm, avg 241µs/call
sub type_to_coderef {
1074012µs my ( $type, %args ) = @_;
1084019µs my $post_method = $args{post_method} || q();
109
110408µs my ( $coderef, $qualified_name );
111
1124070µs if ( ! defined $type ) {
113 my $library = $args{type_library};
114 my $name = $args{type_name};
115
116 $qualified_name = "$library\::$name";
117 $coderef = sub (;@) {
118 my $params;
119 $params = shift if ref( $_[0] ) eq "ARRAY";
120
121 $type ||= do {
122 $library->can( 'get_type' )
123 or require Error::TypeTiny
124 && Error::TypeTiny::croak( "Expected $library to be a type library, but it doesn't seem to be" );
125 $library->get_type( $name );
126 };
127
128 my $t;
129 if ( $type ) {
130 $t = $params ? $type->parameterize( @$params ) : $type;
131 $t = $t->$post_method if $post_method;
132 }
133 else {
134 require Error::TypeTiny && Error::TypeTiny::croak( "Cannot parameterize a non-existant type" )
135 if $params;
136 require Type::Tiny::_DeclaredType;
137 $t = Type::Tiny::_DeclaredType->new( library => $library, name => $name );
138 }
139
140 @_ && wantarray ? return ( $t, @_ ) : return $t;
141 };
142
143 require Scalar::Util && &Scalar::Util::set_prototype( $coderef, ';$' )
144 if Eval::TypeTiny::NICE_PROTOTYPES;
145 }
146 else {
147
148 #<<<
14940149µs40279µs my $source = $type->is_parameterizable ?
# spent 265µs making 37 calls to Type::Tiny::is_parameterizable, avg 7µs/call # spent 14µs making 3 calls to Type::Coercion::is_parameterizable, avg 5µs/call
150 sprintf(
151 q{
152 sub (%s) {
153 if (ref($_[0]) eq 'Type::Tiny::_HalfOp') {
154 my $complete_type = shift->complete($type);
155 @_ && wantarray ? return($complete_type, @_) : return $complete_type;
156 }
157 my $params; $params = shift if ref($_[0]) eq q(ARRAY);
158 my $t = $params ? $type->parameterize(@$params) : $type;
159 @_ && wantarray ? return($t%s, @_) : return $t%s;
160 }
161 },
162 NICE_PROTOTYPES ? q(;$) : q(;@),
163 $post_method,
164 $post_method,
165 ) :
166 sprintf( q{ sub () { $type%s if $] } }, $post_method );
167 #>>>
168
1694081µs40253µs $qualified_name = $type->qualified_name;
# spent 231µs making 37 calls to Type::Tiny::qualified_name, avg 6µs/call # spent 22µs making 3 calls to Type::Coercion::qualified_name, avg 7µs/call
170 $coderef = eval_closure(
171 source => $source,
17240135µs406.83ms description => $args{description} || sprintf( "exportable function '%s'", $qualified_name ),
# spent 6.83ms making 40 calls to Eval::TypeTiny::eval_closure, avg 171µs/call
173 environment => { '$type' => \$type },
174 );
175 }
176
17740219µs40439µs $args{anonymous} ? $coderef : set_subname( $qualified_name, $coderef );
# spent 439µs making 40 calls to Eval::TypeTiny::set_subname, avg 11µs/call
178}
179
180
# spent 23.6ms (3.60+20.0) within Eval::TypeTiny::eval_closure which was called 131 times, avg 181µs/call: # 48 times (1.29ms+7.28ms) by Type::Tiny::_build_compiled_check at line 537 of Type/Tiny.pm, avg 179µs/call # 40 times (1.23ms+5.60ms) by Eval::TypeTiny::type_to_coderef at line 172, avg 171µs/call # 37 times (841µs+6.50ms) by Type::Tiny::_overload_coderef at line 215 of Type/Tiny.pm, avg 198µs/call # 5 times (199µs+491µs) by Type::Tiny::new at line 268 of Type/Tiny.pm, avg 138µs/call # once (35µs+175µs) by Type::Coercion::_build_compiled_coercion at line 265 of Type/Coercion.pm
sub eval_closure {
181131165µs my ( %args ) = @_;
182 my $src =
183 ref $args{source} eq "ARRAY"
184 ? join( "\n", @{ $args{source} } )
185131111µs : $args{source};
186
18713188µs $args{alias} = 0 unless defined $args{alias};
18813156µs $args{line} = 1 unless defined $args{line};
189 $args{description} =~ s/[^\w .:-\[\]\(\)\{\}\']//g
190131600µs131291µs if defined $args{description};
# spent 291µs making 131 calls to Eval::TypeTiny::CORE:subst, avg 2µs/call
191 $src = qq{#line $args{line} "$args{description}"\n$src}
192131151µs if defined $args{description} && !( $^P & 0x10 );
19313196µs $args{environment} ||= {};
194
195 if ( _EXTENDED_TESTING ) {
196 require Scalar::Util;
197 for my $k ( sort keys %{ $args{environment} } ) {
198 next
199 if $k =~ /^\$/
200 && Scalar::Util::reftype( $args{environment}{$k} ) =~ /^(SCALAR|REF)$/;
201 next
202 if $k =~ /^\@/
203 && Scalar::Util::reftype( $args{environment}{$k} ) eq q(ARRAY);
204 next
205 if $k =~ /^\%/
206 && Scalar::Util::reftype( $args{environment}{$k} ) eq q(HASH);
207 next
208 if $k =~ /^\&/
209 && Scalar::Util::reftype( $args{environment}{$k} ) eq q(CODE);
210
211 require Error::TypeTiny;
212 Error::TypeTiny::croak(
213 "Expected a variable name and ref; got %s => %s", $k,
214 $args{environment}{$k}
215 );
216 } #/ for my $k ( sort keys %...)
217 } #/ if ( _EXTENDED_TESTING)
218
21913152µs my $sandpkg = 'Eval::TypeTiny::Sandbox';
22013152µs my $alias = exists( $args{alias} ) ? $args{alias} : 0;
221131614µs13175µs my @keys = sort keys %{ $args{environment} };
# spent 75µs making 131 calls to Eval::TypeTiny::CORE:sort, avg 573ns/call
22213119µs my $i = 0;
223131288µs40292µs my $source = join "\n" => (
# spent 292µs making 40 calls to Eval::TypeTiny::_make_lexical_assignment, avg 7µs/call
224 "package $sandpkg;",
225 "sub {",
226 map( _make_lexical_assignment( $_, $i++, $alias ), @keys ),
227 $src,
228 "}",
229 );
230
23113122µs if ( $alias and ALIAS_IMPLEMENTATION eq IMPLEMENTATION_TIE ) {
232 _manufacture_ties();
233 }
234
235131277µs13119.0ms my ( $compiler, $e ) = _clean_eval( $source );
# spent 19.0ms making 131 calls to Eval::TypeTiny::_clean_eval, avg 145µs/call
23613130µs if ( $e ) {
237 chomp $e;
238 require Error::TypeTiny::Compilation;
239 "Error::TypeTiny::Compilation"->throw(
240 code => (
241 ref $args{source} eq "ARRAY" ? join( "\n", @{ $args{source} } ) : $args{source}
242 ),
243 errstr => $e,
244 environment => $args{environment},
245 );
246 } #/ if ( $e )
247
248131343µs131361µs my $code = $compiler->( @{ $args{environment} }{@keys} );
# spent 73µs making 20 calls to Eval::TypeTiny::Sandbox::__ANON__[(eval 103)[Eval/TypeTiny.pm:8]:15], avg 4µs/call # spent 47µs making 20 calls to Eval::TypeTiny::Sandbox::__ANON__[(eval 100)[Eval/TypeTiny.pm:8]:5], avg 2µs/call # spent 35µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 361)[Eval/TypeTiny.pm:8]:4] # spent 29µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 124)[Eval/TypeTiny.pm:8]:4] # spent 7µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 420)[Eval/TypeTiny.pm:8]:4] # spent 7µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 53)[Eval/TypeTiny.pm:8]:4] # spent 6µs making 2 calls to Eval::TypeTiny::Sandbox::__ANON__[(eval 271)[Eval/TypeTiny.pm:8]:4], avg 3µs/call # spent 5µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 274)[Eval/TypeTiny.pm:8]:4] # spent 5µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 64)[Eval/TypeTiny.pm:8]:4] # spent 4µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 101)[Eval/TypeTiny.pm:8]:4] # spent 4µs making 2 calls to Eval::TypeTiny::Sandbox::__ANON__[(eval 270)[Eval/TypeTiny.pm:8]:4], avg 2µs/call # spent 4µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 320)[Eval/TypeTiny.pm:8]:4] # spent 4µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 322)[Eval/TypeTiny.pm:8]:4] # spent 4µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 57)[Eval/TypeTiny.pm:8]:4] # spent 3µs making 2 calls to Eval::TypeTiny::Sandbox::__ANON__[(eval 107)[Eval/TypeTiny.pm:8]:4], avg 2µs/call # spent 3µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 135)[Eval/TypeTiny.pm:8]:4] # spent 3µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 136)[Eval/TypeTiny.pm:8]:4] # spent 3µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 143)[Eval/TypeTiny.pm:8]:4] # spent 3µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 147)[Eval/TypeTiny.pm:8]:4] # spent 3µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 275)[Eval/TypeTiny.pm:8]:4] # spent 3µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 278)[Eval/TypeTiny.pm:8]:4] # spent 3µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 309)[Eval/TypeTiny.pm:8]:4] # spent 3µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 356)[Eval/TypeTiny.pm:8]:4] # spent 3µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 363)[Eval/TypeTiny.pm:8]:4] # spent 3µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 80)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 102)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 110)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 111)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 114)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 116)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 118)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 122)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 126)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 128)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 130)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 131)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 133)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 139)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 151)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 214)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 216)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 238)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 248)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 262)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 319)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 321)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 332)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 335)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 351)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 400)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 50)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 51)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 55)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 61)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 63)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 66)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 69)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 75)[Eval/TypeTiny.pm:8]:9] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 76)[Eval/TypeTiny.pm:8]:9] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 84)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 89)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 90)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 92)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 93)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 95)[Eval/TypeTiny.pm:8]:4] # spent 2µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 96)[Eval/TypeTiny.pm:8]:4] # spent 1µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 104)[Eval/TypeTiny.pm:8]:4] # spent 1µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 120)[Eval/TypeTiny.pm:8]:4] # spent 1µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 138)[Eval/TypeTiny.pm:8]:4] # spent 1µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 145)[Eval/TypeTiny.pm:8]:4] # spent 1µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 267)[Eval/TypeTiny.pm:8]:4] # spent 1µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 56)[Eval/TypeTiny.pm:8]:4] # spent 1µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 58)[Eval/TypeTiny.pm:8]:4] # spent 1µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 72)[Eval/TypeTiny.pm:8]:4] # spent 1µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 73)[Eval/TypeTiny.pm:8]:4] # spent 1µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 83)[Eval/TypeTiny.pm:8]:4] # spent 1µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 86)[Eval/TypeTiny.pm:8]:4] # spent 1µs making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 99)[Eval/TypeTiny.pm:8]:4] # spent 0s making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 105)[Eval/TypeTiny.pm:8]:4] # spent 0s making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 108)[Eval/TypeTiny.pm:8]:4] # spent 0s making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 113)[Eval/TypeTiny.pm:8]:4] # spent 0s making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 141)[Eval/TypeTiny.pm:8]:4] # spent 0s making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 211)[Eval/TypeTiny.pm:8]:4] # spent 0s making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 252)[Eval/TypeTiny.pm:8]:4] # spent 0s making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 60)[Eval/TypeTiny.pm:8]:4] # spent 0s making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 67)[Eval/TypeTiny.pm:8]:4] # spent 0s making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 70)[Eval/TypeTiny.pm:8]:4] # spent 0s making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 78)[Eval/TypeTiny.pm:8]:4] # spent 0s making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 81)[Eval/TypeTiny.pm:8]:4] # spent 0s making 1 call to Eval::TypeTiny::Sandbox::__ANON__[(eval 87)[Eval/TypeTiny.pm:8]:4]
24913141µs undef( $compiler );
250
25113124µs if ( $alias and ALIAS_IMPLEMENTATION eq IMPLEMENTATION_DEVEL_LEXALIAS ) {
252 require Devel::LexAlias;
253 Devel::LexAlias::lexalias( $code, $_ => $args{environment}{$_} )
254 for grep !/^\&/, @keys;
255 }
256
25713125µs if ( $alias and ALIAS_IMPLEMENTATION eq IMPLEMENTATION_PADWALKER ) {
258 require PadWalker;
259 my %env = map +( $_ => $args{environment}{$_} ), grep !/^\&/, @keys;
260 PadWalker::set_closed_over( $code, \%env );
261 }
262
263131539µs return $code;
264} #/ sub eval_closure
265
26610smy $tmp;
267
268
# spent 292µs (273+19) within Eval::TypeTiny::_make_lexical_assignment which was called 40 times, avg 7µs/call: # 40 times (273µs+19µs) by Eval::TypeTiny::eval_closure at line 223, avg 7µs/call
sub _make_lexical_assignment {
2694015µs my ( $key, $index, $alias ) = @_;
2704056µs my $name = substr( $key, 1 );
271
2724091µs4019µs if ( HAS_LEXICAL_SUBS and $key =~ /^\&/ ) {
# spent 19µs making 40 calls to Eval::TypeTiny::CORE:match, avg 475ns/call
273 $tmp++;
274 my $tmpname = '$__LEXICAL_SUB__' . $tmp;
275 return
276 "no warnings 'experimental::lexical_subs';"
277 . "use feature 'lexical_subs';"
278 . "my $tmpname = \$_[$index];"
279 . "my sub $name { goto $tmpname };";
280 }
281
2824012µs if ( !$alias ) {
2834024µs my $sigil = substr( $key, 0, 1 );
28440108µs return "my $key = $sigil\{ \$_[$index] };";
285 }
286 elsif ( ALIAS_IMPLEMENTATION eq IMPLEMENTATION_NATIVE ) {
287 return
288 "no warnings 'experimental::refaliasing';"
289 . "use feature 'refaliasing';"
290 . "my $key; \\$key = \$_[$index];";
291 }
292 elsif ( ALIAS_IMPLEMENTATION eq IMPLEMENTATION_DEVEL_LEXALIAS ) {
293 return "my $key;";
294 }
295 elsif ( ALIAS_IMPLEMENTATION eq IMPLEMENTATION_PADWALKER ) {
296 return "my $key;";
297 }
298 else {
299 my $tieclass = {
300 '@' => 'Eval::TypeTiny::_TieArray',
301 '%' => 'Eval::TypeTiny::_TieHash',
302 '$' => 'Eval::TypeTiny::_TieScalar',
303 }->{ substr( $key, 0, 1 ) };
304
305 return sprintf(
306 'tie(my(%s), "%s", $_[%d]);',
307 $key,
308 $tieclass,
309 $index,
310 );
311 } #/ else [ if ( !$alias ) ]
312} #/ sub _make_lexical_assignment
313
314{
31510s my $tie;
316
317 sub _manufacture_ties {
318 $tie ||= eval <<'FALLBACK'; } }
319no warnings qw(void once uninitialized numeric);
320use Type::Tiny ();
321
322{
323 package #
324 Eval::TypeTiny::_TieArray;
325 require Tie::Array;
326 our @ISA = qw( Tie::StdArray );
327 sub TIEARRAY {
328 my $class = shift;
329 bless $_[0] => $class;
330 }
331 sub AUTOLOAD {
332 my $self = shift;
333 my ($method) = (our $AUTOLOAD =~ /(\w+)$/);
334 defined tied(@$self) and return tied(@$self)->$method(@_);
335 require Carp;
336 Carp::croak(qq[Can't call method "$method" on an undefined value]) unless $method eq 'DESTROY';
337 }
338 sub can {
339 my $self = shift;
340 my $code = $self->SUPER::can(@_)
341 || (defined tied(@$self) and tied(@$self)->can(@_));
342 return $code;
343 }
344 __PACKAGE__->Type::Tiny::_install_overloads(
345 q[bool] => sub { !! tied @{$_[0]} },
346 q[""] => sub { '' . tied @{$_[0]} },
347 q[0+] => sub { 0 + tied @{$_[0]} },
348 );
349}
350{
351 package #
352 Eval::TypeTiny::_TieHash;
353 require Tie::Hash;
354 our @ISA = qw( Tie::StdHash );
355 sub TIEHASH {
356 my $class = shift;
357 bless $_[0] => $class;
358 }
359 sub AUTOLOAD {
360 my $self = shift;
361 my ($method) = (our $AUTOLOAD =~ /(\w+)$/);
362 defined tied(%$self) and return tied(%$self)->$method(@_);
363 require Carp;
364 Carp::croak(qq[Can't call method "$method" on an undefined value]) unless $method eq 'DESTROY';
365 }
366 sub can {
367 my $self = shift;
368 my $code = $self->SUPER::can(@_)
369 || (defined tied(%$self) and tied(%$self)->can(@_));
370 return $code;
371 }
372 __PACKAGE__->Type::Tiny::_install_overloads(
373 q[bool] => sub { !! tied %{$_[0]} },
374 q[""] => sub { '' . tied %{$_[0]} },
375 q[0+] => sub { 0 + tied %{$_[0]} },
376 );
377}
378{
379 package #
380 Eval::TypeTiny::_TieScalar;
381 require Tie::Scalar;
382 our @ISA = qw( Tie::StdScalar );
383 sub TIESCALAR {
384 my $class = shift;
385 bless $_[0] => $class;
386 }
387 sub AUTOLOAD {
388 my $self = shift;
389 my ($method) = (our $AUTOLOAD =~ /(\w+)$/);
390 defined tied($$self) and return tied($$self)->$method(@_);
391 require Carp;
392 Carp::croak(qq[Can't call method "$method" on an undefined value]) unless $method eq 'DESTROY';
393 }
394 sub can {
395 my $self = shift;
396 my $code = $self->SUPER::can(@_)
397 || (defined tied($$self) and tied($$self)->can(@_));
398 return $code;
399 }
400 __PACKAGE__->Type::Tiny::_install_overloads(
401 q[bool] => sub { !! tied ${$_[0]} },
402 q[""] => sub { '' . tied ${$_[0]} },
403 q[0+] => sub { 0 + tied ${$_[0]} },
404 );
405}
406
4071;
408FALLBACK
409
41026µs1;
411
412__END__
 
# spent 19µs within Eval::TypeTiny::CORE:match which was called 40 times, avg 475ns/call: # 40 times (19µs+0s) by Eval::TypeTiny::_make_lexical_assignment at line 272, avg 475ns/call
sub Eval::TypeTiny::CORE:match; # opcode
# spent 75µs within Eval::TypeTiny::CORE:sort which was called 131 times, avg 573ns/call: # 131 times (75µs+0s) by Eval::TypeTiny::eval_closure at line 221, avg 573ns/call
sub Eval::TypeTiny::CORE:sort; # opcode
# spent 291µs within Eval::TypeTiny::CORE:subst which was called 131 times, avg 2µs/call: # 131 times (291µs+0s) by Eval::TypeTiny::eval_closure at line 190, avg 2µs/call
sub Eval::TypeTiny::CORE:subst; # opcode