Filename | /opt/perl-5.18.1/lib/site_perl/5.18.1/Type/Library.pm |
Statements | Executed 4001690 statements in 9.68s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1000036 | 3 | 3 | 4.09s | 8.39s | get_type | Type::Library::
1000158 | 8 | 2 | 3.90s | 4.30s | meta | Type::Library::
35 | 35 | 1 | 8.73ms | 33.2ms | add_type | Type::Library::
1 | 1 | 1 | 8.29ms | 11.6ms | BEGIN@14 | Type::Library::
143 | 4 | 1 | 4.35ms | 4.35ms | _subname | Type::Library::
3 | 3 | 1 | 3.79ms | 5.84ms | add_coercion | Type::Library::
1 | 1 | 1 | 1.31ms | 3.54ms | BEGIN@12 | Type::Library::
38 | 2 | 1 | 928µs | 15.2ms | _mksub | Type::Library::
35 | 1 | 1 | 445µs | 1.48ms | _exporter_expand_sub | Type::Library::
3 | 1 | 1 | 184µs | 184µs | CORE:regcomp (opcode) | Type::Library::
38 | 2 | 1 | 164µs | 315µs | has_type | Type::Library::
38 | 2 | 1 | 142µs | 257µs | has_coercion | Type::Library::
3 | 1 | 1 | 102µs | 457µs | _exporter_permitted_regexp | Type::Library::
2 | 1 | 1 | 42µs | 71µs | _exporter_expand_tag | Type::Library::
4 | 2 | 1 | 32µs | 60µs | type_names | Type::Library::
3 | 1 | 1 | 31µs | 34µs | _exporter_validate_opts | Type::Library::
70 | 2 | 1 | 30µs | 30µs | CORE:match (opcode) | Type::Library::
6 | 2 | 1 | 30µs | 30µs | CORE:sort (opcode) | Type::Library::
1 | 1 | 1 | 20µs | 20µs | BEGIN@3 | Type::Library::
1 | 1 | 1 | 18µs | 248µs | BEGIN@15 | Type::Library::
3 | 1 | 1 | 15µs | 27µs | coercion_names | Type::Library::
1 | 1 | 1 | 15µs | 27µs | BEGIN@208 | Type::Library::
1 | 1 | 1 | 10µs | 42µs | BEGIN@13 | Type::Library::
1 | 1 | 1 | 10µs | 22µs | BEGIN@281 | Type::Library::
1 | 1 | 1 | 10µs | 24µs | BEGIN@207 | Type::Library::
1 | 1 | 1 | 9µs | 22µs | BEGIN@232 | Type::Library::
1 | 1 | 1 | 9µs | 14µs | BEGIN@5 | Type::Library::
1 | 1 | 1 | 9µs | 22µs | BEGIN@58 | Type::Library::
1 | 1 | 1 | 9µs | 23µs | BEGIN@280 | Type::Library::
1 | 1 | 1 | 9µs | 23µs | BEGIN@38 | Type::Library::
1 | 1 | 1 | 9µs | 22µs | BEGIN@231 | Type::Library::
1 | 1 | 1 | 9µs | 24µs | BEGIN@4 | Type::Library::
1 | 1 | 1 | 6µs | 6µs | BEGIN@20 | Type::Library::
3 | 1 | 1 | 5µs | 5µs | CORE:qr (opcode) | Type::Library::
1 | 1 | 1 | 4µs | 4µs | BEGIN@7 | Type::Library::
0 | 0 | 0 | 0s | 0s | __ANON__[:191] | Type::Library::
0 | 0 | 0 | 0s | 0s | __ANON__[:197] | Type::Library::
0 | 0 | 0 | 0s | 0s | __ANON__[:243] | Type::Library::
0 | 0 | 0 | 0s | 0s | _croak | Type::Library::
0 | 0 | 0 | 0s | 0s | _exporter_fail | Type::Library::
0 | 0 | 0 | 0s | 0s | get_coercion | Type::Library::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Type::Library; | ||||
2 | |||||
3 | 2 | 65µs | 1 | 20µs | # spent 20µs within Type::Library::BEGIN@3 which was called:
# once (20µs+0s) by Types::Standard::BEGIN@18 at line 3 # spent 20µs making 1 call to Type::Library::BEGIN@3 |
4 | 2 | 29µs | 2 | 39µs | # spent 24µs (9+15) within Type::Library::BEGIN@4 which was called:
# once (9µs+15µs) by Types::Standard::BEGIN@18 at line 4 # spent 24µs making 1 call to Type::Library::BEGIN@4
# spent 15µs making 1 call to strict::import |
5 | 2 | 50µs | 2 | 19µs | # spent 14µs (9+5) within Type::Library::BEGIN@5 which was called:
# once (9µs+5µs) by Types::Standard::BEGIN@18 at line 5 # spent 14µs making 1 call to Type::Library::BEGIN@5
# spent 5µs making 1 call to warnings::import |
6 | |||||
7 | # spent 4µs within Type::Library::BEGIN@7 which was called:
# once (4µs+0s) by Types::Standard::BEGIN@18 at line 10 | ||||
8 | 1 | 500ns | $Type::Library::AUTHORITY = 'cpan:TOBYINK'; | ||
9 | 1 | 5µs | $Type::Library::VERSION = '0.038'; | ||
10 | 1 | 26µs | 1 | 4µs | } # spent 4µs making 1 call to Type::Library::BEGIN@7 |
11 | |||||
12 | 2 | 145µs | 2 | 5.68ms | # spent 3.54ms (1.31+2.23) within Type::Library::BEGIN@12 which was called:
# once (1.31ms+2.23ms) by Types::Standard::BEGIN@18 at line 12 # spent 3.54ms making 1 call to Type::Library::BEGIN@12
# spent 2.15ms making 1 call to Eval::TypeTiny::import |
13 | 2 | 32µs | 2 | 73µs | # spent 42µs (10+32) within Type::Library::BEGIN@13 which was called:
# once (10µs+32µs) by Types::Standard::BEGIN@18 at line 13 # spent 42µs making 1 call to Type::Library::BEGIN@13
# spent 32µs making 1 call to Exporter::import |
14 | 2 | 137µs | 1 | 11.6ms | # spent 11.6ms (8.29+3.36) within Type::Library::BEGIN@14 which was called:
# once (8.29ms+3.36ms) by Types::Standard::BEGIN@18 at line 14 # spent 11.6ms making 1 call to Type::Library::BEGIN@14 |
15 | 2 | 97µs | 2 | 478µs | # spent 248µs (18+230) within Type::Library::BEGIN@15 which was called:
# once (18µs+230µs) by Types::Standard::BEGIN@18 at line 15 # spent 248µs making 1 call to Type::Library::BEGIN@15
# spent 230µs making 1 call to Types::TypeTiny::import |
16 | |||||
17 | 1 | 600ns | require Exporter::Tiny; | ||
18 | 1 | 9µs | our @ISA = 'Exporter::Tiny'; | ||
19 | |||||
20 | 1 | 123µs | 1 | 6µs | # spent 6µs within Type::Library::BEGIN@20 which was called:
# once (6µs+0s) by Types::Standard::BEGIN@18 at line 20 # spent 6µs making 1 call to Type::Library::BEGIN@20 |
21 | |||||
22 | sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak } | ||||
23 | |||||
24 | { | ||||
25 | 2 | 600ns | my $got_subname; | ||
26 | sub _subname ($$) | ||||
27 | # spent 4.35ms within Type::Library::_subname which was called 143 times, avg 30µs/call:
# 38 times (1.32ms+0s) by Type::Library::_mksub at line 100, avg 35µs/call
# 35 times (1.06ms+0s) by Type::Library::add_type at line 242, avg 30µs/call
# 35 times (993µs+0s) by Type::Library::add_type at line 243, avg 28µs/call
# 35 times (976µs+0s) by Type::Library::add_type at line 244, avg 28µs/call | ||||
28 | 143 | 5.33ms | 143 | 100µs | $got_subname = 1 && goto \&Sub::Name::subname # spent 100µs making 143 calls to Sub::Name::subname, avg 701ns/call # spent 426µs executing statements in 143 string evals (merged) |
29 | if $got_subname || eval "require Sub::Name"; | ||||
30 | return $_[1]; | ||||
31 | } | ||||
32 | } | ||||
33 | |||||
34 | sub _exporter_validate_opts | ||||
35 | # spent 34µs (31+3) within Type::Library::_exporter_validate_opts which was called 3 times, avg 11µs/call:
# 3 times (31µs+3µs) by Exporter::Tiny::import at line 33 of Exporter/Tiny.pm, avg 11µs/call | ||||
36 | 3 | 900ns | my $class = shift; | ||
37 | |||||
38 | 2 | 204µs | 2 | 37µs | # spent 23µs (9+14) within Type::Library::BEGIN@38 which was called:
# once (9µs+14µs) by Types::Standard::BEGIN@18 at line 38 # spent 23µs making 1 call to Type::Library::BEGIN@38
# spent 14µs making 1 call to strict::unimport |
39 | 3 | 2µs | my $into = $_[0]{into}; | ||
40 | 3 | 9µs | push @{"$into\::ISA"}, $class if $_[0]{base}; | ||
41 | |||||
42 | 3 | 15µs | 3 | 3µs | return $class->SUPER::_exporter_validate_opts(@_); # spent 3µs making 3 calls to Exporter::Tiny::_exporter_validate_opts, avg 1µs/call |
43 | } | ||||
44 | |||||
45 | sub _exporter_expand_tag | ||||
46 | # spent 71µs (42+29) within Type::Library::_exporter_expand_tag which was called 2 times, avg 35µs/call:
# 2 times (42µs+29µs) by Exporter::Tiny::import at line 28 of Exporter/Tiny.pm, avg 35µs/call | ||||
47 | 2 | 800ns | my $class = shift; | ||
48 | 2 | 4µs | my ($name, $value, $globals) = @_; | ||
49 | |||||
50 | 2 | 24µs | 1 | 20µs | $name eq 'types' and return map [ "$_" => $value ], $class->type_names; # spent 20µs making 1 call to Type::Library::type_names |
51 | 1 | 100ns | $name eq 'is' and return map [ "is_$_" => $value ], $class->type_names; | ||
52 | 1 | 200ns | $name eq 'assert' and return map [ "assert_$_" => $value ], $class->type_names; | ||
53 | 1 | 100ns | $name eq 'to' and return map [ "to_$_" => $value ], $class->type_names; | ||
54 | 1 | 100ns | $name eq 'coercions' and return map [ "$_" => $value ], $class->coercion_names; | ||
55 | |||||
56 | 1 | 200ns | if ($name eq 'all') | ||
57 | { | ||||
58 | 2 | 807µs | 2 | 35µs | # spent 22µs (9+13) within Type::Library::BEGIN@58 which was called:
# once (9µs+13µs) by Types::Standard::BEGIN@18 at line 58 # spent 22µs making 1 call to Type::Library::BEGIN@58
# spent 13µs making 1 call to strict::unimport |
59 | return ( | ||||
60 | map( | ||||
61 | [ "+$_" => $value ], | ||||
62 | $class->type_names, | ||||
63 | ), | ||||
64 | map( | ||||
65 | [ $_ => $value ], | ||||
66 | $class->coercion_names, | ||||
67 | @{"$class\::EXPORT"}, | ||||
68 | @{"$class\::EXPORT_OK"}, | ||||
69 | ), | ||||
70 | ); | ||||
71 | } | ||||
72 | |||||
73 | 1 | 7µs | 1 | 9µs | return $class->SUPER::_exporter_expand_tag(@_); # spent 9µs making 1 call to Exporter::Tiny::_exporter_expand_tag |
74 | } | ||||
75 | |||||
76 | sub _mksub | ||||
77 | { | ||||
78 | 38 | 8µs | my $class = shift; | ||
79 | 38 | 17µs | my ($type, $post_method) = @_; | ||
80 | 38 | 8µs | $post_method ||= q(); | ||
81 | |||||
82 | 38 | 127µs | 38 | 172µs | my $source = $type->is_parameterizable # spent 157µs making 35 calls to Type::Tiny::is_parameterizable, avg 4µs/call
# spent 15µs making 3 calls to Type::Coercion::is_parameterizable, avg 5µs/call |
83 | ? sprintf( | ||||
84 | q{ | ||||
85 | sub (%s) { | ||||
86 | my $params; $params = shift if ref($_[0]) eq q(ARRAY); | ||||
87 | my $t = $params ? $type->parameterize(@$params) : $type; | ||||
88 | @_ && wantarray ? return($t%s, @_) : return $t%s; | ||||
89 | } | ||||
90 | }, | ||||
91 | NICE_PROTOTYPES ? q(;$) : q(;@), | ||||
92 | $post_method, | ||||
93 | $post_method, | ||||
94 | ) | ||||
95 | : sprintf( | ||||
96 | q{ sub () { $type%s if $] } }, | ||||
97 | $post_method, | ||||
98 | ); | ||||
99 | |||||
100 | 38 | 282µs | 152 | 14.1ms | return _subname( # spent 11.9ms making 38 calls to Eval::TypeTiny::eval_closure, avg 314µs/call
# spent 1.32ms making 38 calls to Type::Library::_subname, avg 35µs/call
# spent 529µs making 35 calls to Type::Tiny::__ANON__[Type/Tiny.pm:31], avg 15µs/call
# spent 207µs making 35 calls to Type::Tiny::qualified_name, avg 6µs/call
# spent 54µs making 3 calls to Type::Coercion::__ANON__[Type/Coercion.pm:19], avg 18µs/call
# spent 28µs making 3 calls to Type::Coercion::qualified_name, avg 9µs/call |
101 | $type->qualified_name, | ||||
102 | eval_closure( | ||||
103 | source => $source, | ||||
104 | description => sprintf("exportable function '%s'", $type), | ||||
105 | environment => {'$type' => \$type}, | ||||
106 | ), | ||||
107 | ); | ||||
108 | } | ||||
109 | |||||
110 | sub _exporter_permitted_regexp | ||||
111 | # spent 457µs (102+355) within Type::Library::_exporter_permitted_regexp which was called 3 times, avg 152µs/call:
# 3 times (102µs+355µs) by Exporter::Tiny::import at line 34 of Exporter/Tiny.pm, avg 152µs/call | ||||
112 | 3 | 800ns | my $class = shift; | ||
113 | |||||
114 | 3 | 8µs | 3 | 67µs | my $inherited = $class->SUPER::_exporter_permitted_regexp(@_); # spent 67µs making 3 calls to Exporter::Tiny::_exporter_permitted_regexp, avg 22µs/call |
115 | my $types = join "|", map quotemeta, sort { | ||||
116 | 3 | 60µs | 6 | 68µs | length($b) <=> length($a) or $a cmp $b # spent 40µs making 3 calls to Type::Library::type_names, avg 13µs/call
# spent 28µs making 3 calls to Type::Library::CORE:sort, avg 9µs/call |
117 | } $class->type_names; | ||||
118 | my $coercions = join "|", map quotemeta, sort { | ||||
119 | 3 | 20µs | 6 | 30µs | length($b) <=> length($a) or $a cmp $b # spent 27µs making 3 calls to Type::Library::coercion_names, avg 9µs/call
# spent 3µs making 3 calls to Type::Library::CORE:sort, avg 900ns/call |
120 | } $class->coercion_names; | ||||
121 | |||||
122 | 3 | 222µs | 6 | 190µs | qr{^(?: # spent 184µs making 3 calls to Type::Library::CORE:regcomp, avg 61µs/call
# spent 5µs making 3 calls to Type::Library::CORE:qr, avg 2µs/call |
123 | $inherited | ||||
124 | | (?: (?:is_|to_|assert_)? (?:$types) ) | ||||
125 | | (?:$coercions) | ||||
126 | )$}xms; | ||||
127 | } | ||||
128 | |||||
129 | sub _exporter_expand_sub | ||||
130 | # spent 1.48ms (445µs+1.03) within Type::Library::_exporter_expand_sub which was called 35 times, avg 42µs/call:
# 35 times (445µs+1.03ms) by Exporter::Tiny::import at line 38 of Exporter/Tiny.pm, avg 42µs/call | ||||
131 | 35 | 8µs | my $class = shift; | ||
132 | 35 | 11µs | my ($name, $value, $globals) = @_; | ||
133 | |||||
134 | 35 | 76µs | 35 | 14µs | if ($name =~ /^\+(.+)/ and $class->has_type($1)) # spent 14µs making 35 calls to Type::Library::CORE:match, avg 403ns/call |
135 | { | ||||
136 | my $type = $1; | ||||
137 | my $value2 = +{%{$value||{}}}; | ||||
138 | |||||
139 | return map $class->_exporter_expand_sub($_, $value2, $globals), | ||||
140 | $type, "is_$type", "assert_$type", "to_$type"; | ||||
141 | } | ||||
142 | |||||
143 | 35 | 98µs | 70 | 323µs | if (my $type = $class->get_type($name)) # spent 283µs making 35 calls to Type::Library::get_type, avg 8µs/call
# spent 40µs making 35 calls to Type::Tiny::__ANON__[Type/Tiny.pm:32], avg 1µs/call |
144 | { | ||||
145 | 35 | 7µs | my $post_method = q(); | ||
146 | 35 | 11µs | $post_method = '->mouse_type' if $globals->{mouse}; | ||
147 | 35 | 4µs | $post_method = '->moose_type' if $globals->{moose}; | ||
148 | 35 | 7µs | return ($name => $class->_mksub($type, $post_method)) if $post_method; | ||
149 | } | ||||
150 | |||||
151 | 35 | 127µs | 35 | 695µs | return $class->SUPER::_exporter_expand_sub(@_); # spent 695µs making 35 calls to Exporter::Tiny::_exporter_expand_sub, avg 20µs/call |
152 | } | ||||
153 | |||||
154 | #sub _exporter_install_sub | ||||
155 | #{ | ||||
156 | # my $class = shift; | ||||
157 | # my ($name, $value, $globals, $sym) = @_; | ||||
158 | # | ||||
159 | # warn sprintf( | ||||
160 | # 'Exporter %s exporting %s with prototype %s', | ||||
161 | # $class, | ||||
162 | # $name, | ||||
163 | # prototype($sym), | ||||
164 | # ); | ||||
165 | # | ||||
166 | # $class->SUPER::_exporter_install_sub(@_); | ||||
167 | #} | ||||
168 | |||||
169 | sub _exporter_fail | ||||
170 | { | ||||
171 | my $class = shift; | ||||
172 | my ($name, $value, $globals) = @_; | ||||
173 | |||||
174 | my $into = $globals->{into} | ||||
175 | or _croak("Parameter 'into' not supplied"); | ||||
176 | |||||
177 | if ($globals->{declare}) | ||||
178 | { | ||||
179 | my $declared = sub (;$) | ||||
180 | { | ||||
181 | my $params; $params = shift if ref($_[0]) eq "ARRAY"; | ||||
182 | my $type = $into->get_type($name); | ||||
183 | unless ($type) | ||||
184 | { | ||||
185 | _croak "Cannot parameterize a non-existant type" if $params; | ||||
186 | $type = $name; | ||||
187 | } | ||||
188 | |||||
189 | my $t = $params ? $type->parameterize(@$params) : $type; | ||||
190 | @_ && wantarray ? return($t, @_) : return $t; | ||||
191 | }; | ||||
192 | |||||
193 | return( | ||||
194 | $name, | ||||
195 | _subname( | ||||
196 | "$class\::$name", | ||||
197 | NICE_PROTOTYPES ? sub (;$) { goto $declared } : sub (;@) { goto $declared }, | ||||
198 | ), | ||||
199 | ); | ||||
200 | } | ||||
201 | |||||
202 | return $class->SUPER::_exporter_fail(@_); | ||||
203 | } | ||||
204 | |||||
205 | sub meta | ||||
206 | # spent 4.30s (3.90+403ms) within Type::Library::meta which was called 1000158 times, avg 4µs/call:
# 1000036 times (3.90s+403ms) by Type::Library::get_type at line 251, avg 4µs/call
# 38 times (118µs+33µs) by Type::Library::has_type at line 257, avg 4µs/call
# 38 times (92µs+23µs) by Type::Library::has_coercion at line 297, avg 3µs/call
# 35 times (131µs+47µs) by Type::Library::add_type at line 215, avg 5µs/call
# 4 times (26µs+3µs) by Type::Library::type_names at line 263, avg 7µs/call
# 3 times (15µs+4µs) by Type::Library::add_coercion at line 270, avg 6µs/call
# 3 times (11µs+1µs) by Type::Library::coercion_names at line 303, avg 4µs/call
# once (11µs+900ns) by Typed::BEGIN@10 at line 39 of Types/Standard.pm | ||||
207 | 2 | 34µs | 2 | 38µs | # spent 24µs (10+14) within Type::Library::BEGIN@207 which was called:
# once (10µs+14µs) by Types::Standard::BEGIN@18 at line 207 # spent 24µs making 1 call to Type::Library::BEGIN@207
# spent 14µs making 1 call to strict::unimport |
208 | 2 | 246µs | 2 | 40µs | # spent 27µs (15+12) within Type::Library::BEGIN@208 which was called:
# once (15µs+12µs) by Types::Standard::BEGIN@18 at line 208 # spent 27µs making 1 call to Type::Library::BEGIN@208
# spent 12µs making 1 call to warnings::unimport |
209 | 1000158 | 2.64s | 1000158 | 403ms | return $_[0] if blessed $_[0]; # spent 403ms making 1000158 calls to Scalar::Util::blessed, avg 403ns/call |
210 | 1000043 | 3.12s | ${"$_[0]\::META"} ||= bless {}, $_[0]; | ||
211 | } | ||||
212 | |||||
213 | sub add_type | ||||
214 | # spent 33.2ms (8.73+24.5) within Type::Library::add_type which was called 35 times, avg 948µs/call:
# once (5.87ms+529µs) by Typed::BEGIN@10 at line 688 of Types/Standard.pm
# once (130µs+5.94ms) by Typed::BEGIN@10 at line 78 of Types/Standard.pm
# once (83µs+980µs) by Typed::BEGIN@10 at line 565 of Types/Standard.pm
# once (90µs+836µs) by Typed::BEGIN@10 at line 630 of Types/Standard.pm
# once (85µs+827µs) by Typed::BEGIN@10 at line 160 of Types/Standard.pm
# once (82µs+758µs) by Typed::BEGIN@10 at line 476 of Types/Standard.pm
# once (91µs+739µs) by Typed::BEGIN@10 at line 134 of Types/Standard.pm
# once (86µs+695µs) by Typed::BEGIN@10 at line 189 of Types/Standard.pm
# once (84µs+603µs) by Typed::BEGIN@10 at line 652 of Types/Standard.pm
# once (84µs+540µs) by Typed::BEGIN@10 at line 229 of Types/Standard.pm
# once (86µs+520µs) by Typed::BEGIN@10 at line 406 of Types/Standard.pm
# once (81µs+523µs) by Typed::BEGIN@10 at line 702 of Types/Standard.pm
# once (86µs+516µs) by Typed::BEGIN@10 at line 421 of Types/Standard.pm
# once (80µs+514µs) by Typed::BEGIN@10 at line 542 of Types/Standard.pm
# once (79µs+512µs) by Typed::BEGIN@10 at line 275 of Types/Standard.pm
# once (83µs+507µs) by Typed::BEGIN@10 at line 437 of Types/Standard.pm
# once (80µs+507µs) by Typed::BEGIN@10 at line 674 of Types/Standard.pm
# once (82µs+497µs) by Typed::BEGIN@10 at line 357 of Types/Standard.pm
# once (80µs+498µs) by Typed::BEGIN@10 at line 359 of Types/Standard.pm
# once (80µs+497µs) by Typed::BEGIN@10 at line 299 of Types/Standard.pm
# once (81µs+495µs) by Typed::BEGIN@10 at line 287 of Types/Standard.pm
# once (80µs+487µs) by Typed::BEGIN@10 at line 84 of Types/Standard.pm
# once (83µs+466µs) by Typed::BEGIN@10 at line 109 of Types/Standard.pm
# once (82µs+464µs) by Typed::BEGIN@10 at line 174 of Types/Standard.pm
# once (79µs+465µs) by Typed::BEGIN@10 at line 127 of Types/Standard.pm
# once (82µs+461µs) by Typed::BEGIN@10 at line 311 of Types/Standard.pm
# once (81µs+459µs) by Typed::BEGIN@10 at line 101 of Types/Standard.pm
# once (90µs+449µs) by Typed::BEGIN@10 at line 93 of Types/Standard.pm
# once (80µs+458µs) by Typed::BEGIN@10 at line 182 of Types/Standard.pm
# once (79µs+458µs) by Typed::BEGIN@10 at line 245 of Types/Standard.pm
# once (79µs+457µs) by Typed::BEGIN@10 at line 267 of Types/Standard.pm
# once (85µs+451µs) by Typed::BEGIN@10 at line 253 of Types/Standard.pm
# once (80µs+455µs) by Typed::BEGIN@10 at line 162 of Types/Standard.pm
# once (79µs+450µs) by Typed::BEGIN@10 at line 117 of Types/Standard.pm
# once (82µs+437µs) by Typed::BEGIN@10 at line 237 of Types/Standard.pm | ||||
215 | 35 | 46µs | 35 | 178µs | my $meta = shift->meta; # spent 178µs making 35 calls to Type::Library::meta, avg 5µs/call |
216 | 35 | 89µs | 35 | 22µs | my $class = blessed($meta); # spent 22µs making 35 calls to Scalar::Util::blessed, avg 643ns/call |
217 | |||||
218 | my $type = | ||||
219 | ref($_[0]) =~ /^Type::Tiny\b/ ? $_[0] : | ||||
220 | blessed($_[0]) ? to_TypeTiny($_[0]) : | ||||
221 | 35 | 289µs | 105 | 2.15ms | ref($_[0]) eq q(HASH) ? "Type::Tiny"->new(library => $class, %{$_[0]}) : # spent 2.12ms making 35 calls to Type::Tiny::new, avg 61µs/call
# spent 16µs making 35 calls to Type::Library::CORE:match, avg 469ns/call
# spent 14µs making 35 calls to Scalar::Util::blessed, avg 409ns/call |
222 | "Type::Tiny"->new(library => $class, @_); | ||||
223 | 35 | 14µs | my $name = $type->{name}; | ||
224 | |||||
225 | 35 | 171µs | $meta->{types} ||= {}; | ||
226 | 35 | 55µs | 35 | 295µs | _croak 'Type %s already exists in this library', $name if $meta->has_type($name); # spent 295µs making 35 calls to Type::Library::has_type, avg 8µs/call |
227 | 35 | 46µs | 35 | 233µs | _croak 'Type %s conflicts with coercion of same name', $name if $meta->has_coercion($name); # spent 233µs making 35 calls to Type::Library::has_coercion, avg 7µs/call |
228 | 35 | 47µs | 35 | 173µs | _croak 'Cannot add anonymous type to a library' if $type->is_anon; # spent 173µs making 35 calls to Type::Tiny::is_anon, avg 5µs/call |
229 | 35 | 32µs | $meta->{types}{$name} = $type; | ||
230 | |||||
231 | 2 | 35µs | 2 | 36µs | # spent 22µs (9+13) within Type::Library::BEGIN@231 which was called:
# once (9µs+13µs) by Types::Standard::BEGIN@18 at line 231 # spent 22µs making 1 call to Type::Library::BEGIN@231
# spent 13µs making 1 call to strict::unimport |
232 | 2 | 413µs | 2 | 35µs | # spent 22µs (9+13) within Type::Library::BEGIN@232 which was called:
# once (9µs+13µs) by Types::Standard::BEGIN@18 at line 232 # spent 22µs making 1 call to Type::Library::BEGIN@232
# spent 13µs making 1 call to warnings::unimport |
233 | |||||
234 | |||||
235 | # There is an inlined coercion available, but don't use that because | ||||
236 | # additional coercions can be added *after* the type has been installed | ||||
237 | # into the library. | ||||
238 | # | ||||
239 | # XXX: maybe we can use it if the coercion is frozen??? | ||||
240 | # | ||||
241 | 35 | 217µs | 35 | 14.4ms | *{"$class\::$name"} = $class->_mksub($type); # spent 14.4ms making 35 calls to Type::Library::_mksub, avg 411µs/call |
242 | 35 | 133µs | 105 | 4.13ms | *{"$class\::is_$name"} = _subname "is_" .$type->qualified_name, $type->compiled_check; # spent 2.80ms making 35 calls to Type::Tiny::compiled_check, avg 80µs/call
# spent 1.06ms making 35 calls to Type::Library::_subname, avg 30µs/call
# spent 275µs making 35 calls to Type::Tiny::qualified_name, avg 8µs/call |
243 | 35 | 181µs | 70 | 1.24ms | *{"$class\::to_$name"} = _subname "to_" .$type->qualified_name, sub ($) { $type->coerce($_[0]) }; # spent 993µs making 35 calls to Type::Library::_subname, avg 28µs/call
# spent 251µs making 35 calls to Type::Tiny::qualified_name, avg 7µs/call |
244 | 35 | 124µs | 105 | 1.56ms | *{"$class\::assert_$name"} = _subname "assert_".$type->qualified_name, $type->_overload_coderef; # spent 976µs making 35 calls to Type::Library::_subname, avg 28µs/call
# spent 344µs making 35 calls to Type::Tiny::_overload_coderef, avg 10µs/call
# spent 239µs making 35 calls to Type::Tiny::qualified_name, avg 7µs/call |
245 | |||||
246 | 35 | 184µs | return $type; | ||
247 | } | ||||
248 | |||||
249 | sub get_type | ||||
250 | # spent 8.39s (4.09+4.30) within Type::Library::get_type which was called 1000036 times, avg 8µs/call:
# 1000000 times (4.09s+4.30s) by Typed::__ANON__[/opt/perl-5.18.1/lib/site_perl/5.18.1/Typed.pm:134] at line 118 of Typed.pm, avg 8µs/call
# 35 times (133µs+150µs) by Type::Library::_exporter_expand_sub at line 143, avg 8µs/call
# once (11µs+5µs) by Typed::BEGIN@10 at line 704 of Types/Standard.pm | ||||
251 | 1000036 | 983ms | 1000036 | 4.30s | my $meta = shift->meta; # spent 4.30s making 1000036 calls to Type::Library::meta, avg 4µs/call |
252 | 1000036 | 2.92s | $meta->{types}{$_[0]}; | ||
253 | } | ||||
254 | |||||
255 | sub has_type | ||||
256 | { | ||||
257 | 38 | 46µs | 38 | 151µs | my $meta = shift->meta; # spent 151µs making 38 calls to Type::Library::meta, avg 4µs/call |
258 | 38 | 101µs | exists $meta->{types}{$_[0]}; | ||
259 | } | ||||
260 | |||||
261 | sub type_names | ||||
262 | { | ||||
263 | 4 | 5µs | 4 | 29µs | my $meta = shift->meta; # spent 29µs making 4 calls to Type::Library::meta, avg 7µs/call |
264 | 4 | 26µs | keys %{ $meta->{types} }; | ||
265 | } | ||||
266 | |||||
267 | sub add_coercion | ||||
268 | # spent 5.84ms (3.79+2.04) within Type::Library::add_coercion which was called 3 times, avg 1.95ms/call:
# once (3.73ms+1.38ms) by Typed::BEGIN@10 at line 704 of Types/Standard.pm
# once (34µs+334µs) by Typed::BEGIN@10 at line 738 of Types/Standard.pm
# once (33µs+330µs) by Typed::BEGIN@10 at line 725 of Types/Standard.pm | ||||
269 | 3 | 121µs | require Type::Coercion; | ||
270 | 3 | 6µs | 3 | 18µs | my $meta = shift->meta; # spent 18µs making 3 calls to Type::Library::meta, avg 6µs/call |
271 | 3 | 14µs | 6 | 951µs | my $c = blessed($_[0]) ? $_[0] : "Type::Coercion"->new(@_); # spent 950µs making 3 calls to Type::Coercion::new, avg 317µs/call
# spent 2µs making 3 calls to Scalar::Util::blessed, avg 533ns/call |
272 | 3 | 4µs | 3 | 4µs | my $name = $c->name; # spent 4µs making 3 calls to Type::Coercion::name, avg 1µs/call |
273 | |||||
274 | 3 | 11µs | $meta->{coercions} ||= {}; | ||
275 | 3 | 5µs | 3 | 24µs | _croak 'Coercion %s already exists in this library', $name if $meta->has_coercion($name); # spent 24µs making 3 calls to Type::Library::has_coercion, avg 8µs/call |
276 | 3 | 4µs | 3 | 20µs | _croak 'Coercion %s conflicts with type of same name', $name if $meta->has_type($name); # spent 20µs making 3 calls to Type::Library::has_type, avg 7µs/call |
277 | 3 | 4µs | 3 | 13µs | _croak 'Cannot add anonymous type to a library' if $c->is_anon; # spent 13µs making 3 calls to Type::Coercion::is_anon, avg 4µs/call |
278 | 3 | 3µs | $meta->{coercions}{$name} = $c; | ||
279 | |||||
280 | 2 | 40µs | 2 | 36µs | # spent 23µs (9+14) within Type::Library::BEGIN@280 which was called:
# once (9µs+14µs) by Types::Standard::BEGIN@18 at line 280 # spent 23µs making 1 call to Type::Library::BEGIN@280
# spent 14µs making 1 call to strict::unimport |
281 | 2 | 228µs | 2 | 35µs | # spent 22µs (10+12) within Type::Library::BEGIN@281 which was called:
# once (10µs+12µs) by Types::Standard::BEGIN@18 at line 281 # spent 22µs making 1 call to Type::Library::BEGIN@281
# spent 12µs making 1 call to warnings::unimport |
282 | |||||
283 | 3 | 10µs | 3 | 2µs | my $class = blessed($meta); # spent 2µs making 3 calls to Scalar::Util::blessed, avg 733ns/call |
284 | 3 | 19µs | 3 | 806µs | *{"$class\::$name"} = $class->_mksub($c); # spent 806µs making 3 calls to Type::Library::_mksub, avg 269µs/call |
285 | |||||
286 | 3 | 14µs | return $c; | ||
287 | } | ||||
288 | |||||
289 | sub get_coercion | ||||
290 | { | ||||
291 | my $meta = shift->meta; | ||||
292 | $meta->{coercions}{$_[0]}; | ||||
293 | } | ||||
294 | |||||
295 | sub has_coercion | ||||
296 | { | ||||
297 | 38 | 35µs | 38 | 115µs | my $meta = shift->meta; # spent 115µs making 38 calls to Type::Library::meta, avg 3µs/call |
298 | 38 | 87µs | exists $meta->{coercions}{$_[0]}; | ||
299 | } | ||||
300 | |||||
301 | sub coercion_names | ||||
302 | # spent 27µs (15+12) within Type::Library::coercion_names which was called 3 times, avg 9µs/call:
# 3 times (15µs+12µs) by Type::Library::_exporter_permitted_regexp at line 119, avg 9µs/call | ||||
303 | 3 | 3µs | 3 | 12µs | my $meta = shift->meta; # spent 12µs making 3 calls to Type::Library::meta, avg 4µs/call |
304 | 3 | 10µs | keys %{ $meta->{coercions} }; | ||
305 | } | ||||
306 | |||||
307 | 1 | 5µs | 1; | ||
308 | |||||
309 | __END__ | ||||
sub Type::Library::CORE:match; # opcode | |||||
# spent 5µs within Type::Library::CORE:qr which was called 3 times, avg 2µs/call:
# 3 times (5µs+0s) by Type::Library::_exporter_permitted_regexp at line 122, avg 2µs/call | |||||
# spent 184µs within Type::Library::CORE:regcomp which was called 3 times, avg 61µs/call:
# 3 times (184µs+0s) by Type::Library::_exporter_permitted_regexp at line 122, avg 61µs/call | |||||
sub Type::Library::CORE:sort; # opcode |