← Index
NYTProf Performance Profile   « line view »
For script/ponapi
  Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:11 2016

Filename/usr/local/lib/perl/5.18.2/Moose/Meta/Method/Accessor/Native/Collection.pm
StatementsExecuted 281 statements in 1.31ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1721267µs377µsMoose::Meta::Method::Accessor::Native::Collection::::_tc_member_typeMoose::Meta::Method::Accessor::Native::Collection::_tc_member_type
511134µs604µsMoose::Meta::Method::Accessor::Native::Collection::::_inline_check_member_constraintMoose::Meta::Method::Accessor::Native::Collection::_inline_check_member_constraint
51196µs1.06msMoose::Meta::Method::Accessor::Native::Collection::::_inline_tc_codeMoose::Meta::Method::Accessor::Native::Collection::_inline_tc_code
51192µs208µsMoose::Meta::Method::Accessor::Native::Collection::::_check_new_members_onlyMoose::Meta::Method::Accessor::Native::Collection::_check_new_members_only
71155µs74µsMoose::Meta::Method::Accessor::Native::Collection::::_inline_get_old_value_for_triggerMoose::Meta::Method::Accessor::Native::Collection::_inline_get_old_value_for_trigger
41129µs36µsMoose::Meta::Method::Accessor::Native::Collection::::_inline_coerce_new_valuesMoose::Meta::Method::Accessor::Native::Collection::_inline_coerce_new_values
11111µs24µsMoose::Meta::Method::Accessor::Native::Collection::::BEGIN@4Moose::Meta::Method::Accessor::Native::Collection::BEGIN@4
1119µs2.21msMoose::Meta::Method::Accessor::Native::Collection::::BEGIN@7Moose::Meta::Method::Accessor::Native::Collection::BEGIN@7
1118µs92µsMoose::Meta::Method::Accessor::Native::Collection::::BEGIN@165Moose::Meta::Method::Accessor::Native::Collection::BEGIN@165
1116µs12µsMoose::Meta::Method::Accessor::Native::Collection::::BEGIN@5Moose::Meta::Method::Accessor::Native::Collection::BEGIN@5
0000s0sMoose::Meta::Method::Accessor::Native::Collection::::__ANON__[:163]Moose::Meta::Method::Accessor::Native::Collection::__ANON__[:163]
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;
21500nsour $VERSION = '2.1604';
3
4223µs238µs
# spent 24µs (11+13) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@4 which was called: # once (11µs+13µs) by Module::Runtime::require_module at line 4
use strict;
# spent 24µs making 1 call to Moose::Meta::Method::Accessor::Native::Collection::BEGIN@4 # spent 13µs making 1 call to strict::import
5220µs219µs
# spent 12µs (6+6) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@5 which was called: # once (6µs+6µs) by Module::Runtime::require_module at line 5
use warnings;
# spent 12µs making 1 call to Moose::Meta::Method::Accessor::Native::Collection::BEGIN@5 # spent 6µs making 1 call to warnings::import
6
72566µs24.42ms
# spent 2.21ms (9µs+2.20) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@7 which was called: # once (9µs+2.20ms) by Module::Runtime::require_module at line 7
use Moose::Role;
# spent 2.21ms making 1 call to Moose::Meta::Method::Accessor::Native::Collection::BEGIN@7 # spent 2.20ms making 1 call to Moose::Role::import
8
911µs174µsrequires qw( _adds_members );
# spent 74µs making 1 call to Moose::Role::requires
10
11
# spent 36µs (29+7) within Moose::Meta::Method::Accessor::Native::Collection::_inline_coerce_new_values which was called 4 times, avg 9µs/call: # 4 times (29µs+7µs) by Moose::Meta::Method::Accessor::Native::Array::Writer::_inline_coerce_new_values at line 15 of Moose/Meta/Method/Accessor/Native/Array/Writer.pm, avg 9µs/call
sub _inline_coerce_new_values {
1241µs my $self = shift;
13
14418µs87µs return unless $self->associated_attribute->should_coerce;
# spent 4µs making 4 calls to Moose::Meta::Mixin::AttributeCore::should_coerce, avg 950ns/call # spent 3µs making 4 calls to Class::MOP::Method::Accessor::associated_attribute, avg 800ns/call
15
16 return unless $self->_tc_member_type_can_coerce;
17
18 return (
19 '(' . $self->_new_members . ') = map { $member_coercion->($_) }',
20 $self->_new_members . ';',
21 );
22}
23
24sub _tc_member_type_can_coerce {
25 my $self = shift;
26
27 my $member_tc = $self->_tc_member_type;
28
29 return $member_tc && $member_tc->has_coercion;
30}
31
32
# spent 377µs (267+110) within Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type which was called 17 times, avg 22µs/call: # 10 times (131µs+50µs) by Moose::Meta::Method::Accessor::Native::Collection::_inline_check_member_constraint at line 103, avg 18µs/call # 7 times (136µs+60µs) by Class::MOP::Class:::around at line 144, avg 28µs/call
sub _tc_member_type {
33176µs my $self = shift;
34
351728µs3431µs my $tc = $self->associated_attribute->type_constraint;
# spent 18µs making 17 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 1µs/call # spent 13µs making 17 calls to Class::MOP::Method::Accessor::associated_attribute, avg 776ns/call
361734µs1720µs while ($tc) {
# spent 20µs making 17 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 1µs/call
3725123µs4043µs return $tc->type_parameter
# spent 24µs making 25 calls to UNIVERSAL::can, avg 964ns/call # spent 19µs making 15 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 1µs/call
38 if $tc->can('type_parameter');
391022µs1816µs $tc = $tc->parent;
# spent 13µs making 10 calls to Moose::Meta::TypeConstraint::parent, avg 1µs/call # spent 4µs making 8 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 450ns/call
40 }
41
4226µs return;
43}
44
45sub _writer_value_needs_copy {
46 my $self = shift;
47
48 return $self->_constraint_must_be_checked
49 && !$self->_check_new_members_only;
50}
51
52
# spent 1.06ms (96µs+963µs) within Moose::Meta::Method::Accessor::Native::Collection::_inline_tc_code which was called 5 times, avg 212µs/call: # 5 times (96µs+963µs) by Class::MOP::Class:::around at line 127 of Moose/Meta/Method/Accessor/Native/Writer.pm, avg 212µs/call
sub _inline_tc_code {
5353µs my $self = shift;
5454µs my ($value, $tc, $coercion, $message, $is_lazy) = @_;
55
56510µs5132µs return unless $self->_constraint_must_be_checked;
# spent 132µs making 5 calls to Moose::Meta::Method::Accessor::Native::Writer::_constraint_must_be_checked, avg 26µs/call
57
58513µs5208µs if ($self->_check_new_members_only) {
# spent 208µs making 5 calls to Moose::Meta::Method::Accessor::Native::Collection::_check_new_members_only, avg 42µs/call
59510µs58µs return unless $self->_adds_members;
60
61530µs10615µs return $self->_inline_check_member_constraint($self->_new_members);
62 }
63 else {
64 return (
65 $self->_inline_check_coercion($value, $tc, $coercion, $is_lazy),
66 $self->_inline_check_constraint($value, $tc, $message, $is_lazy),
67 );
68 }
69}
70
71
# spent 208µs (92+116) within Moose::Meta::Method::Accessor::Native::Collection::_check_new_members_only which was called 5 times, avg 42µs/call: # 5 times (92µs+116µs) by Moose::Meta::Method::Accessor::Native::Collection::_inline_tc_code at line 58, avg 42µs/call
sub _check_new_members_only {
7252µs my $self = shift;
73
7457µs54µs my $attr = $self->associated_attribute;
# spent 4µs making 5 calls to Class::MOP::Method::Accessor::associated_attribute, avg 780ns/call
75
7658µs55µs my $tc = $attr->type_constraint;
# spent 5µs making 5 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 1µs/call
77
78 # If we have a coercion, we could come up with an entirely new value after
79 # coercing, so we need to check everything,
8058µs55µs return 0 if $attr->should_coerce && $tc->has_coercion;
# spent 5µs making 5 calls to Moose::Meta::Mixin::AttributeCore::should_coerce, avg 1µs/call
81
82 # If the parent is our root type (ArrayRef, HashRef, etc), that means we
83 # can just check the new members of the collection, because we know that
84 # we will always be generating an appropriate collection type.
85 #
86 # However, if this type has its own constraint (it's Parameteriz_able_,
87 # not Paramet_erized_), we don't know what is being checked by the
88 # constraint, so we need to check the whole value, not just the members.
89545µs15101µs return 1
# spent 83µs making 5 calls to Moose::Meta::Method::Accessor::Native::Writer::_is_root_type, avg 17µs/call # spent 12µs making 5 calls to Moose::Meta::TypeConstraint::parent, avg 2µs/call # spent 7µs making 5 calls to UNIVERSAL::isa, avg 1µs/call
90 if $self->_is_root_type( $tc->parent )
91 && ( $tc->isa('Moose::Meta::TypeConstraint::Parameterized')
92 || $tc->isa('Specio::Constraint::Parameterized') );
93
94 return 0;
95}
96
97
# spent 604µs (134+469) within Moose::Meta::Method::Accessor::Native::Collection::_inline_check_member_constraint which was called 5 times, avg 121µs/call: # 5 times (134µs+469µs) by Moose::Meta::Method::Accessor::Native::Collection::_inline_tc_code at line 61, avg 121µs/call
sub _inline_check_member_constraint {
9852µs my $self = shift;
9953µs my ($new_value) = @_;
100
101523µs109µs my $attr_name = $self->associated_attribute->name;
# spent 4µs making 5 calls to Class::MOP::Method::Accessor::associated_attribute, avg 900ns/call # spent 4µs making 5 calls to Class::MOP::Mixin::AttributeCore::name, avg 840ns/call
102
103534µs20446µs my $check
# spent 181µs making 10 calls to Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type, avg 18µs/call # spent 136µs making 4 calls to Moose::Meta::TypeConstraint::_inline_check, avg 34µs/call # spent 59µs making 1 call to Moose::Meta::TypeConstraint::Union::_inline_check # spent 48µs making 4 calls to Moose::Meta::TypeConstraint::can_be_inlined, avg 12µs/call # spent 22µs making 1 call to Moose::Meta::TypeConstraint::Union::can_be_inlined
104 = $self->_tc_member_type->can_be_inlined
105 ? '! (' . $self->_tc_member_type->_inline_check('$new_val') . ')'
106 : ' !$member_tc->($new_val) ';
107
108 return (
109543µs515µs 'for my $new_val (' . $new_value . ') {',
# spent 15µs making 5 calls to Class::MOP::Method::Accessor::_inline_throw_exception, avg 3µs/call
110 "if ($check) {",
111 'my $msg = do { local $_ = $new_val; $member_message->($new_val) };'.
112 $self->_inline_throw_exception( ValidationFailedForInlineTypeConstraint =>
113 "attribute_name => '".$attr_name."',".
114 'type_constraint_message => $msg,'.
115 'class_name => $class_name,'.
116 'value => $new_val,'.
117 'new_member => 1',
118 ) . ';',
119 '}',
120 '}',
121 );
122}
123
124
# spent 74µs (55+19) within Moose::Meta::Method::Accessor::Native::Collection::_inline_get_old_value_for_trigger which was called 7 times, avg 11µs/call: # 7 times (55µs+19µs) by Moose::Meta::Method::Accessor::Native::Writer::_inline_writer_core at line 52 of Moose/Meta/Method/Accessor/Native/Writer.pm, avg 11µs/call
sub _inline_get_old_value_for_trigger {
12574µs my $self = shift;
12674µs my ($instance, $old) = @_;
127
12878µs76µs my $attr = $self->associated_attribute;
# spent 6µs making 7 calls to Class::MOP::Method::Accessor::associated_attribute, avg 829ns/call
129728µs713µs return unless $attr->has_trigger;
# spent 13µs making 7 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 2µs/call
130
131 return (
132 'my ' . $old . ' = ' . $self->_has_value($instance),
133 '? ' . $self->_copy_old_value($self->_get_value($instance)),
134 ': ();',
135 );
136}
137
138around _eval_environment => sub {
13973µs my $orig = shift;
14072µs my $self = shift;
141
142713µs71.15ms my $env = $self->$orig(@_);
# spent 614µs making 4 calls to Moose::Meta::Class::__ANON__::SERIAL::10::_eval_environment, avg 154µs/call # spent 536µs making 3 calls to Moose::Meta::Class::__ANON__::SERIAL::6::_eval_environment, avg 178µs/call
143
144716µs7196µs my $member_tc = $self->_tc_member_type;
# spent 196µs making 7 calls to Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type, avg 28µs/call
145
146712µs53µs return $env unless $member_tc;
# spent 3µs making 5 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 620ns/call
147
148515µs514µs $env->{'$member_tc'} = \( $member_tc->_compiled_type_constraint );
# spent 14µs making 5 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 3µs/call
149511µs524µs $env->{'$member_coercion'} = \(
# spent 18µs making 1 call to Moose::Meta::TypeConstraint::Union::has_coercion # spent 6µs making 4 calls to Moose::Meta::TypeConstraint::has_coercion, avg 1µs/call
150 $member_tc->coercion->_compiled_type_coercion
151 ) if $member_tc->has_coercion;
152518µs1012µs $env->{'$member_message'} = \(
# spent 7µs making 5 calls to Moose::Meta::TypeConstraint::_default_message, avg 1µs/call # spent 5µs making 5 calls to Moose::Meta::TypeConstraint::has_message, avg 1µs/call
153 $member_tc->has_message
154 ? $member_tc->message
155 : $member_tc->_default_message
156 );
157
15859µs558µs my $tc_env = $member_tc->inline_environment();
# spent 38µs making 4 calls to Moose::Meta::TypeConstraint::inline_environment, avg 9µs/call # spent 20µs making 1 call to Moose::Meta::TypeConstraint::Union::inline_environment
159
160520µs $env = { %{$env}, %{$tc_env} };
161
162514µs return $env;
16313µs148µs};
# spent 48µs making 1 call to Moose::Role::around
164
165229µs2175µs
# spent 92µs (8+84) within Moose::Meta::Method::Accessor::Native::Collection::BEGIN@165 which was called: # once (8µs+84µs) by Module::Runtime::require_module at line 165
no Moose::Role;
# spent 92µs making 1 call to Moose::Meta::Method::Accessor::Native::Collection::BEGIN@165 # spent 84µs making 1 call to Moose::Role::unimport
166
16717µs1;