← 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:49 2012

Filename/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Meta/TypeConstraint/Parameterizable.pm
StatementsExecuted 27 statements in 593µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1119µs9µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@14Moose::Meta::TypeConstraint::Parameterizable::BEGIN@14
1119µs9µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@2Moose::Meta::TypeConstraint::Parameterizable::BEGIN@2
1118µs88µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@13Moose::Meta::TypeConstraint::Parameterizable::BEGIN@13
1118µs37µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@17Moose::Meta::TypeConstraint::Parameterizable::BEGIN@17
1117µs19µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@10Moose::Meta::TypeConstraint::Parameterizable::BEGIN@10
1117µs10µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@9Moose::Meta::TypeConstraint::Parameterizable::BEGIN@9
1116µs460µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@11Moose::Meta::TypeConstraint::Parameterizable::BEGIN@11
1114µs4µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@15Moose::Meta::TypeConstraint::Parameterizable::BEGIN@15
0000s0sMoose::Meta::TypeConstraint::Parameterizable::::__ANON__[:53]Moose::Meta::TypeConstraint::Parameterizable::__ANON__[:53]
0000s0sMoose::Meta::TypeConstraint::Parameterizable::::_can_coerce_constraint_fromMoose::Meta::TypeConstraint::Parameterizable::_can_coerce_constraint_from
0000s0sMoose::Meta::TypeConstraint::Parameterizable::::_parse_type_parameterMoose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter
0000s0sMoose::Meta::TypeConstraint::Parameterizable::::generate_constraint_forMoose::Meta::TypeConstraint::Parameterizable::generate_constraint_for
0000s0sMoose::Meta::TypeConstraint::Parameterizable::::generate_inline_forMoose::Meta::TypeConstraint::Parameterizable::generate_inline_for
0000s0sMoose::Meta::TypeConstraint::Parameterizable::::parameterizeMoose::Meta::TypeConstraint::Parameterizable::parameterize
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Moose::Meta::TypeConstraint::Parameterizable;
2
# spent 9µs within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@2 which was called: # once (9µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 4
BEGIN {
315µs $Moose::Meta::TypeConstraint::Parameterizable::AUTHORITY = 'cpan:STEVAN';
4124µs19µs}
5{
621µs $Moose::Meta::TypeConstraint::Parameterizable::VERSION = '2.0602';
7}
8
9316µs213µs
# spent 10µs (7+3) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@9 which was called: # once (7µs+3µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 9
use strict;
# spent 10µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@9 # spent 3µs making 1 call to strict::import
10320µs232µs
# spent 19µs (7+12) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@10 which was called: # once (7µs+12µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 10
use warnings;
# spent 19µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@10 # spent 12µs making 1 call to warnings::import
11324µs2913µs
# spent 460µs (6+453) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@11 which was called: # once (6µs+453µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 11
use metaclass;
# spent 460µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@11 # spent 454µs making 1 call to metaclass::import
12
13321µs2167µs
# spent 88µs (8+79) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@13 which was called: # once (8µs+79µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 13
use base 'Moose::Meta::TypeConstraint';
# spent 88µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@13 # spent 79µs making 1 call to base::import
14322µs19µs
# spent 9µs within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@14 which was called: # once (9µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 14
use Moose::Meta::TypeConstraint::Parameterized;
15317µs14µs
# spent 4µs within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@15 which was called: # once (4µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 15
use Moose::Util::TypeConstraints ();
16
173424µs266µs
# spent 37µs (8+29) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@17 which was called: # once (8µs+29µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 17
use Carp 'confess';
# spent 37µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@17 # spent 29µs making 1 call to Exporter::import
18
1916µs3649µs__PACKAGE__->meta->add_attribute('constraint_generator' => (
# spent 616µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 23µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::meta # spent 9µs making 1 call to Class::MOP::_definition_context
20 accessor => 'constraint_generator',
21 predicate => 'has_constraint_generator',
22 Class::MOP::_definition_context(),
23));
24
2514µs3450µs__PACKAGE__->meta->add_attribute('inline_generator' => (
# spent 434µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::meta # spent 6µs making 1 call to Class::MOP::_definition_context
26 accessor => 'inline_generator',
27 predicate => 'has_inline_generator',
28 Class::MOP::_definition_context(),
29));
30
31sub generate_constraint_for {
32 my ($self, $type) = @_;
33
34 return unless $self->has_constraint_generator;
35
36 return $self->constraint_generator->($type->type_parameter)
37 if $type->is_subtype_of($self->name);
38
39 return $self->_can_coerce_constraint_from($type)
40 if $self->has_coercion
41 && $self->coercion->has_coercion_for_type($type->parent->name);
42
43 return;
44}
45
46sub _can_coerce_constraint_from {
47 my ($self, $type) = @_;
48 my $coercion = $self->coercion;
49 my $constraint = $self->constraint_generator->($type->type_parameter);
50 return sub {
51 local $_ = $coercion->coerce($_);
52 $constraint->(@_);
53 };
54}
55
56sub generate_inline_for {
57 my ($self, $type, $val) = @_;
58
59 confess "Can't generate an inline constraint for $type, since none "
60 . "was defined"
61 unless $self->has_inline_generator;
62
63 return '( do { ' . $self->inline_generator->( $self, $type, $val ) . ' } )';
64}
65
66sub _parse_type_parameter {
67 my ($self, $type_parameter) = @_;
68 return Moose::Util::TypeConstraints::find_or_create_isa_type_constraint($type_parameter);
69}
70
71sub parameterize {
72 my ($self, $type_parameter) = @_;
73
74 my $contained_tc = $self->_parse_type_parameter($type_parameter);
75
76 ## The type parameter should be a subtype of the parent's type parameter
77 ## if there is one.
78
79 if(my $parent = $self->parent) {
80 if($parent->can('type_parameter')) {
81 unless ( $contained_tc->is_a_type_of($parent->type_parameter) ) {
82 require Moose;
83 Moose->throw_error("$type_parameter is not a subtype of ".$parent->type_parameter);
84 }
85 }
86 }
87
88 if ( $contained_tc->isa('Moose::Meta::TypeConstraint') ) {
89 my $tc_name = $self->name . '[' . $contained_tc->name . ']';
90 return Moose::Meta::TypeConstraint::Parameterized->new(
91 name => $tc_name,
92 parent => $self,
93 type_parameter => $contained_tc,
94 parameterized_from => $self,
95 );
96 }
97 else {
98 require Moose;
99 Moose->throw_error("The type parameter must be a Moose meta type");
100 }
101}
102
103
10419µs1;
105
106# ABSTRACT: Type constraints which can take a parameter (ArrayRef)
107
- -
110=pod
111
112=head1 NAME
113
114Moose::Meta::TypeConstraint::Parameterizable - Type constraints which can take a parameter (ArrayRef)
115
116=head1 VERSION
117
118version 2.0602
119
120=head1 DESCRIPTION
121
122This class represents a parameterizable type constraint. This is a
123type constraint like C<ArrayRef> or C<HashRef>, that can be
124parameterized and made more specific by specifying a contained
125type. For example, instead of just an C<ArrayRef> of anything, you can
126specify that is an C<ArrayRef[Int]>.
127
128A parameterizable constraint should not be used as an attribute type
129constraint. Instead, when parameterized it creates a
130L<Moose::Meta::TypeConstraint::Parameterized> which should be used.
131
132=head1 INHERITANCE
133
134C<Moose::Meta::TypeConstraint::Parameterizable> is a subclass of
135L<Moose::Meta::TypeConstraint>.
136
137=head1 METHODS
138
139This class is intentionally not documented because the API is
140confusing and needs some work.
141
142=head1 BUGS
143
144See L<Moose/BUGS> for details on reporting bugs.
145
146=head1 AUTHOR
147
148Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details.
149
150=head1 COPYRIGHT AND LICENSE
151
152This software is copyright (c) 2012 by Infinity Interactive, Inc..
153
154This is free software; you can redistribute it and/or modify it under
155the same terms as the Perl 5 programming language system itself.
156
157=cut
158
159
160__END__