← 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/Parameterizable.pm
Statements Executed 153
Statement Execution Time 795µs
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1611225µs3.04msMoose::Meta::TypeConstraint::Parameterizable::::generate_constraint_forMoose::Meta::TypeConstraint::Parameterizable::generate_constraint_for
722215µs5.49msMoose::Meta::TypeConstraint::Parameterizable::::parameterizeMoose::Meta::TypeConstraint::Parameterizable::parameterize
71129µs567µsMoose::Meta::TypeConstraint::Parameterizable::::_parse_type_parameterMoose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter
11118µs20µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@3Moose::Meta::TypeConstraint::Parameterizable::BEGIN@3
11114µs14µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@12Moose::Meta::TypeConstraint::Parameterizable::BEGIN@12
11113µs104µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@5Moose::Meta::TypeConstraint::Parameterizable::BEGIN@5
1117µs16µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@4Moose::Meta::TypeConstraint::Parameterizable::BEGIN@4
1117µs47µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@11Moose::Meta::TypeConstraint::Parameterizable::BEGIN@11
1113µs3µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@13Moose::Meta::TypeConstraint::Parameterizable::BEGIN@13
0000s0sMoose::Meta::TypeConstraint::Parameterizable::::__ANON__[:42]Moose::Meta::TypeConstraint::Parameterizable::__ANON__[:42]
0000s0sMoose::Meta::TypeConstraint::Parameterizable::::_can_coerce_constraint_fromMoose::Meta::TypeConstraint::Parameterizable::_can_coerce_constraint_from
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
3321µs223µs
# spent 20µs (18+3) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@3 which was called # once (18µs+3µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 at line 3
use strict;
# spent 20µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@3 # spent 3µs making 1 call to strict::import
4319µs224µs
# spent 16µs (7+9) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@4 which was called # once (7µs+9µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 at line 4
use warnings;
# spent 16µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@4 # spent 9µs making 1 call to warnings::import
5352µs2196µs
# spent 104µs (13+92) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@5 which was called # once (13µs+92µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 at line 5
use metaclass;
# spent 104µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@5 # spent 92µs making 1 call to metaclass::import
6
71700nsour $VERSION = '0.98';
8114µs$VERSION = eval $VERSION;
91300nsour $AUTHORITY = 'cpan:STEVAN';
10
11323µs287µs
# spent 47µs (7+40) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@11 which was called # once (7µs+40µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 at line 11
use base 'Moose::Meta::TypeConstraint';
# spent 47µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@11 # spent 40µs making 1 call to base::import
12330µs114µs
# spent 14µs within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@12 which was called # once (14µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 at line 12
use Moose::Meta::TypeConstraint::Parameterized;
133266µs13µs
# spent 3µs within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@13 which was called # once (3µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 at line 13
use Moose::Util::TypeConstraints ();
14
1513µs2419µs__PACKAGE__->meta->add_attribute('constraint_generator' => (
16 accessor => 'constraint_generator',
17 predicate => 'has_constraint_generator',
18));
19
20
# spent 3.04ms (225µs+2.81) within Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for which was called 16 times, avg 190µs/call: # 16 times (225µs+2.81ms) by Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint at line 52 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 190µs/call
sub generate_constraint_for {
2166148µs my ($self, $type) = @_;
22
23 return unless $self->has_constraint_generator;
# spent 28µs making 16 calls to Moose::Meta::TypeConstraint::Parameterizable::has_constraint_generator, avg 2µs/call
24
25 return $self->constraint_generator->($type->type_parameter)
# spent 2.56ms making 16 calls to Moose::Meta::TypeConstraint::is_subtype_of, avg 160µs/call # spent 133µs making 5 calls to Moose::Util::TypeConstraints::__ANON__[Moose/Util/TypeConstraints.pm:750], avg 27µs/call # spent 22µs making 16 calls to Moose::Meta::TypeConstraint::name, avg 1µs/call # spent 22µs making 2 calls to Moose::Util::TypeConstraints::__ANON__[Moose/Util/TypeConstraints.pm:771], avg 11µs/call # spent 17µs making 7 calls to Moose::Meta::TypeConstraint::Parameterizable::constraint_generator, avg 2µs/call # spent 9µs making 7 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 1µs/call
26 if $type->is_subtype_of($self->name);
27
28 return $self->_can_coerce_constraint_from($type)
# spent 21µs making 9 calls to Moose::Meta::TypeConstraint::has_coercion, avg 2µs/call
29 if $self->has_coercion
30 && $self->coercion->has_coercion_for_type($type->parent->name);
31
32 return;
33}
34
35sub _can_coerce_constraint_from {
36 my ($self, $type) = @_;
37 my $coercion = $self->coercion;
38 my $constraint = $self->constraint_generator->($type->type_parameter);
39 return sub {
40 local $_ = $coercion->coerce($_);
41 $constraint->(@_);
42 };
43}
44
45
# spent 567µs (29+538) within Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter which was called 7 times, avg 81µs/call: # 7 times (29µs+538µs) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 53, avg 81µs/call
sub _parse_type_parameter {
461427µs my ($self, $type_parameter) = @_;
47 return Moose::Util::TypeConstraints::find_or_create_isa_type_constraint($type_parameter);
# spent 538µs making 7 calls to Moose::Util::TypeConstraints::find_or_create_isa_type_constraint, avg 77µs/call, recursion: max depth 1, time 93µs
48}
49
50
# spent 5.49ms (215µs+5.28) within Moose::Meta::TypeConstraint::Parameterizable::parameterize which was called 7 times, avg 785µs/call: # 4 times (102µs+2.51ms) by MooseX::Types::create_arged_type_constraint at line 430 of MooseX/Types.pm, avg 653µs/call # 3 times (113µs+2.77ms) by Moose::Util::TypeConstraints::_create_parameterized_type_constraint at line 122 of Moose/Util/TypeConstraints.pm, avg 960µs/call
sub parameterize {
5149174µs my ($self, $type_parameter) = @_;
52
53 my $contained_tc = $self->_parse_type_parameter($type_parameter);
# spent 567µs making 7 calls to Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter, avg 81µs/call
54
55 ## The type parameter should be a subtype of the parent's type parameter
56 ## if there is one.
57
5812µs1448µs if(my $parent = $self->parent) {
# spent 33µs making 7 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:8], avg 5µs/call # spent 15µs making 7 calls to Moose::Meta::TypeConstraint::parent, avg 2µs/call
59 if($parent->can('type_parameter')) {
# spent 11µs making 7 calls to UNIVERSAL::can, avg 2µs/call
60 unless ( $contained_tc->is_a_type_of($parent->type_parameter) ) {
61 require Moose;
62 Moose->throw_error("$type_parameter is not a subtype of ".$parent->type_parameter);
63 }
64 }
65 }
66
67 if ( $contained_tc->isa('Moose::Meta::TypeConstraint') ) {
# spent 42µs making 4 calls to MooseX::Types::TypeDecorator::isa, avg 10µs/call # spent 3µs making 3 calls to UNIVERSAL::isa, avg 1µs/call
68 my $tc_name = $self->name . '[' . $contained_tc->name . ']';
# spent 76µs making 4 calls to MooseX::Types::TypeDecorator::AUTOLOAD, avg 19µs/call # spent 13µs making 10 calls to Moose::Meta::TypeConstraint::name, avg 1µs/call
69 return Moose::Meta::TypeConstraint::Parameterized->new(
# spent 4.52ms making 7 calls to Moose::Meta::TypeConstraint::new, avg 645µs/call
70 name => $tc_name,
71 parent => $self,
72 type_parameter => $contained_tc,
73 );
74 }
75 else {
76 require Moose;
77 Moose->throw_error("The type parameter must be a Moose meta type");
78 }
79}
80
81
82114µs1;
83
84__END__
85
86
87=pod
88
89=head1 NAME
90
91Moose::Meta::TypeConstraint::Parameterizable - Type constraints which can take a parameter (ArrayRef)
92
93=head1 DESCRIPTION
94
95This class represents a parameterizable type constraint. This is a
96type constraint like C<ArrayRef> or C<HashRef>, that can be
97parameterized and made more specific by specifying a contained
98type. For example, instead of just an C<ArrayRef> of anything, you can
99specify that is an C<ArrayRef[Int]>.
100
101A parameterizable constraint should not be used as an attribute type
102constraint. Instead, when parameterized it creates a
103L<Moose::Meta::TypeConstraint::Parameterized> which should be used.
104
105=head1 INHERITANCE
106
107C<Moose::Meta::TypeConstraint::Parameterizable> is a subclass of
108L<Moose::Meta::TypeConstraint>.
109
110=head1 METHODS
111
112This class is intentionally not documented because the API is
113confusing and needs some work.
114
115=head1 BUGS
116
117See L<Moose/BUGS> for details on reporting bugs.
118
119=head1 AUTHOR
120
121Stevan Little E<lt>stevan@iinteractive.comE<gt>
122
123=head1 COPYRIGHT AND LICENSE
124
125Copyright 2006-2010 by Infinity Interactive, Inc.
126
127L<http://www.iinteractive.com>
128
129This library is free software; you can redistribute it and/or modify
130it under the same terms as Perl itself.
131
132=cut