← Index
NYTProf Performance Profile   « line view »
For fastest.pl
  Run on Fri Jan 31 20:48:16 2014
Reported on Fri Jan 31 20:49:41 2014

Filename/opt/perl-5.18.1/lib/site_perl/5.18.1/Type/Library.pm
StatementsExecuted 4001690 statements in 9.68s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1000036334.09s8.39sType::Library::::get_typeType::Library::get_type
1000158823.90s4.30sType::Library::::metaType::Library::meta
353518.73ms33.2msType::Library::::add_typeType::Library::add_type
1118.29ms11.6msType::Library::::BEGIN@14Type::Library::BEGIN@14
143414.35ms4.35msType::Library::::_subnameType::Library::_subname
3313.79ms5.84msType::Library::::add_coercionType::Library::add_coercion
1111.31ms3.54msType::Library::::BEGIN@12Type::Library::BEGIN@12
3821928µs15.2msType::Library::::_mksubType::Library::_mksub
3511445µs1.48msType::Library::::_exporter_expand_subType::Library::_exporter_expand_sub
311184µs184µsType::Library::::CORE:regcompType::Library::CORE:regcomp (opcode)
3821164µs315µsType::Library::::has_typeType::Library::has_type
3821142µs257µsType::Library::::has_coercionType::Library::has_coercion
311102µs457µsType::Library::::_exporter_permitted_regexpType::Library::_exporter_permitted_regexp
21142µs71µsType::Library::::_exporter_expand_tagType::Library::_exporter_expand_tag
42132µs60µsType::Library::::type_namesType::Library::type_names
31131µs34µsType::Library::::_exporter_validate_optsType::Library::_exporter_validate_opts
702130µs30µsType::Library::::CORE:matchType::Library::CORE:match (opcode)
62130µs30µsType::Library::::CORE:sortType::Library::CORE:sort (opcode)
11120µs20µsType::Library::::BEGIN@3Type::Library::BEGIN@3
11118µs248µsType::Library::::BEGIN@15Type::Library::BEGIN@15
31115µs27µsType::Library::::coercion_namesType::Library::coercion_names
11115µs27µsType::Library::::BEGIN@208Type::Library::BEGIN@208
11110µs42µsType::Library::::BEGIN@13Type::Library::BEGIN@13
11110µs22µsType::Library::::BEGIN@281Type::Library::BEGIN@281
11110µs24µsType::Library::::BEGIN@207Type::Library::BEGIN@207
1119µs22µsType::Library::::BEGIN@232Type::Library::BEGIN@232
1119µs14µsType::Library::::BEGIN@5Type::Library::BEGIN@5
1119µs22µsType::Library::::BEGIN@58Type::Library::BEGIN@58
1119µs23µsType::Library::::BEGIN@280Type::Library::BEGIN@280
1119µs23µsType::Library::::BEGIN@38Type::Library::BEGIN@38
1119µs22µsType::Library::::BEGIN@231Type::Library::BEGIN@231
1119µs24µsType::Library::::BEGIN@4Type::Library::BEGIN@4
1116µs6µsType::Library::::BEGIN@20Type::Library::BEGIN@20
3115µs5µsType::Library::::CORE:qrType::Library::CORE:qr (opcode)
1114µs4µsType::Library::::BEGIN@7Type::Library::BEGIN@7
0000s0sType::Library::::__ANON__[:191]Type::Library::__ANON__[:191]
0000s0sType::Library::::__ANON__[:197]Type::Library::__ANON__[:197]
0000s0sType::Library::::__ANON__[:243]Type::Library::__ANON__[:243]
0000s0sType::Library::::_croakType::Library::_croak
0000s0sType::Library::::_exporter_failType::Library::_exporter_fail
0000s0sType::Library::::get_coercionType::Library::get_coercion
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Type::Library;
2
3265µs120µs
# spent 20µs within Type::Library::BEGIN@3 which was called: # once (20µs+0s) by Types::Standard::BEGIN@18 at line 3
use 5.006001;
# spent 20µs making 1 call to Type::Library::BEGIN@3
4229µs239µ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
use strict;
# spent 24µs making 1 call to Type::Library::BEGIN@4 # spent 15µs making 1 call to strict::import
5250µs219µ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
use warnings;
# 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
BEGIN {
81500ns $Type::Library::AUTHORITY = 'cpan:TOBYINK';
915µs $Type::Library::VERSION = '0.038';
10126µs14µs}
# spent 4µs making 1 call to Type::Library::BEGIN@7
11
122145µs25.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
use Eval::TypeTiny qw< eval_closure >;
# spent 3.54ms making 1 call to Type::Library::BEGIN@12 # spent 2.15ms making 1 call to Eval::TypeTiny::import
13232µs273µ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
use Scalar::Util qw< blessed >;
# spent 42µs making 1 call to Type::Library::BEGIN@13 # spent 32µs making 1 call to Exporter::import
142137µs111.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
use Type::Tiny;
# spent 11.6ms making 1 call to Type::Library::BEGIN@14
15297µs2478µ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
use Types::TypeTiny qw< TypeTiny to_TypeTiny >;
# spent 248µs making 1 call to Type::Library::BEGIN@15 # spent 230µs making 1 call to Types::TypeTiny::import
16
171600nsrequire Exporter::Tiny;
1819µsour @ISA = 'Exporter::Tiny';
19
201123µs16µs
# spent 6µs within Type::Library::BEGIN@20 which was called: # once (6µs+0s) by Types::Standard::BEGIN@18 at line 20
BEGIN { *NICE_PROTOTYPES = ($] >= 5.014) ? sub () { !!1 } : sub () { !!0 } };
# spent 6µs making 1 call to Type::Library::BEGIN@20
21
22sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak }
23
24{
252600ns 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
{
281435.33ms143100µ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
34sub _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
{
363900ns my $class = shift;
37
382204µs237µ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
no strict "refs";
# spent 23µs making 1 call to Type::Library::BEGIN@38 # spent 14µs making 1 call to strict::unimport
3932µs my $into = $_[0]{into};
4039µs push @{"$into\::ISA"}, $class if $_[0]{base};
41
42315µs33µ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
45sub _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
{
472800ns my $class = shift;
4824µs my ($name, $value, $globals) = @_;
49
50224µs120µs $name eq 'types' and return map [ "$_" => $value ], $class->type_names;
# spent 20µs making 1 call to Type::Library::type_names
511100ns $name eq 'is' and return map [ "is_$_" => $value ], $class->type_names;
521200ns $name eq 'assert' and return map [ "assert_$_" => $value ], $class->type_names;
531100ns $name eq 'to' and return map [ "to_$_" => $value ], $class->type_names;
541100ns $name eq 'coercions' and return map [ "$_" => $value ], $class->coercion_names;
55
561200ns if ($name eq 'all')
57 {
582807µs235µ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
no strict "refs";
# 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
7317µs19µs return $class->SUPER::_exporter_expand_tag(@_);
# spent 9µs making 1 call to Exporter::Tiny::_exporter_expand_tag
74}
75
76sub _mksub
77
# spent 15.2ms (928µs+14.3) within Type::Library::_mksub which was called 38 times, avg 400µs/call: # 35 times (853µs+13.5ms) by Type::Library::add_type at line 241, avg 411µs/call # 3 times (75µs+732µs) by Type::Library::add_coercion at line 284, avg 269µs/call
{
78388µs my $class = shift;
793817µs my ($type, $post_method) = @_;
80388µs $post_method ||= q();
81
8238127µs38172µ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
10038282µs15214.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
110sub _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
{
1123800ns my $class = shift;
113
11438µs367µ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 {
116360µs668µ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 {
119320µs630µ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
1223222µs6190µ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
129sub _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
{
131358µs my $class = shift;
1323511µs my ($name, $value, $globals) = @_;
133
1343576µs3514µ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
1433598µs70323µ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 {
145357µs my $post_method = q();
1463511µs $post_method = '->mouse_type' if $globals->{mouse};
147354µs $post_method = '->moose_type' if $globals->{moose};
148357µs return ($name => $class->_mksub($type, $post_method)) if $post_method;
149 }
150
15135127µs35695µ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
169sub _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
205sub 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
{
207234µs238µ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
no strict "refs";
# spent 24µs making 1 call to Type::Library::BEGIN@207 # spent 14µs making 1 call to strict::unimport
2082246µs240µ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
no warnings "once";
# spent 27µs making 1 call to Type::Library::BEGIN@208 # spent 12µs making 1 call to warnings::unimport
20910001582.64s1000158403ms return $_[0] if blessed $_[0];
# spent 403ms making 1000158 calls to Scalar::Util::blessed, avg 403ns/call
21010000433.12s ${"$_[0]\::META"} ||= bless {}, $_[0];
211}
212
213sub 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
{
2153546µs35178µs my $meta = shift->meta;
# spent 178µs making 35 calls to Type::Library::meta, avg 5µs/call
2163589µs3522µ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]) :
22135289µs1052.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, @_);
2233514µs my $name = $type->{name};
224
22535171µs $meta->{types} ||= {};
2263555µs35295µ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
2273546µs35233µ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
2283547µs35173µ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
2293532µs $meta->{types}{$name} = $type;
230
231235µs236µ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
no strict "refs";
# spent 22µs making 1 call to Type::Library::BEGIN@231 # spent 13µs making 1 call to strict::unimport
2322413µs235µ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
no warnings "redefine", "prototype";
# 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 #
24135217µs3514.4ms *{"$class\::$name"} = $class->_mksub($type);
# spent 14.4ms making 35 calls to Type::Library::_mksub, avg 411µs/call
24235133µs1054.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
24335181µs701.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
24435124µs1051.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
24635184µs return $type;
247}
248
249sub 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
{
2511000036983ms10000364.30s my $meta = shift->meta;
# spent 4.30s making 1000036 calls to Type::Library::meta, avg 4µs/call
25210000362.92s $meta->{types}{$_[0]};
253}
254
255sub has_type
256
# spent 315µs (164+151) within Type::Library::has_type which was called 38 times, avg 8µs/call: # 35 times (153µs+142µs) by Type::Library::add_type at line 226, avg 8µs/call # 3 times (11µs+9µs) by Type::Library::add_coercion at line 276, avg 7µs/call
{
2573846µs38151µs my $meta = shift->meta;
# spent 151µs making 38 calls to Type::Library::meta, avg 4µs/call
25838101µs exists $meta->{types}{$_[0]};
259}
260
261sub type_names
262
# spent 60µs (32+29) within Type::Library::type_names which was called 4 times, avg 15µs/call: # 3 times (22µs+19µs) by Type::Library::_exporter_permitted_regexp at line 116, avg 13µs/call # once (10µs+10µs) by Type::Library::_exporter_expand_tag at line 50
{
26345µs429µs my $meta = shift->meta;
# spent 29µs making 4 calls to Type::Library::meta, avg 7µs/call
264426µs keys %{ $meta->{types} };
265}
266
267sub 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
{
2693121µs require Type::Coercion;
27036µs318µs my $meta = shift->meta;
# spent 18µs making 3 calls to Type::Library::meta, avg 6µs/call
271314µs6951µ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
27234µs34µs my $name = $c->name;
# spent 4µs making 3 calls to Type::Coercion::name, avg 1µs/call
273
274311µs $meta->{coercions} ||= {};
27535µs324µ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
27634µs320µ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
27734µs313µ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
27833µs $meta->{coercions}{$name} = $c;
279
280240µs236µ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
no strict "refs";
# spent 23µs making 1 call to Type::Library::BEGIN@280 # spent 14µs making 1 call to strict::unimport
2812228µs235µ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
no warnings "redefine", "prototype";
# spent 22µs making 1 call to Type::Library::BEGIN@281 # spent 12µs making 1 call to warnings::unimport
282
283310µs32µs my $class = blessed($meta);
# spent 2µs making 3 calls to Scalar::Util::blessed, avg 733ns/call
284319µs3806µs *{"$class\::$name"} = $class->_mksub($c);
# spent 806µs making 3 calls to Type::Library::_mksub, avg 269µs/call
285
286314µs return $c;
287}
288
289sub get_coercion
290{
291 my $meta = shift->meta;
292 $meta->{coercions}{$_[0]};
293}
294
295sub has_coercion
296
# spent 257µs (142+115) within Type::Library::has_coercion which was called 38 times, avg 7µs/call: # 35 times (129µs+104µs) by Type::Library::add_type at line 227, avg 7µs/call # 3 times (12µs+11µs) by Type::Library::add_coercion at line 275, avg 8µs/call
{
2973835µs38115µs my $meta = shift->meta;
# spent 115µs making 38 calls to Type::Library::meta, avg 3µs/call
2983887µs exists $meta->{coercions}{$_[0]};
299}
300
301sub 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
{
30333µs312µs my $meta = shift->meta;
# spent 12µs making 3 calls to Type::Library::meta, avg 4µs/call
304310µs keys %{ $meta->{coercions} };
305}
306
30715µs1;
308
309__END__
 
# spent 30µs within Type::Library::CORE:match which was called 70 times, avg 436ns/call: # 35 times (16µs+0s) by Type::Library::add_type at line 221, avg 469ns/call # 35 times (14µs+0s) by Type::Library::_exporter_expand_sub at line 134, avg 403ns/call
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
sub Type::Library::CORE:qr; # opcode
# 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:regcomp; # opcode
# spent 30µs within Type::Library::CORE:sort which was called 6 times, avg 5µs/call: # 3 times (28µs+0s) by Type::Library::_exporter_permitted_regexp at line 116, avg 9µs/call # 3 times (3µs+0s) by Type::Library::_exporter_permitted_regexp at line 119, avg 900ns/call
sub Type::Library::CORE:sort; # opcode