← 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/Role/Attribute.pm
StatementsExecuted 20 statements in 407µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11114µs52µsMoose::Meta::Role::Attribute::::BEGIN@7Moose::Meta::Role::Attribute::BEGIN@7
1118µs10µsMoose::Meta::Role::Attribute::::BEGIN@4Moose::Meta::Role::Attribute::BEGIN@4
1116µs154µsMoose::Meta::Role::Attribute::::BEGIN@12Moose::Meta::Role::Attribute::BEGIN@12
1115µs23µsMoose::Meta::Role::Attribute::::BEGIN@8Moose::Meta::Role::Attribute::BEGIN@8
1115µs33µsMoose::Meta::Role::Attribute::::BEGIN@10Moose::Meta::Role::Attribute::BEGIN@10
1114µs7µsMoose::Meta::Role::Attribute::::BEGIN@5Moose::Meta::Role::Attribute::BEGIN@5
0000s0sMoose::Meta::Role::Attribute::::__ANON__[:119]Moose::Meta::Role::Attribute::__ANON__[:119]
0000s0sMoose::Meta::Role::Attribute::::attach_to_roleMoose::Meta::Role::Attribute::attach_to_role
0000s0sMoose::Meta::Role::Attribute::::attribute_for_classMoose::Meta::Role::Attribute::attribute_for_class
0000s0sMoose::Meta::Role::Attribute::::cloneMoose::Meta::Role::Attribute::clone
0000s0sMoose::Meta::Role::Attribute::::is_same_asMoose::Meta::Role::Attribute::is_same_as
0000s0sMoose::Meta::Role::Attribute::::newMoose::Meta::Role::Attribute::new
0000s0sMoose::Meta::Role::Attribute::::original_roleMoose::Meta::Role::Attribute::original_role
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::Role::Attribute;
21300nsour $VERSION = '2.1605';
3
4215µs211µs
# spent 10µs (8+2) within Moose::Meta::Role::Attribute::BEGIN@4 which was called: # once (8µs+2µs) by Moose::Meta::Role::BEGIN@11 at line 4
use strict;
# spent 10µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@4 # spent 2µs making 1 call to strict::import
5218µs211µs
# spent 7µs (4+3) within Moose::Meta::Role::Attribute::BEGIN@5 which was called: # once (4µs+3µs) by Moose::Meta::Role::BEGIN@11 at line 5
use warnings;
# spent 7µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@5 # spent 3µs making 1 call to warnings::import
6
7336µs371µs
# spent 52µs (14+37) within Moose::Meta::Role::Attribute::BEGIN@7 which was called: # once (14µs+37µs) by Moose::Meta::Role::BEGIN@11 at line 7
use List::Util 1.33 'all';
# spent 52µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@7 # spent 10µs making 1 call to UNIVERSAL::VERSION # spent 9µs making 1 call to List::Util::import
8218µs240µs
# spent 23µs (5+17) within Moose::Meta::Role::Attribute::BEGIN@8 which was called: # once (5µs+17µs) by Moose::Meta::Role::BEGIN@11 at line 8
use Scalar::Util 'blessed', 'weaken';
# spent 23µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@8 # spent 17µs making 1 call to Exporter::import
9
10216µs260µs
# spent 33µs (5+28) within Moose::Meta::Role::Attribute::BEGIN@10 which was called: # once (5µs+28µs) by Moose::Meta::Role::BEGIN@11 at line 10
use parent 'Moose::Meta::Mixin::AttributeCore', 'Class::MOP::Object';
# spent 33µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@10 # spent 28µs making 1 call to parent::import
11
122285µs2302µs
# spent 154µs (6+148) within Moose::Meta::Role::Attribute::BEGIN@12 which was called: # once (6µs+148µs) by Moose::Meta::Role::BEGIN@11 at line 12
use Moose::Util 'throw_exception';
# spent 154µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@12 # spent 148µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
13
1416µs3568µs__PACKAGE__->meta->add_attribute(
# spent 296µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 266µs making 1 call to Class::MOP::Mixin::meta # spent 5µs making 1 call to Class::MOP::_definition_context
15 'metaclass' => (
16 reader => 'metaclass',
17 Class::MOP::_definition_context(),
18 )
19);
20
2112µs3253µs__PACKAGE__->meta->add_attribute(
# spent 244µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 6µs making 1 call to Class::MOP::Mixin::meta # spent 3µs making 1 call to Class::MOP::_definition_context
22 'associated_role' => (
23 reader => 'associated_role',
24 Class::MOP::_definition_context(),
25 )
26);
27
2812µs3191µs__PACKAGE__->meta->add_attribute(
# spent 181µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 7µs making 1 call to Class::MOP::Mixin::meta # spent 4µs making 1 call to Class::MOP::_definition_context
29 '_original_role' => (
30 reader => '_original_role',
31 Class::MOP::_definition_context(),
32 )
33);
34
3512µs3180µs__PACKAGE__->meta->add_attribute(
# spent 171µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 6µs making 1 call to Class::MOP::Mixin::meta # spent 3µs making 1 call to Class::MOP::_definition_context
36 'is' => (
37 reader => 'is',
38 Class::MOP::_definition_context(),
39 )
40);
41
4212µs3174µs__PACKAGE__->meta->add_attribute(
# spent 166µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 6µs making 1 call to Class::MOP::Mixin::meta # spent 3µs making 1 call to Class::MOP::_definition_context
43 'original_options' => (
44 reader => 'original_options',
45 Class::MOP::_definition_context(),
46 )
47);
48
49sub new {
50 my ( $class, $name, %options ) = @_;
51
52 (defined $name)
53 || throw_exception( MustProvideANameForTheAttribute => params => \%options,
54 class => $class
55 );
56
57 my $role = delete $options{_original_role};
58
59 return bless {
60 name => $name,
61 original_options => \%options,
62 _original_role => $role,
63 %options,
64 }, $class;
65}
66
67sub attach_to_role {
68 my ( $self, $role ) = @_;
69
70 ( blessed($role) && $role->isa('Moose::Meta::Role') )
71 || throw_exception( MustPassAMooseMetaRoleInstanceOrSubclass => class => $self,
72 role => $role
73 );
74
75 weaken( $self->{'associated_role'} = $role );
76}
77
78sub original_role {
79 my $self = shift;
80
81 return $self->_original_role || $self->associated_role;
82}
83
84sub attribute_for_class {
85 my $self = shift;
86
87 my $metaclass = $self->original_role->applied_attribute_metaclass;
88
89 return $metaclass->interpolate_class_and_new(
90 $self->name => %{ $self->original_options } );
91}
92
93sub clone {
94 my $self = shift;
95
96 my $role = $self->original_role;
97
98 return ( ref $self )->new(
99 $self->name,
100 %{ $self->original_options },
101 _original_role => $role,
102 );
103}
104
105sub is_same_as {
106 my $self = shift;
107 my $attr = shift;
108
109 my $self_options = $self->original_options;
110 my $other_options = $attr->original_options;
111
112 return 0
113 unless ( join q{|}, sort keys %{$self_options} ) eq ( join q{|}, sort keys %{$other_options} );
114
115 for my $key ( keys %{$self_options} ) {
116 return 0 if defined $self_options->{$key} && ! defined $other_options->{$key};
117 return 0 if ! defined $self_options->{$key} && defined $other_options->{$key};
118
119 next if all { ! defined } $self_options->{$key}, $other_options->{$key};
120
121 return 0 unless $self_options->{$key} eq $other_options->{$key};
122 }
123
124 return 1;
125}
126
12716µs1;
128
129# ABSTRACT: The Moose attribute metaclass for Roles
130
131__END__