← 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/Class.pm
StatementsExecuted 132 statements in 872µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
2411136µs191µsMoose::Meta::TypeConstraint::Class::::__ANON__[:30]Moose::Meta::TypeConstraint::Class::__ANON__[:30]
51175µs2.18msMoose::Meta::TypeConstraint::Class::::newMoose::Meta::TypeConstraint::Class::new
1118µs24µsMoose::Meta::TypeConstraint::Class::::BEGIN@13Moose::Meta::TypeConstraint::Class::BEGIN@13
1118µs19µsMoose::Meta::TypeConstraint::Class::::BEGIN@9Moose::Meta::TypeConstraint::Class::BEGIN@9
1118µs8µsMoose::Meta::TypeConstraint::Class::::BEGIN@2Moose::Meta::TypeConstraint::Class::BEGIN@2
1116µs9µsMoose::Meta::TypeConstraint::Class::::BEGIN@10Moose::Meta::TypeConstraint::Class::BEGIN@10
1116µs25µsMoose::Meta::TypeConstraint::Class::::BEGIN@14Moose::Meta::TypeConstraint::Class::BEGIN@14
1115µs53µsMoose::Meta::TypeConstraint::Class::::BEGIN@17Moose::Meta::TypeConstraint::Class::BEGIN@17
1115µs325µsMoose::Meta::TypeConstraint::Class::::BEGIN@11Moose::Meta::TypeConstraint::Class::BEGIN@11
1113µs3µsMoose::Meta::TypeConstraint::Class::::BEGIN@15Moose::Meta::TypeConstraint::Class::BEGIN@15
0000s0sMoose::Meta::TypeConstraint::Class::::__ANON__[:39]Moose::Meta::TypeConstraint::Class::__ANON__[:39]
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;
2
# spent 8µs within Moose::Meta::TypeConstraint::Class::BEGIN@2 which was called: # once (8µs+0s) by Moose::Util::TypeConstraints::BEGIN@36 at line 4
BEGIN {
314µs $Moose::Meta::TypeConstraint::Class::AUTHORITY = 'cpan:STEVAN';
4129µs18µs}
# spent 8µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@2
5{
62700ns $Moose::Meta::TypeConstraint::Class::VERSION = '2.1005';
7}
8
9220µs229µs
# spent 19µs (8+10) within Moose::Meta::TypeConstraint::Class::BEGIN@9 which was called: # once (8µs+10µs) by Moose::Util::TypeConstraints::BEGIN@36 at line 9
use strict;
# spent 19µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@9 # spent 10µs making 1 call to strict::import
10217µs212µs
# spent 9µs (6+3) within Moose::Meta::TypeConstraint::Class::BEGIN@10 which was called: # once (6µs+3µs) by Moose::Util::TypeConstraints::BEGIN@36 at line 10
use warnings;
# spent 9µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@10 # spent 3µs making 1 call to warnings::import
11223µs2645µs
# spent 325µs (5+320) within Moose::Meta::TypeConstraint::Class::BEGIN@11 which was called: # once (5µs+320µs) by Moose::Util::TypeConstraints::BEGIN@36 at line 11
use metaclass;
# spent 325µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@11 # spent 320µs making 1 call to metaclass::import
12
13224µs239µs
# spent 24µs (8+16) within Moose::Meta::TypeConstraint::Class::BEGIN@13 which was called: # once (8µs+16µs) by Moose::Util::TypeConstraints::BEGIN@36 at line 13
use B;
# spent 24µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@13 # spent 16µs making 1 call to Exporter::import
14219µs244µs
# spent 25µs (6+19) within Moose::Meta::TypeConstraint::Class::BEGIN@14 which was called: # once (6µs+19µs) by Moose::Util::TypeConstraints::BEGIN@36 at line 14
use Scalar::Util 'blessed';
# spent 25µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@14 # spent 19µs making 1 call to Exporter::import
15219µs13µs
# spent 3µs within Moose::Meta::TypeConstraint::Class::BEGIN@15 which was called: # once (3µs+0s) by Moose::Util::TypeConstraints::BEGIN@36 at line 15
use Moose::Util::TypeConstraints ();
# spent 3µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@15
16
172504µs2101µs
# spent 53µs (5+48) within Moose::Meta::TypeConstraint::Class::BEGIN@17 which was called: # once (5µs+48µs) by Moose::Util::TypeConstraints::BEGIN@36 at line 17
use base 'Moose::Meta::TypeConstraint';
# spent 53µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@17 # spent 48µs making 1 call to base::import
18
1913µs3286µs__PACKAGE__->meta->add_attribute('class' => (
# spent 268µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 13µs making 1 call to Moose::Meta::TypeConstraint::Class::meta # spent 5µs making 1 call to Class::MOP::_definition_context
20 reader => 'class',
21 Class::MOP::_definition_context(),
22));
23
24
# spent 191µs (136+54) within Moose::Meta::TypeConstraint::Class::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/TypeConstraint/Class.pm:30] which was called 24 times, avg 8µs/call: # 24 times (136µs+54µs) by Moose::Meta::TypeConstraint::_inline_check at line 216 of Moose/Meta/TypeConstraint.pm, avg 8µs/call
my $inliner = sub {
25243µs my $self = shift;
26244µs my $val = shift;
27
2824138µs4854µs return 'Scalar::Util::blessed(' . $val . ')'
# spent 29µs making 24 calls to Moose::Meta::TypeConstraint::Class::class, avg 1µs/call # spent 26µs making 24 calls to B::perlstring, avg 1µs/call
29 . ' && ' . $val . '->isa(' . B::perlstring($self->class) . ')';
3012µs};
31
32
# spent 2.18ms (75µs+2.10) within Moose::Meta::TypeConstraint::Class::new which was called 5 times, avg 436µs/call: # 5 times (75µs+2.10ms) by Moose::Util::TypeConstraints::create_class_type_constraint at line 188 of Moose/Util/TypeConstraints.pm, avg 436µs/call
sub new {
3354µs my ( $class, %args ) = @_;
34
3556µs564µs $args{parent}
# spent 64µs making 5 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 13µs/call
36 = Moose::Util::TypeConstraints::find_type_constraint('Object');
37
3852µs my $class_name = $args{class};
39513µs $args{constraint} = sub { $_[0]->isa($class_name) };
40
4152µs $args{inlined} = $inliner;
42
43511µs51.21ms my $self = $class->SUPER::new( \%args );
# spent 1.21ms making 5 calls to Moose::Meta::TypeConstraint::new, avg 242µs/call
44
4557µs5829µs $self->compile_type_constraint();
# spent 829µs making 5 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 166µs/call
46
47513µs return $self;
48}
49
50sub parents {
51 my $self = shift;
52 return (
53 $self->parent,
54 map {
55 # FIXME find_type_constraint might find a TC named after the class but that isn't really it
56 # I did this anyway since it's a convention that preceded TypeConstraint::Class, and it should DWIM
57 # if anybody thinks this problematic please discuss on IRC.
58 # a possible fix is to add by attr indexing to the type registry to find types of a certain property
59 # regardless of their name
60 Moose::Util::TypeConstraints::find_type_constraint($_)
61 ||
62 __PACKAGE__->new( class => $_, name => "__ANON__" )
63 } Class::MOP::class_of($self->class)->superclasses,
64 );
65}
66
67sub equals {
68 my ( $self, $type_or_name ) = @_;
69
70 my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
71
72 if (!defined($other)) {
73 if (!ref($type_or_name)) {
74 return $self->class eq $type_or_name;
75 }
76 return;
77 }
78
79 return unless $other->isa(__PACKAGE__);
80
81 return $self->class eq $other->class;
82}
83
84sub is_a_type_of {
85 my ($self, $type_or_name) = @_;
86
87 ($self->equals($type_or_name) || $self->is_subtype_of($type_or_name));
88}
89
90sub is_subtype_of {
91 my ($self, $type_or_name_or_class ) = @_;
92
93 my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name_or_class);
94
95 if ( not defined $type ) {
96 if ( not ref $type_or_name_or_class ) {
97 # it might be a class
98 my $class = $self->class;
99 return 1 if $class ne $type_or_name_or_class
100 && $class->isa( $type_or_name_or_class );
101 }
102 return;
103 }
104
105 if ( $type->isa(__PACKAGE__) && $type->class ne $self->class) {
106 # if $type_or_name_or_class isn't a class, it might be the TC name of another ::Class type
107 # or it could also just be a type object in this branch
108 return $self->class->isa( $type->class );
109 } else {
110 # the only other thing we are a subtype of is Object
111 $self->SUPER::is_subtype_of($type);
112 }
113}
114
115# This is a bit counter-intuitive, but a child type of a Class type
116# constraint is not itself a Class type constraint (it has no class
117# attribute). This whole create_child_type thing needs some changing
118# though, probably making MMC->new a factory or something.
119sub create_child_type {
120 my ($self, @args) = @_;
121 return Moose::Meta::TypeConstraint->new(@args, parent => $self);
122}
123
124sub get_message {
125 my $self = shift;
126 my ($value) = @_;
127
128 if ($self->has_message) {
129 return $self->SUPER::get_message(@_);
130 }
131
132 $value = (defined $value ? overload::StrVal($value) : 'undef');
133 return "Validation failed for '" . $self->name . "' with value $value (not isa " . $self->class . ")";
134}
135
13614µs1;
137
138# ABSTRACT: Class/TypeConstraint parallel hierarchy
139
140__END__