← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:45:08 2010
Reported on Wed Nov 17 22:14:05 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/MooseX/Types/Base.pm
StatementsExecuted 8616 statements in 118ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
333372.2ms481msMooseX::Types::Base::::importMooseX::Types::Base::import
6481124.8ms51.7msMooseX::Types::Base::::get_typeMooseX::Types::Base::get_type
6481116.2ms21.4msMooseX::Types::Base::::has_typeMooseX::Types::Base::has_type
1113.72ms25.1msMooseX::Types::Base::::BEGIN@16MooseX::Types::Base::BEGIN@16
89223.22ms4.41msMooseX::Types::Base::::type_namesMooseX::Types::Base::type_names
151413.09ms3.09msMooseX::Types::Base::::type_storageMooseX::Types::Base::type_storage
69112.05ms5.74msMooseX::Types::Base::::__ANON__[:73]MooseX::Types::Base::__ANON__[:73]
69111.53ms3.03msMooseX::Types::Base::::__ANON__[:78]MooseX::Types::Base::__ANON__[:78]
1111.33ms2.23msMooseX::Types::Base::::BEGIN@12MooseX::Types::Base::BEGIN@12
911266µs425µsMooseX::Types::Base::::add_typeMooseX::Types::Base::add_type
911194µs443µsMooseX::Types::Base::::__ANON__[:86]MooseX::Types::Base::__ANON__[:86]
11171µs23.4msMooseX::Types::Base::::BEGIN@3MooseX::Types::Base::BEGIN@3
11152µs109µsMooseX::Types::Base::::BEGIN@202MooseX::Types::Base::BEGIN@202
11146µs123µsMooseX::Types::Base::::BEGIN@187MooseX::Types::Base::BEGIN@187
11143µs908µsMooseX::Types::Base::::BEGIN@13MooseX::Types::Base::BEGIN@13
11143µs10.7msMooseX::Types::Base::::BEGIN@14MooseX::Types::Base::BEGIN@14
11141µs413µsMooseX::Types::Base::::BEGIN@11MooseX::Types::Base::BEGIN@11
11137µs97µsMooseX::Types::Base::::BEGIN@244MooseX::Types::Base::BEGIN@244
0000s0sMooseX::Types::Base::::get_registered_class_typeMooseX::Types::Base::get_registered_class_type
0000s0sMooseX::Types::Base::::get_registered_role_typeMooseX::Types::Base::get_registered_role_type
0000s0sMooseX::Types::Base::::register_class_typeMooseX::Types::Base::register_class_type
0000s0sMooseX::Types::Base::::register_role_typeMooseX::Types::Base::register_role_type
0000s0sMooseX::Types::Base::::registered_class_typesMooseX::Types::Base::registered_class_types
0000s0sMooseX::Types::Base::::registered_role_typesMooseX::Types::Base::registered_role_types
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package MooseX::Types::Base;
214µsour $VERSION = "0.23";
33174µs246.7ms
# spent 23.4ms (71µs+23.3) within MooseX::Types::Base::BEGIN@3 which was called: # once (71µs+23.3ms) by MooseX::Types::BEGIN@12 at line 3
use Moose;
# spent 23.4ms making 1 call to MooseX::Types::Base::BEGIN@3 # spent 23.3ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:456]
4
5=head1 NAME
6
- -
113124µs2785µs
# spent 413µs (41+372) within MooseX::Types::Base::BEGIN@11 which was called: # once (41µs+372µs) by MooseX::Types::BEGIN@12 at line 11
use Carp::Clan qw( ^MooseX::Types );
# spent 413µs making 1 call to MooseX::Types::Base::BEGIN@11 # spent 372µs making 1 call to Carp::Clan::import
123572µs22.45ms
# spent 2.23ms (1.33+902µs) within MooseX::Types::Base::BEGIN@12 which was called: # once (1.33ms+902µs) by MooseX::Types::BEGIN@12 at line 12
use MooseX::Types::Util qw( filter_tags );
# spent 2.23ms making 1 call to MooseX::Types::Base::BEGIN@12 # spent 225µs making 1 call to Exporter::import
133142µs21.77ms
# spent 908µs (43+864) within MooseX::Types::Base::BEGIN@13 which was called: # once (43µs+864µs) by MooseX::Types::BEGIN@12 at line 13
use Sub::Exporter qw( build_exporter );
# spent 908µs making 1 call to MooseX::Types::Base::BEGIN@13 # spent 864µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
143176µs221.3ms
# spent 10.7ms (43µs+10.6) within MooseX::Types::Base::BEGIN@14 which was called: # once (43µs+10.6ms) by MooseX::Types::BEGIN@12 at line 14
use Moose::Util::TypeConstraints;
# spent 10.7ms making 1 call to MooseX::Types::Base::BEGIN@14 # spent 10.6ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:456]
15
1632.72ms233.4ms
# spent 25.1ms (3.72+21.4) within MooseX::Types::Base::BEGIN@16 which was called: # once (3.72ms+21.4ms) by MooseX::Types::BEGIN@12 at line 16
use namespace::clean -except => [qw( meta )];
# spent 25.1ms making 1 call to MooseX::Types::Base::BEGIN@16 # spent 8.24ms making 1 call to namespace::clean::import
17
18=head1 DESCRIPTION
19
- -
2613µsmy $UndefMsg = q{Unable to find type '%s' in library '%s'};
27
28=head1 METHODS
29
- -
32=head2 import
33
- -
39
# spent 481ms (72.2+409) within MooseX::Types::Base::import which was called 33 times, avg 14.6ms/call: # 31 times (68.7ms+375ms) by MooseX::Types::Combine::import at line 58 of MooseX/Types/Combine.pm, avg 14.3ms/call # once (1.20ms+17.9ms) by MooseX::Types::import at line 358 of MooseX/Types.pm # once (2.35ms+16.1ms) by Markdent::Types::Internal::BEGIN@24 at line 24 of Markdent/Types/Internal.pm
sub import {
4033260µs my ($class, @args) = @_;
41
42 # filter or create options hash for S:E
4333217µs my $options = (@args and (ref($args[0]) eq 'HASH')) ? $args[0] : undef;
443371µs unless ($options) {
4516µs $options = {foo => 23};
4616µs unshift @args, $options;
47 }
48
49 # all types known to us
5033878µs331.40ms my @types = $class->type_names;
# spent 1.40ms making 33 calls to MooseX::Types::Base::type_names, avg 42µs/call
51
52 # determine the wrapper, -into is supported for compatibility reasons
5333204µs my $wrapper = $options->{ -wrapper } || 'MooseX::Types';
54 $args[0]->{into} = $options->{ -into }
5533333µs if exists $options->{ -into };
56
573383µs my (%ex_spec, %ex_util);
58 TYPE:
59331.71ms for my $type_short (@types) {
60
61 # find type name and object, create undefined message
626487.92ms64851.7ms my $type_full = $class->get_type($type_short)
# spent 51.7ms making 648 calls to MooseX::Types::Base::get_type, avg 80µs/call
63 or croak "No fully qualified type name stored for '$type_short'";
646486.72ms64879.8ms my $type_cons = find_type_constraint($type_full);
# spent 79.8ms making 648 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 123µs/call
656485.25ms my $undef_msg = sprintf($UndefMsg, $type_short, $class);
66
67 # the type itself
68 push @{ $ex_spec{exports} },
69 $type_short,
70
# spent 5.74ms (2.05+3.69) within MooseX::Types::Base::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/MooseX/Types/Base.pm:73] which was called 69 times, avg 83µs/call: # 69 times (2.05ms+3.69ms) by Sub::Exporter::default_generator at line 856 of Sub/Exporter.pm, avg 83µs/call
sub {
71691.93ms693.69ms bless $wrapper->type_export_generator($type_short, $type_full),
# spent 3.69ms making 69 calls to MooseX::Types::type_export_generator, avg 53µs/call
72 'MooseX::Types::EXPORTED_TYPE_CONSTRAINT';
736488.81ms };
74
75 # the check helper
76 push @{ $ex_spec{exports} },
77 "is_${type_short}",
787179.68ms691.50ms
# spent 3.03ms (1.53+1.50) within MooseX::Types::Base::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/MooseX/Types/Base.pm:78] which was called 69 times, avg 44µs/call: # 69 times (1.53ms+1.50ms) by Sub::Exporter::default_generator at line 856 of Sub/Exporter.pm, avg 44µs/call
sub { $wrapper->check_export_generator($type_short, $type_full, $undef_msg) };
# spent 1.50ms making 69 calls to MooseX::Types::check_export_generator, avg 22µs/call
79
80 # only export coercion helper if full (for libraries) or coercion is defined
81 next TYPE
82 unless $options->{ -full }
8364818.4ms127812.9ms or ($type_cons and $type_cons->has_coercion);
# spent 7.55ms making 639 calls to Moose::Meta::TypeConstraint::has_coercion, avg 12µs/call # spent 5.35ms making 639 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 8µs/call
84 push @{ $ex_spec{exports} },
85 "to_${type_short}",
8618293µs9249µs
# spent 443µs (194+249) within MooseX::Types::Base::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/MooseX/Types/Base.pm:86] which was called 9 times, avg 49µs/call: # 9 times (194µs+249µs) by Sub::Exporter::default_generator at line 856 of Sub/Exporter.pm, avg 49µs/call
sub { $wrapper->coercion_export_generator($type_short, $type_full, $undef_msg) };
# spent 249µs making 9 calls to MooseX::Types::coercion_export_generator, avg 28µs/call
87987µs $ex_util{ $type_short }{to}++; # shortcut to remember this exists
88 }
89
90 # create S:E exporter and increase export level unless specified explicitly
9133462µs33179ms my $exporter = build_exporter \%ex_spec;
# spent 179ms making 33 calls to Sub::Exporter::build_exporter, avg 5.42ms/call
9233130µs $options->{into_level}++
93 unless $options->{into};
94
95 # remember requested symbols to determine what helpers to auto-export
96 my %was_requested =
97 map { ($_ => 1) }
9833562µs grep { not ref }
99 @args;
100
101 # determine which additional symbols (helpers) to export along
1023370µs my %add;
103 EXPORT:
10433856µs for my $type (grep { exists $was_requested{ $_ } } @types) {
10569366µs $add{ "is_$type" }++
106 unless $was_requested{ "is_$type" };
107 next EXPORT
10869337µs unless exists $ex_util{ $type }{to};
109955µs $add{ "to_$type" }++
110 unless $was_requested{ "to_$type" };
111 }
112
113 # and on to the real exporter
11433351µs my @new_args = (@args, keys %add);
115332.21ms3384.0ms return $class->$exporter(@new_args);
# spent 84.0ms making 33 calls to Sub::Exporter::__ANON__[Sub/Exporter.pm:756], avg 2.55ms/call
116}
117
118=head2 get_type
119
- -
124
# spent 51.7ms (24.8+26.9) within MooseX::Types::Base::get_type which was called 648 times, avg 80µs/call: # 648 times (24.8ms+26.9ms) by MooseX::Types::Base::import at line 62, avg 80µs/call
sub get_type {
1256482.50ms my ($class, $type) = @_;
126
127 # useful message if the type couldn't be found
1286486.20ms64821.4ms croak "Unknown type '$type' in library '$class'"
# spent 21.4ms making 648 calls to MooseX::Types::Base::has_type, avg 33µs/call
129 unless $class->has_type($type);
130
131 # return real name of the type
13264813.3ms6485.46ms return $class->type_storage->{ $type };
# spent 4.34ms making 594 calls to MooseX::Types::Moose::type_storage, avg 7µs/call # spent 1.12ms making 54 calls to MooseX::Types::Base::type_storage, avg 21µs/call
133}
134
135=head2 type_names
136
- -
141
# spent 4.41ms (3.22+1.19) within MooseX::Types::Base::type_names which was called 89 times, avg 50µs/call: # 56 times (2.15ms+865µs) by MooseX::Types::Combine::import at line 44 of MooseX/Types/Combine.pm, avg 54µs/call # 33 times (1.08ms+322µs) by MooseX::Types::Base::import at line 50, avg 42µs/call
sub type_names {
14289325µs my ($class) = @_;
143
144 # return short names of all stored types
145892.66ms891.19ms return keys %{ $class->type_storage };
# spent 764µs making 34 calls to MooseX::Types::Base::type_storage, avg 22µs/call # spent 423µs making 55 calls to MooseX::Types::Moose::type_storage, avg 8µs/call
146}
147
148=head2 add_type
149
- -
154
# spent 425µs (266+158) within MooseX::Types::Base::add_type which was called 9 times, avg 47µs/call: # 9 times (266µs+158µs) by MooseX::Types::import at line 354 of MooseX/Types.pm, avg 47µs/call
sub add_type {
155935µs my ($class, $type) = @_;
156
157 # store type with library prefix as real name
1589211µs9158µs $class->type_storage->{ $type } = "${class}::${type}";
# spent 158µs making 9 calls to MooseX::Types::Base::type_storage, avg 18µs/call
159}
160
161=head2 has_type
162
- -
168
# spent 21.4ms (16.2+5.22) within MooseX::Types::Base::has_type which was called 648 times, avg 33µs/call: # 648 times (16.2ms+5.22ms) by MooseX::Types::Base::get_type at line 128, avg 33µs/call
sub has_type {
1696482.10ms my ($class, $type) = @_;
170
171 # check if we stored a type under that name
17264813.2ms6485.22ms return ! ! $class->type_storage->{ $type };
# spent 4.16ms making 594 calls to MooseX::Types::Moose::type_storage, avg 7µs/call # spent 1.05ms making 54 calls to MooseX::Types::Base::type_storage, avg 19µs/call
173}
174
175=head2 type_storage
176
- -
183
# spent 3.09ms within MooseX::Types::Base::type_storage which was called 151 times, avg 20µs/call: # 54 times (1.12ms+0s) by MooseX::Types::Base::get_type at line 132, avg 21µs/call # 54 times (1.05ms+0s) by MooseX::Types::Base::has_type at line 172, avg 19µs/call # 34 times (764µs+0s) by MooseX::Types::Base::type_names at line 145, avg 22µs/call # 9 times (158µs+0s) by MooseX::Types::Base::add_type at line 158, avg 18µs/call
sub type_storage {
184151467µs my ($class) = @_;
185
186 # return a reference to the storage in ourself
187154587µs2199µs
# spent 123µs (46+76) within MooseX::Types::Base::BEGIN@187 which was called: # once (46µs+76µs) by MooseX::Types::BEGIN@12 at line 187
{ no strict 'refs';
# spent 123µs making 1 call to MooseX::Types::Base::BEGIN@187 # spent 76µs making 1 call to strict::unimport
1881512.97ms return \%{ $class . '::__MOOSEX_TYPELIBRARY_STORAGE' };
189 }
190}
191
192=head2 registered_class_types
193
- -
198sub registered_class_types {
199 my ($class) = @_;
200
201 {
2023542µs2167µs
# spent 109µs (52+57) within MooseX::Types::Base::BEGIN@202 which was called: # once (52µs+57µs) by MooseX::Types::BEGIN@12 at line 202
no strict 'refs';
# spent 109µs making 1 call to MooseX::Types::Base::BEGIN@202 # spent 57µs making 1 call to strict::unimport
203 return \%{ $class . '::__MOOSEX_TYPELIBRARY_CLASS_TYPES' };
204 }
205}
206
207=head2 register_class_type
208
- -
213sub register_class_type {
214 my ($class, $type) = @_;
215
216 croak "Not a class_type"
217 unless $type->isa('Moose::Meta::TypeConstraint::Class');
218
219 $class->registered_class_types->{$type->class} = $type;
220}
221
222=head2 get_registered_class_type
223
- -
228sub get_registered_class_type {
229 my ($class, $name) = @_;
230
231 $class->registered_class_types->{$name};
232}
233
234=head2 registered_role_types
235
- -
240sub registered_role_types {
241 my ($class) = @_;
242
243 {
2443482µs2157µs
# spent 97µs (37+60) within MooseX::Types::Base::BEGIN@244 which was called: # once (37µs+60µs) by MooseX::Types::BEGIN@12 at line 244
no strict 'refs';
# spent 97µs making 1 call to MooseX::Types::Base::BEGIN@244 # spent 60µs making 1 call to strict::unimport
245 return \%{ $class . '::__MOOSEX_TYPELIBRARY_ROLE_TYPES' };
246 }
247}
248
249=head2 register_role_type
250
- -
255sub register_role_type {
256 my ($class, $type) = @_;
257
258 croak "Not a role_type"
259 unless $type->isa('Moose::Meta::TypeConstraint::Role');
260
261 $class->registered_role_types->{$type->role} = $type;
262}
263
264=head2 get_registered_role_type
265
- -
270sub get_registered_role_type {
271 my ($class, $name) = @_;
272
273 $class->registered_role_types->{$name};
274}
275
276=head1 SEE ALSO
277
- -
291158µs130.0ms1;