Profile of Moose/Meta/TypeConstraint/Role.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For xt/tapper-mcp-scheduler-with-db-longrun.t
Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:22:35 2012

Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Meta/TypeConstraint/Role.pm
Statements | Executed 87 statements in 877µs

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
4 | 1 | 1 | 128µs | 2.14ms | Moose::Meta::TypeConstraint::Role::::newMoose::Meta::TypeConstraint::Role::new
4 | 1 | 1 | 46µs | 73µs | Moose::Meta::TypeConstraint::Role::::__ANON__[:32]Moose::Meta::TypeConstraint::Role::__ANON__[:32]
4 | 1 | 1 | 45µs | 64µs | Moose::Meta::TypeConstraint::Role::::_create_hand_optimized_type_constraintMoose::Meta::TypeConstraint::Role::_create_hand_optimized_type_constraint
1 | 1 | 1 | 10µs | 10µs | Moose::Meta::TypeConstraint::Role::::BEGIN@2Moose::Meta::TypeConstraint::Role::BEGIN@2
1 | 1 | 1 | 10µs | 33µs | Moose::Meta::TypeConstraint::Role::::BEGIN@13Moose::Meta::TypeConstraint::Role::BEGIN@13
1 | 1 | 1 | 9µs | 556µs | Moose::Meta::TypeConstraint::Role::::BEGIN@11Moose::Meta::TypeConstraint::Role::BEGIN@11
1 | 1 | 1 | 9µs | 13µs | Moose::Meta::TypeConstraint::Role::::BEGIN@9Moose::Meta::TypeConstraint::Role::BEGIN@9
1 | 1 | 1 | 9µs | 25µs | Moose::Meta::TypeConstraint::Role::::BEGIN@10Moose::Meta::TypeConstraint::Role::BEGIN@10
1 | 1 | 1 | 7µs | 82µs | Moose::Meta::TypeConstraint::Role::::BEGIN@17Moose::Meta::TypeConstraint::Role::BEGIN@17
1 | 1 | 1 | 7µs | 34µs | Moose::Meta::TypeConstraint::Role::::BEGIN@14Moose::Meta::TypeConstraint::Role::BEGIN@14
1 | 1 | 1 | 4µs | 4µs | Moose::Meta::TypeConstraint::Role::::BEGIN@15Moose::Meta::TypeConstraint::Role::BEGIN@15
0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeConstraint::Role::::__ANON__[:40]Moose::Meta::TypeConstraint::Role::__ANON__[:40]
0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeConstraint::Role::::__ANON__[:56]Moose::Meta::TypeConstraint::Role::__ANON__[:56]
0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeConstraint::Role::::create_child_typeMoose::Meta::TypeConstraint::Role::create_child_type
0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeConstraint::Role::::equalsMoose::Meta::TypeConstraint::Role::equals
0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeConstraint::Role::::is_a_type_ofMoose::Meta::TypeConstraint::Role::is_a_type_of
0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeConstraint::Role::::is_subtype_ofMoose::Meta::TypeConstraint::Role::is_subtype_of
0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeConstraint::Role::::parentsMoose::Meta::TypeConstraint::Role::parents

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

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package Moose::Meta::TypeConstraint::Role;
2 |  |  |  |  | # spent 10µs within Moose::Meta::TypeConstraint::Role::BEGIN@2 which was called: # once (10µs+0s) by Moose::Util::TypeConstraints::BEGIN@37 at line 4 BEGIN {
3 | 1 | 7µs |  |  | $Moose::Meta::TypeConstraint::Role::AUTHORITY = 'cpan:STEVAN';
4 | 1 | 23µs | 1 | 10µs | } # spent 10µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@2
5 |  |  |  |  | {
6 | 2 | 1µs |  |  | $Moose::Meta::TypeConstraint::Role::VERSION = '2.0602';
7 |  |  |  |  | }
8 |  |  |  |  |
9 | 3 | 18µs | 2 | 18µs | # spent 13µs (9+5) within Moose::Meta::TypeConstraint::Role::BEGIN@9 which was called: # once (9µs+5µs) by Moose::Util::TypeConstraints::BEGIN@37 at line 9 use strict; # spent 13µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@9 # spent 5µs making 1 call to strict::import
10 | 3 | 18µs | 2 | 41µs | # spent 25µs (9+16) within Moose::Meta::TypeConstraint::Role::BEGIN@10 which was called: # once (9µs+16µs) by Moose::Util::TypeConstraints::BEGIN@37 at line 10 use warnings; # spent 25µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@10 # spent 16µs making 1 call to warnings::import
11 | 3 | 26µs | 2 | 1.10ms | # spent 556µs (9+547) within Moose::Meta::TypeConstraint::Role::BEGIN@11 which was called: # once (9µs+547µs) by Moose::Util::TypeConstraints::BEGIN@37 at line 11 use metaclass; # spent 556µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@11 # spent 547µs making 1 call to metaclass::import
12 |  |  |  |  |
13 | 3 | 21µs | 2 | 56µs | # spent 33µs (10+23) within Moose::Meta::TypeConstraint::Role::BEGIN@13 which was called: # once (10µs+23µs) by Moose::Util::TypeConstraints::BEGIN@37 at line 13 use B; # spent 33µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@13 # spent 23µs making 1 call to Exporter::import
14 | 3 | 19µs | 2 | 61µs | # spent 34µs (7+27) within Moose::Meta::TypeConstraint::Role::BEGIN@14 which was called: # once (7µs+27µs) by Moose::Util::TypeConstraints::BEGIN@37 at line 14 use Scalar::Util 'blessed'; # spent 34µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@14 # spent 27µs making 1 call to Exporter::import
15 | 3 | 17µs | 1 | 4µs | # spent 4µs within Moose::Meta::TypeConstraint::Role::BEGIN@15 which was called: # once (4µs+0s) by Moose::Util::TypeConstraints::BEGIN@37 at line 15 use Moose::Util::TypeConstraints (); # spent 4µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@15
16 |  |  |  |  |
17 | 3 | 506µs | 2 | 156µs | # spent 82µs (7+75) within Moose::Meta::TypeConstraint::Role::BEGIN@17 which was called: # once (7µs+75µs) by Moose::Util::TypeConstraints::BEGIN@37 at line 17 use base 'Moose::Meta::TypeConstraint'; # spent 82µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@17 # spent 75µs making 1 call to base::import
18 |  |  |  |  |
19 | 1 | 6µs | 3 | 468µs | __PACKAGE__->meta->add_attribute('role' => ( # spent 441µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 18µs making 1 call to Moose::Meta::TypeConstraint::Role::meta # spent 8µs making 1 call to Class::MOP::_definition_context
20 |  |  |  |  | reader => 'role',
21 |  |  |  |  | Class::MOP::_definition_context(),
22 |  |  |  |  | ));
23 |  |  |  |  |
24 |  |  |  |  | # spent 73µs (46+27) within Moose::Meta::TypeConstraint::Role::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Meta/TypeConstraint/Role.pm:32] which was called 4 times, avg 18µs/call: # 4 times (46µs+27µs) by Moose::Meta::TypeConstraint::_inline_check at line 225 of Moose/Meta/TypeConstraint.pm, avg 18µs/call my $inliner = sub {
25 | 12 | 59µs |  |  | my $self = shift;
26 |  |  |  |  | my $val = shift;
27 |  |  |  |  |
28 |  |  | 8 | 27µs | return 'Moose::Util::does_role(' # spent 16µs making 4 calls to B::perlstring, avg 4µs/call # spent 11µs making 4 calls to Moose::Meta::TypeConstraint::Role::role, avg 3µs/call
29 |  |  |  |  | . $val . ', '
30 |  |  |  |  | . B::perlstring($self->role)
31 |  |  |  |  | . ')';
32 | 1 | 2µs |  |  | };
33 |  |  |  |  |
34 |  |  |  |  | # spent 2.14ms (128µs+2.01) within Moose::Meta::TypeConstraint::Role::new which was called 4 times, avg 535µs/call: # 4 times (128µs+2.01ms) by Moose::Util::TypeConstraints::create_role_type_constraint at line 224 of Moose/Util/TypeConstraints.pm, avg 535µs/call sub new {
35 | 36 | 110µs |  |  | my ( $class, %args ) = @_;
36 |  |  |  |  |
37 |  |  | 4 | 70µs | $args{parent} = Moose::Util::TypeConstraints::find_type_constraint('Object'); # spent 70µs making 4 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 17µs/call
38 |  |  |  |  |
39 |  |  |  |  | my $role_name = $args{role};
40 |  |  |  |  | $args{constraint} = sub { Moose::Util::does_role( $_[0], $role_name ) };
41 |  |  |  |  |
42 |  |  |  |  | $args{inlined} = $inliner;
43 |  |  |  |  |
44 |  |  | 4 | 1.78ms | my $self = $class->SUPER::new( \%args ); # spent 1.78ms making 4 calls to Moose::Meta::TypeConstraint::new, avg 444µs/call
45 |  |  |  |  |
46 |  |  | 4 | 64µs | $self->_create_hand_optimized_type_constraint; # spent 64µs making 4 calls to Moose::Meta::TypeConstraint::Role::_create_hand_optimized_type_constraint, avg 16µs/call
47 |  |  | 4 | 100µs | $self->compile_type_constraint(); # spent 100µs making 4 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 25µs/call
48 |  |  |  |  |
49 |  |  |  |  | return $self;
50 |  |  |  |  | }
51 |  |  |  |  |
52 |  |  |  |  | # spent 64µs (45+19) within Moose::Meta::TypeConstraint::Role::_create_hand_optimized_type_constraint which was called 4 times, avg 16µs/call: # 4 times (45µs+19µs) by Moose::Meta::TypeConstraint::Role::new at line 46, avg 16µs/call sub _create_hand_optimized_type_constraint {
53 | 12 | 36µs |  |  | my $self = shift;
54 |  |  | 4 | 6µs | my $role = $self->role; # spent 6µs making 4 calls to Moose::Meta::TypeConstraint::Role::role, avg 1µs/call
55 |  |  |  |  | $self->hand_optimized_type_constraint(
56 |  |  |  |  | sub { Moose::Util::does_role($_[0], $role) }
57 |  |  | 4 | 13µs | ); # spent 13µs making 4 calls to Moose::Meta::TypeConstraint::hand_optimized_type_constraint, avg 3µs/call
58 |  |  |  |  | }
59 |  |  |  |  |
60 |  |  |  |  | sub parents {
61 |  |  |  |  | my $self = shift;
62 |  |  |  |  | return (
63 |  |  |  |  | $self->parent,
64 |  |  |  |  | map {
65 |  |  |  |  | # FIXME find_type_constraint might find a TC named after the role but that isn't really it
66 |  |  |  |  | # I did this anyway since it's a convention that preceded TypeConstraint::Role, and it should DWIM
67 |  |  |  |  | # if anybody thinks this problematic please discuss on IRC.
68 |  |  |  |  | # a possible fix is to add by attr indexing to the type registry to find types of a certain property
69 |  |  |  |  | # regardless of their name
70 |  |  |  |  | Moose::Util::TypeConstraints::find_type_constraint($_)
71 |  |  |  |  | ||
72 |  |  |  |  | __PACKAGE__->new( role => $_, name => "__ANON__" )
73 |  |  |  |  | } @{ Class::MOP::class_of($self->role)->get_roles },
74 |  |  |  |  | );
75 |  |  |  |  | }
76 |  |  |  |  |
77 |  |  |  |  | sub equals {
78 |  |  |  |  | my ( $self, $type_or_name ) = @_;
79 |  |  |  |  |
80 |  |  |  |  | my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
81 |  |  |  |  |
82 |  |  |  |  | return unless defined $other;
83 |  |  |  |  | return unless $other->isa(__PACKAGE__);
84 |  |  |  |  |
85 |  |  |  |  | return $self->role eq $other->role;
86 |  |  |  |  | }
87 |  |  |  |  |
88 |  |  |  |  | sub is_a_type_of {
89 |  |  |  |  | my ($self, $type_or_name) = @_;
90 |  |  |  |  |
91 |  |  |  |  | my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
92 |  |  |  |  |
93 |  |  |  |  | ($self->equals($type) || $self->is_subtype_of($type_or_name));
94 |  |  |  |  | }
95 |  |  |  |  |
96 |  |  |  |  | sub is_subtype_of {
97 |  |  |  |  | my ($self, $type_or_name_or_role ) = @_;
98 |  |  |  |  |
99 |  |  |  |  | if ( not ref $type_or_name_or_role ) {
100 |  |  |  |  | # it might be a role
101 |  |  |  |  | return 1 if Class::MOP::class_of($self->role)->does_role( $type_or_name_or_role );
102 |  |  |  |  | }
103 |  |  |  |  |
104 |  |  |  |  | my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name_or_role);
105 |  |  |  |  |
106 |  |  |  |  | return unless defined $type;
107 |  |  |  |  |
108 |  |  |  |  | if ( $type->isa(__PACKAGE__) ) {
109 |  |  |  |  | # if $type_or_name_or_role isn't a role, it might be the TC name of another ::Role type
110 |  |  |  |  | # or it could also just be a type object in this branch
111 |  |  |  |  | return Class::MOP::class_of($self->role)->does_role( $type->role );
112 |  |  |  |  | } else {
113 |  |  |  |  | # the only other thing we are a subtype of is Object
114 |  |  |  |  | $self->SUPER::is_subtype_of($type);
115 |  |  |  |  | }
116 |  |  |  |  | }
117 |  |  |  |  |
118 |  |  |  |  | sub create_child_type {
119 |  |  |  |  | my ($self, @args) = @_;
120 |  |  |  |  | return Moose::Meta::TypeConstraint->new(@args, parent => $self);
121 |  |  |  |  | }
122 |  |  |  |  |
123 | 1 | 8µs |  |  | 1;
124 |  |  |  |  |
125 |  |  |  |  | # ABSTRACT: Role/TypeConstraint parallel hierarchy
126 |  |  |  |  |
- - |  |  |  |  |
129 |  |  |  |  | =pod
130 |  |  |  |  |
131 |  |  |  |  | =head1 NAME
132 |  |  |  |  |
133 |  |  |  |  | Moose::Meta::TypeConstraint::Role - Role/TypeConstraint parallel hierarchy
134 |  |  |  |  |
135 |  |  |  |  | =head1 VERSION
136 |  |  |  |  |
137 |  |  |  |  | version 2.0602
138 |  |  |  |  |
139 |  |  |  |  | =head1 DESCRIPTION
140 |  |  |  |  |
141 |  |  |  |  | This class represents type constraints for a role.
142 |  |  |  |  |
143 |  |  |  |  | =head1 INHERITANCE
144 |  |  |  |  |
145 |  |  |  |  | C<Moose::Meta::TypeConstraint::Role> is a subclass of
146 |  |  |  |  | L<Moose::Meta::TypeConstraint>.
147 |  |  |  |  |
148 |  |  |  |  | =head1 METHODS
149 |  |  |  |  |
150 |  |  |  |  | =over 4
151 |  |  |  |  |
152 |  |  |  |  | =item B<< Moose::Meta::TypeConstraint::Role->new(%options) >>
153 |  |  |  |  |
154 |  |  |  |  | This creates a new role type constraint based on the given
155 |  |  |  |  | C<%options>.
156 |  |  |  |  |
157 |  |  |  |  | It takes the same options as its parent, with two exceptions. First,
158 |  |  |  |  | it requires an additional option, C<role>, which is name of the
159 |  |  |  |  | constraint's role. Second, it automatically sets the parent to the
160 |  |  |  |  | C<Object> type.
161 |  |  |  |  |
162 |  |  |  |  | The constructor also overrides the hand optimized type constraint with
163 |  |  |  |  | one it creates internally.
164 |  |  |  |  |
165 |  |  |  |  | =item B<< $constraint->role >>
166 |  |  |  |  |
167 |  |  |  |  | Returns the role name associated with the constraint.
168 |  |  |  |  |
169 |  |  |  |  | =item B<< $constraint->parents >>
170 |  |  |  |  |
171 |  |  |  |  | Returns all the type's parent types, corresponding to the roles that
172 |  |  |  |  | its role does.
173 |  |  |  |  |
174 |  |  |  |  | =item B<< $constraint->is_subtype_of($type_name_or_object) >>
175 |  |  |  |  |
176 |  |  |  |  | If the given type is also a role type, then this checks that the
177 |  |  |  |  | type's role does the other type's role.
178 |  |  |  |  |
179 |  |  |  |  | Otherwise it falls back to the implementation in
180 |  |  |  |  | L<Moose::Meta::TypeConstraint>.
181 |  |  |  |  |
182 |  |  |  |  | =item B<< $constraint->create_child_type(%options) >>
183 |  |  |  |  |
184 |  |  |  |  | This returns a new L<Moose::Meta::TypeConstraint> object with the type
185 |  |  |  |  | as its parent.
186 |  |  |  |  |
187 |  |  |  |  | Note that it does I<not> return a C<Moose::Meta::TypeConstraint::Role>
188 |  |  |  |  | object!
189 |  |  |  |  |
190 |  |  |  |  | =back
191 |  |  |  |  |
192 |  |  |  |  | =head1 BUGS
193 |  |  |  |  |
194 |  |  |  |  | See L<Moose/BUGS> for details on reporting bugs.
195 |  |  |  |  |
196 |  |  |  |  | =head1 AUTHOR
197 |  |  |  |  |
198 |  |  |  |  | Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details.
199 |  |  |  |  |
200 |  |  |  |  | =head1 COPYRIGHT AND LICENSE
201 |  |  |  |  |
202 |  |  |  |  | This software is copyright (c) 2012 by Infinity Interactive, Inc..
203 |  |  |  |  |
204 |  |  |  |  | This is free software; you can redistribute it and/or modify it under
205 |  |  |  |  | the same terms as the Perl 5 programming language system itself.
206 |  |  |  |  |
207 |  |  |  |  | =cut
208 |  |  |  |  |
209 |  |  |  |  |
210 |  |  |  |  | __END__