Profile of /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Meta/TypeConstraint/Registry.pm

← 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:22:21 2010

File | /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Meta/TypeConstraint/Registry.pm
Statements Executed | 2380
Statement Execution Time | 4.62ms

Subroutines — ordered by exclusive time
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
443 | 2 | 1 | 2.05ms | 2.80ms | Moose::Meta::TypeConstraint::Registry::::has_type_constraintMoose::Meta::TypeConstraint::Registry::has_type_constraint
403 | 4 | 1 | 1.66ms | 2.25ms | Moose::Meta::TypeConstraint::Registry::::get_type_constraintMoose::Meta::TypeConstraint::Registry::get_type_constraint
86 | 7 | 1 | 1.16ms | 1.97ms | Moose::Meta::TypeConstraint::Registry::::add_type_constraintMoose::Meta::TypeConstraint::Registry::add_type_constraint
1 | 1 | 1 | 14µs | 16µs | Moose::Meta::TypeConstraint::Registry::::BEGIN@4Moose::Meta::TypeConstraint::Registry::BEGIN@4
1 | 1 | 1 | 8µs | 327µs | Moose::Meta::TypeConstraint::Registry::::newMoose::Meta::TypeConstraint::Registry::new
1 | 1 | 1 | 8µs | 36µs | Moose::Meta::TypeConstraint::Registry::::BEGIN@8Moose::Meta::TypeConstraint::Registry::BEGIN@8
1 | 1 | 1 | 7µs | 54µs | Moose::Meta::TypeConstraint::Registry::::BEGIN@14Moose::Meta::TypeConstraint::Registry::BEGIN@14
1 | 1 | 1 | 7µs | 16µs | Moose::Meta::TypeConstraint::Registry::::BEGIN@5Moose::Meta::TypeConstraint::Registry::BEGIN@5
1 | 1 | 1 | 6µs | 116µs | Moose::Meta::TypeConstraint::Registry::::BEGIN@6Moose::Meta::TypeConstraint::Registry::BEGIN@6
1 | 1 | 1 | 2µs | 2µs | Moose::Meta::TypeConstraint::Registry::::__ANON__[:24]Moose::Meta::TypeConstraint::Registry::__ANON__[:24]
0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeConstraint::Registry::::find_type_constraintMoose::Meta::TypeConstraint::Registry::find_type_constraint

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  |
2 |  |  |  |  | package Moose::Meta::TypeConstraint::Registry;
3 |  |  |  |  |
4 | 3 | 20µs | 2 | 19µs | # spent 16µs (14+3) within Moose::Meta::TypeConstraint::Registry::BEGIN@4 which was called # once (14µs+3µs) by Moose::Util::TypeConstraints::BEGIN@38 at line 4 use strict; # spent 16µs making 1 call to Moose::Meta::TypeConstraint::Registry::BEGIN@4 # spent 3µs making 1 call to strict::import
5 | 3 | 25µs | 2 | 25µs | # spent 16µs (7+9) within Moose::Meta::TypeConstraint::Registry::BEGIN@5 which was called # once (7µs+9µs) by Moose::Util::TypeConstraints::BEGIN@38 at line 5 use warnings; # spent 16µs making 1 call to Moose::Meta::TypeConstraint::Registry::BEGIN@5 # spent 9µs making 1 call to warnings::import
6 | 3 | 27µs | 2 | 227µs | # spent 116µs (6+110) within Moose::Meta::TypeConstraint::Registry::BEGIN@6 which was called # once (6µs+110µs) by Moose::Util::TypeConstraints::BEGIN@38 at line 6 use metaclass; # spent 116µs making 1 call to Moose::Meta::TypeConstraint::Registry::BEGIN@6 # spent 110µs making 1 call to metaclass::import
7 |  |  |  |  |
8 | 3 | 44µs | 2 | 65µs | # spent 36µs (8+29) within Moose::Meta::TypeConstraint::Registry::BEGIN@8 which was called # once (8µs+29µs) by Moose::Util::TypeConstraints::BEGIN@38 at line 8 use Scalar::Util 'blessed'; # spent 36µs making 1 call to Moose::Meta::TypeConstraint::Registry::BEGIN@8 # spent 29µs making 1 call to Exporter::import
9 |  |  |  |  |
10 | 1 | 700ns |  |  | our $VERSION = '0.98';
11 | 1 | 14µs |  |  | $VERSION = eval $VERSION;
12 | 1 | 300ns |  |  | our $AUTHORITY = 'cpan:STEVAN';
13 |  |  |  |  |
14 | 3 | 237µs | 2 | 100µs | # spent 54µs (7+47) within Moose::Meta::TypeConstraint::Registry::BEGIN@14 which was called # once (7µs+47µs) by Moose::Util::TypeConstraints::BEGIN@38 at line 14 use base 'Class::MOP::Object'; # spent 54µs making 1 call to Moose::Meta::TypeConstraint::Registry::BEGIN@14 # spent 47µs making 1 call to base::import
15 |  |  |  |  |
16 | 1 | 3µs | 2 | 585µs | __PACKAGE__->meta->add_attribute('parent_registry' => ( # spent 569µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 16µs making 1 call to Moose::Meta::TypeConstraint::Registry::meta
17 |  |  |  |  | reader => 'get_parent_registry',
18 |  |  |  |  | writer => 'set_parent_registry',
19 |  |  |  |  | predicate => 'has_parent_registry',
20 |  |  |  |  | ));
21 |  |  |  |  |
22 |  |  |  |  | __PACKAGE__->meta->add_attribute('type_constraints' => (
23 |  |  |  |  | reader => 'type_constraints',
24 | 1 | 3µs |  |  | # spent 2µs within Moose::Meta::TypeConstraint::Registry::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Meta/TypeConstraint/Registry.pm:24] which was called # once (2µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 53 of Class/MOP/Mixin/AttributeCore.pm default => sub { {} }
25 | 1 | 3µs | 2 | 276µs | )); # spent 265µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Moose::Meta::TypeConstraint::Registry::meta
26 |  |  |  |  |
27 |  |  |  |  | # spent 327µs (8+319) within Moose::Meta::TypeConstraint::Registry::new which was called # once (8µs+319µs) by Moose::Meta::Attribute::BEGIN@18 at line 58 of Moose/Util/TypeConstraints.pm sub new {
28 | 3 | 7µs |  |  | my $class = shift;
29 |  |  |  |  | my $self = $class->_new(@_); # spent 319µs making 1 call to Class::MOP::Object::_new
30 |  |  |  |  | return $self;
31 |  |  |  |  | }
32 |  |  |  |  |
33 |  |  |  |  | # spent 2.80ms (2.05+758µs) within Moose::Meta::TypeConstraint::Registry::has_type_constraint which was called 443 times, avg 6µs/call: # 440 times (2.03ms+753µs) by Moose::Util::TypeConstraints::find_type_constraint at line 259 of Moose/Util/TypeConstraints.pm, avg 6µs/call # 3 times (14µs+4µs) by Moose::Util::TypeConstraints::create_parameterized_type_constraint at line 107 of Moose/Util/TypeConstraints.pm, avg 6µs/call sub has_type_constraint {
34 | 886 | 1.76ms |  |  | my ($self, $type_name) = @_;
35 |  |  |  |  | ($type_name and exists $self->type_constraints->{$type_name}) ? 1 : 0 # spent 758µs making 443 calls to Moose::Meta::TypeConstraint::Registry::type_constraints, avg 2µs/call
36 |  |  |  |  | }
37 |  |  |  |  |
38 |  |  |  |  | # spent 2.25ms (1.66+589µs) within Moose::Meta::TypeConstraint::Registry::get_type_constraint which was called 403 times, avg 6µs/call: # 367 times (1.48ms+402µs) by Moose::Util::TypeConstraints::find_type_constraint at line 260 of Moose/Util/TypeConstraints.pm, avg 5µs/call # 29 times (150µs+180µs) by Moose::Util::TypeConstraints::_create_type_constraint at line 498 of Moose/Util/TypeConstraints.pm, avg 11µs/call # 4 times (14µs+5µs) by Moose::Meta::Attribute::BEGIN@18 at line 793 of Moose/Util/TypeConstraints.pm, avg 5µs/call # 3 times (13µs+3µs) by Moose::Util::TypeConstraints::create_parameterized_type_constraint at line 108 of Moose/Util/TypeConstraints.pm, avg 5µs/call sub get_type_constraint {
39 | 1209 | 1.34ms |  |  | my ($self, $type_name) = @_;
40 |  |  |  |  | return unless defined $type_name;
41 | 1 | 26µs | 413 | 589µs | $self->type_constraints->{$type_name} # spent 449µs making 403 calls to Moose::Meta::TypeConstraint::Registry::type_constraints, avg 1µs/call # spent 140µs making 10 calls to MooseX::Types::TypeDecorator::__ANON__[MooseX/Types/TypeDecorator.pm:20], avg 14µs/call
42 |  |  |  |  | }
43 |  |  |  |  |
44 |  |  |  |  | # spent 1.97ms (1.16+808µs) within Moose::Meta::TypeConstraint::Registry::add_type_constraint which was called 86 times, avg 23µs/call: # 49 times (694µs+459µs) by Moose::Util::TypeConstraints::register_type_constraint at line 268 of Moose/Util/TypeConstraints.pm, avg 24µs/call # 29 times (348µs+258µs) by Moose::Util::TypeConstraints::_create_type_constraint at line 536 of Moose/Util/TypeConstraints.pm, avg 21µs/call # 4 times (74µs+55µs) by Moose::Util::TypeConstraints::find_or_parse_type_constraint at line 231 of Moose/Util/TypeConstraints.pm, avg 32µs/call # once (13µs+11µs) by Moose::Meta::Attribute::BEGIN@18 at line 731 of Moose/Util/TypeConstraints.pm # once (12µs+9µs) by Moose::Meta::Attribute::BEGIN@18 at line 790 of Moose/Util/TypeConstraints.pm # once (11µs+8µs) by Moose::Meta::Attribute::BEGIN@18 at line 752 of Moose/Util/TypeConstraints.pm # once (11µs+8µs) by Moose::Meta::Attribute::BEGIN@18 at line 773 of Moose/Util/TypeConstraints.pm sub add_type_constraint {
45 | 258 | 565µs |  |  | my ($self, $type) = @_;
46 |  |  |  |  |
47 | 1 | 540µs | 258 | 581µs | unless ( $type && blessed $type && $type->isa('Moose::Meta::TypeConstraint') ) { # spent 417µs making 86 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:8], avg 5µs/call # spent 83µs making 86 calls to Scalar::Util::blessed, avg 964ns/call # spent 81µs making 86 calls to UNIVERSAL::isa, avg 941ns/call
48 |  |  |  |  | require Moose;
49 |  |  |  |  | Moose->throw_error("No type supplied / type is not a valid type constraint");
50 |  |  |  |  | }
51 |  |  |  |  |
52 |  |  |  |  | $self->type_constraints->{$type->name} = $type; # spent 119µs making 86 calls to Moose::Meta::TypeConstraint::Registry::type_constraints, avg 1µs/call # spent 107µs making 86 calls to Moose::Meta::TypeConstraint::name, avg 1µs/call
53 |  |  |  |  | }
54 |  |  |  |  |
55 |  |  |  |  | sub find_type_constraint {
56 |  |  |  |  | my ($self, $type_name) = @_;
57 |  |  |  |  | return $self->get_type_constraint($type_name)
58 |  |  |  |  | if $self->has_type_constraint($type_name);
59 |  |  |  |  | return $self->get_parent_registry->find_type_constraint($type_name)
60 |  |  |  |  | if $self->has_parent_registry;
61 |  |  |  |  | return;
62 |  |  |  |  | }
63 |  |  |  |  |
64 | 1 | 10µs |  |  | 1;
65 |  |  |  |  |
66 |  |  |  |  | __END__
67 |  |  |  |  |
68 |  |  |  |  |
69 |  |  |  |  | =pod
70 |  |  |  |  |
71 |  |  |  |  | =head1 NAME
72 |  |  |  |  |
73 |  |  |  |  | Moose::Meta::TypeConstraint::Registry - registry for type constraints
74 |  |  |  |  |
75 |  |  |  |  | =head1 DESCRIPTION
76 |  |  |  |  |
77 |  |  |  |  | This class is a registry that maps type constraint names to
78 |  |  |  |  | L<Moose::Meta::TypeConstraint> objects.
79 |  |  |  |  |
80 |  |  |  |  | Currently, it is only used internally by
81 |  |  |  |  | L<Moose::Util::TypeConstraints>, which creates a single global
82 |  |  |  |  | registry.
83 |  |  |  |  |
84 |  |  |  |  | =head1 INHERITANCE
85 |  |  |  |  |
86 |  |  |  |  | C<Moose::Meta::TypeConstraint::Registry> is a subclass of
87 |  |  |  |  | L<Class::MOP::Object>.
88 |  |  |  |  |
89 |  |  |  |  | =head1 METHODS
90 |  |  |  |  |
91 |  |  |  |  | =over 4
92 |  |  |  |  |
93 |  |  |  |  | =item B<< Moose::Meta::TypeConstraint::Registry->new(%options) >>
94 |  |  |  |  |
95 |  |  |  |  | This creates a new registry object based on the provided C<%options>:
96 |  |  |  |  |
97 |  |  |  |  | =over 8
98 |  |  |  |  |
99 |  |  |  |  | =item * parent_registry
100 |  |  |  |  |
101 |  |  |  |  | This is an optional L<Moose::Meta::TypeConstraint::Registry>
102 |  |  |  |  | object.
103 |  |  |  |  |
104 |  |  |  |  | =item * type_constraints
105 |  |  |  |  |
106 |  |  |  |  | This is hash reference of type names to type objects. This is
107 |  |  |  |  | optional. Constraints can be added to the registry after it is
108 |  |  |  |  | created.
109 |  |  |  |  |
110 |  |  |  |  | =back
111 |  |  |  |  |
112 |  |  |  |  | =item B<< $registry->get_parent_registry >>
113 |  |  |  |  |
114 |  |  |  |  | Returns the registry's parent registry, if it has one.
115 |  |  |  |  |
116 |  |  |  |  | =item B<< $registry->has_parent_registry >>
117 |  |  |  |  |
118 |  |  |  |  | Returns true if the registry has a parent.
119 |  |  |  |  |
120 |  |  |  |  | =item B<< $registry->set_parent_registry($registry) >>
121 |  |  |  |  |
122 |  |  |  |  | Sets the parent registry.
123 |  |  |  |  |
124 |  |  |  |  | =item B<< $registry->get_type_constraint($type_name) >>
125 |  |  |  |  |
126 |  |  |  |  | This returns the L<Moose::Meta::TypeConstraint> object from the
127 |  |  |  |  | registry for the given name, if one exists.
128 |  |  |  |  |
129 |  |  |  |  | =item B<< $registry->has_type_constraint($type_name) >>
130 |  |  |  |  |
131 |  |  |  |  | Returns true if the registry has a type of the given name.
132 |  |  |  |  |
133 |  |  |  |  | =item B<< $registry->add_type_constraint($type) >>
134 |  |  |  |  |
135 |  |  |  |  | Adds a new L<Moose::Meta::TypeConstraint> object to the registry.
136 |  |  |  |  |
137 |  |  |  |  | =item B<< $registry->find_type_constraint($type_name) >>
138 |  |  |  |  |
139 |  |  |  |  | This method looks in the current registry for the named type. If the
140 |  |  |  |  | type is not found, then this method will look in the registry's
141 |  |  |  |  | parent, if it has one.
142 |  |  |  |  |
143 |  |  |  |  | =back
144 |  |  |  |  |
145 |  |  |  |  | =head1 BUGS
146 |  |  |  |  |
147 |  |  |  |  | See L<Moose/BUGS> for details on reporting bugs.
148 |  |  |  |  |
149 |  |  |  |  | =head1 AUTHOR
150 |  |  |  |  |
151 |  |  |  |  | Stevan Little E<lt>stevan@iinteractive.comE<gt>
152 |  |  |  |  |
153 |  |  |  |  | =head1 COPYRIGHT AND LICENSE
154 |  |  |  |  |
155 |  |  |  |  | Copyright 2006-2010 by Infinity Interactive, Inc.
156 |  |  |  |  |
157 |  |  |  |  | L<http://www.iinteractive.com>
158 |  |  |  |  |
159 |  |  |  |  | This library is free software; you can redistribute it and/or modify
160 |  |  |  |  | it under the same terms as Perl itself.
161 |  |  |  |  |
162 |  |  |  |  | =cut