← Index
NYTProf Performance Profile   « line view »
For examples/Atom-timer.pl
  Run on Mon Aug 12 14:45:28 2013
Reported on Mon Aug 12 14:46:15 2013

Filename/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Role/Attribute.pm
StatementsExecuted 477 statements in 1.44ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
3822244µs244µsMoose::Meta::Role::Attribute::::newMoose::Meta::Role::Attribute::new
3811196µs251µsMoose::Meta::Role::Attribute::::attach_to_roleMoose::Meta::Role::Attribute::attach_to_role
1911189µs32.8msMoose::Meta::Role::Attribute::::attribute_for_classMoose::Meta::Role::Attribute::attribute_for_class (recurses: max depth 1, inclusive time 472µs)
1922141µs391µsMoose::Meta::Role::Attribute::::cloneMoose::Meta::Role::Attribute::clone
3821109µs170µsMoose::Meta::Role::Attribute::::original_roleMoose::Meta::Role::Attribute::original_role
1118µs18µsMoose::Meta::Role::Attribute::::BEGIN@9Moose::Meta::Role::Attribute::BEGIN@9
1118µs8µsMoose::Meta::Role::Attribute::::BEGIN@2Moose::Meta::Role::Attribute::BEGIN@2
1116µs23µsMoose::Meta::Role::Attribute::::BEGIN@13Moose::Meta::Role::Attribute::BEGIN@13
1116µs25µsMoose::Meta::Role::Attribute::::BEGIN@12Moose::Meta::Role::Attribute::BEGIN@12
1116µs9µsMoose::Meta::Role::Attribute::::BEGIN@10Moose::Meta::Role::Attribute::BEGIN@10
1116µs26µsMoose::Meta::Role::Attribute::::BEGIN@14Moose::Meta::Role::Attribute::BEGIN@14
1116µs93µsMoose::Meta::Role::Attribute::::BEGIN@16Moose::Meta::Role::Attribute::BEGIN@16
0000s0sMoose::Meta::Role::Attribute::::__ANON__[:120]Moose::Meta::Role::Attribute::__ANON__[:120]
0000s0sMoose::Meta::Role::Attribute::::is_same_asMoose::Meta::Role::Attribute::is_same_as
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 {
314µs $Moose::Meta::Role::Attribute::AUTHORITY = 'cpan:STEVAN';
4128µs18µs}
# spent 8µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@2
5{
62700ns $Moose::Meta::Role::Attribute::VERSION = '2.1005';
7}
8
9219µs228µs
# spent 18µs (8+10) within Moose::Meta::Role::Attribute::BEGIN@9 which was called: # once (8µs+10µs) by Moose::Meta::Role::BEGIN@19 at line 9
use strict;
# spent 18µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@9 # spent 10µs making 1 call to strict::import
10220µs212µs
# spent 9µs (6+3) within Moose::Meta::Role::Attribute::BEGIN@10 which was called: # once (6µs+3µs) by Moose::Meta::Role::BEGIN@19 at line 10
use warnings;
# spent 9µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@10 # spent 3µs making 1 call to warnings::import
11
12220µs244µs
# spent 25µs (6+19) within Moose::Meta::Role::Attribute::BEGIN@12 which was called: # once (6µs+19µs) by Moose::Meta::Role::BEGIN@19 at line 12
use Carp 'confess';
# spent 25µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@12 # spent 19µs making 1 call to Exporter::import
13221µs240µs
# spent 23µs (6+17) within Moose::Meta::Role::Attribute::BEGIN@13 which was called: # once (6µs+17µs) by Moose::Meta::Role::BEGIN@19 at line 13
use List::MoreUtils 'all';
# spent 23µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@13 # spent 17µs making 1 call to Exporter::import
14222µs245µs
# spent 26µs (6+20) within Moose::Meta::Role::Attribute::BEGIN@14 which was called: # once (6µs+20µs) by Moose::Meta::Role::BEGIN@19 at line 14
use Scalar::Util 'blessed', 'weaken';
# spent 26µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@14 # spent 20µs making 1 call to Exporter::import
15
162403µs2180µs
# spent 93µs (6+87) within Moose::Meta::Role::Attribute::BEGIN@16 which was called: # once (6µs+87µs) by Moose::Meta::Role::BEGIN@19 at line 16
use base 'Moose::Meta::Mixin::AttributeCore', 'Class::MOP::Object';
# spent 93µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@16 # spent 87µs making 1 call to base::import
17
1816µs3616µs__PACKAGE__->meta->add_attribute(
# spent 350µs making 1 call to Class::MOP::Mixin::meta # spent 262µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 5µs making 1 call to Class::MOP::_definition_context
19 'metaclass' => (
20 reader => 'metaclass',
21 Class::MOP::_definition_context(),
22 )
23);
24
2513µs3263µs__PACKAGE__->meta->add_attribute(
# spent 250µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 9µ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
3213µs3260µs__PACKAGE__->meta->add_attribute(
# spent 248µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µs making 1 call to Class::MOP::Mixin::meta # spent 4µs making 1 call to Class::MOP::_definition_context
33 '_original_role' => (
34 reader => '_original_role',
35 Class::MOP::_definition_context(),
36 )
37);
38
3913µs3256µs__PACKAGE__->meta->add_attribute(
# spent 244µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µs making 1 call to Class::MOP::Mixin::meta # spent 4µs making 1 call to Class::MOP::_definition_context
40 'is' => (
41 reader => 'is',
42 Class::MOP::_definition_context(),
43 )
44);
45
4613µs3255µs__PACKAGE__->meta->add_attribute(
# spent 242µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µs making 1 call to Class::MOP::Mixin::meta # spent 4µs making 1 call to Class::MOP::_definition_context
47 'original_options' => (
48 reader => 'original_options',
49 Class::MOP::_definition_context(),
50 )
51);
52
53
# spent 244µs within Moose::Meta::Role::Attribute::new which was called 38 times, avg 6µs/call: # 19 times (126µs+0s) by Class::MOP::Mixin::HasAttributes::add_attribute at line 20 of Class/MOP/Mixin/HasAttributes.pm, avg 7µs/call # 19 times (118µs+0s) by Moose::Meta::Role::Attribute::clone at line 101, avg 6µs/call
sub new {
543858µs my ( $class, $name, %options ) = @_;
55
56384µs (defined $name)
57 || confess "You must provide a name for the attribute";
58
593811µs my $role = delete $options{_original_role};
60
6138196µs return bless {
62 name => $name,
63 original_options => \%options,
64 _original_role => $role,
65 %options,
66 }, $class;
67}
68
69
# spent 251µs (196+55) within Moose::Meta::Role::Attribute::attach_to_role which was called 38 times, avg 7µs/call: # 38 times (196µs+55µs) by Moose::Meta::Role::_attach_attribute at line 259 of Moose/Meta/Role.pm, avg 7µs/call
sub attach_to_role {
70383µs my ( $self, $role ) = @_;
71
7238135µs7633µs ( blessed($role) && $role->isa('Moose::Meta::Role') )
# spent 17µs making 38 calls to Scalar::Util::blessed, avg 447ns/call # spent 16µs making 38 calls to UNIVERSAL::isa, avg 413ns/call
73 || confess
74 "You must pass a Moose::Meta::Role instance (or a subclass)";
75
7638131µs3822µs weaken( $self->{'associated_role'} = $role );
# spent 22µs making 38 calls to Scalar::Util::weaken, avg 576ns/call
77}
78
79
# spent 170µs (109+62) within Moose::Meta::Role::Attribute::original_role which was called 38 times, avg 4µs/call: # 19 times (66µs+37µs) by Moose::Meta::Role::Attribute::clone at line 97, avg 5µs/call # 19 times (43µs+25µs) by Moose::Meta::Role::Attribute::attribute_for_class at line 88, avg 4µs/call
sub original_role {
80382µs my $self = shift;
81
823884µs5762µs return $self->_original_role || $self->associated_role;
# spent 43µs making 38 calls to Moose::Meta::Role::Attribute::_original_role, avg 1µs/call # spent 18µs making 19 calls to Moose::Meta::Role::Attribute::associated_role, avg 974ns/call
83}
84
85
# spent 32.8ms (189µs+32.6) within Moose::Meta::Role::Attribute::attribute_for_class which was called 19 times, avg 1.73ms/call: # 19 times (189µs+32.6ms) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 152 of Moose/Meta/Role/Application/ToClass.pm, avg 1.73ms/call
sub attribute_for_class {
86192µs my $self = shift;
87
881930µs3893µs my $metaclass = $self->original_role->applied_attribute_metaclass;
# spent 67µs making 19 calls to Moose::Meta::Role::Attribute::original_role, avg 4µs/call # spent 26µs making 19 calls to Moose::Meta::Role::applied_attribute_metaclass, avg 1µs/call
89
90 return $metaclass->interpolate_class_and_new(
9119113µs5732.5ms $self->name => %{ $self->original_options } );
# spent 32.9ms making 19 calls to Moose::Meta::Attribute::interpolate_class_and_new, avg 1.73ms/call, recursion: max depth 1, sum of overlapping time 440µs # spent 22µs making 19 calls to Moose::Meta::Role::Attribute::original_options, avg 1µs/call # spent 10µs making 19 calls to Class::MOP::Mixin::AttributeCore::name, avg 547ns/call
92}
93
94
# spent 391µs (141+250) within Moose::Meta::Role::Attribute::clone which was called 19 times, avg 21µs/call: # 17 times (126µs+222µs) by Moose::Meta::Role::Application::RoleSummation::apply_attributes at line 151 of Moose/Meta/Role/Application/RoleSummation.pm, avg 20µs/call # 2 times (16µs+27µs) by Moose::Meta::Role::Application::ToRole::apply_attributes at line 73 of Moose/Meta/Role/Application/ToRole.pm, avg 21µs/call
sub clone {
95192µs my $self = shift;
96
971910µs19103µs my $role = $self->original_role;
# spent 103µs making 19 calls to Moose::Meta::Role::Attribute::original_role, avg 5µs/call
98
99 return ( ref $self )->new(
100 $self->name,
1011996µs57146µs %{ $self->original_options },
# spent 118µs making 19 calls to Moose::Meta::Role::Attribute::new, avg 6µs/call # spent 20µs making 19 calls to Moose::Meta::Role::Attribute::original_options, avg 1µs/call # spent 9µs making 19 calls to Class::MOP::Mixin::AttributeCore::name, avg 463ns/call
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
12817µs1;
129
130# ABSTRACT: The Moose attribute metaclass for Roles
131
132__END__