← Index
NYTProf Performance Profile   « line view »
For /home/ss5/perl5/perlbrew/perls/perl-5.22.0/bin/benchmarkanything-storage
  Run on Mon Jan 29 16:55:34 2018
Reported on Mon Jan 29 16:57:07 2018

Filename/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Meta/TypeConstraint/Role.pm
StatementsExecuted 186 statements in 667µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1211137µs8.83msMoose::Meta::TypeConstraint::Role::::newMoose::Meta::TypeConstraint::Role::new
2411125µs181µsMoose::Meta::TypeConstraint::Role::::__ANON__[:27]Moose::Meta::TypeConstraint::Role::__ANON__[:27]
11110µs14µsMoose::Meta::TypeConstraint::Role::::BEGIN@4Moose::Meta::TypeConstraint::Role::BEGIN@4
1116µs23µsMoose::Meta::TypeConstraint::Role::::BEGIN@8Moose::Meta::TypeConstraint::Role::BEGIN@8
1116µs12µsMoose::Meta::TypeConstraint::Role::::BEGIN@5Moose::Meta::TypeConstraint::Role::BEGIN@5
1116µs332µsMoose::Meta::TypeConstraint::Role::::BEGIN@6Moose::Meta::TypeConstraint::Role::BEGIN@6
1115µs22µsMoose::Meta::TypeConstraint::Role::::BEGIN@12Moose::Meta::TypeConstraint::Role::BEGIN@12
1113µs3µsMoose::Meta::TypeConstraint::Role::::BEGIN@9Moose::Meta::TypeConstraint::Role::BEGIN@9
1112µs2µsMoose::Meta::TypeConstraint::Role::::BEGIN@10Moose::Meta::TypeConstraint::Role::BEGIN@10
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;
21300nsour $VERSION = '2.1605';
3
4216µs218µs
# spent 14µs (10+4) within Moose::Meta::TypeConstraint::Role::BEGIN@4 which was called: # once (10µs+4µs) by Moose::Util::TypeConstraints::BEGIN@29 at line 4
use strict;
# spent 14µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@4 # spent 4µs making 1 call to strict::import
5214µs218µs
# spent 12µs (6+6) within Moose::Meta::TypeConstraint::Role::BEGIN@5 which was called: # once (6µs+6µs) by Moose::Util::TypeConstraints::BEGIN@29 at line 5
use warnings;
# spent 12µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@5 # spent 6µs making 1 call to warnings::import
6221µs2657µs
# spent 332µs (6+326) within Moose::Meta::TypeConstraint::Role::BEGIN@6 which was called: # once (6µs+326µs) by Moose::Util::TypeConstraints::BEGIN@29 at line 6
use metaclass;
# spent 332µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@6 # spent 326µs making 1 call to metaclass::import
7
8218µs240µs
# spent 23µs (6+17) within Moose::Meta::TypeConstraint::Role::BEGIN@8 which was called: # once (6µs+17µs) by Moose::Util::TypeConstraints::BEGIN@29 at line 8
use B;
# spent 23µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@8 # spent 17µs making 1 call to Exporter::import
9212µ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
10215µs12µs
# spent 2µs within Moose::Meta::TypeConstraint::Role::BEGIN@10 which was called: # once (2µs+0s) by Moose::Util::TypeConstraints::BEGIN@29 at line 10
use Moose::Util ();
# spent 2µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@10
11
122294µs238µs
# spent 22µs (5+17) within Moose::Meta::TypeConstraint::Role::BEGIN@12 which was called: # once (5µs+17µs) by Moose::Util::TypeConstraints::BEGIN@29 at line 12
use parent 'Moose::Meta::TypeConstraint';
# spent 22µs making 1 call to Moose::Meta::TypeConstraint::Role::BEGIN@12 # spent 17µs making 1 call to parent::import
13
1413µs3249µs__PACKAGE__->meta->add_attribute('role' => (
# spent 233µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 12µs making 1 call to Moose::Meta::TypeConstraint::Role::meta # spent 5µs making 1 call to Class::MOP::_definition_context
15 reader => 'role',
16 Class::MOP::_definition_context(),
17));
18
19
# spent 181µs (125+56) within Moose::Meta::TypeConstraint::Role::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Meta/TypeConstraint/Role.pm:27] which was called 24 times, avg 8µs/call: # 24 times (125µs+56µs) by Moose::Meta::TypeConstraint::_inline_check at line 195 of Moose/Meta/TypeConstraint.pm, avg 8µs/call
my $inliner = sub {
20243µs my $self = shift;
21244µs my $val = shift;
22
2324146µs4856µs return 'Moose::Util::does_role('
# spent 34µs making 24 calls to B::perlstring, avg 1µs/call # spent 22µs making 24 calls to Moose::Meta::TypeConstraint::Role::role, avg 933ns/call
24 . $val . ', '
25 . B::perlstring($self->role)
26 . ')';
2711µs};
28
29
# spent 8.83ms (137µs+8.69) within Moose::Meta::TypeConstraint::Role::new which was called 12 times, avg 736µs/call: # 12 times (137µs+8.69ms) by Moose::Util::TypeConstraints::create_role_type_constraint at line 210 of Moose/Util/TypeConstraints.pm, avg 736µs/call
sub new {
301211µs my ( $class, %args ) = @_;
31
321218µs12104µs $args{parent} = Moose::Util::TypeConstraints::find_type_constraint('Object');
# spent 104µs making 12 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 9µs/call
33
34125µs my $role_name = $args{role};
351219µs $args{constraint} = sub { Moose::Util::does_role( $_[0], $role_name ) };
36
37124µs $args{inlined} = $inliner;
38
391223µs127.15ms my $self = $class->SUPER::new( \%args );
# spent 7.15ms making 12 calls to Moose::Meta::TypeConstraint::new, avg 596µs/call
40
411211µs121.44ms $self->compile_type_constraint();
# spent 1.44ms making 12 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 120µs/call
42
431225µ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__