← 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:11:06 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/TypeConstraint/Role.pm
StatementsExecuted 779 statements in 12.6ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
84117.07ms46.2msMoose::Meta::TypeConstraint::Role::::newMoose::Meta::TypeConstraint::Role::new
84114.42ms6.97msMoose::Meta::TypeConstraint::Role::::_create_hand_optimized_type_constraintMoose::Meta::TypeConstraint::Role::_create_hand_optimized_type_constraint
11173µs91µsMoose::Meta::TypeConstraint::Role::::BEGIN@3Moose::Meta::TypeConstraint::Role::BEGIN@3
11146µs209µsMoose::Meta::TypeConstraint::Role::::BEGIN@7Moose::Meta::TypeConstraint::Role::BEGIN@7
11138µs107µsMoose::Meta::TypeConstraint::Role::::BEGIN@4Moose::Meta::TypeConstraint::Role::BEGIN@4
11138µs286µsMoose::Meta::TypeConstraint::Role::::BEGIN@14Moose::Meta::TypeConstraint::Role::BEGIN@14
11137µs3.00msMoose::Meta::TypeConstraint::Role::::BEGIN@5Moose::Meta::TypeConstraint::Role::BEGIN@5
11121µs21µ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
33101µs2109µs
# spent 91µs (73+18) within Moose::Meta::TypeConstraint::Role::BEGIN@3 which was called: # once (73µs+18µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 3
use strict;
# spent 91µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@3 # spent 18µs making 1 call to strict::import
4395µs2176µs
# spent 107µs (38+69) within Moose::Meta::TypeConstraint::Role::BEGIN@4 which was called: # once (38µs+69µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 4
use warnings;
# spent 107µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@4 # spent 69µs making 1 call to warnings::import
53150µs25.96ms
# spent 3.00ms (37µs+2.96) within Moose::Meta::TypeConstraint::Role::BEGIN@5 which was called: # once (37µs+2.96ms) by Moose::Util::TypeConstraints::BEGIN@34 at line 5
use metaclass;
# spent 3.00ms making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@5 # spent 2.96ms making 1 call to metaclass::import
6
73118µs2373µs
# spent 209µs (46+164) within Moose::Meta::TypeConstraint::Role::BEGIN@7 which was called: # once (46µs+164µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 7
use Scalar::Util 'blessed';
# spent 209µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@7 # spent 164µs making 1 call to Exporter::import
83220µs121µs
# spent 21µs within Moose::Meta::TypeConstraint::Role::BEGIN@8 which was called: # once (21µs+0s) by Moose::Util::TypeConstraints::BEGIN@34 at line 8
use Moose::Util::TypeConstraints ();
# spent 21µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@8
9
1015µsour $VERSION = '1.19';
11171µs$VERSION = eval $VERSION;
# spent 11µs executing statements in string eval
1213µsour $AUTHORITY = 'cpan:STEVAN';
13
1431.60ms2534µs
# spent 286µs (38+248) within Moose::Meta::TypeConstraint::Role::BEGIN@14 which was called: # once (38µs+248µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 14
use base 'Moose::Meta::TypeConstraint';
# spent 286µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@14 # spent 248µs making 1 call to base::import
15
16127µs22.20ms__PACKAGE__->meta->add_attribute('role' => (
# spent 2.08ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 116µs making 1 call to Moose::Meta::TypeConstraint::Role::meta
17 reader => 'role',
18));
19
20
# spent 46.2ms (7.07+39.1) within Moose::Meta::TypeConstraint::Role::new which was called 84 times, avg 550µs/call: # 84 times (7.07ms+39.1ms) by Moose::Util::TypeConstraints::create_role_type_constraint at line 170 of Moose/Util/TypeConstraints.pm, avg 550µs/call
sub new {
215046.45ms my ( $class, %args ) = @_;
22
238410.9ms $args{parent} = Moose::Util::TypeConstraints::find_type_constraint('Object');
# spent 10.9ms making 84 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 130µs/call
24849.18ms my $self = $class->_new(\%args);
# spent 9.18ms making 84 calls to Moose::Meta::TypeConstraint::Role::_new, avg 109µs/call
25
26846.97ms $self->_create_hand_optimized_type_constraint;
# spent 6.97ms making 84 calls to Moose::Meta::TypeConstraint::Role::_create_hand_optimized_type_constraint, avg 83µs/call
278412.0ms $self->compile_type_constraint();
# spent 12.0ms making 84 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 143µs/call
28
29 return $self;
30}
31
32
# spent 6.97ms (4.42+2.55) within Moose::Meta::TypeConstraint::Role::_create_hand_optimized_type_constraint which was called 84 times, avg 83µs/call: # 84 times (4.42ms+2.55ms) by Moose::Meta::TypeConstraint::Role::new at line 26, avg 83µs/call
sub _create_hand_optimized_type_constraint {
332523.76ms my $self = shift;
34841.12ms my $role = $self->role;
# spent 1.12ms making 84 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) }
37841.43ms );
# spent 1.43ms making 84 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__