← 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:03 2010

File /usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types/Util.pm
Statements Executed 38
Statement Execution Time 276µs
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11133µs35µsMooseX::Types::Util::::filter_tagsMooseX::Types::Util::filter_tags
11116µs28µsMooseX::Types::Util::::BEGIN@9MooseX::Types::Util::BEGIN@9
1119µs67µsMooseX::Types::Util::::BEGIN@13MooseX::Types::Util::BEGIN@13
1118µs10µsMooseX::Types::Util::::BEGIN@10MooseX::Types::Util::BEGIN@10
1118µs38µsMooseX::Types::Util::::BEGIN@11MooseX::Types::Util::BEGIN@11
10122µs2µsMooseX::Types::Util::::CORE:matchMooseX::Types::Util::CORE:match (opcode)
0000s0sMooseX::Types::Util::::has_available_type_exportMooseX::Types::Util::has_available_type_export
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::Util;
2
3=head1 NAME
4
5MooseX::Types::Util - Common utility functions for the module
6
7=cut
8
9323µs240µs
# spent 28µs (16+12) within MooseX::Types::Util::BEGIN@9 which was called # once (16µs+12µs) by MooseX::Types::Base::BEGIN@11 at line 9
use warnings;
# spent 28µs making 1 call to MooseX::Types::Util::BEGIN@9 # spent 12µs making 1 call to warnings::import
10321µs212µs
# spent 10µs (8+2) within MooseX::Types::Util::BEGIN@10 which was called # once (8µs+2µs) by MooseX::Types::Base::BEGIN@11 at line 10
use strict;
# spent 10µs making 1 call to MooseX::Types::Util::BEGIN@10 # spent 2µs making 1 call to strict::import
11336µs269µs
# spent 38µs (8+31) within MooseX::Types::Util::BEGIN@11 which was called # once (8µs+31µs) by MooseX::Types::Base::BEGIN@11 at line 11
use Scalar::Util 'blessed';
# spent 38µs making 1 call to MooseX::Types::Util::BEGIN@11 # spent 31µs making 1 call to Exporter::import
12
133154µs2126µs
# spent 67µs (9+58) within MooseX::Types::Util::BEGIN@13 which was called # once (9µs+58µs) by MooseX::Types::Base::BEGIN@11 at line 13
use base 'Exporter';
# spent 67µs making 1 call to MooseX::Types::Util::BEGIN@13 # spent 58µs making 1 call to base::import
14
15=head1 DESCRIPTION
16
17This package the exportable functions that many parts in
18L<MooseX::Types> might need.
19
20=cut
21
2211µsour @EXPORT_OK = qw( filter_tags has_available_type_export );
23
24=head1 FUNCTIONS
25
26=head2 filter_tags
27
28Takes a list and returns two references. The first is a hash reference
29containing the tags as keys and the number of their appearance as values.
30The second is an array reference containing all other elements.
31
32=cut
33
34
# spent 35µs (33+2) within MooseX::Types::Util::filter_tags which was called # once (33µs+2µs) by MooseX::Types::import at line 345 of MooseX/Types.pm
sub filter_tags {
3512µs my (@list) = @_;
361800ns my (%tags, @other);
3711µs for (@list) {
381018µs102µs if (/^:(.*)$/) {
# spent 2µs making 10 calls to MooseX::Types::Util::CORE:match, avg 190ns/call
39 $tags{ $1 }++;
40 next;
41 }
42105µs push @other, $_;
43 }
4415µs return \%tags, \@other;
45}
46
47=head2 has_available_type_export
48
49 TypeConstraint | Undef = has_available_type_export($package, $name);
50
51This function allows you to introspect if a given type export is available
52I<at this point in time>. This means that the C<$package> must have imported
53a typeconstraint with the name C<$name>, and it must be still in its symbol
54table.
55
56Two arguments are expected:
57
58=over 4
59
60=item $package
61
62The name of the package to introspect.
63
64=item $name
65
66The name of the type export to introspect.
67
68=back
69
70B<Note> that the C<$name> is the I<exported> name of the type, not the declared
71one. This means that if you use L<Sub::Exporter>s functionality to rename an import
72like this:
73
74 use MyTypes Str => { -as => 'MyStr' };
75
76you would have to introspect this type like this:
77
78 has_available_type_export $package, 'MyStr';
79
80The return value will be either the type constraint that belongs to the export
81or an undefined value.
82
83=cut
84
85sub has_available_type_export {
86 my ($package, $name) = @_;
87
88 my $sub = $package->can($name)
89 or return undef;
90
91 return undef
92 unless blessed $sub && $sub->isa('MooseX::Types::EXPORTED_TYPE_CONSTRAINT');
93
94 return $sub->();
95}
96
97=head1 SEE ALSO
98
99L<MooseX::Types::Moose>, L<Exporter>
100
101=head1 AUTHOR
102
103See L<MooseX::Types/AUTHOR>.
104
105=head1 LICENSE
106
107This program is free software; you can redistribute it and/or modify
108it under the same terms as perl itself.
109
110=cut
111
11218µs1;
# spent 2µs within MooseX::Types::Util::CORE:match which was called 10 times, avg 190ns/call: # 10 times (2µs+0s) by MooseX::Types::Util::filter_tags at line 38 of MooseX/Types/Util.pm, avg 190ns/call
sub MooseX::Types::Util::CORE:match; # xsub