← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mentat.storage.mongo.pl
  Run on Tue Jun 24 09:58:41 2014
Reported on Tue Jun 24 09:59:36 2014

Filename/usr/local/lib/perl/5.14.2/Moose/Meta/Role/Attribute.pm
StatementsExecuted 21 statements in 627µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1118µs8µsMoose::Meta::Role::Attribute::::BEGIN@2Moose::Meta::Role::Attribute::BEGIN@2
1118µs11µsMoose::Meta::Role::Attribute::::BEGIN@9Moose::Meta::Role::Attribute::BEGIN@9
1117µs27µsMoose::Meta::Role::Attribute::::BEGIN@13Moose::Meta::Role::Attribute::BEGIN@13
1117µs15µsMoose::Meta::Role::Attribute::::BEGIN@10Moose::Meta::Role::Attribute::BEGIN@10
1117µs30µsMoose::Meta::Role::Attribute::::BEGIN@12Moose::Meta::Role::Attribute::BEGIN@12
1116µs78µsMoose::Meta::Role::Attribute::::BEGIN@16Moose::Meta::Role::Attribute::BEGIN@16
1116µs35µsMoose::Meta::Role::Attribute::::BEGIN@14Moose::Meta::Role::Attribute::BEGIN@14
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 8µs within Moose::Meta::Role::Attribute::BEGIN@2 which was called: # once (8µs+0s) by Moose::Meta::Role::BEGIN@19 at line 4
BEGIN {
315µs $Moose::Meta::Role::Attribute::AUTHORITY = 'cpan:STEVAN';
4134µs18µs}
# spent 8µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@2
5{
621µs $Moose::Meta::Role::Attribute::VERSION = '2.1005';
7}
8
9221µs213µs
# spent 11µs (8+3) within Moose::Meta::Role::Attribute::BEGIN@9 which was called: # once (8µs+3µs) by Moose::Meta::Role::BEGIN@19 at line 9
use strict;
# spent 11µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@9 # spent 3µs making 1 call to strict::import
10222µs223µs
# spent 15µs (7+8) within Moose::Meta::Role::Attribute::BEGIN@10 which was called: # once (7µs+8µs) by Moose::Meta::Role::BEGIN@19 at line 10
use warnings;
# spent 15µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@10 # spent 8µs making 1 call to warnings::import
11
12224µs254µs
# spent 30µs (7+24) within Moose::Meta::Role::Attribute::BEGIN@12 which was called: # once (7µs+24µs) by Moose::Meta::Role::BEGIN@19 at line 12
use Carp 'confess';
# spent 30µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@12 # spent 24µs making 1 call to Exporter::import
13224µs247µs
# spent 27µs (7+20) within Moose::Meta::Role::Attribute::BEGIN@13 which was called: # once (7µs+20µs) by Moose::Meta::Role::BEGIN@19 at line 13
use List::MoreUtils 'all';
# spent 27µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@13 # spent 20µs making 1 call to Exporter::import
14224µs264µs
# spent 35µs (6+29) within Moose::Meta::Role::Attribute::BEGIN@14 which was called: # once (6µs+29µs) by Moose::Meta::Role::BEGIN@19 at line 14
use Scalar::Util 'blessed', 'weaken';
# spent 35µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@14 # spent 29µs making 1 call to Exporter::import
15
162428µs2150µs
# spent 78µs (6+72) within Moose::Meta::Role::Attribute::BEGIN@16 which was called: # once (6µs+72µs) by Moose::Meta::Role::BEGIN@19 at line 16
use base 'Moose::Meta::Mixin::AttributeCore', 'Class::MOP::Object';
# spent 78µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@16 # spent 72µs making 1 call to base::import
17
1818µs3741µs__PACKAGE__->meta->add_attribute(
# spent 424µs making 1 call to Class::MOP::Mixin::meta # spent 311µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 6µs making 1 call to Class::MOP::_definition_context
19 'metaclass' => (
20 reader => 'metaclass',
21 Class::MOP::_definition_context(),
22 )
23);
24
2513µs3314µs__PACKAGE__->meta->add_attribute(
# spent 298µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 12µs making 1 call to Class::MOP::Mixin::meta # spent 5µ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µs3309µs__PACKAGE__->meta->add_attribute(
# spent 293µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Class::MOP::Mixin::meta # spent 5µ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µs3314µs__PACKAGE__->meta->add_attribute(
# spent 294µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Class::MOP::Mixin::meta # spent 9µs making 1 call to Class::MOP::_definition_context
40 'is' => (
41 reader => 'is',
42 Class::MOP::_definition_context(),
43 )
44);
45
4613µs3355µs__PACKAGE__->meta->add_attribute(
# spent 339µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Class::MOP::Mixin::meta # spent 5µ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
128121µs1;
129
130# ABSTRACT: The Moose attribute metaclass for Roles
131
132__END__