← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:42:38 2010
Reported on Wed Nov 17 22:06:32 2010

Filename/home/doy/coding/src/Moose/blib/lib//Moose/Meta/Method/Accessor/Native/Collection.pm
StatementsExecuted 68 statements in 3.45ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
211532µs832µsMoose::Meta::Method::Accessor::Native::Collection::::_tc_member_typeMoose::Meta::Method::Accessor::Native::Collection::_tc_member_type
211164µs217µsMoose::Meta::Method::Accessor::Native::Collection::::_inline_get_old_value_for_triggerMoose::Meta::Method::Accessor::Native::Collection::_inline_get_old_value_for_trigger
211113µs157µsMoose::Meta::Method::Accessor::Native::Collection::::_inline_coerce_new_valuesMoose::Meta::Method::Accessor::Native::Collection::_inline_coerce_new_values
11178µs95µsMoose::Meta::Method::Accessor::Native::Collection::::BEGIN@3Moose::Meta::Method::Accessor::Native::Collection::BEGIN@3
11147µs749µsMoose::Meta::Method::Accessor::Native::Collection::::BEGIN@149Moose::Meta::Method::Accessor::Native::Collection::BEGIN@149
11142µs13.7msMoose::Meta::Method::Accessor::Native::Collection::::BEGIN@10Moose::Meta::Method::Accessor::Native::Collection::BEGIN@10
11141µs110µsMoose::Meta::Method::Accessor::Native::Collection::::BEGIN@4Moose::Meta::Method::Accessor::Native::Collection::BEGIN@4
0000s0sMoose::Meta::Method::Accessor::Native::Collection::::__ANON__[:147]Moose::Meta::Method::Accessor::Native::Collection::__ANON__[:147]
0000s0sMoose::Meta::Method::Accessor::Native::Collection::::_check_new_members_onlyMoose::Meta::Method::Accessor::Native::Collection::_check_new_members_only
0000s0sMoose::Meta::Method::Accessor::Native::Collection::::_inline_check_member_constraintMoose::Meta::Method::Accessor::Native::Collection::_inline_check_member_constraint
0000s0sMoose::Meta::Method::Accessor::Native::Collection::::_inline_tc_codeMoose::Meta::Method::Accessor::Native::Collection::_inline_tc_code
0000s0sMoose::Meta::Method::Accessor::Native::Collection::::_tc_member_type_can_coerceMoose::Meta::Method::Accessor::Native::Collection::_tc_member_type_can_coerce
0000s0sMoose::Meta::Method::Accessor::Native::Collection::::_writer_value_needs_copyMoose::Meta::Method::Accessor::Native::Collection::_writer_value_needs_copy
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::Method::Accessor::Native::Collection;
2
33102µs2113µs
# spent 95µs (78+17) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@3 which was called: # once (78µs+17µs) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 3
use strict;
# spent 95µs making 1 call to Moose::Meta::Method::Accessor::Native::Collection::BEGIN@3 # spent 17µs making 1 call to strict::import
43224µs2178µs
# spent 110µs (41+69) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@4 which was called: # once (41µs+69µs) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 4
use warnings;
# spent 110µs making 1 call to Moose::Meta::Method::Accessor::Native::Collection::BEGIN@4 # spent 69µs making 1 call to warnings::import
5
614µsour $VERSION = '1.19';
7174µs$VERSION = eval $VERSION;
# spent 10µs executing statements in string eval
813µsour $AUTHORITY = 'cpan:STEVAN';
9
1032.02ms227.4ms
# spent 13.7ms (42µs+13.7) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@10 which was called: # once (42µs+13.7ms) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 10
use Moose::Role;
11
12112µs1390µsrequires qw( _adds_members );
# spent 390µs making 1 call to Moose::Role::requires
13
14
# spent 157µs (113+44) within Moose::Meta::Method::Accessor::Native::Collection::_inline_coerce_new_values which was called 2 times, avg 78µs/call: # 2 times (113µs+44µs) by Moose::Meta::Method::Accessor::Native::Writer::_inline_writer_core at line 54 of Moose/Meta/Method/Accessor/Native/Writer.pm, avg 78µs/call
sub _inline_coerce_new_values {
15496µs my $self = shift;
16
17444µs return unless $self->associated_attribute->should_coerce;
# spent 26µs making 2 calls to Moose::Meta::Mixin::AttributeCore::should_coerce, avg 13µs/call # spent 17µs making 2 calls to Class::MOP::Method::Accessor::associated_attribute, avg 8µs/call
18
19 return unless $self->_tc_member_type_can_coerce;
20
21 return (
22 '(' . $self->_new_members . ') = map { $member_tc_obj->coerce($_) }',
23 $self->_new_members . ';',
24 );
25}
26
27sub _tc_member_type_can_coerce {
28 my $self = shift;
29
30 my $member_tc = $self->_tc_member_type;
31
32 return $member_tc && $member_tc->has_coercion;
33}
34
35
# spent 832µs (532+299) within Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type which was called 2 times, avg 416µs/call: # 2 times (532µs+299µs) by Class::MOP::Class:::around at line 138, avg 416µs/call
sub _tc_member_type {
36890µs my $self = shift;
37
38439µs my $tc = $self->associated_attribute->type_constraint;
# spent 23µs making 2 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 12µs/call # spent 16µs making 2 calls to Class::MOP::Method::Accessor::associated_attribute, avg 8µs/call
3916µs215µs while ($tc) {
# spent 15µs making 2 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 8µs/call
4020358µs1074µs return $tc->type_parameter
# spent 74µs making 10 calls to UNIVERSAL::can, avg 7µs/call
41 if $tc->can('type_parameter');
42121µs18171µs $tc = $tc->parent;
# spent 113µs making 10 calls to Moose::Meta::TypeConstraint::parent, avg 11µs/call # spent 58µs making 8 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 7µs/call
43 }
44
45 return;
46}
47
48sub _writer_value_needs_copy {
49 my $self = shift;
50
51 return $self->_constraint_must_be_checked
52 && !$self->_check_new_members_only;
53}
54
55sub _inline_tc_code {
56 my $self = shift;
57
58 return unless $self->_constraint_must_be_checked;
59
60 if ($self->_check_new_members_only) {
61 return unless $self->_adds_members;
62
63 return $self->_inline_check_member_constraint($self->_new_members);
64 }
65 else {
66 return (
67 $self->_inline_check_coercion(@_),
68 $self->_inline_check_constraint(@_),
69 );
70 }
71}
72
73sub _check_new_members_only {
74 my $self = shift;
75
76 my $attr = $self->associated_attribute;
77
78 my $tc = $attr->type_constraint;
79
80 # If we have a coercion, we could come up with an entirely new value after
81 # coercing, so we need to check everything,
82 return 0 if $attr->should_coerce && $tc->has_coercion;
83
84 # If the parent is our root type (ArrayRef, HashRef, etc), that means we
85 # can just check the new members of the collection, because we know that
86 # we will always be generating an appropriate collection type.
87 #
88 # However, if this type has its own constraint (it's Parameteriz_able_,
89 # not Paramet_erized_), we don't know what is being checked by the
90 # constraint, so we need to check the whole value, not just the members.
91 return 1
92 if $self->_is_root_type( $tc->parent )
93 && $tc->isa('Moose::Meta::TypeConstraint::Parameterized');
94
95 return 0;
96}
97
98sub _inline_check_member_constraint {
99 my $self = shift;
100 my ($new_value) = @_;
101
102 my $attr_name = $self->associated_attribute->name;
103
104 return (
105 'for (' . $new_value . ') {',
106 'if (!$member_tc->($_)) {',
107 $self->_inline_throw_error(
108 '"A new member value for ' . $attr_name
109 . ' does not pass its type constraint because: "'
110 . ' . $member_tc->get_message($_)',
111 'data => $_',
112 ) . ';',
113 '}',
114 '}',
115 );
116}
117
118
# spent 217µs (164+52) within Moose::Meta::Method::Accessor::Native::Collection::_inline_get_old_value_for_trigger which was called 2 times, avg 108µs/call: # 2 times (164µs+52µs) by Moose::Meta::Method::Accessor::Native::Writer::_inline_writer_core at line 54 of Moose/Meta/Method/Accessor/Native/Writer.pm, avg 108µs/call
sub _inline_get_old_value_for_trigger {
1198132µs my $self = shift;
120 my ($instance, $old) = @_;
121
122222µs my $attr = $self->associated_attribute;
# spent 22µs making 2 calls to Class::MOP::Method::Accessor::associated_attribute, avg 11µs/call
123231µs return unless $attr->has_trigger;
# spent 31µs making 2 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 15µs/call
124
125 return (
126 'my ' . $old . ' = ' . $self->_has_value($instance),
127 '? ' . $self->_copy_old_value($self->_get_value($instance)),
128 ': ();',
129 );
130}
131
132around _eval_environment => sub {
13310104µs my $orig = shift;
134 my $self = shift;
135
1362787µs my $env = $self->$orig(@_);
137
1382832µs my $member_tc = $self->_tc_member_type;
# spent 832µs making 2 calls to Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type, avg 416µs/call
139
140 return $env unless $member_tc;
141
142 $env->{'$member_tc_obj'} = \($member_tc);
143
144 $env->{'$member_tc'} = \( $member_tc->_compiled_type_constraint );
145
146 return $env;
147121µs1306µs};
# spent 306µs making 1 call to Moose::Role::around
148
1493113µs21.45ms
# spent 749µs (47+702) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@149 which was called: # once (47µs+702µs) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 149
no Moose::Role;
150
151168µs1;