← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:45:08 2010
Reported on Wed Nov 17 22:13:52 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/TypeConstraint/Class.pm
StatementsExecuted 532 statements in 14.6ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
86224.11ms5.94msMoose::Meta::TypeConstraint::Class::::__ANON__[:38]Moose::Meta::TypeConstraint::Class::__ANON__[:38]
47114.06ms26.4msMoose::Meta::TypeConstraint::Class::::newMoose::Meta::TypeConstraint::Class::new
47112.53ms3.92msMoose::Meta::TypeConstraint::Class::::_create_hand_optimized_type_constraintMoose::Meta::TypeConstraint::Class::_create_hand_optimized_type_constraint
11171µs89µsMoose::Meta::TypeConstraint::Class::::BEGIN@3Moose::Meta::TypeConstraint::Class::BEGIN@3
11141µs201µsMoose::Meta::TypeConstraint::Class::::BEGIN@7Moose::Meta::TypeConstraint::Class::BEGIN@7
11138µs281µsMoose::Meta::TypeConstraint::Class::::BEGIN@14Moose::Meta::TypeConstraint::Class::BEGIN@14
11138µs107µsMoose::Meta::TypeConstraint::Class::::BEGIN@4Moose::Meta::TypeConstraint::Class::BEGIN@4
11137µs3.00msMoose::Meta::TypeConstraint::Class::::BEGIN@5Moose::Meta::TypeConstraint::Class::BEGIN@5
11120µs20µsMoose::Meta::TypeConstraint::Class::::BEGIN@8Moose::Meta::TypeConstraint::Class::BEGIN@8
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
33100µs2108µs
# spent 89µs (71+19) within Moose::Meta::TypeConstraint::Class::BEGIN@3 which was called: # once (71µs+19µs) by Moose::Util::TypeConstraints::BEGIN@33 at line 3
use strict;
# spent 89µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@3 # spent 19µs making 1 call to strict::import
4394µs2175µs
# spent 107µs (38+69) within Moose::Meta::TypeConstraint::Class::BEGIN@4 which was called: # once (38µs+69µs) by Moose::Util::TypeConstraints::BEGIN@33 at line 4
use warnings;
# spent 107µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@4 # spent 69µs making 1 call to warnings::import
53148µs25.97ms
# spent 3.00ms (37µs+2.97) within Moose::Meta::TypeConstraint::Class::BEGIN@5 which was called: # once (37µs+2.97ms) by Moose::Util::TypeConstraints::BEGIN@33 at line 5
use metaclass;
# spent 3.00ms making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@5 # spent 2.97ms making 1 call to metaclass::import
6
73102µs2362µs
# spent 201µs (41+160) within Moose::Meta::TypeConstraint::Class::BEGIN@7 which was called: # once (41µs+160µs) by Moose::Util::TypeConstraints::BEGIN@33 at line 7
use Scalar::Util 'blessed';
# spent 201µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@7 # spent 160µs making 1 call to Exporter::import
83216µs120µs
# spent 20µs within Moose::Meta::TypeConstraint::Class::BEGIN@8 which was called: # once (20µs+0s) by Moose::Util::TypeConstraints::BEGIN@33 at line 8
use Moose::Util::TypeConstraints ();
# spent 20µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@8
9
1015µsour $VERSION = '1.19';
11166µs$VERSION = eval $VERSION;
# spent 11µs executing statements in string eval
1214µsour $AUTHORITY = 'cpan:STEVAN';
13
1431.96ms2524µs
# spent 281µs (38+243) within Moose::Meta::TypeConstraint::Class::BEGIN@14 which was called: # once (38µs+243µs) by Moose::Util::TypeConstraints::BEGIN@33 at line 14
use base 'Moose::Meta::TypeConstraint';
# spent 281µs making 1 call to Moose::Meta::TypeConstraint::Class::BEGIN@14 # spent 243µs making 1 call to base::import
15
16128µs22.25ms__PACKAGE__->meta->add_attribute('class' => (
# spent 2.13ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 120µs making 1 call to Moose::Meta::TypeConstraint::Class::meta
17 reader => 'class',
18));
19
20
# spent 26.4ms (4.06+22.4) within Moose::Meta::TypeConstraint::Class::new which was called 47 times, avg 562µs/call: # 47 times (4.06ms+22.4ms) by Moose::Util::TypeConstraints::create_class_type_constraint at line 152 of Moose/Util/TypeConstraints.pm, avg 562µs/call
sub new {
2147371µs my ( $class, %args ) = @_;
22
2347536µs475.98ms $args{parent} = Moose::Util::TypeConstraints::find_type_constraint('Object');
# spent 5.98ms making 47 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 127µs/call
2447728µs475.60ms my $self = $class->_new(\%args);
# spent 5.60ms making 47 calls to Moose::Meta::TypeConstraint::Class::_new, avg 119µs/call
25
2647584µs473.92ms $self->_create_hand_optimized_type_constraint;
# spent 3.92ms making 47 calls to Moose::Meta::TypeConstraint::Class::_create_hand_optimized_type_constraint, avg 83µs/call
2747570µs476.87ms $self->compile_type_constraint();
# spent 6.87ms making 47 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 146µs/call
28
2947728µs return $self;
30}
31
32
# spent 3.92ms (2.53+1.39) within Moose::Meta::TypeConstraint::Class::_create_hand_optimized_type_constraint which was called 47 times, avg 83µs/call: # 47 times (2.53ms+1.39ms) by Moose::Meta::TypeConstraint::Class::new at line 26, avg 83µs/call
sub _create_hand_optimized_type_constraint {
3347135µs my $self = shift;
3447538µs47602µs my $class = $self->class;
# spent 602µs making 47 calls to Moose::Meta::TypeConstraint::Class::class, avg 13µs/call
35 $self->hand_optimized_type_constraint(
36
# spent 5.94ms (4.11+1.83) within Moose::Meta::TypeConstraint::Class::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/TypeConstraint/Class.pm:38] which was called 86 times, avg 69µs/call: # 84 times (3.98ms+1.79ms) by Moose::Meta::TypeConstraint::check at line 115 of Moose/Meta/TypeConstraint.pm, avg 69µs/call # 2 times (124µs+49µs) by MooseX::Role::Parameterized::Meta::Role::Parameterizable::parameters_metaclass at line 46 of accessor parameters_metaclass defined at MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm, avg 87µs/call
sub {
37866.12ms2581.83ms blessed( $_[0] ) && blessed( $_[0] ) ne 'Regexp' && $_[0]->isa($class)
# spent 1.19ms making 172 calls to Scalar::Util::blessed, avg 7µs/call # spent 644µs making 86 calls to UNIVERSAL::isa, avg 7µs/call
38 }
39471.51ms47783µs );
# spent 783µs making 47 calls to Moose::Meta::TypeConstraint::hand_optimized_type_constraint, avg 17µs/call
40}
41
42sub parents {
43 my $self = shift;
44 return (
45 $self->parent,
46 map {
47 # FIXME find_type_constraint might find a TC named after the class but that isn't really it
48 # I did this anyway since it's a convention that preceded TypeConstraint::Class, and it should DWIM
49 # if anybody thinks this problematic please discuss on IRC.
50 # a possible fix is to add by attr indexing to the type registry to find types of a certain property
51 # regardless of their name
52 Moose::Util::TypeConstraints::find_type_constraint($_)
53 ||
54 __PACKAGE__->new( class => $_, name => "__ANON__" )
55 } Class::MOP::class_of($self->class)->superclasses,
56 );
57}
58
59sub equals {
60 my ( $self, $type_or_name ) = @_;
61
62 my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
63
64 return unless defined $other;
65 return unless $other->isa(__PACKAGE__);
66
67 return $self->class eq $other->class;
68}
69
70sub is_a_type_of {
71 my ($self, $type_or_name) = @_;
72
73 my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
74
75 ($self->equals($type) || $self->is_subtype_of($type_or_name));
76}
77
78sub is_subtype_of {
79 my ($self, $type_or_name_or_class ) = @_;
80
81 my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name_or_class);
82
83 if ( not defined $type ) {
84 if ( not ref $type_or_name_or_class ) {
85 # it might be a class
86 return 1 if $self->class->isa( $type_or_name_or_class );
87 }
88 return;
89 }
90
91 if ( $type->isa(__PACKAGE__) && $type->class ne $self->class) {
92 # if $type_or_name_or_class isn't a class, it might be the TC name of another ::Class type
93 # or it could also just be a type object in this branch
94 return $self->class->isa( $type->class );
95 } else {
96 # the only other thing we are a subtype of is Object
97 $self->SUPER::is_subtype_of($type);
98 }
99}
100
101# This is a bit counter-intuitive, but a child type of a Class type
102# constraint is not itself a Class type constraint (it has no class
103# attribute). This whole create_child_type thing needs some changing
104# though, probably making MMC->new a factory or something.
105sub create_child_type {
106 my ($self, @args) = @_;
107 return Moose::Meta::TypeConstraint->new(@args, parent => $self);
108}
109
110sub get_message {
111 my $self = shift;
112 my ($value) = @_;
113
114 if ($self->has_message) {
115 return $self->SUPER::get_message(@_);
116 }
117
118 $value = (defined $value ? overload::StrVal($value) : 'undef');
119 return "Validation failed for '" . $self->name . "' with value $value (not isa " . $self->class . ")";
120}
121
122125µs1;
123
124__END__