| File | /usr/lib/perl5/vendor_perl/5.10.1/MooseX/Types/TypeDecorator.pm |
| Statements Executed | 535 |
| Statement Execution Time | 12.1ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 6.28ms | 7.14ms | MooseX::Types::TypeDecorator::BEGIN@8 |
| 64 | 3 | 1 | 1.89ms | 2.26ms | MooseX::Types::TypeDecorator::__type_constraint |
| 20 | 5 | 4 | 1.43ms | 10.3ms | MooseX::Types::TypeDecorator::AUTOLOAD |
| 23 | 5 | 3 | 1.27ms | 2.56ms | MooseX::Types::TypeDecorator::__ANON__[:21] |
| 21 | 4 | 4 | 1.08ms | 2.20ms | MooseX::Types::TypeDecorator::isa |
| 9 | 1 | 1 | 683µs | 1.00ms | MooseX::Types::TypeDecorator::new |
| 20 | 1 | 2 | 585µs | 585µs | MooseX::Types::TypeDecorator::CORE:match (opcode) |
| 1 | 1 | 1 | 215µs | 215µs | MooseX::Types::TypeDecorator::BEGIN@9 |
| 1 | 1 | 1 | 172µs | 190µs | MooseX::Types::TypeDecorator::BEGIN@10 |
| 1 | 1 | 1 | 92µs | 149µs | MooseX::Types::TypeDecorator::BEGIN@5 |
| 1 | 1 | 1 | 58µs | 239µs | MooseX::Types::TypeDecorator::BEGIN@13 |
| 1 | 1 | 1 | 53µs | 66µs | MooseX::Types::TypeDecorator::BEGIN@4 |
| 1 | 1 | 1 | 43µs | 310µs | MooseX::Types::TypeDecorator::BEGIN@11 |
| 0 | 0 | 0 | 0s | 0s | MooseX::Types::TypeDecorator::DESTROY |
| 0 | 0 | 0 | 0s | 0s | MooseX::Types::TypeDecorator::__ANON__[:44] |
| 0 | 0 | 0 | 0s | 0s | MooseX::Types::TypeDecorator::_throw_error |
| 0 | 0 | 0 | 0s | 0s | MooseX::Types::TypeDecorator::can |
| 0 | 0 | 0 | 0s | 0s | MooseX::Types::TypeDecorator::meta |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package MooseX::Types::TypeDecorator; | ||||
| 2 | 1 | 2µs | our $VERSION = "0.21"; | ||
| 3 | |||||
| 4 | 3 | 181µs | 2 | 79µs | # spent 66µs (53+13) within MooseX::Types::TypeDecorator::BEGIN@4 which was called
# once (53µs+13µs) by MooseX::Types::BEGIN@11 at line 4 # spent 66µs making 1 call to MooseX::Types::TypeDecorator::BEGIN@4
# spent 13µs making 1 call to strict::import |
| 5 | 3 | 94µs | 2 | 206µs | # spent 149µs (92+57) within MooseX::Types::TypeDecorator::BEGIN@5 which was called
# once (92µs+57µs) by MooseX::Types::BEGIN@11 at line 5 # spent 149µs making 1 call to MooseX::Types::TypeDecorator::BEGIN@5
# spent 57µs making 1 call to warnings::import |
| 6 | |||||
| 7 | |||||
| 8 | 3 | 599µs | 2 | 7.50ms | # spent 7.14ms (6.28+866µs) within MooseX::Types::TypeDecorator::BEGIN@8 which was called
# once (6.28ms+866µs) by MooseX::Types::BEGIN@11 at line 8 # spent 7.14ms making 1 call to MooseX::Types::TypeDecorator::BEGIN@8
# spent 360µs making 1 call to Carp::Clan::import |
| 9 | 3 | 290µs | 1 | 215µs | # spent 215µs within MooseX::Types::TypeDecorator::BEGIN@9 which was called
# once (215µs+0s) by MooseX::Types::BEGIN@11 at line 9 # spent 215µs making 1 call to MooseX::Types::TypeDecorator::BEGIN@9 |
| 10 | 3 | 242µs | 2 | 208µs | # spent 190µs (172+18) within MooseX::Types::TypeDecorator::BEGIN@10 which was called
# once (172µs+18µs) by MooseX::Types::BEGIN@11 at line 10 # spent 190µs making 1 call to MooseX::Types::TypeDecorator::BEGIN@10
# spent 18µs making 1 call to UNIVERSAL::import |
| 11 | 3 | 914µs | 2 | 577µs | # spent 310µs (43+267) within MooseX::Types::TypeDecorator::BEGIN@11 which was called
# once (43µs+267µs) by MooseX::Types::BEGIN@11 at line 11 # spent 310µs making 1 call to MooseX::Types::TypeDecorator::BEGIN@11
# spent 267µs making 1 call to Exporter::import |
| 12 | |||||
| 13 | # spent 239µs (58+181) within MooseX::Types::TypeDecorator::BEGIN@13 which was called
# once (58µs+181µs) by MooseX::Types::BEGIN@11 at line 47 | ||||
| 14 | # spent 2.56ms (1.27+1.29) within MooseX::Types::TypeDecorator::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/MooseX/Types/TypeDecorator.pm:21] which was called 23 times, avg 111µs/call:
# 6 times (250µs+297µs) by Moose::Meta::Method::Accessor::_eval_code at line 26 of Moose/Meta/Method/Accessor.pm, avg 91µs/call
# 5 times (181µs+470µs) by Moose::Util::TypeConstraints::find_or_create_isa_type_constraint at line 203 of Moose/Util/TypeConstraints.pm, avg 130µs/call
# 5 times (395µs+231µs) by Moose::Util::TypeConstraints::find_or_parse_type_constraint at line 217 of Moose/Util/TypeConstraints.pm, avg 125µs/call
# 5 times (303µs+201µs) by Moose::Util::TypeConstraints::CORE:subst at line 237 of Moose/Util/TypeConstraints.pm, avg 101µs/call
# 2 times (145µs+87µs) by Moose::Meta::Role::Attribute::is_same_as at line 92 of Moose/Meta/Role/Attribute.pm, avg 116µs/call | ||||
| 15 | 46 | 1.21ms | my $self = shift @_; | ||
| 16 | if(blessed $self) { # spent 765µs making 23 calls to MooseX::Types::TypeDecorator::__type_constraint, avg 33µs/call
# spent 406µs making 23 calls to Moose::Meta::TypeConstraint::name, avg 18µs/call
# spent 114µs making 23 calls to Scalar::Util::blessed, avg 5µs/call | ||||
| 17 | return $self->__type_constraint->name; | ||||
| 18 | } else { | ||||
| 19 | return "$self"; | ||||
| 20 | } | ||||
| 21 | }, | ||||
| 22 | '|' => sub { | ||||
| 23 | |||||
| 24 | ## It's kind of ugly that we need to know about Union Types, but this | ||||
| 25 | ## is needed for syntax compatibility. Maybe someday we'll all just do | ||||
| 26 | ## Or[Str,Str,Int] | ||||
| 27 | |||||
| 28 | my @args = @_[0,1]; ## arg 3 is special, see the overload docs. | ||||
| 29 | my @tc = grep {blessed $_} map { | ||||
| 30 | blessed $_ ? $_ : | ||||
| 31 | Moose::Util::TypeConstraints::find_or_parse_type_constraint($_) | ||||
| 32 | || __PACKAGE__->_throw_error( "$_ is not a type constraint") | ||||
| 33 | } @args; | ||||
| 34 | |||||
| 35 | ( scalar @tc == scalar @args) | ||||
| 36 | || __PACKAGE__->_throw_error( | ||||
| 37 | "one of your type constraints is bad. Passed: ". join(', ', @args) ." Got: ". join(', ', @tc)); | ||||
| 38 | |||||
| 39 | ( scalar @tc >= 2 ) | ||||
| 40 | || __PACKAGE__->_throw_error("You must pass in at least 2 type names to make a union"); | ||||
| 41 | |||||
| 42 | my $union = Moose::Meta::TypeConstraint::Union->new(type_constraints=>\@tc); | ||||
| 43 | return Moose::Util::TypeConstraints::register_type_constraint($union); | ||||
| 44 | }, | ||||
| 45 | fallback => 1, # spent 181µs making 1 call to overload::import | ||||
| 46 | |||||
| 47 | 3 | 1.89ms | 1 | 239µs | ); # spent 239µs making 1 call to MooseX::Types::TypeDecorator::BEGIN@13 |
| 48 | |||||
| 49 | =head1 NAME | ||||
| 50 | |||||
| 51 | MooseX::Types::TypeDecorator - More flexible access to a Type Constraint | ||||
| 52 | |||||
| 53 | =head1 DESCRIPTION | ||||
| 54 | |||||
| 55 | This is a decorator object that contains an underlying type constraint. We use | ||||
| 56 | this to control access to the type constraint and to add some features. | ||||
| 57 | |||||
| 58 | =head1 METHODS | ||||
| 59 | |||||
| 60 | This class defines the following methods. | ||||
| 61 | |||||
| 62 | =head2 new | ||||
| 63 | |||||
| 64 | Old school instantiation | ||||
| 65 | |||||
| 66 | =cut | ||||
| 67 | |||||
| 68 | # spent 1.00ms (683µs+321µs) within MooseX::Types::TypeDecorator::new which was called 9 times, avg 112µs/call:
# 9 times (683µs+321µs) by MooseX::Types::create_type_decorator at line 464 of MooseX/Types.pm, avg 112µs/call | ||||
| 69 | 27 | 750µs | my $class = shift @_; | ||
| 70 | 1 | 20µs | 9 | 237µs | if(my $arg = shift @_) { # spent 237µs making 9 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:8], avg 26µs/call |
| 71 | if(blessed $arg && $arg->isa('Moose::Meta::TypeConstraint')) { # spent 47µs making 9 calls to Scalar::Util::blessed, avg 5µs/call
# spent 38µs making 9 calls to UNIVERSAL::isa, avg 4µs/call | ||||
| 72 | return bless {'__type_constraint'=>$arg}, $class; | ||||
| 73 | } elsif( | ||||
| 74 | blessed $arg && | ||||
| 75 | $arg->isa('MooseX::Types::UndefinedType') | ||||
| 76 | ) { | ||||
| 77 | ## stub in case we'll need to handle these types differently | ||||
| 78 | return bless {'__type_constraint'=>$arg}, $class; | ||||
| 79 | } elsif(blessed $arg) { | ||||
| 80 | __PACKAGE__->_throw_error("Argument must be ->isa('Moose::Meta::TypeConstraint') or ->isa('MooseX::Types::UndefinedType'), not ". blessed $arg); | ||||
| 81 | } else { | ||||
| 82 | __PACKAGE__->_throw_error("Argument cannot be '$arg'"); | ||||
| 83 | } | ||||
| 84 | } else { | ||||
| 85 | __PACKAGE__->_throw_error("This method [new] requires a single argument."); | ||||
| 86 | } | ||||
| 87 | } | ||||
| 88 | |||||
| 89 | =head2 __type_constraint ($type_constraint) | ||||
| 90 | |||||
| 91 | Set/Get the type_constraint. | ||||
| 92 | |||||
| 93 | =cut | ||||
| 94 | |||||
| 95 | # spent 2.26ms (1.89+377µs) within MooseX::Types::TypeDecorator::__type_constraint which was called 64 times, avg 35µs/call:
# 23 times (683µs+82µs) by MooseX::Types::TypeDecorator::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/MooseX/Types/TypeDecorator.pm:21] at line 16, avg 33µs/call
# 21 times (558µs+202µs) by MooseX::Types::TypeDecorator::isa at line 115, avg 36µs/call
# 20 times (645µs+93µs) by MooseX::Types::TypeDecorator::AUTOLOAD at line 200, avg 37µs/call | ||||
| 96 | 256 | 2.74ms | my $self = shift @_; | ||
| 97 | if(blessed $self) { # spent 377µs making 64 calls to Scalar::Util::blessed, avg 6µs/call | ||||
| 98 | if(defined(my $tc = shift @_)) { | ||||
| 99 | $self->{__type_constraint} = $tc; | ||||
| 100 | } | ||||
| 101 | return $self->{__type_constraint}; | ||||
| 102 | } else { | ||||
| 103 | __PACKAGE__->_throw_error('cannot call __type_constraint as a class method'); | ||||
| 104 | } | ||||
| 105 | } | ||||
| 106 | |||||
| 107 | =head2 isa | ||||
| 108 | |||||
| 109 | handle $self->isa since AUTOLOAD can't. | ||||
| 110 | |||||
| 111 | =cut | ||||
| 112 | |||||
| 113 | # spent 2.20ms (1.08+1.12) within MooseX::Types::TypeDecorator::isa which was called 21 times, avg 105µs/call:
# 6 times (287µs+374µs) by Moose::Meta::Attribute::_process_options at line 303 of Moose/Meta/Attribute.pm, avg 110µs/call
# 5 times (390µs+434µs) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 67 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 165µs/call
# 5 times (221µs+157µs) by Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint at line 46 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 76µs/call
# 5 times (180µs+155µs) by Moose::Util::TypeConstraints::find_type_constraint at line 255 of Moose/Util/TypeConstraints.pm, avg 67µs/call | ||||
| 114 | 42 | 1.18ms | my ($self, $target) = @_; | ||
| 115 | if(defined $target) { # spent 760µs making 21 calls to MooseX::Types::TypeDecorator::__type_constraint, avg 36µs/call
# spent 245µs making 21 calls to Scalar::Util::blessed, avg 12µs/call
# spent 115µs making 21 calls to UNIVERSAL::isa, avg 5µs/call | ||||
| 116 | if(blessed $self) { | ||||
| 117 | return $self->__type_constraint->isa($target); | ||||
| 118 | } else { | ||||
| 119 | return; | ||||
| 120 | } | ||||
| 121 | } else { | ||||
| 122 | return; | ||||
| 123 | } | ||||
| 124 | } | ||||
| 125 | |||||
| 126 | |||||
| 127 | =head2 can | ||||
| 128 | |||||
| 129 | handle $self->can since AUTOLOAD can't. | ||||
| 130 | |||||
| 131 | =cut | ||||
| 132 | |||||
| 133 | sub can { | ||||
| 134 | my ($self, $target) = @_; | ||||
| 135 | if(defined $target) { | ||||
| 136 | if(blessed $self) { | ||||
| 137 | return $self->__type_constraint->can($target); | ||||
| 138 | } else { | ||||
| 139 | return; | ||||
| 140 | } | ||||
| 141 | } else { | ||||
| 142 | return; | ||||
| 143 | } | ||||
| 144 | } | ||||
| 145 | |||||
| 146 | =head2 meta | ||||
| 147 | |||||
| 148 | have meta examine the underlying type constraints | ||||
| 149 | |||||
| 150 | =cut | ||||
| 151 | |||||
| 152 | sub meta { | ||||
| 153 | my $self = shift @_; | ||||
| 154 | if(blessed $self) { | ||||
| 155 | return $self->__type_constraint->meta; | ||||
| 156 | } | ||||
| 157 | } | ||||
| 158 | |||||
| 159 | =head2 _throw_error | ||||
| 160 | |||||
| 161 | properly delegate error messages | ||||
| 162 | |||||
| 163 | =cut | ||||
| 164 | |||||
| 165 | sub _throw_error { | ||||
| 166 | shift; | ||||
| 167 | require Moose; | ||||
| 168 | unshift @_, 'Moose'; | ||||
| 169 | goto &Moose::throw_error; | ||||
| 170 | } | ||||
| 171 | |||||
| 172 | =head2 DESTROY | ||||
| 173 | |||||
| 174 | We might need it later | ||||
| 175 | |||||
| 176 | =cut | ||||
| 177 | |||||
| 178 | sub DESTROY { | ||||
| 179 | return; | ||||
| 180 | } | ||||
| 181 | |||||
| 182 | =head2 AUTOLOAD | ||||
| 183 | |||||
| 184 | Delegate to the decorator targe | ||||
| 185 | |||||
| 186 | =cut | ||||
| 187 | |||||
| 188 | # spent 10.3ms (1.43+8.88) within MooseX::Types::TypeDecorator::AUTOLOAD which was called 20 times, avg 515µs/call:
# 6 times (515µs+380µs) by Moose::Meta::Method::Accessor::_eval_code at line 26 of Moose/Meta/Method/Accessor.pm, avg 149µs/call
# 5 times (391µs+610µs) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 68 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 200µs/call
# 4 times (201µs+7.45ms) by Moose::Meta::Attribute::verify_against_type_constraint at line 759 of Moose/Meta/Attribute.pm, avg 1.91ms/call
# 4 times (272µs+393µs) by Moose::Util::TypeConstraints::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/i386-linux-thread-multi/Moose/Util/TypeConstraints.pm:750] at line 743 of Moose/Util/TypeConstraints.pm, avg 166µs/call
# once (48µs+54µs) by Moose::Util::TypeConstraints::__ANON__[/usr/lib/perl5/vendor_perl/5.10.1/i386-linux-thread-multi/Moose/Util/TypeConstraints.pm:771] at line 764 of Moose/Util/TypeConstraints.pm | ||||
| 189 | |||||
| 190 | 140 | 1.98ms | my ($self, @args) = @_; | ||
| 191 | my ($method) = (our $AUTOLOAD =~ /([^:]+)$/); # spent 585µs making 20 calls to MooseX::Types::TypeDecorator::CORE:match, avg 29µs/call | ||||
| 192 | |||||
| 193 | ## We delegate with this method in an attempt to support a value of | ||||
| 194 | ## __type_constraint which is also AUTOLOADing, in particular the class | ||||
| 195 | ## MooseX::Types::UndefinedType which AUTOLOADs during autovivication. | ||||
| 196 | |||||
| 197 | my $return; | ||||
| 198 | |||||
| 199 | eval { | ||||
| 200 | $return = $self->__type_constraint->$method(@args); # spent 7.27ms making 4 calls to Moose::Meta::TypeConstraint::check, avg 1.82ms/call
# spent 738µs making 20 calls to MooseX::Types::TypeDecorator::__type_constraint, avg 37µs/call
# spent 238µs making 11 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 22µs/call
# spent 48µs making 5 calls to Moose::Meta::TypeConstraint::name, avg 10µs/call | ||||
| 201 | }; if($@) { | ||||
| 202 | __PACKAGE__->_throw_error($@); | ||||
| 203 | } else { | ||||
| 204 | return $return; | ||||
| 205 | } | ||||
| 206 | } | ||||
| 207 | |||||
| 208 | =head1 AUTHOR | ||||
| 209 | |||||
| 210 | See L<MooseX::Types/AUTHOR>. | ||||
| 211 | |||||
| 212 | =head1 LICENSE | ||||
| 213 | |||||
| 214 | This program is free software; you can redistribute it and/or modify | ||||
| 215 | it under the same terms as perl itself. | ||||
| 216 | |||||
| 217 | =cut | ||||
| 218 | |||||
| 219 | 1 | 5µs | 1; | ||
# spent 585µs within MooseX::Types::TypeDecorator::CORE:match which was called 20 times, avg 29µs/call:
# 20 times (585µs+0s) by MooseX::Types::TypeDecorator::AUTOLOAD at line 191 of MooseX/Types/TypeDecorator.pm, avg 29µs/call |