← Index
NYTProf Performance Profile   « line view »
For examples/Atom-timer.pl
  Run on Mon Aug 12 14:45:28 2013
Reported on Mon Aug 12 14:46:14 2013

Filename/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/TypeConstraint/Parameterizable.pm
StatementsExecuted 127 statements in 783µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1711122µs889µsMoose::Meta::TypeConstraint::Parameterizable::::generate_inline_forMoose::Meta::TypeConstraint::Parameterizable::generate_inline_for
71183µs999µsMoose::Meta::TypeConstraint::Parameterizable::::generate_constraint_forMoose::Meta::TypeConstraint::Parameterizable::generate_constraint_for
31176µs3.03msMoose::Meta::TypeConstraint::Parameterizable::::parameterizeMoose::Meta::TypeConstraint::Parameterizable::parameterize
31110µs582µsMoose::Meta::TypeConstraint::Parameterizable::::_parse_type_parameterMoose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter
1118µs8µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@2Moose::Meta::TypeConstraint::Parameterizable::BEGIN@2
1116µs53µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@13Moose::Meta::TypeConstraint::Parameterizable::BEGIN@13
1116µs6µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@14Moose::Meta::TypeConstraint::Parameterizable::BEGIN@14
1116µs26µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@17Moose::Meta::TypeConstraint::Parameterizable::BEGIN@17
1116µs9µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@10Moose::Meta::TypeConstraint::Parameterizable::BEGIN@10
1116µs16µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@9Moose::Meta::TypeConstraint::Parameterizable::BEGIN@9
1115µs333µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@11Moose::Meta::TypeConstraint::Parameterizable::BEGIN@11
1113µs3µsMoose::Meta::TypeConstraint::Parameterizable::::BEGIN@15Moose::Meta::TypeConstraint::Parameterizable::BEGIN@15
0000s0sMoose::Meta::TypeConstraint::Parameterizable::::__ANON__[:53]Moose::Meta::TypeConstraint::Parameterizable::__ANON__[:53]
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;
2
# spent 8µs within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@2 which was called: # once (8µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 4
BEGIN {
314µs $Moose::Meta::TypeConstraint::Parameterizable::AUTHORITY = 'cpan:STEVAN';
4130µs18µs}
5{
62800ns $Moose::Meta::TypeConstraint::Parameterizable::VERSION = '2.1005';
7}
8
9220µs226µs
# spent 16µs (6+10) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@9 which was called: # once (6µs+10µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 9
use strict;
# spent 16µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@9 # spent 10µs making 1 call to strict::import
10218µs212µs
# spent 9µs (6+3) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@10 which was called: # once (6µs+3µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 10
use warnings;
# spent 9µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@10 # spent 3µs making 1 call to warnings::import
11228µs2660µs
# spent 333µs (5+327) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@11 which was called: # once (5µs+327µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 11
use metaclass;
# spent 333µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@11 # spent 327µs making 1 call to metaclass::import
12
13225µs299µs
# spent 53µs (6+47) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@13 which was called: # once (6µs+47µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 13
use base 'Moose::Meta::TypeConstraint';
# spent 53µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@13 # spent 46µs making 1 call to base::import
14221µs16µs
# spent 6µs within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@14 which was called: # once (6µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 14
use Moose::Meta::TypeConstraint::Parameterized;
15221µs13µs
# spent 3µs within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@15 which was called: # once (3µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 15
use Moose::Util::TypeConstraints ();
16
172408µs246µs
# spent 26µs (6+20) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@17 which was called: # once (6µs+20µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 17
use Carp 'confess';
# spent 26µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@17 # spent 20µs making 1 call to Exporter::import
18
1913µs3457µs__PACKAGE__->meta->add_attribute('constraint_generator' => (
# spent 439µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 14µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::meta # spent 5µs making 1 call to Class::MOP::_definition_context
20 accessor => 'constraint_generator',
21 predicate => 'has_constraint_generator',
22 Class::MOP::_definition_context(),
23));
24
2513µs3409µs__PACKAGE__->meta->add_attribute('inline_generator' => (
# spent 396µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::meta # spent 5µs making 1 call to Class::MOP::_definition_context
26 accessor => 'inline_generator',
27 predicate => 'has_inline_generator',
28 Class::MOP::_definition_context(),
29));
30
31
# spent 999µs (83+916) within Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for which was called 7 times, avg 143µs/call: # 7 times (83µs+916µs) by Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint at line 61 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 143µs/call
sub generate_constraint_for {
3272µs my ($self, $type) = @_;
33
3478µs710µs return unless $self->has_constraint_generator;
# spent 10µs making 7 calls to Moose::Meta::TypeConstraint::Parameterizable::has_constraint_generator, avg 1µs/call
35
36727µs23902µs return $self->constraint_generator->($type->type_parameter)
# spent 858µs making 7 calls to Moose::Meta::TypeConstraint::is_subtype_of, avg 122µs/call # spent 17µs making 2 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:222], avg 8µs/call # spent 9µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:257] # spent 8µs making 7 calls to Moose::Meta::TypeConstraint::name, avg 1µs/call # spent 6µs making 3 calls to Moose::Meta::TypeConstraint::Parameterizable::constraint_generator, avg 2µs/call # spent 4µs making 3 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 1µs/call
37 if $type->is_subtype_of($self->name);
38
3944µs45µs return $self->_can_coerce_constraint_from($type)
# spent 5µs making 4 calls to Moose::Meta::TypeConstraint::has_coercion, avg 1µs/call
40 if $self->has_coercion
41 && $self->coercion->has_coercion_for_type($type->parent->name);
42
4347µs return;
44}
45
46sub _can_coerce_constraint_from {
47 my ($self, $type) = @_;
48 my $coercion = $self->coercion;
49 my $constraint = $self->constraint_generator->($type->type_parameter);
50 return sub {
51 local $_ = $coercion->coerce($_);
52 $constraint->(@_);
53 };
54}
55
56
# spent 889µs (122+767) within Moose::Meta::TypeConstraint::Parameterizable::generate_inline_for which was called 17 times, avg 52µs/call: # 17 times (122µs+767µs) by Moose::Meta::TypeConstraint::Parameterized::_inline_check at line 101 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 52µs/call
sub generate_inline_for {
57175µs my ($self, $type, $val) = @_;
58
591711µs1714µs confess "Can't generate an inline constraint for $type, since none "
# spent 14µs making 17 calls to Moose::Meta::TypeConstraint::Parameterizable::has_inline_generator, avg 824ns/call
60 . "was defined"
61 unless $self->has_inline_generator;
62
631760µs34753µs return '( do { ' . $self->inline_generator->( $self, $type, $val ) . ' } )';
64}
65
66
# spent 582µs (10+571) within Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter which was called 3 times, avg 194µs/call: # 3 times (10µs+571µs) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 74, avg 194µs/call
sub _parse_type_parameter {
673700ns my ($self, $type_parameter) = @_;
6839µs3512µs return Moose::Util::TypeConstraints::find_or_create_isa_type_constraint($type_parameter);
# spent 571µs making 3 calls to Moose::Util::TypeConstraints::find_or_create_isa_type_constraint, avg 190µs/call, recursion: max depth 1, sum of overlapping time 60µs
69}
70
71
# spent 3.03ms (76µs+2.96) within Moose::Meta::TypeConstraint::Parameterizable::parameterize which was called 3 times, avg 1.01ms/call: # 3 times (76µs+2.96ms) by Moose::Util::TypeConstraints::_create_parameterized_type_constraint at line 143 of Moose/Util/TypeConstraints.pm, avg 1.01ms/call
sub parameterize {
7231µs my ($self, $type_parameter) = @_;
73
7435µs3582µs my $contained_tc = $self->_parse_type_parameter($type_parameter);
# spent 582µs making 3 calls to Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter, avg 194µs/call
75
76 ## The type parameter should be a subtype of the parent's type parameter
77 ## if there is one.
78
7939µs67µs if(my $parent = $self->parent) {
# spent 5µs making 3 calls to Moose::Meta::TypeConstraint::parent, avg 2µs/call # spent 2µs making 3 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:16], avg 667ns/call
80311µs33µs if($parent->can('type_parameter')) {
# spent 3µs making 3 calls to UNIVERSAL::can, avg 1µs/call
81 unless ( $contained_tc->is_a_type_of($parent->type_parameter) ) {
82 require Moose;
83 Moose->throw_error("$type_parameter is not a subtype of ".$parent->type_parameter);
84 }
85 }
86 }
87
8838µs32µs if ( $contained_tc->isa('Moose::Meta::TypeConstraint') ) {
# spent 2µs making 3 calls to UNIVERSAL::isa, avg 733ns/call
8938µs67µs my $tc_name = $self->name . '[' . $contained_tc->name . ']';
# spent 7µs making 6 calls to Moose::Meta::TypeConstraint::name, avg 1µs/call
90318µs32.36ms return Moose::Meta::TypeConstraint::Parameterized->new(
# spent 2.36ms making 3 calls to Moose::Meta::TypeConstraint::new, avg 785µs/call
91 name => $tc_name,
92 parent => $self,
93 type_parameter => $contained_tc,
94 parameterized_from => $self,
95 );
96 }
97 else {
98 require Moose;
99 Moose->throw_error("The type parameter must be a Moose meta type");
100 }
101}
102
103
10416µs1;
105
106# ABSTRACT: Type constraints which can take a parameter (ArrayRef)
107
108__END__