← Index
NYTProf Performance Profile   « line view »
For /home/ss5/perl5/perlbrew/perls/perl-5.22.0/bin/benchmarkanything-storage
  Run on Mon Jan 29 16:55:34 2018
Reported on Mon Jan 29 16:57:07 2018

Filename/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Meta/TypeConstraint/Parameterizable.pm
StatementsExecuted 94 statements in 506µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
71156µs597µsMoose::Meta::TypeConstraint::Parameterizable::::generate_constraint_forMoose::Meta::TypeConstraint::Parameterizable::generate_constraint_for
91151µs230µsMoose::Meta::TypeConstraint::Parameterizable::::generate_inline_forMoose::Meta::TypeConstraint::Parameterizable::generate_inline_for (recurses: max depth 1, inclusive time 86µs)
21146µs1.44msMoose::Meta::TypeConstraint::Parameterizable::::parameterizeMoose::Meta::TypeConstraint::Parameterizable::parameterize (recurses: max depth 1, inclusive time 758µs)
11110µs11µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@4Moose::Meta::TypeConstraint::Parameterizable::BEGIN@4
1117µs25µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@14Moose::Meta::TypeConstraint::Parameterizable::BEGIN@14
2117µs841µsMoose::Meta::TypeConstraint::Parameterizable::::_parse_type_parameterMoose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter (recurses: max depth 1, inclusive time 27µs)
1117µs158µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@12Moose::Meta::TypeConstraint::Parameterizable::BEGIN@12
1116µs24µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@8Moose::Meta::TypeConstraint::Parameterizable::BEGIN@8
1114µs4µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@9Moose::Meta::TypeConstraint::Parameterizable::BEGIN@9
1114µs8µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@5Moose::Meta::TypeConstraint::Parameterizable::BEGIN@5
1114µs260µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@6Moose::Meta::TypeConstraint::Parameterizable::BEGIN@6
1112µs2µ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;
21300nsour $VERSION = '2.1605';
3
4214µs213µs
# spent 11µs (10+2) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@4 which was called: # once (10µs+2µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 4
use strict;
# spent 11µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@4 # spent 2µs making 1 call to strict::import
5212µs212µs
# spent 8µs (4+4) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@5 which was called: # once (4µs+4µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 5
use warnings;
# spent 8µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@5 # spent 4µs making 1 call to warnings::import
6221µs2516µs
# spent 260µs (4+256) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@6 which was called: # once (4µs+256µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 6
use metaclass;
# spent 260µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@6 # spent 256µs making 1 call to metaclass::import
7
8216µs242µs
# spent 24µs (6+18) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@8 which was called: # once (6µs+18µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 8
use parent 'Moose::Meta::TypeConstraint';
# spent 24µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@8 # spent 18µs making 1 call to parent::import
9214µs14µs
# spent 4µs within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@9 which was called: # once (4µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 9
use Moose::Meta::TypeConstraint::Parameterized;
10212µs12µs
# spent 2µs within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@10 which was called: # once (2µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 10
use Moose::Util::TypeConstraints ();
11
12223µs2309µs
# spent 158µs (7+151) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@12 which was called: # once (7µs+151µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 12
use Moose::Util 'throw_exception';
13
142259µs242µs
# spent 25µs (7+18) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@14 which was called: # once (7µs+18µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 14
use Carp 'confess';
# spent 25µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@14 # spent 18µs making 1 call to Exporter::import
15
1614µs3454µs__PACKAGE__->meta->add_attribute('constraint_generator' => (
# spent 435µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 14µ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µs3305µs__PACKAGE__->meta->add_attribute('inline_generator' => (
# spent 295µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 6µ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 597µs (56+541) within Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for which was called 7 times, avg 85µs/call: # 7 times (56µs+541µs) by Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint at line 55 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 85µs/call
sub generate_constraint_for {
2971µs my ($self, $type) = @_;
30
3177µs77µs return unless $self->has_constraint_generator;
# spent 7µs making 7 calls to Moose::Meta::TypeConstraint::Parameterizable::has_constraint_generator, avg 1µs/call
32
33718µs20531µs return $self->constraint_generator->($type->type_parameter)
34 if $type->is_subtype_of($self->name);
35
3654µs53µs return $self->_can_coerce_constraint_from($type)
# spent 3µs making 5 calls to Moose::Meta::TypeConstraint::has_coercion, avg 580ns/call
37 if $self->has_coercion
38 && $self->coercion->has_coercion_for_type($type->parent->name);
39
4057µ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 230µs (51+178) within Moose::Meta::TypeConstraint::Parameterizable::generate_inline_for which was called 9 times, avg 26µs/call: # 9 times (51µs+178µs) by Moose::Meta::TypeConstraint::Parameterized::_inline_check at line 95 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 26µs/call
sub generate_inline_for {
5492µs my ($self, $type, $val) = @_;
55
5695µs93µs throw_exception( CannotGenerateInlineConstraint => parameterizable_type_object_name => $self->name,
# spent 3µs making 9 calls to Moose::Meta::TypeConstraint::Parameterizable::has_inline_generator, avg 344ns/call
57 type_name => $type->name,
58 value => $val,
59 )
60 unless $self->has_inline_generator;
61
62928µs18261µs return '( do { ' . $self->inline_generator->( $self, $type, $val ) . ' } )';
63}
64
65
# spent 841µs (7+834) within Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter which was called 2 times, avg 421µs/call: # 2 times (7µs+834µs) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 73, avg 421µs/call
sub _parse_type_parameter {
662500ns my ($self, $type_parameter) = @_;
6727µs20s return Moose::Util::TypeConstraints::find_or_create_isa_type_constraint($type_parameter);
# spent 861µs making 2 calls to Moose::Util::TypeConstraints::find_or_create_isa_type_constraint, avg 431µs/call, recursion: max depth 2, sum of overlapping time 861µs
68}
69
70
# spent 1.44ms (46µs+1.40) within Moose::Meta::TypeConstraint::Parameterizable::parameterize which was called 2 times, avg 721µs/call: # 2 times (46µs+1.40ms) by Moose::Util::TypeConstraints::_create_parameterized_type_constraint at line 133 of Moose/Util/TypeConstraints.pm, avg 721µs/call
sub parameterize {
7122µs my ($self, $type_parameter) = @_;
72
7323µs2841µs my $contained_tc = $self->_parse_type_parameter($type_parameter);
# spent 868µs making 2 calls to Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter, avg 434µs/call, recursion: max depth 1, sum of overlapping time 27µs
74
75 ## The type parameter should be a subtype of the parent's type parameter
76 ## if there is one.
77
78218µs66µs if(my $parent = $self->parent) {
# spent 3µs making 2 calls to Moose::Meta::TypeConstraint::parent, avg 1µs/call # spent 3µs making 2 calls to UNIVERSAL::can, avg 1µs/call # spent 600ns making 2 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 300ns/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
8824µs2900ns if ( $contained_tc->isa('Moose::Meta::TypeConstraint') ) {
# spent 900ns making 2 calls to UNIVERSAL::isa, avg 450ns/call
8925µs44µs my $tc_name = $self->name . '[' . $contained_tc->name . ']';
# spent 4µs making 4 calls to Moose::Meta::TypeConstraint::name, avg 1µs/call
9028µs21.27ms return Moose::Meta::TypeConstraint::Parameterized->new(
# spent 1.27ms making 2 calls to Moose::Meta::TypeConstraint::new, avg 637µ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
10318µs1;
104
105# ABSTRACT: Type constraints which can take a parameter (ArrayRef)
106
107__END__