File | /usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types/TypeDecorator.pm |
Statements Executed | 1789 |
Statement Execution Time | 4.45ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 1.28ms | 1.49ms | BEGIN@7 | MooseX::Types::TypeDecorator::
94 | 8 | 5 | 1.11ms | 4.41ms | AUTOLOAD | MooseX::Types::TypeDecorator::
179 | 3 | 1 | 719µs | 818µs | __type_constraint | MooseX::Types::TypeDecorator::
64 | 1 | 1 | 616µs | 1.01ms | new | MooseX::Types::TypeDecorator::
94 | 1 | 2 | 480µs | 480µs | CORE:match (opcode) | MooseX::Types::TypeDecorator::
62 | 8 | 4 | 429µs | 771µs | __ANON__[:20] | MooseX::Types::TypeDecorator::
23 | 4 | 4 | 153µs | 270µs | isa | MooseX::Types::TypeDecorator::
30 | 21 | 1 | 21µs | 21µs | DESTROY | MooseX::Types::TypeDecorator::
1 | 1 | 1 | 15µs | 24µs | BEGIN@4 | MooseX::Types::TypeDecorator::
1 | 1 | 1 | 14µs | 17µs | BEGIN@3 | MooseX::Types::TypeDecorator::
1 | 1 | 1 | 14µs | 68µs | BEGIN@12 | MooseX::Types::TypeDecorator::
1 | 1 | 1 | 12µs | 45µs | BEGIN@10 | MooseX::Types::TypeDecorator::
1 | 1 | 1 | 12µs | 12µs | BEGIN@9 | MooseX::Types::TypeDecorator::
1 | 1 | 1 | 4µs | 4µs | BEGIN@8 | MooseX::Types::TypeDecorator::
0 | 0 | 0 | 0s | 0s | __ANON__[:43] | MooseX::Types::TypeDecorator::
0 | 0 | 0 | 0s | 0s | _throw_error | MooseX::Types::TypeDecorator::
0 | 0 | 0 | 0s | 0s | can | MooseX::Types::TypeDecorator::
0 | 0 | 0 | 0s | 0s | meta | MooseX::Types::TypeDecorator::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package MooseX::Types::TypeDecorator; | ||||
2 | |||||
3 | 3 | 22µs | 2 | 20µs | # spent 17µs (14+3) within MooseX::Types::TypeDecorator::BEGIN@3 which was called
# once (14µs+3µs) by MooseX::Types::BEGIN@11 at line 3 # spent 17µs making 1 call to MooseX::Types::TypeDecorator::BEGIN@3
# spent 3µs making 1 call to strict::import |
4 | 3 | 24µs | 2 | 33µs | # spent 24µs (15+9) within MooseX::Types::TypeDecorator::BEGIN@4 which was called
# once (15µs+9µs) by MooseX::Types::BEGIN@11 at line 4 # spent 24µs making 1 call to MooseX::Types::TypeDecorator::BEGIN@4
# spent 9µs making 1 call to warnings::import |
5 | |||||
6 | |||||
7 | 3 | 126µs | 2 | 1.58ms | # spent 1.49ms (1.28+212µs) within MooseX::Types::TypeDecorator::BEGIN@7 which was called
# once (1.28ms+212µs) by MooseX::Types::BEGIN@11 at line 7 # spent 1.49ms making 1 call to MooseX::Types::TypeDecorator::BEGIN@7
# spent 83µs making 1 call to Carp::Clan::import |
8 | 3 | 20µs | 1 | 4µs | # spent 4µs within MooseX::Types::TypeDecorator::BEGIN@8 which was called
# once (4µs+0s) by MooseX::Types::BEGIN@11 at line 8 # spent 4µs making 1 call to MooseX::Types::TypeDecorator::BEGIN@8 |
9 | 3 | 35µs | 1 | 12µs | # spent 12µs within MooseX::Types::TypeDecorator::BEGIN@9 which was called
# once (12µs+0s) by MooseX::Types::BEGIN@11 at line 9 # spent 12µs making 1 call to MooseX::Types::TypeDecorator::BEGIN@9 |
10 | 3 | 180µs | 2 | 78µs | # spent 45µs (12+33) within MooseX::Types::TypeDecorator::BEGIN@10 which was called
# once (12µs+33µs) by MooseX::Types::BEGIN@11 at line 10 # spent 45µs making 1 call to MooseX::Types::TypeDecorator::BEGIN@10
# spent 33µs making 1 call to Exporter::import |
11 | |||||
12 | # spent 68µs (14+54) within MooseX::Types::TypeDecorator::BEGIN@12 which was called
# once (14µs+54µs) by MooseX::Types::BEGIN@11 at line 46 | ||||
13 | # spent 771µs (429+341) within MooseX::Types::TypeDecorator::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types/TypeDecorator.pm:20] which was called 62 times, avg 12µs/call:
# 20 times (130µs+111µs) by Moose::Meta::TypeConstraint::new at line 66 of Moose/Meta/TypeConstraint.pm, avg 12µs/call
# 10 times (79µs+61µs) by Moose::Meta::TypeConstraint::Registry::get_type_constraint at line 41 of Moose/Meta/TypeConstraint/Registry.pm, avg 14µs/call
# 10 times (70µs+51µs) by Moose::Util::TypeConstraints::CORE:match at line 508 of Moose/Util/TypeConstraints.pm, avg 12µs/call
# 9 times (61µs+50µs) by Moose::Util::TypeConstraints::_create_type_constraint at line 523 of Moose/Util/TypeConstraints.pm, avg 12µs/call
# 4 times (28µs+23µs) by Moose::Util::TypeConstraints::CORE:subst at line 237 of Moose/Util/TypeConstraints.pm, avg 13µs/call
# 4 times (25µs+20µs) by Moose::Util::TypeConstraints::find_or_parse_type_constraint at line 217 of Moose/Util/TypeConstraints.pm, avg 11µs/call
# 4 times (24µs+20µs) by Moose::Util::TypeConstraints::find_or_create_isa_type_constraint at line 203 of Moose/Util/TypeConstraints.pm, avg 11µs/call
# once (12µs+6µs) by Moose::Meta::Method::Accessor::_eval_code at line 26 of Moose/Meta/Method/Accessor.pm | ||||
14 | 124 | 370µs | my $self = shift @_; | ||
15 | if(blessed $self) { # spent 219µs making 62 calls to MooseX::Types::TypeDecorator::__type_constraint, avg 4µs/call
# spent 61µs making 40 calls to MooseX::Types::UndefinedType::name, avg 2µs/call
# spent 35µs making 22 calls to Moose::Meta::TypeConstraint::name, avg 2µs/call
# spent 27µs making 62 calls to Scalar::Util::blessed, avg 431ns/call | ||||
16 | return $self->__type_constraint->name; | ||||
17 | } else { | ||||
18 | return "$self"; | ||||
19 | } | ||||
20 | }, | ||||
21 | '|' => sub { | ||||
22 | |||||
23 | ## It's kind of ugly that we need to know about Union Types, but this | ||||
24 | ## is needed for syntax compatibility. Maybe someday we'll all just do | ||||
25 | ## Or[Str,Str,Int] | ||||
26 | |||||
27 | my @args = @_[0,1]; ## arg 3 is special, see the overload docs. | ||||
28 | my @tc = grep {blessed $_} map { | ||||
29 | blessed $_ ? $_ : | ||||
30 | Moose::Util::TypeConstraints::find_or_parse_type_constraint($_) | ||||
31 | || __PACKAGE__->_throw_error( "$_ is not a type constraint") | ||||
32 | } @args; | ||||
33 | |||||
34 | ( scalar @tc == scalar @args) | ||||
35 | || __PACKAGE__->_throw_error( | ||||
36 | "one of your type constraints is bad. Passed: ". join(', ', @args) ." Got: ". join(', ', @tc)); | ||||
37 | |||||
38 | ( scalar @tc >= 2 ) | ||||
39 | || __PACKAGE__->_throw_error("You must pass in at least 2 type names to make a union"); | ||||
40 | |||||
41 | my $union = Moose::Meta::TypeConstraint::Union->new(type_constraints=>\@tc); | ||||
42 | return Moose::Util::TypeConstraints::register_type_constraint($union); | ||||
43 | }, | ||||
44 | fallback => 1, # spent 54µs making 1 call to overload::import | ||||
45 | |||||
46 | 3 | 398µs | 1 | 68µs | ); # spent 68µs making 1 call to MooseX::Types::TypeDecorator::BEGIN@12 |
47 | |||||
48 | =head1 NAME | ||||
49 | |||||
50 | MooseX::Types::TypeDecorator - More flexible access to a Type Constraint | ||||
51 | |||||
52 | =head1 DESCRIPTION | ||||
53 | |||||
54 | This is a decorator object that contains an underlying type constraint. We use | ||||
55 | this to control access to the type constraint and to add some features. | ||||
56 | |||||
57 | =head1 METHODS | ||||
58 | |||||
59 | This class defines the following methods. | ||||
60 | |||||
61 | =head2 new | ||||
62 | |||||
63 | Old school instantiation | ||||
64 | |||||
65 | =cut | ||||
66 | |||||
67 | # spent 1.01ms (616µs+396µs) within MooseX::Types::TypeDecorator::new which was called 64 times, avg 16µs/call:
# 64 times (616µs+396µs) by MooseX::Types::create_type_decorator at line 464 of MooseX/Types.pm, avg 16µs/call | ||||
68 | 192 | 678µs | my $class = shift @_; | ||
69 | 1 | 14µs | 64 | 286µs | if(my $arg = shift @_) { # spent 240µs making 54 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:8], avg 4µs/call
# spent 46µs making 10 calls to MooseX::Types::UndefinedType::__ANON__[MooseX/Types/UndefinedType.pm:15], avg 5µs/call |
70 | if(blessed $arg && $arg->isa('Moose::Meta::TypeConstraint')) { # spent 63µs making 74 calls to UNIVERSAL::isa, avg 846ns/call
# spent 47µs making 74 calls to Scalar::Util::blessed, avg 636ns/call | ||||
71 | return bless {'__type_constraint'=>$arg}, $class; | ||||
72 | } elsif( | ||||
73 | blessed $arg && | ||||
74 | $arg->isa('MooseX::Types::UndefinedType') | ||||
75 | ) { | ||||
76 | ## stub in case we'll need to handle these types differently | ||||
77 | return bless {'__type_constraint'=>$arg}, $class; | ||||
78 | } elsif(blessed $arg) { | ||||
79 | __PACKAGE__->_throw_error("Argument must be ->isa('Moose::Meta::TypeConstraint') or ->isa('MooseX::Types::UndefinedType'), not ". blessed $arg); | ||||
80 | } else { | ||||
81 | __PACKAGE__->_throw_error("Argument cannot be '$arg'"); | ||||
82 | } | ||||
83 | } else { | ||||
84 | __PACKAGE__->_throw_error("This method [new] requires a single argument."); | ||||
85 | } | ||||
86 | } | ||||
87 | |||||
88 | =head2 __type_constraint ($type_constraint) | ||||
89 | |||||
90 | Set/Get the type_constraint. | ||||
91 | |||||
92 | =cut | ||||
93 | |||||
94 | # spent 818µs (719+99) within MooseX::Types::TypeDecorator::__type_constraint which was called 179 times, avg 5µs/call:
# 94 times (441µs+69µs) by MooseX::Types::TypeDecorator::AUTOLOAD at line 199, avg 5µs/call
# 62 times (196µs+22µs) by MooseX::Types::TypeDecorator::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types/TypeDecorator.pm:20] at line 15, avg 4µs/call
# 23 times (81µs+7µs) by MooseX::Types::TypeDecorator::isa at line 114, avg 4µs/call | ||||
95 | 716 | 914µs | my $self = shift @_; | ||
96 | if(blessed $self) { # spent 99µs making 179 calls to Scalar::Util::blessed, avg 551ns/call | ||||
97 | if(defined(my $tc = shift @_)) { | ||||
98 | $self->{__type_constraint} = $tc; | ||||
99 | } | ||||
100 | return $self->{__type_constraint}; | ||||
101 | } else { | ||||
102 | __PACKAGE__->_throw_error('cannot call __type_constraint as a class method'); | ||||
103 | } | ||||
104 | } | ||||
105 | |||||
106 | =head2 isa | ||||
107 | |||||
108 | handle $self->isa since AUTOLOAD can't. | ||||
109 | |||||
110 | =cut | ||||
111 | |||||
112 | # spent 270µs (153+117) within MooseX::Types::TypeDecorator::isa which was called 23 times, avg 12µs/call:
# 14 times (92µs+71µs) by Moose::Util::TypeConstraints::find_type_constraint at line 255 of Moose/Util/TypeConstraints.pm, avg 12µs/call
# 4 times (27µs+19µs) by Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint at line 46 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 12µs/call
# 4 times (23µs+18µs) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 67 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 10µs/call
# once (11µs+9µs) by Moose::Meta::Attribute::_process_options at line 303 of Moose/Meta/Attribute.pm | ||||
113 | 46 | 172µs | my ($self, $target) = @_; | ||
114 | if(defined $target) { # spent 89µs making 23 calls to MooseX::Types::TypeDecorator::__type_constraint, avg 4µs/call
# spent 18µs making 23 calls to UNIVERSAL::isa, avg 778ns/call
# spent 10µs making 23 calls to Scalar::Util::blessed, avg 443ns/call | ||||
115 | if(blessed $self) { | ||||
116 | return $self->__type_constraint->isa($target); | ||||
117 | } else { | ||||
118 | return; | ||||
119 | } | ||||
120 | } else { | ||||
121 | return; | ||||
122 | } | ||||
123 | } | ||||
124 | |||||
125 | |||||
126 | =head2 can | ||||
127 | |||||
128 | handle $self->can since AUTOLOAD can't. | ||||
129 | |||||
130 | =cut | ||||
131 | |||||
132 | sub can { | ||||
133 | my ($self, $target) = @_; | ||||
134 | if(defined $target) { | ||||
135 | if(blessed $self) { | ||||
136 | return $self->__type_constraint->can($target); | ||||
137 | } else { | ||||
138 | return; | ||||
139 | } | ||||
140 | } else { | ||||
141 | return; | ||||
142 | } | ||||
143 | } | ||||
144 | |||||
145 | =head2 meta | ||||
146 | |||||
147 | have meta examine the underlying type constraints | ||||
148 | |||||
149 | =cut | ||||
150 | |||||
151 | sub meta { | ||||
152 | my $self = shift @_; | ||||
153 | if(blessed $self) { | ||||
154 | return $self->__type_constraint->meta; | ||||
155 | } | ||||
156 | } | ||||
157 | |||||
158 | =head2 _throw_error | ||||
159 | |||||
160 | properly delegate error messages | ||||
161 | |||||
162 | =cut | ||||
163 | |||||
164 | sub _throw_error { | ||||
165 | shift; | ||||
166 | require Moose; | ||||
167 | unshift @_, 'Moose'; | ||||
168 | goto &Moose::throw_error; | ||||
169 | } | ||||
170 | |||||
171 | =head2 DESTROY | ||||
172 | |||||
173 | We might need it later | ||||
174 | |||||
175 | =cut | ||||
176 | |||||
177 | # spent 21µs within MooseX::Types::TypeDecorator::DESTROY which was called 30 times, avg 710ns/call:
# 2 times (2µs+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 93 of ../lib/SimpleDB/Class/Types.pm, avg 950ns/call
# 2 times (2µs+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 112 of ../lib/SimpleDB/Class/Types.pm, avg 750ns/call
# 2 times (1µs+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 156 of ../lib/SimpleDB/Class/Types.pm, avg 700ns/call
# 2 times (1µs+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 95 of ../lib/SimpleDB/Class/Types.pm, avg 700ns/call
# 2 times (1µs+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 108 of ../lib/SimpleDB/Class/Types.pm, avg 700ns/call
# 2 times (1µs+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 120 of ../lib/SimpleDB/Class/Types.pm, avg 650ns/call
# 2 times (1µs+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 98 of ../lib/SimpleDB/Class/Types.pm, avg 650ns/call
# 2 times (1µs+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 114 of ../lib/SimpleDB/Class/Types.pm, avg 600ns/call
# 2 times (1µs+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 117 of ../lib/SimpleDB/Class/Types.pm, avg 600ns/call
# once (900ns+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 103 of ../lib/SimpleDB/Class/Types.pm
# once (800ns+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 159 of ../lib/SimpleDB/Class/Types.pm
# once (800ns+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 165 of ../lib/SimpleDB/Class/Types.pm
# once (700ns+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 208 of ../lib/SimpleDB/Class/Types.pm
# once (700ns+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 166 of ../lib/SimpleDB/Class/Types.pm
# once (700ns+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 222 of ../lib/SimpleDB/Class/Types.pm
# once (700ns+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 192 of ../lib/SimpleDB/Class/Types.pm
# once (700ns+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 232 of ../lib/SimpleDB/Class/Types.pm
# once (700ns+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 175 of ../lib/SimpleDB/Class/Types.pm
# once (700ns+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 171 of ../lib/SimpleDB/Class/Types.pm
# once (700ns+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 195 of ../lib/SimpleDB/Class/Types.pm
# once (600ns+0s) by SimpleDB::Class::Role::Itemized::BEGIN@4 at line 188 of ../lib/SimpleDB/Class/Types.pm | ||||
178 | 30 | 71µs | return; | ||
179 | } | ||||
180 | |||||
181 | =head2 AUTOLOAD | ||||
182 | |||||
183 | Delegate to the decorator targe | ||||
184 | |||||
185 | =cut | ||||
186 | |||||
187 | # spent 4.41ms (1.11+3.30) within MooseX::Types::TypeDecorator::AUTOLOAD which was called 94 times, avg 47µs/call:
# 29 times (242µs+261µs) by Moose::Meta::TypeCoercion::compile_type_coercion at line 52 of Moose/Meta/TypeCoercion.pm, avg 17µs/call
# 27 times (482µs+1.27ms) by Moose::Meta::Attribute::verify_against_type_constraint at line 757 of Moose/Meta/Attribute.pm, avg 65µs/call
# 10 times (89µs+99µs) by Moose::Util::TypeConstraints::_install_type_coercions at line 548 of Moose/Util/TypeConstraints.pm, avg 19µs/call
# 10 times (87µs+92µs) by Moose::Util::TypeConstraints::_install_type_coercions at line 556 of Moose/Util/TypeConstraints.pm, avg 18µs/call
# 9 times (119µs+1.48ms) by Moose::Util::TypeConstraints::_create_type_constraint at line 523 of Moose/Util/TypeConstraints.pm, avg 178µs/call
# 4 times (38µs+45µs) by Moose::Util::TypeConstraints::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Util/TypeConstraints.pm:750] at line 743 of Moose/Util/TypeConstraints.pm, avg 21µs/call
# 4 times (37µs+39µs) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 68 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 19µs/call
# once (16µs+17µs) by Moose::Meta::Method::Accessor::_eval_code at line 26 of Moose/Meta/Method/Accessor.pm | ||||
188 | |||||
189 | 658 | 1.42ms | my ($self, @args) = @_; | ||
190 | my ($method) = (our $AUTOLOAD =~ /([^:]+)$/); # spent 480µs making 94 calls to MooseX::Types::TypeDecorator::CORE:match, avg 5µs/call | ||||
191 | |||||
192 | ## We delegate with this method in an attempt to support a value of | ||||
193 | ## __type_constraint which is also AUTOLOADing, in particular the class | ||||
194 | ## MooseX::Types::UndefinedType which AUTOLOADs during autovivication. | ||||
195 | |||||
196 | my $return; | ||||
197 | |||||
198 | eval { | ||||
199 | $return = $self->__type_constraint->$method(@args); # spent 813µs making 27 calls to Moose::Meta::TypeConstraint::check, avg 30µs/call
# spent 736µs making 5 calls to Moose::Meta::TypeConstraint::create_child_type, avg 147µs/call
# spent 672µs making 4 calls to Moose::Meta::TypeConstraint::Parameterized::create_child_type, avg 168µs/call
# spent 510µs making 94 calls to MooseX::Types::TypeDecorator::__type_constraint, avg 5µs/call
# spent 49µs making 34 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 1µs/call
# spent 20µs making 10 calls to Moose::Meta::TypeConstraint::coercion, avg 2µs/call
# spent 16µs making 10 calls to Moose::Meta::TypeConstraint::has_coercion, avg 2µs/call
# spent 6µs making 4 calls to Moose::Meta::TypeConstraint::name, avg 1µs/call | ||||
200 | }; if($@) { | ||||
201 | __PACKAGE__->_throw_error($@); | ||||
202 | } else { | ||||
203 | return $return; | ||||
204 | } | ||||
205 | } | ||||
206 | |||||
207 | =head1 AUTHOR | ||||
208 | |||||
209 | See L<MooseX::Types/AUTHOR>. | ||||
210 | |||||
211 | =head1 LICENSE | ||||
212 | |||||
213 | This program is free software; you can redistribute it and/or modify | ||||
214 | it under the same terms as perl itself. | ||||
215 | |||||
216 | =cut | ||||
217 | |||||
218 | 1 | 3µs | 1; | ||
# spent 480µs within MooseX::Types::TypeDecorator::CORE:match which was called 94 times, avg 5µs/call:
# 94 times (480µs+0s) by MooseX::Types::TypeDecorator::AUTOLOAD at line 190 of MooseX/Types/TypeDecorator.pm, avg 5µs/call |