← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 22:00:36 2010
Reported on Wed Nov 17 22:10:06 2010

Filename/home/doy/coding/src/Moose/blib/lib//Moose/Meta/TypeConstraint/Role.pm
StatementsExecuted 392 statements in 7.08ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
41113.35ms22.6msMoose::Meta::TypeConstraint::Role::::newMoose::Meta::TypeConstraint::Role::new
41112.07ms3.31msMoose::Meta::TypeConstraint::Role::::_create_hand_optimized_type_constraintMoose::Meta::TypeConstraint::Role::_create_hand_optimized_type_constraint
111111µs361µsMoose::Meta::TypeConstraint::Role::::BEGIN@14Moose::Meta::TypeConstraint::Role::BEGIN@14
11171µs89µsMoose::Meta::TypeConstraint::Role::::BEGIN@3Moose::Meta::TypeConstraint::Role::BEGIN@3
11169µs136µsMoose::Meta::TypeConstraint::Role::::BEGIN@4Moose::Meta::TypeConstraint::Role::BEGIN@4
11142µs221µsMoose::Meta::TypeConstraint::Role::::BEGIN@7Moose::Meta::TypeConstraint::Role::BEGIN@7
11141µs2.65msMoose::Meta::TypeConstraint::Role::::BEGIN@5Moose::Meta::TypeConstraint::Role::BEGIN@5
11123µs23µsMoose::Meta::TypeConstraint::Role::::BEGIN@8Moose::Meta::TypeConstraint::Role::BEGIN@8
0000s0sMoose::Meta::TypeConstraint::Role::::__ANON__[:36]Moose::Meta::TypeConstraint::Role::__ANON__[:36]
0000s0sMoose::Meta::TypeConstraint::Role::::create_child_typeMoose::Meta::TypeConstraint::Role::create_child_type
0000s0sMoose::Meta::TypeConstraint::Role::::equalsMoose::Meta::TypeConstraint::Role::equals
0000s0sMoose::Meta::TypeConstraint::Role::::is_a_type_ofMoose::Meta::TypeConstraint::Role::is_a_type_of
0000s0sMoose::Meta::TypeConstraint::Role::::is_subtype_ofMoose::Meta::TypeConstraint::Role::is_subtype_of
0000s0sMoose::Meta::TypeConstraint::Role::::parentsMoose::Meta::TypeConstraint::Role::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::Role;
2
33103µs2107µs
# spent 89µs (71+18) within Moose::Meta::TypeConstraint::Role::BEGIN@3 which was called: # once (71µs+18µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 3
use strict;
# spent 89µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@3 # spent 18µs making 1 call to strict::import
4399µs2204µs
# spent 136µs (69+67) within Moose::Meta::TypeConstraint::Role::BEGIN@4 which was called: # once (69µs+67µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 4
use warnings;
# spent 136µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@4 # spent 67µs making 1 call to warnings::import
53141µs25.25ms
# spent 2.65ms (41µs+2.61) within Moose::Meta::TypeConstraint::Role::BEGIN@5 which was called: # once (41µs+2.61ms) by Moose::Util::TypeConstraints::BEGIN@34 at line 5
use metaclass;
# spent 2.65ms making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@5 # spent 2.61ms making 1 call to metaclass::import
6
73110µs2399µs
# spent 221µs (42+178) within Moose::Meta::TypeConstraint::Role::BEGIN@7 which was called: # once (42µs+178µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 7
use Scalar::Util 'blessed';
# spent 221µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@7 # spent 178µs making 1 call to Exporter::import
83219µs123µs
# spent 23µs within Moose::Meta::TypeConstraint::Role::BEGIN@8 which was called: # once (23µs+0s) by Moose::Util::TypeConstraints::BEGIN@34 at line 8
use Moose::Util::TypeConstraints ();
# spent 23µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@8
9
1015µsour $VERSION = '1.19';
11160µs$VERSION = eval $VERSION;
# spent 11µs executing statements in string eval
1213µsour $AUTHORITY = 'cpan:STEVAN';
13
1431.53ms2612µs
# spent 361µs (111+251) within Moose::Meta::TypeConstraint::Role::BEGIN@14 which was called: # once (111µs+251µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 14
use base 'Moose::Meta::TypeConstraint';
# spent 361µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@14 # spent 251µs making 1 call to base::import
15
16126µs22.16ms__PACKAGE__->meta->add_attribute('role' => (
# spent 2.04ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 118µs making 1 call to Moose::Meta::TypeConstraint::Role::meta
17 reader => 'role',
18));
19
20
# spent 22.6ms (3.35+19.2) within Moose::Meta::TypeConstraint::Role::new which was called 41 times, avg 551µs/call: # 41 times (3.35ms+19.2ms) by Moose::Util::TypeConstraints::create_role_type_constraint at line 170 of Moose/Util/TypeConstraints.pm, avg 551µs/call
sub new {
212462.99ms my ( $class, %args ) = @_;
22
23415.10ms $args{parent} = Moose::Util::TypeConstraints::find_type_constraint('Object');
# spent 5.10ms making 41 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 124µs/call
24414.95ms my $self = $class->_new(\%args);
# spent 4.95ms making 41 calls to Moose::Meta::TypeConstraint::Role::_new, avg 121µs/call
25
26413.31ms $self->_create_hand_optimized_type_constraint;
# spent 3.31ms making 41 calls to Moose::Meta::TypeConstraint::Role::_create_hand_optimized_type_constraint, avg 81µs/call
27415.87ms $self->compile_type_constraint();
# spent 5.87ms making 41 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 143µs/call
28
29 return $self;
30}
31
32
# spent 3.31ms (2.07+1.23) within Moose::Meta::TypeConstraint::Role::_create_hand_optimized_type_constraint which was called 41 times, avg 81µs/call: # 41 times (2.07ms+1.23ms) by Moose::Meta::TypeConstraint::Role::new at line 26, avg 81µs/call
sub _create_hand_optimized_type_constraint {
331231.77ms my $self = shift;
3441549µs my $role = $self->role;
# spent 549µs making 41 calls to Moose::Meta::TypeConstraint::Role::role, avg 13µs/call
35 $self->hand_optimized_type_constraint(
36 sub { Moose::Util::does_role($_[0], $role) }
3741685µs );
# spent 685µs making 41 calls to Moose::Meta::TypeConstraint::hand_optimized_type_constraint, avg 17µs/call
38}
39
40sub parents {
41 my $self = shift;
42 return (
43 $self->parent,
44 map {
45 # FIXME find_type_constraint might find a TC named after the role but that isn't really it
46 # I did this anyway since it's a convention that preceded TypeConstraint::Role, and it should DWIM
47 # if anybody thinks this problematic please discuss on IRC.
48 # a possible fix is to add by attr indexing to the type registry to find types of a certain property
49 # regardless of their name
50 Moose::Util::TypeConstraints::find_type_constraint($_)
51 ||
52 __PACKAGE__->new( role => $_, name => "__ANON__" )
53 } @{ Class::MOP::class_of($self->role)->get_roles },
54 );
55}
56
57sub equals {
58 my ( $self, $type_or_name ) = @_;
59
60 my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
61
62 return unless defined $other;
63 return unless $other->isa(__PACKAGE__);
64
65 return $self->role eq $other->role;
66}
67
68sub is_a_type_of {
69 my ($self, $type_or_name) = @_;
70
71 my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
72
73 ($self->equals($type) || $self->is_subtype_of($type_or_name));
74}
75
76sub is_subtype_of {
77 my ($self, $type_or_name_or_role ) = @_;
78
79 if ( not ref $type_or_name_or_role ) {
80 # it might be a role
81 return 1 if Class::MOP::class_of($self->role)->does_role( $type_or_name_or_role );
82 }
83
84 my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name_or_role);
85
86 return unless defined $type;
87
88 if ( $type->isa(__PACKAGE__) ) {
89 # if $type_or_name_or_role isn't a role, it might be the TC name of another ::Role type
90 # or it could also just be a type object in this branch
91 return Class::MOP::class_of($self->role)->does_role( $type->role );
92 } else {
93 # the only other thing we are a subtype of is Object
94 $self->SUPER::is_subtype_of($type);
95 }
96}
97
98sub create_child_type {
99 my ($self, @args) = @_;
100 return Moose::Meta::TypeConstraint->new(@args, parent => $self);
101}
102
103124µs1;
104
105__END__