← Index
NYTProf Performance Profile   « block view • line view • sub view »
For 01.HTTP.t
  Run on Tue May 4 15:25:55 2010
Reported on Tue May 4 15:26:14 2010

File /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Meta/TypeConstraint/Registry.pm
Statements Executed 273
Statement Execution Time 871µs
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
2361280µs481µsMoose::Meta::TypeConstraint::Registry::::add_type_constraintMoose::Meta::TypeConstraint::Registry::add_type_constraint
4431166µs219µsMoose::Meta::TypeConstraint::Registry::::get_type_constraintMoose::Meta::TypeConstraint::Registry::get_type_constraint
231190µs125µsMoose::Meta::TypeConstraint::Registry::::has_type_constraintMoose::Meta::TypeConstraint::Registry::has_type_constraint
11113µs16µsMoose::Meta::TypeConstraint::Registry::::BEGIN@4Moose::Meta::TypeConstraint::Registry::BEGIN@4
11112µs21µsMoose::Meta::TypeConstraint::Registry::::BEGIN@5Moose::Meta::TypeConstraint::Registry::BEGIN@5
11112µs54µsMoose::Meta::TypeConstraint::Registry::::BEGIN@14Moose::Meta::TypeConstraint::Registry::BEGIN@14
11111µs323µsMoose::Meta::TypeConstraint::Registry::::newMoose::Meta::TypeConstraint::Registry::new
1117µs33µsMoose::Meta::TypeConstraint::Registry::::BEGIN@8Moose::Meta::TypeConstraint::Registry::BEGIN@8
1117µs120µsMoose::Meta::TypeConstraint::Registry::::BEGIN@6Moose::Meta::TypeConstraint::Registry::BEGIN@6
1112µs2µsMoose::Meta::TypeConstraint::Registry::::__ANON__[:24]Moose::Meta::TypeConstraint::Registry::__ANON__[:24]
0000s0sMoose::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
2package Moose::Meta::TypeConstraint::Registry;
3
4320µs219µs
# spent 16µs (13+3) within Moose::Meta::TypeConstraint::Registry::BEGIN@4 which was called # once (13µ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
5323µs230µs
# spent 21µs (12+9) within Moose::Meta::TypeConstraint::Registry::BEGIN@5 which was called # once (12µs+9µs) by Moose::Util::TypeConstraints::BEGIN@38 at line 5
use warnings;
# spent 21µs making 1 call to Moose::Meta::TypeConstraint::Registry::BEGIN@5 # spent 9µs making 1 call to warnings::import
6328µs2233µs
# spent 120µs (7+113) within Moose::Meta::TypeConstraint::Registry::BEGIN@6 which was called # once (7µs+113µs) by Moose::Util::TypeConstraints::BEGIN@38 at line 6
use metaclass;
# spent 120µs making 1 call to Moose::Meta::TypeConstraint::Registry::BEGIN@6 # spent 113µs making 1 call to metaclass::import
7
8353µs259µs
# spent 33µs (7+26) within Moose::Meta::TypeConstraint::Registry::BEGIN@8 which was called # once (7µs+26µs) by Moose::Util::TypeConstraints::BEGIN@38 at line 8
use Scalar::Util 'blessed';
# spent 33µs making 1 call to Moose::Meta::TypeConstraint::Registry::BEGIN@8 # spent 26µs making 1 call to Exporter::import
9
101700nsour $VERSION = '0.98';
11113µs$VERSION = eval $VERSION;
121300nsour $AUTHORITY = 'cpan:STEVAN';
13
143229µs295µs
# spent 54µs (12+42) within Moose::Meta::TypeConstraint::Registry::BEGIN@14 which was called # once (12µs+42µ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 42µs making 1 call to base::import
15
1613µs2574µs__PACKAGE__->meta->add_attribute('parent_registry' => (
# spent 557µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 17µ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',
2413µ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 { {} }
2514µs2286µs));
# spent 274µ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 323µs (11+312) within Moose::Meta::TypeConstraint::Registry::new which was called # once (11µs+312µs) by Moose::Meta::Attribute::BEGIN@18 at line 58 of Moose/Util/TypeConstraints.pm
sub new {
28310µs my $class = shift;
29 my $self = $class->_new(@_);
# spent 312µs making 1 call to Class::MOP::Object::_new
30 return $self;
31}
32
33
# spent 125µs (90+35) within Moose::Meta::TypeConstraint::Registry::has_type_constraint which was called 23 times, avg 5µs/call: # 23 times (90µs+35µs) by Moose::Util::TypeConstraints::find_type_constraint at line 259 of Moose/Util/TypeConstraints.pm, avg 5µs/call
sub has_type_constraint {
344678µs my ($self, $type_name) = @_;
35 ($type_name and exists $self->type_constraints->{$type_name}) ? 1 : 0
# spent 35µs making 23 calls to Moose::Meta::TypeConstraint::Registry::type_constraints, avg 2µs/call
36}
37
38
# spent 219µs (166+53) within Moose::Meta::TypeConstraint::Registry::get_type_constraint which was called 44 times, avg 5µs/call: # 22 times (75µs+22µs) by Moose::Util::TypeConstraints::find_type_constraint at line 260 of Moose/Util/TypeConstraints.pm, avg 4µs/call # 18 times (79µs+26µs) by Moose::Util::TypeConstraints::_create_type_constraint at line 498 of Moose/Util/TypeConstraints.pm, avg 6µs/call # 4 times (13µs+4µs) by Moose::Meta::Attribute::BEGIN@18 at line 793 of Moose/Util/TypeConstraints.pm, avg 4µs/call
sub get_type_constraint {
39132130µs my ($self, $type_name) = @_;
40 return unless defined $type_name;
41 $self->type_constraints->{$type_name}
# spent 53µs making 44 calls to Moose::Meta::TypeConstraint::Registry::type_constraints, avg 1µs/call
42}
43
44
# spent 481µs (280+201) within Moose::Meta::TypeConstraint::Registry::add_type_constraint which was called 23 times, avg 21µs/call: # 18 times (215µs+155µs) by Moose::Util::TypeConstraints::_create_type_constraint at line 536 of Moose/Util/TypeConstraints.pm, avg 21µs/call # once (18µs+11µs) by Moose::Util::TypeConstraints::register_type_constraint at line 268 of Moose/Util/TypeConstraints.pm # once (13µs+11µs) by Moose::Meta::Attribute::BEGIN@18 at line 731 of Moose/Util/TypeConstraints.pm # once (11µs+8µ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 773 of Moose/Util/TypeConstraints.pm # once (11µs+8µs) by Moose::Meta::Attribute::BEGIN@18 at line 752 of Moose/Util/TypeConstraints.pm
sub add_type_constraint {
4569134µs my ($self, $type) = @_;
46
471130µs69143µs unless ( $type && blessed $type && $type->isa('Moose::Meta::TypeConstraint') ) {
# spent 105µs making 23 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:8], avg 5µs/call # spent 19µs making 23 calls to UNIVERSAL::isa, avg 839ns/call # spent 19µs making 23 calls to Scalar::Util::blessed, avg 817ns/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 32µs making 23 calls to Moose::Meta::TypeConstraint::Registry::type_constraints, avg 1µs/call # spent 27µs making 23 calls to Moose::Meta::TypeConstraint::name, avg 1µs/call
53}
54
55sub 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
64111µs1;
65
66__END__
67
68
69=pod
70
71=head1 NAME
72
73Moose::Meta::TypeConstraint::Registry - registry for type constraints
74
75=head1 DESCRIPTION
76
77This class is a registry that maps type constraint names to
78L<Moose::Meta::TypeConstraint> objects.
79
80Currently, it is only used internally by
81L<Moose::Util::TypeConstraints>, which creates a single global
82registry.
83
84=head1 INHERITANCE
85
86C<Moose::Meta::TypeConstraint::Registry> is a subclass of
87L<Class::MOP::Object>.
88
89=head1 METHODS
90
91=over 4
92
93=item B<< Moose::Meta::TypeConstraint::Registry->new(%options) >>
94
95This creates a new registry object based on the provided C<%options>:
96
97=over 8
98
99=item * parent_registry
100
101This is an optional L<Moose::Meta::TypeConstraint::Registry>
102object.
103
104=item * type_constraints
105
106This is hash reference of type names to type objects. This is
107optional. Constraints can be added to the registry after it is
108created.
109
110=back
111
112=item B<< $registry->get_parent_registry >>
113
114Returns the registry's parent registry, if it has one.
115
116=item B<< $registry->has_parent_registry >>
117
118Returns true if the registry has a parent.
119
120=item B<< $registry->set_parent_registry($registry) >>
121
122Sets the parent registry.
123
124=item B<< $registry->get_type_constraint($type_name) >>
125
126This returns the L<Moose::Meta::TypeConstraint> object from the
127registry for the given name, if one exists.
128
129=item B<< $registry->has_type_constraint($type_name) >>
130
131Returns true if the registry has a type of the given name.
132
133=item B<< $registry->add_type_constraint($type) >>
134
135Adds a new L<Moose::Meta::TypeConstraint> object to the registry.
136
137=item B<< $registry->find_type_constraint($type_name) >>
138
139This method looks in the current registry for the named type. If the
140type is not found, then this method will look in the registry's
141parent, if it has one.
142
143=back
144
145=head1 BUGS
146
147See L<Moose/BUGS> for details on reporting bugs.
148
149=head1 AUTHOR
150
151Stevan Little E<lt>stevan@iinteractive.comE<gt>
152
153=head1 COPYRIGHT AND LICENSE
154
155Copyright 2006-2010 by Infinity Interactive, Inc.
156
157L<http://www.iinteractive.com>
158
159This library is free software; you can redistribute it and/or modify
160it under the same terms as Perl itself.
161
162=cut