← Index
NYTProf Performance Profile   « line view »
For fastest.pl
  Run on Fri Jan 31 20:48:16 2014
Reported on Fri Jan 31 20:49:41 2014

Filename/opt/perl-5.18.1/lib/site_perl/5.18.1/darwin-thread-multi-2level/Moose/Meta/Role/Attribute.pm
StatementsExecuted 21 statements in 883µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11112µs12µsMoose::Meta::Role::Attribute::::BEGIN@2Moose::Meta::Role::Attribute::BEGIN@2
11110µs37µsMoose::Meta::Role::Attribute::::BEGIN@13Moose::Meta::Role::Attribute::BEGIN@13
1119µs14µsMoose::Meta::Role::Attribute::::BEGIN@10Moose::Meta::Role::Attribute::BEGIN@10
1119µs42µsMoose::Meta::Role::Attribute::::BEGIN@12Moose::Meta::Role::Attribute::BEGIN@12
1119µs40µsMoose::Meta::Role::Attribute::::BEGIN@14Moose::Meta::Role::Attribute::BEGIN@14
1118µs141µsMoose::Meta::Role::Attribute::::BEGIN@16Moose::Meta::Role::Attribute::BEGIN@16
1118µs24µsMoose::Meta::Role::Attribute::::BEGIN@9Moose::Meta::Role::Attribute::BEGIN@9
0000s0sMoose::Meta::Role::Attribute::::__ANON__[:120]Moose::Meta::Role::Attribute::__ANON__[:120]
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;
2
# spent 12µs within Moose::Meta::Role::Attribute::BEGIN@2 which was called: # once (12µs+0s) by Moose::Meta::Role::BEGIN@19 at line 4
BEGIN {
317µs $Moose::Meta::Role::Attribute::AUTHORITY = 'cpan:STEVAN';
4141µs112µs}
# spent 12µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@2
5{
621µs $Moose::Meta::Role::Attribute::VERSION = '2.1005';
7}
8
9238µs240µs
# spent 24µs (8+16) within Moose::Meta::Role::Attribute::BEGIN@9 which was called: # once (8µs+16µs) by Moose::Meta::Role::BEGIN@19 at line 9
use strict;
# spent 24µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@9 # spent 16µs making 1 call to strict::import
10233µs219µs
# spent 14µs (9+5) within Moose::Meta::Role::Attribute::BEGIN@10 which was called: # once (9µs+5µs) by Moose::Meta::Role::BEGIN@19 at line 10
use warnings;
# spent 14µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@10 # spent 5µs making 1 call to warnings::import
11
12239µs275µs
# spent 42µs (9+33) within Moose::Meta::Role::Attribute::BEGIN@12 which was called: # once (9µs+33µs) by Moose::Meta::Role::BEGIN@19 at line 12
use Carp 'confess';
# spent 42µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@12 # spent 33µs making 1 call to Exporter::import
13235µs265µs
# spent 37µs (10+27) within Moose::Meta::Role::Attribute::BEGIN@13 which was called: # once (10µs+27µs) by Moose::Meta::Role::BEGIN@19 at line 13
use List::MoreUtils 'all';
# spent 37µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@13 # spent 28µs making 1 call to Exporter::import
14235µs270µs
# spent 40µs (9+31) within Moose::Meta::Role::Attribute::BEGIN@14 which was called: # once (9µs+31µs) by Moose::Meta::Role::BEGIN@19 at line 14
use Scalar::Util 'blessed', 'weaken';
# spent 40µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@14 # spent 31µs making 1 call to Exporter::import
15
162616µs2274µs
# spent 141µs (8+133) within Moose::Meta::Role::Attribute::BEGIN@16 which was called: # once (8µs+133µs) by Moose::Meta::Role::BEGIN@19 at line 16
use base 'Moose::Meta::Mixin::AttributeCore', 'Class::MOP::Object';
# spent 141µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@16 # spent 133µs making 1 call to base::import
17
18111µs3919µs__PACKAGE__->meta->add_attribute(
# spent 512µs making 1 call to Class::MOP::Mixin::meta # spent 400µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 7µs making 1 call to Class::MOP::_definition_context
19 'metaclass' => (
20 reader => 'metaclass',
21 Class::MOP::_definition_context(),
22 )
23);
24
2514µs3399µs__PACKAGE__->meta->add_attribute(
# spent 380µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 13µs making 1 call to Class::MOP::Mixin::meta # spent 7µs making 1 call to Class::MOP::_definition_context
26 'associated_role' => (
27 reader => 'associated_role',
28 Class::MOP::_definition_context(),
29 )
30);
31
3214µs3392µs__PACKAGE__->meta->add_attribute(
# spent 373µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 12µs making 1 call to Class::MOP::Mixin::meta # spent 7µs making 1 call to Class::MOP::_definition_context
33 '_original_role' => (
34 reader => '_original_role',
35 Class::MOP::_definition_context(),
36 )
37);
38
3914µs3392µs__PACKAGE__->meta->add_attribute(
# spent 372µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 13µs making 1 call to Class::MOP::Mixin::meta # spent 7µs making 1 call to Class::MOP::_definition_context
40 'is' => (
41 reader => 'is',
42 Class::MOP::_definition_context(),
43 )
44);
45
4614µs3394µs__PACKAGE__->meta->add_attribute(
# spent 375µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 12µs making 1 call to Class::MOP::Mixin::meta # spent 7µs making 1 call to Class::MOP::_definition_context
47 'original_options' => (
48 reader => 'original_options',
49 Class::MOP::_definition_context(),
50 )
51);
52
53sub new {
54 my ( $class, $name, %options ) = @_;
55
56 (defined $name)
57 || confess "You must provide a name for the attribute";
58
59 my $role = delete $options{_original_role};
60
61 return bless {
62 name => $name,
63 original_options => \%options,
64 _original_role => $role,
65 %options,
66 }, $class;
67}
68
69sub attach_to_role {
70 my ( $self, $role ) = @_;
71
72 ( blessed($role) && $role->isa('Moose::Meta::Role') )
73 || confess
74 "You must pass a Moose::Meta::Role instance (or a subclass)";
75
76 weaken( $self->{'associated_role'} = $role );
77}
78
79sub original_role {
80 my $self = shift;
81
82 return $self->_original_role || $self->associated_role;
83}
84
85sub attribute_for_class {
86 my $self = shift;
87
88 my $metaclass = $self->original_role->applied_attribute_metaclass;
89
90 return $metaclass->interpolate_class_and_new(
91 $self->name => %{ $self->original_options } );
92}
93
94sub clone {
95 my $self = shift;
96
97 my $role = $self->original_role;
98
99 return ( ref $self )->new(
100 $self->name,
101 %{ $self->original_options },
102 _original_role => $role,
103 );
104}
105
106sub is_same_as {
107 my $self = shift;
108 my $attr = shift;
109
110 my $self_options = $self->original_options;
111 my $other_options = $attr->original_options;
112
113 return 0
114 unless ( join q{|}, sort keys %{$self_options} ) eq ( join q{|}, sort keys %{$other_options} );
115
116 for my $key ( keys %{$self_options} ) {
117 return 0 if defined $self_options->{$key} && ! defined $other_options->{$key};
118 return 0 if ! defined $self_options->{$key} && defined $other_options->{$key};
119
120 next if all { ! defined } $self_options->{$key}, $other_options->{$key};
121
122 return 0 unless $self_options->{$key} eq $other_options->{$key};
123 }
124
125 return 1;
126}
127
128111µs1;
129
130# ABSTRACT: The Moose attribute metaclass for Roles
131
132__END__