← 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/Class.pm
StatementsExecuted 713 statements in 2.47ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
149114.44ms5.02msMoose::Meta::TypeConstraint::Class::::__ANON__[:25]Moose::Meta::TypeConstraint::Class::__ANON__[:25]
3111571µs22.7msMoose::Meta::TypeConstraint::Class::::newMoose::Meta::TypeConstraint::Class::new
11111µs27µsMoose::Meta::TypeConstraint::Class::::BEGIN@8Moose::Meta::TypeConstraint::Class::BEGIN@8
11110µs23µsMoose::Meta::TypeConstraint::Class::::BEGIN@4Moose::Meta::TypeConstraint::Class::BEGIN@4
1116µs12µsMoose::Meta::TypeConstraint::Class::::BEGIN@5Moose::Meta::TypeConstraint::Class::BEGIN@5
1116µs390µsMoose::Meta::TypeConstraint::Class::::BEGIN@6Moose::Meta::TypeConstraint::Class::BEGIN@6
1116µs25µsMoose::Meta::TypeConstraint::Class::::BEGIN@12Moose::Meta::TypeConstraint::Class::BEGIN@12
1113µs3µsMoose::Meta::TypeConstraint::Class::::BEGIN@10Moose::Meta::TypeConstraint::Class::BEGIN@10
1113µs3µsMoose::Meta::TypeConstraint::Class::::BEGIN@9Moose::Meta::TypeConstraint::Class::BEGIN@9
0000s0sMoose::Meta::TypeConstraint::Class::::__ANON__[:34]Moose::Meta::TypeConstraint::Class::__ANON__[:34]
0000s0sMoose::Meta::TypeConstraint::Class::::create_child_typeMoose::Meta::TypeConstraint::Class::create_child_type
0000s0sMoose::Meta::TypeConstraint::Class::::equalsMoose::Meta::TypeConstraint::Class::equals
0000s0sMoose::Meta::TypeConstraint::Class::::get_messageMoose::Meta::TypeConstraint::Class::get_message
0000s0sMoose::Meta::TypeConstraint::Class::::is_a_type_ofMoose::Meta::TypeConstraint::Class::is_a_type_of
0000s0sMoose::Meta::TypeConstraint::Class::::is_subtype_ofMoose::Meta::TypeConstraint::Class::is_subtype_of
0000s0sMoose::Meta::TypeConstraint::Class::::parentsMoose::Meta::TypeConstraint::Class::parents
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::Class;
21600nsour $VERSION = '2.1604';
3
4222µs235µs
# spent 23µs (10+12) within Moose::Meta::TypeConstraint::Class::BEGIN@4 which was called: # once (10µs+12µs) by Moose::Util::TypeConstraints::BEGIN@28 at line 4
use strict;
# spent 23µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@4 # spent 12µs making 1 call to strict::import
5218µs218µs
# spent 12µs (6+6) within Moose::Meta::TypeConstraint::Class::BEGIN@5 which was called: # once (6µs+6µs) by Moose::Util::TypeConstraints::BEGIN@28 at line 5
use warnings;
# spent 12µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@5 # spent 6µs making 1 call to warnings::import
6224µs2774µs
# spent 390µs (6+384) within Moose::Meta::TypeConstraint::Class::BEGIN@6 which was called: # once (6µs+384µs) by Moose::Util::TypeConstraints::BEGIN@28 at line 6
use metaclass;
# spent 390µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@6 # spent 384µs making 1 call to metaclass::import
7
8223µs244µs
# spent 27µs (11+16) within Moose::Meta::TypeConstraint::Class::BEGIN@8 which was called: # once (11µs+16µs) by Moose::Util::TypeConstraints::BEGIN@28 at line 8
use B;
# spent 27µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@8 # spent 16µs making 1 call to Exporter::import
9216µs13µs
# spent 3µs within Moose::Meta::TypeConstraint::Class::BEGIN@9 which was called: # once (3µs+0s) by Moose::Util::TypeConstraints::BEGIN@28 at line 9
use Scalar::Util ();
# spent 3µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@9
10219µs13µs
# spent 3µs within Moose::Meta::TypeConstraint::Class::BEGIN@10 which was called: # once (3µs+0s) by Moose::Util::TypeConstraints::BEGIN@28 at line 10
use Moose::Util::TypeConstraints ();
# spent 3µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@10
11
122501µs243µs
# spent 25µs (6+19) within Moose::Meta::TypeConstraint::Class::BEGIN@12 which was called: # once (6µs+19µs) by Moose::Util::TypeConstraints::BEGIN@28 at line 12
use parent 'Moose::Meta::TypeConstraint';
# spent 25µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@12 # spent 19µs making 1 call to parent::import
13
1415µs3304µs__PACKAGE__->meta->add_attribute('class' => (
# spent 286µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 13µs making 1 call to Moose::Meta::TypeConstraint::Class::meta # spent 4µs making 1 call to Class::MOP::_definition_context
15 reader => 'class',
16 Class::MOP::_definition_context(),
17));
18
19
# spent 5.02ms (4.44+581µs) within Moose::Meta::TypeConstraint::Class::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Meta/TypeConstraint/Class.pm:25] which was called 149 times, avg 34µs/call: # 149 times (4.44ms+581µs) by Moose::Meta::TypeConstraint::_inline_check at line 195 of Moose/Meta/TypeConstraint.pm, avg 34µs/call
my $inliner = sub {
2014935µs my $self = shift;
2114939µs my $val = shift;
22
231491.26ms298581µs return 'Scalar::Util::blessed(' . $val . ')'
# spent 332µs making 149 calls to B::perlstring, avg 2µs/call # spent 249µs making 149 calls to Moose::Meta::TypeConstraint::Class::class, avg 2µs/call
24 . ' && ' . $val . '->isa(' . B::perlstring($self->class) . ')';
2512µs};
26
27
# spent 22.7ms (571µs+22.1) within Moose::Meta::TypeConstraint::Class::new which was called 31 times, avg 731µs/call: # 31 times (571µs+22.1ms) by Moose::Util::TypeConstraints::create_class_type_constraint at line 176 of Moose/Util/TypeConstraints.pm, avg 731µs/call
sub new {
283140µs my ( $class, %args ) = @_;
29
303160µs31427µs $args{parent}
# spent 427µs making 31 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 14µs/call
31 = Moose::Util::TypeConstraints::find_type_constraint('Object');
32
333120µs my $class_name = $args{class};
3431114µs $args{constraint} = sub { $_[0]->isa($class_name) };
35
363126µs $args{inlined} = $inliner;
37
3831103µs3116.5ms my $self = $class->SUPER::new( \%args );
# spent 16.5ms making 31 calls to Moose::Meta::TypeConstraint::new, avg 534µs/call
39
403142µs315.11ms $self->compile_type_constraint();
# spent 5.11ms making 31 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 165µs/call
41
423192µs return $self;
43}
44
45sub parents {
46 my $self = shift;
47 return (
48 $self->parent,
49 map {
50 # FIXME find_type_constraint might find a TC named after the class but that isn't really it
51 # I did this anyway since it's a convention that preceded TypeConstraint::Class, and it should DWIM
52 # if anybody thinks this problematic please discuss on IRC.
53 # a possible fix is to add by attr indexing to the type registry to find types of a certain property
54 # regardless of their name
55 Moose::Util::TypeConstraints::find_type_constraint($_)
56 ||
57 __PACKAGE__->new( class => $_, name => "__ANON__" )
58 } Class::MOP::class_of($self->class)->superclasses,
59 );
60}
61
62sub equals {
63 my ( $self, $type_or_name ) = @_;
64
65 my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
66
67 if (!defined($other)) {
68 if (!ref($type_or_name)) {
69 return $self->class eq $type_or_name;
70 }
71 return;
72 }
73
74 return unless $other->isa(__PACKAGE__);
75
76 return $self->class eq $other->class;
77}
78
79sub is_a_type_of {
80 my ($self, $type_or_name) = @_;
81
82 ($self->equals($type_or_name) || $self->is_subtype_of($type_or_name));
83}
84
85sub is_subtype_of {
86 my ($self, $type_or_name_or_class ) = @_;
87
88 my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name_or_class);
89
90 if ( not defined $type ) {
91 if ( not ref $type_or_name_or_class ) {
92 # it might be a class
93 my $class = $self->class;
94 return 1 if $class ne $type_or_name_or_class
95 && $class->isa( $type_or_name_or_class );
96 }
97 return;
98 }
99
100 if ( $type->isa(__PACKAGE__) && $type->class ne $self->class) {
101 # if $type_or_name_or_class isn't a class, it might be the TC name of another ::Class type
102 # or it could also just be a type object in this branch
103 return $self->class->isa( $type->class );
104 } else {
105 # the only other thing we are a subtype of is Object
106 $self->SUPER::is_subtype_of($type);
107 }
108}
109
110# This is a bit counter-intuitive, but a child type of a Class type
111# constraint is not itself a Class type constraint (it has no class
112# attribute). This whole create_child_type thing needs some changing
113# though, probably making MMC->new a factory or something.
114sub create_child_type {
115 my ($self, @args) = @_;
116 return Moose::Meta::TypeConstraint->new(@args, parent => $self);
117}
118
119sub get_message {
120 my $self = shift;
121 my ($value) = @_;
122
123 if ($self->has_message) {
124 return $self->SUPER::get_message(@_);
125 }
126
127 $value = (defined $value ? overload::StrVal($value) : 'undef');
128 return "Validation failed for '" . $self->name . "' with value $value (not isa " . $self->class . ")";
129}
130
13114µs1;
132
133# ABSTRACT: Class/TypeConstraint parallel hierarchy
134
135__END__