| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/TypeConstraint/Parameterized.pm |
| Statements | Executed 121 statements in 4.01ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 2.28ms | 9.34ms | Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 |
| 10 | 1 | 1 | 1.87ms | 41.6ms | Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint |
| 1 | 1 | 1 | 74µs | 92µs | Moose::Meta::TypeConstraint::Parameterized::BEGIN@3 |
| 1 | 1 | 1 | 45µs | 45µs | Moose::Meta::TypeConstraint::Parameterized::BEGIN@8 |
| 1 | 1 | 1 | 45µs | 236µs | Moose::Meta::TypeConstraint::Parameterized::BEGIN@7 |
| 1 | 1 | 1 | 42µs | 284µs | Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 |
| 1 | 1 | 1 | 41µs | 108µs | Moose::Meta::TypeConstraint::Parameterized::BEGIN@4 |
| 1 | 1 | 1 | 36µs | 3.02ms | Moose::Meta::TypeConstraint::Parameterized::BEGIN@5 |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeConstraint::Parameterized::create_child_type |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeConstraint::Parameterized::equals |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moose::Meta::TypeConstraint::Parameterized; | ||||
| 2 | |||||
| 3 | 3 | 103µs | 2 | 110µs | # spent 92µs (74+18) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@3 which was called:
# once (74µs+18µs) by Moose::Util::TypeConstraints::BEGIN@31 at line 3 # spent 92µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@3
# spent 18µs making 1 call to strict::import |
| 4 | 3 | 94µs | 2 | 175µs | # spent 108µs (41+67) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@4 which was called:
# once (41µs+67µs) by Moose::Util::TypeConstraints::BEGIN@31 at line 4 # spent 108µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@4
# spent 67µs making 1 call to warnings::import |
| 5 | 3 | 149µs | 2 | 6.01ms | # spent 3.02ms (36µs+2.99) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@5 which was called:
# once (36µs+2.99ms) by Moose::Util::TypeConstraints::BEGIN@31 at line 5 # spent 3.02ms making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@5
# spent 2.99ms making 1 call to metaclass::import |
| 6 | |||||
| 7 | 3 | 113µs | 2 | 426µs | # spent 236µs (45+190) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@7 which was called:
# once (45µs+190µs) by Moose::Util::TypeConstraints::BEGIN@31 at line 7 # spent 236µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@7
# spent 190µs making 1 call to Exporter::import |
| 8 | 3 | 109µs | 1 | 45µs | # spent 45µs within Moose::Meta::TypeConstraint::Parameterized::BEGIN@8 which was called:
# once (45µs+0s) by Moose::Util::TypeConstraints::BEGIN@31 at line 8 # spent 45µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@8 |
| 9 | 3 | 628µs | 1 | 9.34ms | # spent 9.34ms (2.28+7.06) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 which was called:
# once (2.28ms+7.06ms) by Moose::Util::TypeConstraints::BEGIN@31 at line 9 # spent 9.34ms making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 |
| 10 | |||||
| 11 | 1 | 5µs | our $VERSION = '1.19'; | ||
| 12 | 1 | 70µs | $VERSION = eval $VERSION; # spent 12µs executing statements in string eval | ||
| 13 | 1 | 4µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 14 | |||||
| 15 | 3 | 943µs | 2 | 525µs | # spent 284µs (42+241) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 which was called:
# once (42µs+241µs) by Moose::Util::TypeConstraints::BEGIN@31 at line 15 # spent 284µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@15
# spent 241µs making 1 call to base::import |
| 16 | |||||
| 17 | 1 | 31µs | 2 | 3.31ms | __PACKAGE__->meta->add_attribute('type_parameter' => ( # spent 3.18ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 135µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::meta |
| 18 | accessor => 'type_parameter', | ||||
| 19 | predicate => 'has_type_parameter', | ||||
| 20 | )); | ||||
| 21 | |||||
| 22 | sub equals { | ||||
| 23 | my ( $self, $type_or_name ) = @_; | ||||
| 24 | |||||
| 25 | my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name); | ||||
| 26 | |||||
| 27 | return unless $other->isa(__PACKAGE__); | ||||
| 28 | |||||
| 29 | return ( | ||||
| 30 | $self->type_parameter->equals( $other->type_parameter ) | ||||
| 31 | and | ||||
| 32 | $self->parent->equals( $other->parent ) | ||||
| 33 | ); | ||||
| 34 | } | ||||
| 35 | |||||
| 36 | # spent 41.6ms (1.87+39.7) within Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint which was called 10 times, avg 4.16ms/call:
# 10 times (1.87ms+39.7ms) by Moose::Meta::TypeConstraint::new at line 71 of Moose/Meta/TypeConstraint.pm, avg 4.16ms/call | ||||
| 37 | 10 | 35µs | my $self = shift; | ||
| 38 | |||||
| 39 | 10 | 107µs | 10 | 105µs | unless ( $self->has_type_parameter ) { # spent 105µs making 10 calls to Moose::Meta::TypeConstraint::Parameterized::has_type_parameter, avg 10µs/call |
| 40 | require Moose; | ||||
| 41 | Moose->throw_error("You cannot create a Higher Order type without a type parameter"); | ||||
| 42 | } | ||||
| 43 | |||||
| 44 | 10 | 120µs | 10 | 123µs | my $type_parameter = $self->type_parameter; # spent 123µs making 10 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 12µs/call |
| 45 | |||||
| 46 | 10 | 335µs | 20 | 128µs | unless ( blessed $type_parameter && $type_parameter->isa('Moose::Meta::TypeConstraint') ) { # spent 74µs making 10 calls to Scalar::Util::blessed, avg 7µs/call
# spent 54µs making 10 calls to UNIVERSAL::isa, avg 5µs/call |
| 47 | require Moose; | ||||
| 48 | Moose->throw_error("The type parameter must be a Moose meta type"); | ||||
| 49 | } | ||||
| 50 | |||||
| 51 | 10 | 170µs | 10 | 109µs | foreach my $type (Moose::Util::TypeConstraints::get_all_parameterizable_types()) { # spent 109µs making 10 calls to Moose::Util::TypeConstraints::get_all_parameterizable_types, avg 11µs/call |
| 52 | 25 | 332µs | 25 | 33.6ms | if (my $constraint = $type->generate_constraint_for($self)) { # spent 33.6ms making 25 calls to Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for, avg 1.34ms/call |
| 53 | 10 | 131µs | 10 | 121µs | $self->_set_constraint($constraint); # spent 121µs making 10 calls to Moose::Meta::TypeConstraint::_set_constraint, avg 12µs/call |
| 54 | 10 | 505µs | 10 | 5.58ms | return $self->SUPER::compile_type_constraint; # spent 5.58ms making 10 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 558µs/call |
| 55 | } | ||||
| 56 | } | ||||
| 57 | |||||
| 58 | # if we get here, then we couldn't | ||||
| 59 | # find a way to parameterize this type | ||||
| 60 | require Moose; | ||||
| 61 | Moose->throw_error("The " . $self->name . " constraint cannot be used, because " | ||||
| 62 | . $self->parent->name . " doesn't subtype or coerce from a parameterizable type."); | ||||
| 63 | } | ||||
| 64 | |||||
| 65 | sub create_child_type { | ||||
| 66 | my ($self, %opts) = @_; | ||||
| 67 | return Moose::Meta::TypeConstraint::Parameterizable->new(%opts, parent=>$self); | ||||
| 68 | } | ||||
| 69 | |||||
| 70 | 1 | 27µs | 1; | ||
| 71 | |||||
| 72 | __END__ |