← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mentat.storage.mongo.pl
  Run on Tue Jun 24 10:04:38 2014
Reported on Tue Jun 24 10:05:17 2014

Filename/usr/local/lib/perl/5.14.2/Moose/Meta/TypeConstraint/Parameterized.pm
StatementsExecuted 20 statements in 689µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111682µs2.24msMoose::Meta::TypeConstraint::Parameterized::::BEGIN@15Moose::Meta::TypeConstraint::Parameterized::BEGIN@15
11110µs10µsMoose::Meta::TypeConstraint::Parameterized::::BEGIN@2Moose::Meta::TypeConstraint::Parameterized::BEGIN@2
1118µs8µsMoose::Meta::TypeConstraint::Parameterized::::BEGIN@14Moose::Meta::TypeConstraint::Parameterized::BEGIN@14
1118µs11µsMoose::Meta::TypeConstraint::Parameterized::::BEGIN@9Moose::Meta::TypeConstraint::Parameterized::BEGIN@9
1118µs61µsMoose::Meta::TypeConstraint::Parameterized::::BEGIN@17Moose::Meta::TypeConstraint::Parameterized::BEGIN@17
1117µs413µsMoose::Meta::TypeConstraint::Parameterized::::BEGIN@11Moose::Meta::TypeConstraint::Parameterized::BEGIN@11
1117µs34µsMoose::Meta::TypeConstraint::Parameterized::::BEGIN@13Moose::Meta::TypeConstraint::Parameterized::BEGIN@13
1117µs16µsMoose::Meta::TypeConstraint::Parameterized::::BEGIN@10Moose::Meta::TypeConstraint::Parameterized::BEGIN@10
0000s0sMoose::Meta::TypeConstraint::Parameterized::::_inline_checkMoose::Meta::TypeConstraint::Parameterized::_inline_check
0000s0sMoose::Meta::TypeConstraint::Parameterized::::can_be_inlinedMoose::Meta::TypeConstraint::Parameterized::can_be_inlined
0000s0sMoose::Meta::TypeConstraint::Parameterized::::compile_type_constraintMoose::Meta::TypeConstraint::Parameterized::compile_type_constraint
0000s0sMoose::Meta::TypeConstraint::Parameterized::::create_child_typeMoose::Meta::TypeConstraint::Parameterized::create_child_type
0000s0sMoose::Meta::TypeConstraint::Parameterized::::equalsMoose::Meta::TypeConstraint::Parameterized::equals
0000s0sMoose::Meta::TypeConstraint::Parameterized::::inline_environmentMoose::Meta::TypeConstraint::Parameterized::inline_environment
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::Parameterized;
2
# spent 10µs within Moose::Meta::TypeConstraint::Parameterized::BEGIN@2 which was called: # once (10µs+0s) by Moose::Util::TypeConstraints::BEGIN@34 at line 4
BEGIN {
315µs $Moose::Meta::TypeConstraint::Parameterized::AUTHORITY = 'cpan:STEVAN';
4131µs110µs}
5{
621µs $Moose::Meta::TypeConstraint::Parameterized::VERSION = '2.1005';
7}
8
9222µs214µs
# spent 11µs (8+3) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 which was called: # once (8µs+3µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 9
use strict;
# spent 11µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 # spent 3µs making 1 call to strict::import
10222µs224µs
# spent 16µs (7+8) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 which was called: # once (7µs+8µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 10
use warnings;
# spent 16µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 # spent 8µs making 1 call to warnings::import
11231µs2818µs
# spent 413µs (7+405) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@11 which was called: # once (7µs+405µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 11
use metaclass;
# spent 413µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@11 # spent 405µs making 1 call to metaclass::import
12
13224µs261µs
# spent 34µs (7+27) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@13 which was called: # once (7µs+27µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 13
use Scalar::Util 'blessed';
# spent 34µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@13 # spent 27µs making 1 call to Exporter::import
14225µs18µs
# spent 8µs within Moose::Meta::TypeConstraint::Parameterized::BEGIN@14 which was called: # once (8µs+0s) by Moose::Util::TypeConstraints::BEGIN@34 at line 14
use Moose::Util::TypeConstraints;
152120µs12.24ms
# spent 2.24ms (682µs+1.56) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 which was called: # once (682µs+1.56ms) by Moose::Util::TypeConstraints::BEGIN@34 at line 15
use Moose::Meta::TypeConstraint::Parameterizable;
16
172393µs2114µs
# spent 61µs (8+53) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@17 which was called: # once (8µs+53µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 17
use base 'Moose::Meta::TypeConstraint';
# spent 61µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@17 # spent 53µs making 1 call to base::import
18
1915µs3529µs__PACKAGE__->meta->add_attribute('type_parameter' => (
# spent 506µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 17µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::meta # spent 6µs making 1 call to Class::MOP::_definition_context
20 accessor => 'type_parameter',
21 predicate => 'has_type_parameter',
22 Class::MOP::_definition_context(),
23));
24
2514µs3491µs__PACKAGE__->meta->add_attribute('parameterized_from' => (
# spent 474µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::meta # spent 5µs making 1 call to Class::MOP::_definition_context
26 accessor => 'parameterized_from',
27 predicate => 'has_parameterized_from',
28 Class::MOP::_definition_context(),
29));
30
31sub equals {
32 my ( $self, $type_or_name ) = @_;
33
34 my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
35
36 return unless $other->isa(__PACKAGE__);
37
38 return (
39 $self->type_parameter->equals( $other->type_parameter )
40 and
41 $self->parent->equals( $other->parent )
42 );
43}
44
45sub compile_type_constraint {
46 my $self = shift;
47
48 unless ( $self->has_type_parameter ) {
49 require Moose;
50 Moose->throw_error("You cannot create a Higher Order type without a type parameter");
51 }
52
53 my $type_parameter = $self->type_parameter;
54
55 unless ( blessed $type_parameter && $type_parameter->isa('Moose::Meta::TypeConstraint') ) {
56 require Moose;
57 Moose->throw_error("The type parameter must be a Moose meta type");
58 }
59
60 foreach my $type (Moose::Util::TypeConstraints::get_all_parameterizable_types()) {
61 if (my $constraint = $type->generate_constraint_for($self)) {
62 $self->_set_constraint($constraint);
63 return $self->SUPER::compile_type_constraint;
64 }
65 }
66
67 # if we get here, then we couldn't
68 # find a way to parameterize this type
69 require Moose;
70 Moose->throw_error("The " . $self->name . " constraint cannot be used, because "
71 . $self->parent->name . " doesn't subtype or coerce from a parameterizable type.");
72}
73
74sub can_be_inlined {
75 my $self = shift;
76
77 return
78 $self->has_parameterized_from
79 && $self->parameterized_from->has_inline_generator
80 && $self->type_parameter->can_be_inlined;
81}
82
83sub inline_environment {
84 my $self = shift;
85
86 return {
87 ($self->has_parameterized_from
88 ? (%{ $self->parameterized_from->inline_environment })
89 : ()),
90 ($self->has_type_parameter
91 ? (%{ $self->type_parameter->inline_environment })
92 : ()),
93 };
94}
95
96sub _inline_check {
97 my $self = shift;
98
99 return unless $self->can_be_inlined;
100
101 return $self->parameterized_from->generate_inline_for( $self->type_parameter, @_ );
102}
103
104sub create_child_type {
105 my ($self, %opts) = @_;
106 return Moose::Meta::TypeConstraint::Parameterizable->new(%opts, parent=>$self);
107}
108
10917µs1;
110
111# ABSTRACT: Type constraints with a bound parameter (ArrayRef[Int])
112
113__END__