← 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/Role.pm
StatementsExecuted 565 statements in 1.87ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
3511617µs21.5msMoose::Meta::TypeConstraint::Role::::newMoose::Meta::TypeConstraint::Role::new
8911588µs942µsMoose::Meta::TypeConstraint::Role::::__ANON__[:27]Moose::Meta::TypeConstraint::Role::__ANON__[:27]
1119µs19µsMoose::Meta::TypeConstraint::Role::::BEGIN@4Moose::Meta::TypeConstraint::Role::BEGIN@4
1116µs351µsMoose::Meta::TypeConstraint::Role::::BEGIN@6Moose::Meta::TypeConstraint::Role::BEGIN@6
1116µs21µsMoose::Meta::TypeConstraint::Role::::BEGIN@8Moose::Meta::TypeConstraint::Role::BEGIN@8
1116µs10µsMoose::Meta::TypeConstraint::Role::::BEGIN@5Moose::Meta::TypeConstraint::Role::BEGIN@5
1115µs24µsMoose::Meta::TypeConstraint::Role::::BEGIN@12Moose::Meta::TypeConstraint::Role::BEGIN@12
1113µs3µsMoose::Meta::TypeConstraint::Role::::BEGIN@10Moose::Meta::TypeConstraint::Role::BEGIN@10
1113µs3µsMoose::Meta::TypeConstraint::Role::::BEGIN@9Moose::Meta::TypeConstraint::Role::BEGIN@9
0000s0sMoose::Meta::TypeConstraint::Role::::__ANON__[:35]Moose::Meta::TypeConstraint::Role::__ANON__[:35]
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;
21500nsour $VERSION = '2.1604';
3
4220µs229µs
# spent 19µs (9+10) within Moose::Meta::TypeConstraint::Role::BEGIN@4 which was called: # once (9µs+10µs) by Moose::Util::TypeConstraints::BEGIN@29 at line 4
use strict;
# spent 19µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@4 # spent 10µs making 1 call to strict::import
5218µs214µs
# spent 10µs (6+4) within Moose::Meta::TypeConstraint::Role::BEGIN@5 which was called: # once (6µs+4µs) by Moose::Util::TypeConstraints::BEGIN@29 at line 5
use warnings;
# spent 10µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@5 # spent 4µs making 1 call to warnings::import
6224µs2696µs
# spent 351µs (6+345) within Moose::Meta::TypeConstraint::Role::BEGIN@6 which was called: # once (6µs+345µs) by Moose::Util::TypeConstraints::BEGIN@29 at line 6
use metaclass;
# spent 351µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@6 # spent 345µs making 1 call to metaclass::import
7
8220µs236µs
# spent 21µs (6+15) within Moose::Meta::TypeConstraint::Role::BEGIN@8 which was called: # once (6µs+15µs) by Moose::Util::TypeConstraints::BEGIN@29 at line 8
use B;
# spent 21µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@8 # spent 15µs making 1 call to Exporter::import
9216µs13µs
# spent 3µs within Moose::Meta::TypeConstraint::Role::BEGIN@9 which was called: # once (3µs+0s) by Moose::Util::TypeConstraints::BEGIN@29 at line 9
use Moose::Util::TypeConstraints ();
# spent 3µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@9
10218µs13µs
# spent 3µs within Moose::Meta::TypeConstraint::Role::BEGIN@10 which was called: # once (3µs+0s) by Moose::Util::TypeConstraints::BEGIN@29 at line 10
use Moose::Util ();
# spent 3µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@10
11
122454µs242µs
# spent 24µs (5+18) within Moose::Meta::TypeConstraint::Role::BEGIN@12 which was called: # once (5µs+18µs) by Moose::Util::TypeConstraints::BEGIN@29 at line 12
use parent 'Moose::Meta::TypeConstraint';
# spent 24µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@12 # spent 18µs making 1 call to parent::import
13
1414µs3289µs__PACKAGE__->meta->add_attribute('role' => (
# spent 272µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 13µs making 1 call to Moose::Meta::TypeConstraint::Role::meta # spent 4µs making 1 call to Class::MOP::_definition_context
15 reader => 'role',
16 Class::MOP::_definition_context(),
17));
18
19
# spent 942µs (588+354) within Moose::Meta::TypeConstraint::Role::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Meta/TypeConstraint/Role.pm:27] which was called 89 times, avg 11µs/call: # 89 times (588µs+354µs) by Moose::Meta::TypeConstraint::_inline_check at line 195 of Moose/Meta/TypeConstraint.pm, avg 11µs/call
my $inliner = sub {
208921µs my $self = shift;
218920µs my $val = shift;
22
2389723µs178354µs return 'Moose::Util::does_role('
# spent 206µs making 89 calls to B::perlstring, avg 2µs/call # spent 148µs making 89 calls to Moose::Meta::TypeConstraint::Role::role, avg 2µs/call
24 . $val . ', '
25 . B::perlstring($self->role)
26 . ')';
2712µs};
28
29
# spent 21.5ms (617µs+20.9) within Moose::Meta::TypeConstraint::Role::new which was called 35 times, avg 615µs/call: # 35 times (617µs+20.9ms) by Moose::Util::TypeConstraints::create_role_type_constraint at line 210 of Moose/Util/TypeConstraints.pm, avg 615µs/call
sub new {
303537µs my ( $class, %args ) = @_;
31
323558µs35493µs $args{parent} = Moose::Util::TypeConstraints::find_type_constraint('Object');
# spent 493µs making 35 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 14µs/call
33
343521µs my $role_name = $args{role};
3535123µs $args{constraint} = sub { Moose::Util::does_role( $_[0], $role_name ) };
36
373530µs $args{inlined} = $inliner;
38
3935104µs3514.9ms my $self = $class->SUPER::new( \%args );
# spent 14.9ms making 35 calls to Moose::Meta::TypeConstraint::new, avg 424µs/call
40
413550µs355.56ms $self->compile_type_constraint();
# spent 5.56ms making 35 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 159µs/call
42
4335101µs return $self;
44}
45
46sub parents {
47 my $self = shift;
48 return (
49 $self->parent,
50 map {
51 # FIXME find_type_constraint might find a TC named after the role but that isn't really it
52 # I did this anyway since it's a convention that preceded TypeConstraint::Role, and it should DWIM
53 # if anybody thinks this problematic please discuss on IRC.
54 # a possible fix is to add by attr indexing to the type registry to find types of a certain property
55 # regardless of their name
56 Moose::Util::TypeConstraints::find_type_constraint($_)
57 ||
58 __PACKAGE__->new( role => $_, name => "__ANON__" )
59 } @{ Class::MOP::class_of($self->role)->get_roles },
60 );
61}
62
63sub equals {
64 my ( $self, $type_or_name ) = @_;
65
66 my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
67
68 return unless defined $other;
69 return unless $other->isa(__PACKAGE__);
70
71 return $self->role eq $other->role;
72}
73
74sub is_a_type_of {
75 my ($self, $type_or_name) = @_;
76
77 my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
78
79 ($self->equals($type) || $self->is_subtype_of($type_or_name));
80}
81
82sub is_subtype_of {
83 my ($self, $type_or_name_or_role ) = @_;
84
85 if ( not ref $type_or_name_or_role ) {
86 # it might be a role
87 my $class = Class::MOP::class_of($self->role);
88 return 1 if defined($class) && $class->does_role( $type_or_name_or_role );
89 }
90
91 my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name_or_role);
92
93 return unless defined $type;
94
95 if ( $type->isa(__PACKAGE__) ) {
96 # if $type_or_name_or_role isn't a role, it might be the TC name of another ::Role type
97 # or it could also just be a type object in this branch
98 my $class = Class::MOP::class_of($self->role);
99 return defined($class) && $class->does_role( $type->role );
100 } else {
101 # the only other thing we are a subtype of is Object
102 $self->SUPER::is_subtype_of($type);
103 }
104}
105
106sub create_child_type {
107 my ($self, @args) = @_;
108 return Moose::Meta::TypeConstraint->new(@args, parent => $self);
109}
110
11114µs1;
112
113# ABSTRACT: Role/TypeConstraint parallel hierarchy
114
115__END__