← Index
NYTProf Performance Profile   « block view • line view • sub view »
For 05.Domain_and_Item.t
  Run on Tue May 4 17:21:41 2010
Reported on Tue May 4 17:23:11 2010

File /usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types/Base.pm
Statements Executed 1125
Statement Execution Time 3.01ms
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
4441.10ms12.8msMooseX::Types::Base::::importMooseX::Types::Base::import
1111.02ms4.79msMooseX::Types::Base::::BEGIN@15MooseX::Types::Base::BEGIN@15
111315µs496µsMooseX::Types::Base::::BEGIN@11MooseX::Types::Base::BEGIN@11
5211275µs589µsMooseX::Types::Base::::get_typeMooseX::Types::Base::get_type
5211170µs245µsMooseX::Types::Base::::has_typeMooseX::Types::Base::has_type
7341148µs148µsMooseX::Types::Base::::type_storageMooseX::Types::Base::type_storage
3511132µs435µsMooseX::Types::Base::::__ANON__[:72]MooseX::Types::Base::__ANON__[:72]
3511111µs266µsMooseX::Types::Base::::__ANON__[:77]MooseX::Types::Base::__ANON__[:77]
301190µs199µsMooseX::Types::Base::::__ANON__[:85]MooseX::Types::Base::__ANON__[:85]
101143µs64µsMooseX::Types::Base::::add_typeMooseX::Types::Base::add_type
41135µs48µsMooseX::Types::Base::::type_namesMooseX::Types::Base::type_names
11118µs29µsMooseX::Types::Base::::BEGIN@243MooseX::Types::Base::BEGIN@243
11117µs2.37msMooseX::Types::Base::::BEGIN@2MooseX::Types::Base::BEGIN@2
11115µs24µsMooseX::Types::Base::::register_class_typeMooseX::Types::Base::register_class_type
11110µs145µsMooseX::Types::Base::::BEGIN@12MooseX::Types::Base::BEGIN@12
22110µs10µsMooseX::Types::Base::::registered_class_typesMooseX::Types::Base::registered_class_types
1119µs1.21msMooseX::Types::Base::::BEGIN@13MooseX::Types::Base::BEGIN@13
1119µs100µsMooseX::Types::Base::::BEGIN@10MooseX::Types::Base::BEGIN@10
1117µs19µsMooseX::Types::Base::::BEGIN@186MooseX::Types::Base::BEGIN@186
1117µs10µsMooseX::Types::Base::::get_registered_class_typeMooseX::Types::Base::get_registered_class_type
1117µs16µsMooseX::Types::Base::::BEGIN@201MooseX::Types::Base::BEGIN@201
0000s0sMooseX::Types::Base::::get_registered_role_typeMooseX::Types::Base::get_registered_role_type
0000s0sMooseX::Types::Base::::register_role_typeMooseX::Types::Base::register_role_type
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;
2335µs24.73ms
# spent 2.37ms (17µs+2.36) within MooseX::Types::Base::BEGIN@2 which was called # once (17µs+2.36ms) by MooseX::Types::BEGIN@12 at line 2
use Moose;
# spent 2.37ms making 1 call to MooseX::Types::Base::BEGIN@2 # spent 2.36ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:389]
3
4=head1 NAME
5
6MooseX::Types::Base - Type library base class
7
8=cut
9
10329µs2192µs
# spent 100µs (9+92) within MooseX::Types::Base::BEGIN@10 which was called # once (9µs+92µs) by MooseX::Types::BEGIN@12 at line 10
use Carp::Clan qw( ^MooseX::Types );
# spent 100µs making 1 call to MooseX::Types::Base::BEGIN@10 # spent 92µs making 1 call to Carp::Clan::import
113120µs2534µs
# spent 496µs (315+181) within MooseX::Types::Base::BEGIN@11 which was called # once (315µs+181µs) by MooseX::Types::BEGIN@12 at line 11
use MooseX::Types::Util qw( filter_tags );
# spent 496µs making 1 call to MooseX::Types::Base::BEGIN@11 # spent 38µs making 1 call to Exporter::import
12330µs2280µs
# spent 145µs (10+135) within MooseX::Types::Base::BEGIN@12 which was called # once (10µs+135µs) by MooseX::Types::BEGIN@12 at line 12
use Sub::Exporter qw( build_exporter );
# spent 145µs making 1 call to MooseX::Types::Base::BEGIN@12 # spent 135µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
13331µs22.41ms
# spent 1.21ms (9µs+1.20) within MooseX::Types::Base::BEGIN@13 which was called # once (9µs+1.20ms) by MooseX::Types::BEGIN@12 at line 13
use Moose::Util::TypeConstraints;
# spent 1.21ms making 1 call to MooseX::Types::Base::BEGIN@13 # spent 1.20ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:389]
14
153603µs25.50ms
# spent 4.79ms (1.02+3.77) within MooseX::Types::Base::BEGIN@15 which was called # once (1.02ms+3.77ms) by MooseX::Types::BEGIN@12 at line 15
use namespace::clean -except => [qw( meta )];
# spent 4.79ms making 1 call to MooseX::Types::Base::BEGIN@15 # spent 707µs making 1 call to namespace::clean::import
16
17=head1 DESCRIPTION
18
19You normally won't need to interact with this class by yourself. It is
20merely a collection of functionality that type libraries need to
21interact with moose and the rest of the L<MooseX::Types> module.
22
23=cut
24
251500nsmy $UndefMsg = q{Unable to find type '%s' in library '%s'};
26
27=head1 METHODS
28
29=cut
30
31=head2 import
32
33Provides the import mechanism for your library. See
34L<MooseX::Types/"LIBRARY USAGE"> for syntax details on this.
35
36=cut
37
38
# spent 12.8ms (1.10+11.7) within MooseX::Types::Base::import which was called 4 times, avg 3.19ms/call: # once (257µs+3.32ms) by SimpleDB::Class::Item::BEGIN@19 at line 19 of ../lib/SimpleDB/Class/Item.pm # once (245µs+3.15ms) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 4 of ../lib/SimpleDB/Class/Role/Itemized.pm # once (223µs+2.88ms) by MooseX::Types::import at line 358 of MooseX/Types.pm # once (379µs+2.32ms) by SimpleDB::Class::Types::BEGIN@83 at line 83 of ../lib/SimpleDB/Class/Types.pm
sub import {
3948µs my ($class, @args) = @_;
40
41 # filter or create options hash for S:E
4248µs my $options = (@args and (ref($args[0]) eq 'HASH')) ? $args[0] : undef;
4342µs unless ($options) {
4434µs $options = {foo => 23};
4532µs unshift @args, $options;
46 }
47
48 # all types known to us
49423µs448µs my @types = $class->type_names;
# spent 48µs making 4 calls to MooseX::Types::Base::type_names, avg 12µs/call
50
51 # determine the wrapper, -into is supported for compatibility reasons
5247µs my $wrapper = $options->{ -wrapper } || 'MooseX::Types';
53 $args[0]->{into} = $options->{ -into }
5445µs if exists $options->{ -into };
55
5642µs my (%ex_spec, %ex_util);
57 TYPE:
5847µs for my $type_short (@types) {
59
60 # find type name and object, create undefined message
615271µs52589µs my $type_full = $class->get_type($type_short)
# spent 589µs making 52 calls to MooseX::Types::Base::get_type, avg 11µs/call
62 or croak "No fully qualified type name stored for '$type_short'";
635253µs52821µs my $type_cons = find_type_constraint($type_full);
# spent 821µs making 52 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 16µs/call
645255µs my $undef_msg = sprintf($UndefMsg, $type_short, $class);
65
66 # the type itself
67 push @{ $ex_spec{exports} },
68 $type_short,
69
# spent 435µs (132+303) within MooseX::Types::Base::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types/Base.pm:72] which was called 35 times, avg 12µs/call: # 35 times (132µs+303µs) by Sub::Exporter::default_generator at line 856 of Sub/Exporter.pm, avg 12µs/call
sub {
7035122µs35303µs bless $wrapper->type_export_generator($type_short, $type_full),
# spent 303µs making 35 calls to MooseX::Types::type_export_generator, avg 9µs/call
71 'MooseX::Types::EXPORTED_TYPE_CONSTRAINT';
7252117µs };
73
74 # the check helper
75 push @{ $ex_spec{exports} },
76 "is_${type_short}",
7787198µs35155µs
# spent 266µs (111+155) within MooseX::Types::Base::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types/Base.pm:77] which was called 35 times, avg 8µs/call: # 35 times (111µs+155µs) by Sub::Exporter::default_generator at line 856 of Sub/Exporter.pm, avg 8µs/call
sub { $wrapper->check_export_generator($type_short, $type_full, $undef_msg) };
# spent 155µs making 35 calls to MooseX::Types::check_export_generator, avg 4µs/call
78
79 # only export coercion helper if full (for libraries) or coercion is defined
80 next TYPE
81 unless $options->{ -full }
8252151µs84289µs or ($type_cons and $type_cons->has_coercion);
# spent 235µs making 42 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:8], avg 6µs/call # spent 54µs making 42 calls to Moose::Meta::TypeConstraint::has_coercion, avg 1µs/call
83 push @{ $ex_spec{exports} },
84 "to_${type_short}",
8560142µs30109µs
# spent 199µs (90+109) within MooseX::Types::Base::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types/Base.pm:85] which was called 30 times, avg 7µs/call: # 30 times (90µs+109µs) by Sub::Exporter::default_generator at line 856 of Sub/Exporter.pm, avg 7µs/call
sub { $wrapper->coercion_export_generator($type_short, $type_full, $undef_msg) };
# spent 109µs making 30 calls to MooseX::Types::coercion_export_generator, avg 4µs/call
863040µs $ex_util{ $type_short }{to}++; # shortcut to remember this exists
87 }
88
89 # create S:E exporter and increase export level unless specified explicitly
9048µs42.74ms my $exporter = build_exporter \%ex_spec;
# spent 2.74ms making 4 calls to Sub::Exporter::build_exporter, avg 684µs/call
9144µs $options->{into_level}++
92 unless $options->{into};
93
94 # remember requested symbols to determine what helpers to auto-export
95 my %was_requested =
96 map { ($_ => 1) }
97421µs grep { not ref }
98 @args;
99
100 # determine which additional symbols (helpers) to export along
10141µs my %add;
102 EXPORT:
103415µs for my $type (grep { exists $was_requested{ $_ } } @types) {
104159µs $add{ "is_$type" }++
105 unless $was_requested{ "is_$type" };
106 next EXPORT
107154µs unless exists $ex_util{ $type }{to};
108107µs $add{ "to_$type" }++
109 unless $was_requested{ "to_$type" };
110 }
111
112 # and on to the real exporter
113412µs my @new_args = (@args, keys %add);
114469µs47.18ms return $class->$exporter(@new_args);
# spent 7.18ms making 4 calls to Sub::Exporter::__ANON__[Sub/Exporter.pm:756], avg 1.80ms/call
115}
116
117=head2 get_type
118
119This returns a type from the library's store by its name.
120
121=cut
122
123
# spent 589µs (275+313) within MooseX::Types::Base::get_type which was called 52 times, avg 11µs/call: # 52 times (275µs+313µs) by MooseX::Types::Base::import at line 61, avg 11µs/call
sub get_type {
1245221µs my ($class, $type) = @_;
125
126 # useful message if the type couldn't be found
1275253µs52245µs croak "Unknown type '$type' in library '$class'"
# spent 245µs making 52 calls to MooseX::Types::Base::has_type, avg 5µs/call
128 unless $class->has_type($type);
129
130 # return real name of the type
13152130µs5269µs return $class->type_storage->{ $type };
# spent 55µs making 30 calls to MooseX::Types::Base::type_storage, avg 2µs/call # spent 13µs making 22 calls to MooseX::Types::Moose::type_storage, avg 605ns/call
132}
133
134=head2 type_names
135
136Returns a list of all known types by their name.
137
138=cut
139
140
# spent 48µs (35+13) within MooseX::Types::Base::type_names which was called 4 times, avg 12µs/call: # 4 times (35µs+13µs) by MooseX::Types::Base::import at line 49, avg 12µs/call
sub type_names {
14143µs my ($class) = @_;
142
143 # return short names of all stored types
144425µs414µs return keys %{ $class->type_storage };
# spent 13µs making 3 calls to MooseX::Types::Base::type_storage, avg 4µs/call # spent 800ns making 1 call to MooseX::Types::Moose::type_storage
145}
146
147=head2 add_type
148
149Adds a new type to the library.
150
151=cut
152
153
# spent 64µs (43+20) within MooseX::Types::Base::add_type which was called 10 times, avg 6µs/call: # 10 times (43µs+20µs) by MooseX::Types::import at line 354 of MooseX/Types.pm, avg 6µs/call
sub add_type {
154104µs my ($class, $type) = @_;
155
156 # store type with library prefix as real name
1571034µs1020µs $class->type_storage->{ $type } = "${class}::${type}";
# spent 20µs making 10 calls to MooseX::Types::Base::type_storage, avg 2µs/call
158}
159
160=head2 has_type
161
162Returns true or false depending on if this library knows a type by that
163name.
164
165=cut
166
167
# spent 245µs (170+75) within MooseX::Types::Base::has_type which was called 52 times, avg 5µs/call: # 52 times (170µs+75µs) by MooseX::Types::Base::get_type at line 127, avg 5µs/call
sub has_type {
1685212µs my ($class, $type) = @_;
169
170 # check if we stored a type under that name
17152127µs5275µs return ! ! $class->type_storage->{ $type };
# spent 60µs making 30 calls to MooseX::Types::Base::type_storage, avg 2µs/call # spent 15µs making 22 calls to MooseX::Types::Moose::type_storage, avg 682ns/call
172}
173
174=head2 type_storage
175
176Returns the library's type storage hash reference. You shouldn't use this
177method directly unless you know what you are doing. It is not an internal
178method because overriding it makes virtual libraries very easy.
179
180=cut
181
182
# spent 148µs within MooseX::Types::Base::type_storage which was called 73 times, avg 2µs/call: # 30 times (60µs+0s) by MooseX::Types::Base::has_type at line 171, avg 2µs/call # 30 times (55µs+0s) by MooseX::Types::Base::get_type at line 131, avg 2µs/call # 10 times (20µs+0s) by MooseX::Types::Base::add_type at line 157, avg 2µs/call # 3 times (13µs+0s) by MooseX::Types::Base::type_names at line 144, avg 4µs/call
sub type_storage {
1837314µs my ($class) = @_;
184
185 # return a reference to the storage in ourself
1867662µs230µs
# spent 19µs (7+11) within MooseX::Types::Base::BEGIN@186 which was called # once (7µs+11µs) by MooseX::Types::BEGIN@12 at line 186
{ no strict 'refs';
# spent 19µs making 1 call to MooseX::Types::Base::BEGIN@186 # spent 11µs making 1 call to strict::unimport
18773184µs return \%{ $class . '::__MOOSEX_TYPELIBRARY_STORAGE' };
188 }
189}
190
191=head2 registered_class_types
192
193Returns the class types registered within this library. Don't use directly.
194
195=cut
196
197
# spent 10µs within MooseX::Types::Base::registered_class_types which was called 2 times, avg 5µs/call: # once (7µs+0s) by MooseX::Types::Base::register_class_type at line 218 # once (3µs+0s) by MooseX::Types::Base::get_registered_class_type at line 230
sub registered_class_types {
19821µs my ($class) = @_;
199
200 {
2015144µs226µs
# spent 16µs (7+9) within MooseX::Types::Base::BEGIN@201 which was called # once (7µs+9µs) by MooseX::Types::BEGIN@12 at line 201
no strict 'refs';
# spent 16µs making 1 call to MooseX::Types::Base::BEGIN@201 # spent 9µs making 1 call to strict::unimport
202212µs return \%{ $class . '::__MOOSEX_TYPELIBRARY_CLASS_TYPES' };
203 }
204}
205
206=head2 register_class_type
207
208Register a C<class_type> for use in this library by class name.
209
210=cut
211
212
# spent 24µs (15+9) within MooseX::Types::Base::register_class_type which was called # once (15µs+9µs) by MooseX::Types::CheckedUtilExports::class_type at line 73 of MooseX/Types/CheckedUtilExports.pm
sub register_class_type {
21311µs my ($class, $type) = @_;
214
21514µs1600ns croak "Not a class_type"
# spent 600ns making 1 call to UNIVERSAL::isa
216 unless $type->isa('Moose::Meta::TypeConstraint::Class');
217
21818µs28µs $class->registered_class_types->{$type->class} = $type;
# spent 7µs making 1 call to MooseX::Types::Base::registered_class_types # spent 2µs making 1 call to Moose::Meta::TypeConstraint::Class::class
219}
220
221=head2 get_registered_class_type
222
223Get a C<class_type> registered in this library by name.
224
225=cut
226
227
# spent 10µs (7+3) within MooseX::Types::Base::get_registered_class_type which was called # once (7µs+3µs) by MooseX::Types::CheckedUtilExports::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types/CheckedUtilExports.pm:63] at line 56 of MooseX/Types/CheckedUtilExports.pm
sub get_registered_class_type {
22811µs my ($class, $name) = @_;
229
23015µs13µs $class->registered_class_types->{$name};
# spent 3µs making 1 call to MooseX::Types::Base::registered_class_types
231}
232
233=head2 registered_role_types
234
235Returns the role types registered within this library. Don't use directly.
236
237=cut
238
239sub registered_role_types {
240 my ($class) = @_;
241
242 {
2433123µs239µs
# spent 29µs (18+10) within MooseX::Types::Base::BEGIN@243 which was called # once (18µs+10µs) by MooseX::Types::BEGIN@12 at line 243
no strict 'refs';
# spent 29µs making 1 call to MooseX::Types::Base::BEGIN@243 # spent 10µs making 1 call to strict::unimport
244 return \%{ $class . '::__MOOSEX_TYPELIBRARY_ROLE_TYPES' };
245 }
246}
247
248=head2 register_role_type
249
250Register a C<role_type> for use in this library by role name.
251
252=cut
253
254sub register_role_type {
255 my ($class, $type) = @_;
256
257 croak "Not a role_type"
258 unless $type->isa('Moose::Meta::TypeConstraint::Role');
259
260 $class->registered_role_types->{$type->role} = $type;
261}
262
263=head2 get_registered_role_type
264
265Get a C<role_type> registered in this library by role name.
266
267=cut
268
269sub get_registered_role_type {
270 my ($class, $name) = @_;
271
272 $class->registered_role_types->{$name};
273}
274
275=head1 SEE ALSO
276
277L<MooseX::Types::Moose>
278
279=head1 AUTHOR
280
281See L<MooseX::Types/AUTHOR>.
282
283=head1 LICENSE
284
285This program is free software; you can redistribute it and/or modify
286it under the same terms as perl itself.
287
288=cut
289
290122µs11.96ms1;