← Index
NYTProf Performance Profile   « line view »
For script/ponapi
  Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:10 2016

Filename/usr/local/lib/perl/5.18.2/Moose/Meta/TypeConstraint/Parameterizable.pm
StatementsExecuted 272 statements in 5.28ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
7114.29ms10.8msMoose::Meta::TypeConstraint::Parameterizable::::parameterizeMoose::Meta::TypeConstraint::Parameterizable::parameterize
4011376µs2.54msMoose::Meta::TypeConstraint::Parameterizable::::generate_inline_forMoose::Meta::TypeConstraint::Parameterizable::generate_inline_for
1811200µs2.18msMoose::Meta::TypeConstraint::Parameterizable::::generate_constraint_forMoose::Meta::TypeConstraint::Parameterizable::generate_constraint_for
71127µs950µsMoose::Meta::TypeConstraint::Parameterizable::::_parse_type_parameterMoose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter
11110µs22µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@4Moose::Meta::TypeConstraint::Parameterizable::BEGIN@4
1118µs12µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@5Moose::Meta::TypeConstraint::Parameterizable::BEGIN@5
1117µs31µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@14Moose::Meta::TypeConstraint::Parameterizable::BEGIN@14
1117µs31µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@8Moose::Meta::TypeConstraint::Parameterizable::BEGIN@8
1116µs6µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@9Moose::Meta::TypeConstraint::Parameterizable::BEGIN@9
1116µs377µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@6Moose::Meta::TypeConstraint::Parameterizable::BEGIN@6
1116µs159µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@12Moose::Meta::TypeConstraint::Parameterizable::BEGIN@12
1113µs3µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@10Moose::Meta::TypeConstraint::Parameterizable::BEGIN@10
0000s0sMoose::Meta::TypeConstraint::Parameterizable::::__ANON__[:50]Moose::Meta::TypeConstraint::Parameterizable::__ANON__[:50]
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;
21500nsour $VERSION = '2.1604';
3
4227µs234µs
# spent 22µs (10+12) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@4 which was called: # once (10µs+12µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 4
use strict;
# spent 22µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@4 # spent 12µs making 1 call to strict::import
5219µs216µs
# spent 12µs (8+4) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@5 which was called: # once (8µs+4µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 5
use warnings;
# spent 12µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@5 # spent 4µs making 1 call to warnings::import
6227µs2748µs
# spent 377µs (6+371) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@6 which was called: # once (6µs+371µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 6
use metaclass;
# spent 377µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@6 # spent 371µs making 1 call to metaclass::import
7
8222µs255µs
# spent 31µs (7+24) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@8 which was called: # once (7µs+24µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 8
use parent 'Moose::Meta::TypeConstraint';
# spent 31µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@8 # spent 24µs making 1 call to parent::import
9221µs16µs
# spent 6µs within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@9 which was called: # once (6µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 9
use Moose::Meta::TypeConstraint::Parameterized;
10218µs13µs
# spent 3µs within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@10 which was called: # once (3µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 10
use Moose::Util::TypeConstraints ();
11
12225µs2313µs
# spent 159µs (6+153) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@12 which was called: # once (6µs+153µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 12
use Moose::Util 'throw_exception';
# spent 159µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@12 # spent 153µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
13
142374µs255µs
# spent 31µs (7+24) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@14 which was called: # once (7µs+24µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 14
use Carp 'confess';
# spent 31µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@14 # spent 24µs making 1 call to Exporter::import
15
1616µs3499µs__PACKAGE__->meta->add_attribute('constraint_generator' => (
# spent 478µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 16µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::meta # spent 6µs making 1 call to Class::MOP::_definition_context
17 accessor => 'constraint_generator',
18 predicate => 'has_constraint_generator',
19 Class::MOP::_definition_context(),
20));
21
2212µs3375µs__PACKAGE__->meta->add_attribute('inline_generator' => (
# spent 363µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::meta # spent 4µs making 1 call to Class::MOP::_definition_context
23 accessor => 'inline_generator',
24 predicate => 'has_inline_generator',
25 Class::MOP::_definition_context(),
26));
27
28
# spent 2.18ms (200µs+1.98) within Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for which was called 18 times, avg 121µs/call: # 18 times (200µs+1.98ms) by Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint at line 55 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 121µs/call
sub generate_constraint_for {
29185µs my ($self, $type) = @_;
30
311822µs1826µs return unless $self->has_constraint_generator;
# spent 26µs making 18 calls to Moose::Meta::TypeConstraint::Parameterizable::has_constraint_generator, avg 1µs/call
32
331871µs571.94ms return $self->constraint_generator->($type->type_parameter)
# spent 1.83ms making 18 calls to Moose::Meta::TypeConstraint::is_subtype_of, avg 102µs/call # spent 39µs making 4 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:216], avg 10µs/call # spent 20µs making 2 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:251], avg 10µs/call # spent 20µs making 18 calls to Moose::Meta::TypeConstraint::name, avg 1µs/call # spent 15µs making 7 calls to Moose::Meta::TypeConstraint::Parameterizable::constraint_generator, avg 2µs/call # spent 9µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:284] # spent 7µs making 7 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 1µs/call
34 if $type->is_subtype_of($self->name);
35
361114µs1114µs return $self->_can_coerce_constraint_from($type)
# spent 14µs making 11 calls to Moose::Meta::TypeConstraint::has_coercion, avg 1µs/call
37 if $self->has_coercion
38 && $self->coercion->has_coercion_for_type($type->parent->name);
39
401120µs return;
41}
42
43sub _can_coerce_constraint_from {
44 my ($self, $type) = @_;
45 my $coercion = $self->coercion;
46 my $constraint = $self->constraint_generator->($type->type_parameter);
47 return sub {
48 local $_ = $coercion->coerce($_);
49 $constraint->(@_);
50 };
51}
52
53
# spent 2.54ms (376µs+2.16) within Moose::Meta::TypeConstraint::Parameterizable::generate_inline_for which was called 40 times, avg 63µs/call: # 40 times (376µs+2.16ms) by Moose::Meta::TypeConstraint::Parameterized::_inline_check at line 95 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 63µs/call
sub generate_inline_for {
544022µs my ($self, $type, $val) = @_;
55
564039µs4030µs throw_exception( CannotGenerateInlineConstraint => parameterizable_type_object_name => $self->name,
# spent 30µs making 40 calls to Moose::Meta::TypeConstraint::Parameterizable::has_inline_generator, avg 742ns/call
57 type_name => $type->name,
58 value => $val,
59 )
60 unless $self->has_inline_generator;
61
6240238µs802.13ms return '( do { ' . $self->inline_generator->( $self, $type, $val ) . ' } )';
63}
64
65
# spent 950µs (27+922) within Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter which was called 7 times, avg 136µs/call: # 7 times (27µs+922µs) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 73, avg 136µs/call
sub _parse_type_parameter {
6672µs my ($self, $type_parameter) = @_;
6774.15ms7604µs return Moose::Util::TypeConstraints::find_or_create_isa_type_constraint($type_parameter);
# spent 922µs making 7 calls to Moose::Util::TypeConstraints::find_or_create_isa_type_constraint, avg 132µs/call, recursion: max depth 1, sum of overlapping time 318µs
68}
69
70
# spent 10.8ms (4.29+6.51) within Moose::Meta::TypeConstraint::Parameterizable::parameterize which was called 7 times, avg 1.54ms/call: # 7 times (4.29ms+6.51ms) by Moose::Util::TypeConstraints::_create_parameterized_type_constraint at line 133 of Moose/Util/TypeConstraints.pm, avg 1.54ms/call
sub parameterize {
7173µs my ($self, $type_parameter) = @_;
72
73714µs7950µs my $contained_tc = $self->_parse_type_parameter($type_parameter);
# spent 950µs making 7 calls to Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter, avg 136µs/call
74
75 ## The type parameter should be a subtype of the parent's type parameter
76 ## if there is one.
77
78745µs2130µs if(my $parent = $self->parent) {
# spent 20µs making 7 calls to Moose::Meta::TypeConstraint::parent, avg 3µs/call # spent 6µs making 7 calls to UNIVERSAL::can, avg 900ns/call # spent 4µs making 7 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 514ns/call
79 if($parent->can('type_parameter')) {
80 unless ( $contained_tc->is_a_type_of($parent->type_parameter) ) {
81 throw_exception( ParameterIsNotSubtypeOfParent => type_parameter => $type_parameter,
82 type_name => $self->name,
83 );
84 }
85 }
86 }
87
88725µs77µs if ( $contained_tc->isa('Moose::Meta::TypeConstraint') ) {
# spent 7µs making 7 calls to UNIVERSAL::isa, avg 1µs/call
89725µs1424µs my $tc_name = $self->name . '[' . $contained_tc->name . ']';
# spent 24µs making 14 calls to Moose::Meta::TypeConstraint::name, avg 2µs/call
90739µs75.50ms return Moose::Meta::TypeConstraint::Parameterized->new(
# spent 5.50ms making 7 calls to Moose::Meta::TypeConstraint::new, avg 786µs/call
91 name => $tc_name,
92 parent => $self,
93 type_parameter => $contained_tc,
94 parameterized_from => $self,
95 );
96 }
97 else {
98 confess("The type parameter must be a Moose meta type");
99 }
100}
101
102
10316µs1;
104
105# ABSTRACT: Type constraints which can take a parameter (ArrayRef)
106
107__END__