← 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:40 2014

Filename/opt/perl-5.18.1/lib/site_perl/5.18.1/darwin-thread-multi-2level/Class/MOP/Attribute.pm
StatementsExecuted 12945 statements in 39.5ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
2485212.2ms82.4msClass::MOP::Attribute::::_process_accessorsClass::MOP::Attribute::_process_accessors
2003210.3ms125msClass::MOP::Attribute::::install_accessorsClass::MOP::Attribute::install_accessors
398113.79ms12.3msClass::MOP::Attribute::::_inline_instance_setClass::MOP::Attribute::_inline_instance_set
248212.62ms3.13msClass::MOP::Attribute::::_accessor_descriptionClass::MOP::Attribute::_accessor_description
1245041.79ms3.84msClass::MOP::Attribute::::newClass::MOP::Attribute::new
398531.32ms13.6msClass::MOP::Attribute::::_inline_set_valueClass::MOP::Attribute::_inline_set_value
164111.27ms2.74msClass::MOP::Attribute::::_set_initial_slot_valueClass::MOP::Attribute::_set_initial_slot_value
123111.22ms1.92msClass::MOP::Attribute::::_newClass::MOP::Attribute::_new
419111.07ms1.28msClass::MOP::Attribute::::slotsClass::MOP::Attribute::slots
12411913µs1.22msClass::MOP::Attribute::::attach_to_classClass::MOP::Attribute::attach_to_class
21811895µs3.91msClass::MOP::Attribute::::initialize_instance_slotClass::MOP::Attribute::initialize_instance_slot
7822801µs3.67msClass::MOP::Attribute::::_inline_instance_getClass::MOP::Attribute::_inline_instance_get
24821645µs645µsClass::MOP::Attribute::::associate_methodClass::MOP::Attribute::associate_method
7521288µs3.70msClass::MOP::Attribute::::_inline_get_valueClass::MOP::Attribute::_inline_get_value
24521286µs286µsClass::MOP::Attribute::::accessor_metaclassClass::MOP::Attribute::accessor_metaclass
1611179µs355µsClass::MOP::Attribute::::_inline_instance_hasClass::MOP::Attribute::_inline_instance_has
1211137µs326µsClass::MOP::Attribute::::get_raw_valueClass::MOP::Attribute::get_raw_value
1211135µs316µsClass::MOP::Attribute::::has_valueClass::MOP::Attribute::has_value
161171µs426µsClass::MOP::Attribute::::_inline_has_valueClass::MOP::Attribute::_inline_has_value
121134µs359µsClass::MOP::Attribute::::get_valueClass::MOP::Attribute::get_value
11112µs48µsClass::MOP::Attribute::::BEGIN@15Class::MOP::Attribute::BEGIN@15
11112µs12µsClass::MOP::Attribute::::BEGIN@3Class::MOP::Attribute::BEGIN@3
11110µs17µsClass::MOP::Attribute::::BEGIN@11Class::MOP::Attribute::BEGIN@11
11110µs46µsClass::MOP::Attribute::::BEGIN@17Class::MOP::Attribute::BEGIN@17
11110µs155µsClass::MOP::Attribute::::BEGIN@19Class::MOP::Attribute::BEGIN@19
11110µs28µsClass::MOP::Attribute::::BEGIN@10Class::MOP::Attribute::BEGIN@10
11110µs43µsClass::MOP::Attribute::::BEGIN@16Class::MOP::Attribute::BEGIN@16
1116µs6µsClass::MOP::Attribute::::BEGIN@13Class::MOP::Attribute::BEGIN@13
0000s0sClass::MOP::Attribute::::__ANON__[:169]Class::MOP::Attribute::__ANON__[:169]
0000s0sClass::MOP::Attribute::::__ANON__[:198]Class::MOP::Attribute::__ANON__[:198]
0000s0sClass::MOP::Attribute::::__ANON__[:218]Class::MOP::Attribute::__ANON__[:218]
0000s0sClass::MOP::Attribute::::__ANON__[:398]Class::MOP::Attribute::__ANON__[:398]
0000s0sClass::MOP::Attribute::::__ANON__[:401]Class::MOP::Attribute::__ANON__[:401]
0000s0sClass::MOP::Attribute::::__ANON__[:456]Class::MOP::Attribute::__ANON__[:456]
0000s0sClass::MOP::Attribute::::_inline_clear_valueClass::MOP::Attribute::_inline_clear_value
0000s0sClass::MOP::Attribute::::_inline_instance_clearClass::MOP::Attribute::_inline_instance_clear
0000s0sClass::MOP::Attribute::::_make_initializer_writer_callbackClass::MOP::Attribute::_make_initializer_writer_callback
0000s0sClass::MOP::Attribute::::clear_valueClass::MOP::Attribute::clear_value
0000s0sClass::MOP::Attribute::::detach_from_classClass::MOP::Attribute::detach_from_class
0000s0sClass::MOP::Attribute::::get_read_methodClass::MOP::Attribute::get_read_method
0000s0sClass::MOP::Attribute::::get_read_method_refClass::MOP::Attribute::get_read_method_ref
0000s0sClass::MOP::Attribute::::get_write_methodClass::MOP::Attribute::get_write_method
0000s0sClass::MOP::Attribute::::get_write_method_refClass::MOP::Attribute::get_write_method_ref
0000s0sClass::MOP::Attribute::::remove_accessorsClass::MOP::Attribute::remove_accessors
0000s0sClass::MOP::Attribute::::set_initial_valueClass::MOP::Attribute::set_initial_value
0000s0sClass::MOP::Attribute::::set_raw_valueClass::MOP::Attribute::set_raw_value
0000s0sClass::MOP::Attribute::::set_valueClass::MOP::Attribute::set_value
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1
2package Class::MOP::Attribute;
3
# spent 12µs within Class::MOP::Attribute::BEGIN@3 which was called: # once (12µs+0s) by Class::MOP::BEGIN@27 at line 5
BEGIN {
417µs $Class::MOP::Attribute::AUTHORITY = 'cpan:STEVAN';
5141µs112µs}
# spent 12µs making 1 call to Class::MOP::Attribute::BEGIN@3
6{
722µs $Class::MOP::Attribute::VERSION = '2.1005';
8}
9
10231µs246µs
# spent 28µs (10+18) within Class::MOP::Attribute::BEGIN@10 which was called: # once (10µs+18µs) by Class::MOP::BEGIN@27 at line 10
use strict;
# spent 28µs making 1 call to Class::MOP::Attribute::BEGIN@10 # spent 18µs making 1 call to strict::import
11232µs223µs
# spent 17µs (10+6) within Class::MOP::Attribute::BEGIN@11 which was called: # once (10µs+6µs) by Class::MOP::BEGIN@27 at line 11
use warnings;
# spent 17µs making 1 call to Class::MOP::Attribute::BEGIN@11 # spent 6µs making 1 call to warnings::import
12
13232µs16µs
# spent 6µs within Class::MOP::Attribute::BEGIN@13 which was called: # once (6µs+0s) by Class::MOP::BEGIN@27 at line 13
use Class::MOP::Method::Accessor;
# spent 6µs making 1 call to Class::MOP::Attribute::BEGIN@13
14
15237µs283µs
# spent 48µs (12+35) within Class::MOP::Attribute::BEGIN@15 which was called: # once (12µs+35µs) by Class::MOP::BEGIN@27 at line 15
use Carp 'confess';
# spent 48µs making 1 call to Class::MOP::Attribute::BEGIN@15 # spent 35µs making 1 call to Exporter::import
16233µs276µs
# spent 43µs (10+33) within Class::MOP::Attribute::BEGIN@16 which was called: # once (10µs+33µs) by Class::MOP::BEGIN@27 at line 16
use Scalar::Util 'blessed', 'weaken';
# spent 43µs making 1 call to Class::MOP::Attribute::BEGIN@16 # spent 33µs making 1 call to Exporter::import
17236µs283µs
# spent 46µs (10+36) within Class::MOP::Attribute::BEGIN@17 which was called: # once (10µs+36µs) by Class::MOP::BEGIN@27 at line 17
use Try::Tiny;
# spent 46µs making 1 call to Class::MOP::Attribute::BEGIN@17 # spent 36µs making 1 call to Exporter::import
18
1922.78ms2301µs
# spent 155µs (10+145) within Class::MOP::Attribute::BEGIN@19 which was called: # once (10µs+145µs) by Class::MOP::BEGIN@27 at line 19
use base 'Class::MOP::Object', 'Class::MOP::Mixin::AttributeCore';
# spent 155µs making 1 call to Class::MOP::Attribute::BEGIN@19 # spent 145µs making 1 call to base::import
20
21# NOTE: (meta-circularity)
22# This method will be replaced in the
23# boostrap section of Class::MOP, by
24# a new version which uses the
25# &Class::MOP::Class::construct_instance
26# method to build an attribute meta-object
27# which itself is described with attribute
28# meta-objects.
29# - Ain't meta-circularity grand? :)
30
# spent 3.84ms (1.79+2.05) within Class::MOP::Attribute::new which was called 124 times, avg 31µs/call: # 74 times (1.10ms+813µs) by Class::MOP::Mixin::HasAttributes::add_attribute at line 20 of Class/MOP/Mixin/HasAttributes.pm, avg 26µs/call # 2 times (35µs+752µs) by Moose::Meta::Attribute::new at line 121 of Moose/Meta/Attribute.pm, avg 394µs/call # once (31µs+19µs) by Moose::Exporter::BEGIN@13 at line 133 of Class/MOP.pm # once (23µs+13µs) by Moose::Exporter::BEGIN@13 at line 597 of Class/MOP.pm # once (17µs+17µs) by Moose::Exporter::BEGIN@13 at line 250 of Class/MOP.pm # once (21µs+13µs) by Moose::Exporter::BEGIN@13 at line 178 of Class/MOP.pm # once (18µs+13µs) by Moose::Exporter::BEGIN@13 at line 479 of Class/MOP.pm # once (16µs+14µs) by Moose::Exporter::BEGIN@13 at line 572 of Class/MOP.pm # once (18µs+12µs) by Moose::Exporter::BEGIN@13 at line 223 of Class/MOP.pm # once (14µs+15µs) by Moose::Exporter::BEGIN@13 at line 182 of Class/MOP.pm # once (14µs+14µs) by Moose::Exporter::BEGIN@13 at line 137 of Class/MOP.pm # once (16µs+12µs) by Moose::Exporter::BEGIN@13 at line 270 of Class/MOP.pm # once (16µs+11µs) by Moose::Exporter::BEGIN@13 at line 287 of Class/MOP.pm # once (13µs+14µs) by Moose::Exporter::BEGIN@13 at line 618 of Class/MOP.pm # once (13µs+13µs) by Moose::Exporter::BEGIN@13 at line 543 of Class/MOP.pm # once (12µs+11µs) by Moose::Exporter::BEGIN@13 at line 562 of Class/MOP.pm # once (12µs+12µs) by Moose::Exporter::BEGIN@13 at line 394 of Class/MOP.pm # once (14µs+9µs) by Moose::BEGIN@27 at line 47 of Moose/Meta/Class.pm # once (13µs+9µs) by Moose::Exporter::BEGIN@13 at line 291 of Class/MOP.pm # once (13µs+9µs) by Moose::Exporter::BEGIN@13 at line 150 of Class/MOP.pm # once (13µs+9µs) by Moose::Exporter::BEGIN@13 at line 327 of Class/MOP.pm # once (12µs+9µs) by Moose::Exporter::BEGIN@13 at line 425 of Class/MOP.pm # once (12µs+9µs) by Moose::Exporter::BEGIN@13 at line 511 of Class/MOP.pm # once (13µs+9µs) by Moose::Exporter::BEGIN@13 at line 449 of Class/MOP.pm # once (12µs+9µs) by Moose::Exporter::BEGIN@13 at line 460 of Class/MOP.pm # once (12µs+9µs) by Moose::Exporter::BEGIN@13 at line 441 of Class/MOP.pm # once (12µs+8µs) by Moose::Exporter::BEGIN@13 at line 401 of Class/MOP.pm # once (12µs+9µs) by Moose::Exporter::BEGIN@13 at line 601 of Class/MOP.pm # once (12µs+9µs) by Moose::Exporter::BEGIN@13 at line 198 of Class/MOP.pm # once (12µs+9µs) by Moose::Exporter::BEGIN@13 at line 355 of Class/MOP.pm # once (12µs+9µs) by Moose::Exporter::BEGIN@13 at line 518 of Class/MOP.pm # once (12µs+9µs) by Moose::Exporter::BEGIN@13 at line 433 of Class/MOP.pm # once (12µs+8µs) by Moose::Exporter::BEGIN@13 at line 417 of Class/MOP.pm # once (12µs+8µs) by Moose::Exporter::BEGIN@13 at line 370 of Class/MOP.pm # once (12µs+8µs) by Moose::Exporter::BEGIN@13 at line 386 of Class/MOP.pm # once (12µs+8µs) by Moose::Exporter::BEGIN@13 at line 317 of Class/MOP.pm # once (12µs+9µs) by Moose::Exporter::BEGIN@13 at line 504 of Class/MOP.pm # once (12µs+8µs) by Moose::Exporter::BEGIN@13 at line 307 of Class/MOP.pm # once (12µs+9µs) by Moose::Exporter::BEGIN@13 at line 497 of Class/MOP.pm # once (12µs+8µs) by Moose::Exporter::BEGIN@13 at line 378 of Class/MOP.pm # once (12µs+9µs) by Moose::Exporter::BEGIN@13 at line 649 of Class/MOP.pm # once (12µs+9µs) by Moose::Exporter::BEGIN@13 at line 490 of Class/MOP.pm # once (12µs+9µs) by Moose::Exporter::BEGIN@13 at line 581 of Class/MOP.pm # once (12µs+8µs) by Moose::Exporter::BEGIN@13 at line 338 of Class/MOP.pm # once (12µs+8µs) by Moose::Exporter::BEGIN@13 at line 642 of Class/MOP.pm # once (12µs+8µs) by Moose::Exporter::BEGIN@13 at line 625 of Class/MOP.pm # once (12µs+9µs) by Moose::Exporter::BEGIN@13 at line 551 of Class/MOP.pm # once (12µs+8µs) by Moose::Exporter::BEGIN@13 at line 635 of Class/MOP.pm # once (12µs+8µs) by Moose::Exporter::BEGIN@13 at line 534 of Class/MOP.pm # once (12µs+8µs) by Moose::Exporter::BEGIN@13 at line 409 of Class/MOP.pm
sub new {
31124187µs my ( $class, @args ) = @_;
32
33124141µs unshift @args, "name" if @args % 2 == 1;
34124247µs my %options = @args;
35
3612446µs my $name = $options{name};
37
3812424µs (defined $name)
39 || confess "You must provide a name for the attribute";
40
41124103µs $options{init_arg} = $name
42 if not exists $options{init_arg};
4312464µs if(exists $options{builder}){
44 confess("builder must be a defined scalar value which is a method name")
45 if ref $options{builder} || !(defined $options{builder});
46 confess("Setting both default and builder is not allowed.")
47 if exists $options{default};
48 } else {
49124106µs2788µs ($class->is_default_a_coderef(\%options))
# spent 88µs making 27 calls to Class::MOP::Mixin::AttributeCore::is_default_a_coderef, avg 3µs/call
50 || confess("References are not allowed as default values, you must ".
51 "wrap the default of '$name' in a CODE reference (ex: sub { [] } and not [])")
52 if exists $options{default} && ref $options{default};
53 }
5412430µs if( $options{required} and not( defined($options{builder}) || defined($options{init_arg}) || exists $options{default} ) ) {
55 confess("A required attribute must have either 'init_arg', 'builder', or 'default'");
56 }
57
58124642µs1241.97ms $class->_new(\%options);
# spent 1.92ms making 123 calls to Class::MOP::Attribute::_new, avg 16µs/call # spent 46µs making 1 call to Moose::Meta::Attribute::_new
59}
60
61
# spent 1.92ms (1.22+695µs) within Class::MOP::Attribute::_new which was called 123 times, avg 16µs/call: # 123 times (1.22ms+695µs) by Class::MOP::Attribute::new at line 58, avg 16µs/call
sub _new {
6212326µs my $class = shift;
63
6412344µs2695µs return Class::MOP::Class->initialize($class)->new_object(@_)
# spent 688µs making 1 call to Class::MOP::Class::new_object # spent 7µs making 1 call to Class::MOP::Class::initialize
65 if $class ne __PACKAGE__;
66
6712253µs my $options = @_ == 1 ? $_[0] : {@_};
68
691221.24ms bless {
70 'name' => $options->{name},
71 'accessor' => $options->{accessor},
72 'reader' => $options->{reader},
73 'writer' => $options->{writer},
74 'predicate' => $options->{predicate},
75 'clearer' => $options->{clearer},
76 'builder' => $options->{builder},
77 'init_arg' => $options->{init_arg},
78 exists $options->{default}
79 ? ('default' => $options->{default})
80 : (),
81 'initializer' => $options->{initializer},
82 'definition_context' => $options->{definition_context},
83 # keep a weakened link to the
84 # class we are associated with
85 'associated_class' => undef,
86 # and a list of the methods
87 # associated with this attr
88 'associated_methods' => [],
89 # this let's us keep track of
90 # our order inside the associated
91 # class
92 'insertion_order' => undef,
93 }, $class;
94}
95
96# NOTE:
97# this is a primitive (and kludgy) clone operation
98# for now, it will be replaced in the Class::MOP
99# bootstrap with a proper one, however we know
100# that this one will work fine for now.
101sub clone {
102 my $self = shift;
103 my %options = @_;
104 (blessed($self))
105 || confess "Can only clone an instance";
106 return bless { %{$self}, %options } => ref($self);
107}
108
109
# spent 3.91ms (895µs+3.01) within Class::MOP::Attribute::initialize_instance_slot which was called 218 times, avg 18µs/call: # 218 times (895µs+3.01ms) by Class::MOP::Class::_construct_instance at line 525 of Class/MOP/Class.pm, avg 18µs/call
sub initialize_instance_slot {
11021855µs my ($self, $meta_instance, $instance, $params) = @_;
11121890µs my $init_arg = $self->{'init_arg'};
112
113 # try to fetch the init arg from the %params ...
114
115 # if nothing was in the %params, we can use the
116 # attribute's default value (if it has one)
117218648µs1943.01ms if(defined $init_arg and exists $params->{$init_arg}){
# spent 2.74ms making 164 calls to Class::MOP::Attribute::_set_initial_slot_value, avg 17µs/call # spent 273µs making 30 calls to Class::MOP::Mixin::AttributeCore::default, avg 9µs/call
118 $self->_set_initial_slot_value(
119 $meta_instance,
120 $instance,
121 $params->{$init_arg},
122 );
123 }
124 elsif (exists $self->{'default'}) {
125 $self->_set_initial_slot_value(
126 $meta_instance,
127 $instance,
128 $self->default($instance),
129 );
130 }
131 elsif (defined( my $builder = $self->{'builder'})) {
132 if ($builder = $instance->can($builder)) {
133 $self->_set_initial_slot_value(
134 $meta_instance,
135 $instance,
136 $instance->$builder,
137 );
138 }
139 else {
140 confess(ref($instance)." does not support builder method '". $self->{'builder'} ."' for attribute '" . $self->name . "'");
141 }
142 }
143}
144
145
# spent 2.74ms (1.27+1.47) within Class::MOP::Attribute::_set_initial_slot_value which was called 164 times, avg 17µs/call: # 164 times (1.27ms+1.47ms) by Class::MOP::Attribute::initialize_instance_slot at line 117, avg 17µs/call
sub _set_initial_slot_value {
14616453µs my ($self, $meta_instance, $instance, $value) = @_;
147
148164430µs16489µs my $slot_name = $self->name;
# spent 89µs making 164 calls to Class::MOP::Mixin::AttributeCore::name, avg 540ns/call
149
150164581µs3281.38ms return $meta_instance->set_slot_value($instance, $slot_name, $value)
# spent 1.18ms making 164 calls to Class::MOP::Instance::set_slot_value, avg 7µs/call # spent 200µs making 164 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 1µs/call
151 unless $self->has_initializer;
152
153 my $callback = $self->_make_initializer_writer_callback(
154 $meta_instance, $instance, $slot_name
155 );
156
157 my $initializer = $self->initializer;
158
159 # most things will just want to set a value, so make it first arg
160 $instance->$initializer($value, $callback, $self);
161}
162
163sub _make_initializer_writer_callback {
164 my $self = shift;
165 my ($meta_instance, $instance, $slot_name) = @_;
166
167 return sub {
168 $meta_instance->set_slot_value($instance, $slot_name, $_[0]);
169 };
170}
171
172sub get_read_method {
173 my $self = shift;
174 my $reader = $self->reader || $self->accessor;
175 # normal case ...
176 return $reader unless ref $reader;
177 # the HASH ref case
178 my ($name) = %$reader;
179 return $name;
180}
181
182sub get_write_method {
183 my $self = shift;
184 my $writer = $self->writer || $self->accessor;
185 # normal case ...
186 return $writer unless ref $writer;
187 # the HASH ref case
188 my ($name) = %$writer;
189 return $name;
190}
191
192sub get_read_method_ref {
193 my $self = shift;
194 if ((my $reader = $self->get_read_method) && $self->associated_class) {
195 return $self->associated_class->get_method($reader);
196 }
197 else {
198 my $code = sub { $self->get_value(@_) };
199 if (my $class = $self->associated_class) {
200 return $class->method_metaclass->wrap(
201 $code,
202 package_name => $class->name,
203 name => '__ANON__'
204 );
205 }
206 else {
207 return $code;
208 }
209 }
210}
211
212sub get_write_method_ref {
213 my $self = shift;
214 if ((my $writer = $self->get_write_method) && $self->associated_class) {
215 return $self->associated_class->get_method($writer);
216 }
217 else {
218 my $code = sub { $self->set_value(@_) };
219 if (my $class = $self->associated_class) {
220 return $class->method_metaclass->wrap(
221 $code,
222 package_name => $class->name,
223 name => '__ANON__'
224 );
225 }
226 else {
227 return $code;
228 }
229 }
230}
231
232# slots
233
2344191.59ms419215µs
# spent 1.28ms (1.07+215µs) within Class::MOP::Attribute::slots which was called 419 times, avg 3µs/call: # 419 times (1.07ms+215µs) by Class::MOP::Instance::BUILDARGS at line 33 of Class/MOP/Instance.pm, avg 3µs/call
sub slots { (shift)->name }
# spent 215µs making 419 calls to Class::MOP::Mixin::AttributeCore::name, avg 514ns/call
235
236# class association
237
238
# spent 1.22ms (913µs+306µs) within Class::MOP::Attribute::attach_to_class which was called 124 times, avg 10µs/call: # 124 times (913µs+306µs) by Class::MOP::Class::_attach_attribute at line 880 of Class/MOP/Class.pm, avg 10µs/call
sub attach_to_class {
23912421µs my ($self, $class) = @_;
240124647µs248174µs (blessed($class) && $class->isa('Class::MOP::Class'))
# spent 96µs making 124 calls to Scalar::Util::blessed, avg 772ns/call # spent 78µs making 124 calls to UNIVERSAL::isa, avg 632ns/call
241 || confess "You must pass a Class::MOP::Class instance (or a subclass)";
242124639µs124132µs weaken($self->{'associated_class'} = $class);
# spent 132µs making 124 calls to Scalar::Util::weaken, avg 1µs/call
243}
244
245sub detach_from_class {
246 my $self = shift;
247 $self->{'associated_class'} = undef;
248}
249
250# method association
251
252
# spent 645µs within Class::MOP::Attribute::associate_method which was called 248 times, avg 3µs/call: # 191 times (514µs+0s) by Class::MOP::Attribute::_process_accessors at line 402, avg 3µs/call # 57 times (131µs+0s) by Class::MOP::Attribute::_process_accessors at line 380, avg 2µs/call
sub associate_method {
25324879µs my ($self, $method) = @_;
254248790µs push @{$self->{'associated_methods'}} => $method;
255}
256
257## Slot management
258
259sub set_initial_value {
260 my ($self, $instance, $value) = @_;
261 $self->_set_initial_slot_value(
262 Class::MOP::Class->initialize(ref($instance))->get_meta_instance,
263 $instance,
264 $value
265 );
266}
267
268sub set_value { shift->set_raw_value(@_) }
269
270sub set_raw_value {
271 my $self = shift;
272 my ($instance, $value) = @_;
273
274 my $mi = Class::MOP::Class->initialize(ref($instance))->get_meta_instance;
275 return $mi->set_slot_value($instance, $self->name, $value);
276}
277
278
# spent 13.6ms (1.32+12.3) within Class::MOP::Attribute::_inline_set_value which was called 398 times, avg 34µs/call: # 273 times (884µs+8.12ms) by Class::MOP::Class::_inline_init_attr_from_constructor at line 630 of Class/MOP/Class.pm, avg 33µs/call # 96 times (322µs+2.40ms) by Class::MOP::Class::_inline_init_attr_from_default at line 651 of Class/MOP/Class.pm, avg 28µs/call # 22 times (83µs+1.46ms) by Class::MOP::Method::Accessor::try {...} at line 112 of Class/MOP/Method/Accessor.pm, avg 70µs/call # 4 times (19µs+233µs) by Moose::Meta::Attribute::_inline_set_value at line 628 of Moose/Meta/Attribute.pm, avg 63µs/call # 3 times (11µs+63µs) by Class::MOP::Method::Accessor::try {...} at line 179 of Class/MOP/Method/Accessor.pm, avg 25µs/call
sub _inline_set_value {
27939848µs my $self = shift;
2803981.15ms39812.3ms return $self->_inline_instance_set(@_) . ';';
# spent 12.3ms making 398 calls to Class::MOP::Attribute::_inline_instance_set, avg 31µs/call
281}
282
283
# spent 12.3ms (3.79+8.49) within Class::MOP::Attribute::_inline_instance_set which was called 398 times, avg 31µs/call: # 398 times (3.79ms+8.49ms) by Class::MOP::Attribute::_inline_set_value at line 280, avg 31µs/call
sub _inline_instance_set {
28439841µs my $self = shift;
28539887µs my ($instance, $value) = @_;
286
2873981.35ms7965.66ms my $mi = $self->associated_class->get_meta_instance;
# spent 3.87ms making 252 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 15µs/call # spent 1.58ms making 146 calls to Class::MOP::Class::get_meta_instance, avg 11µs/call # spent 211µs making 398 calls to Class::MOP::Attribute::associated_class, avg 531ns/call
2883982.10ms7962.83ms return $mi->inline_set_slot_value($instance, $self->name, $value);
# spent 2.56ms making 398 calls to Class::MOP::Instance::inline_set_slot_value, avg 6µs/call # spent 268µs making 398 calls to Class::MOP::Mixin::AttributeCore::name, avg 673ns/call
289}
290
2911239µs12326µs
# spent 359µs (34+326) within Class::MOP::Attribute::get_value which was called 12 times, avg 30µs/call: # 12 times (34µs+326µs) by Moose::Meta::Mixin::AttributeCore::is_lazy or Moose::Meta::Mixin::AttributeCore::is_required or Moose::Meta::Mixin::AttributeCore::is_weak_ref or Moose::Meta::Mixin::AttributeCore::should_auto_deref or Moose::Meta::Mixin::AttributeCore::should_coerce at line 133 of Class/MOP/Method/Accessor.pm, avg 30µs/call
sub get_value { shift->get_raw_value(@_) }
# spent 326µs making 12 calls to Class::MOP::Attribute::get_raw_value, avg 27µs/call
292
293
# spent 326µs (137+189) within Class::MOP::Attribute::get_raw_value which was called 12 times, avg 27µs/call: # 12 times (137µs+189µs) by Class::MOP::Attribute::get_value at line 291, avg 27µs/call
sub get_raw_value {
294121µs my $self = shift;
295123µs my ($instance) = @_;
296
2971229µs24159µs my $mi = Class::MOP::Class->initialize(ref($instance))->get_meta_instance;
# spent 82µs making 10 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 8µs/call # spent 73µs making 12 calls to Class::MOP::Class::initialize, avg 6µs/call # spent 3µs making 2 calls to Class::MOP::Class::get_meta_instance, avg 2µs/call
2981274µs2430µs return $mi->get_slot_value($instance, $self->name);
# spent 22µs making 12 calls to Class::MOP::Instance::get_slot_value, avg 2µs/call # spent 8µs making 12 calls to Class::MOP::Mixin::AttributeCore::name, avg 708ns/call
299}
300
301
# spent 3.70ms (288µs+3.41) within Class::MOP::Attribute::_inline_get_value which was called 75 times, avg 49µs/call: # 53 times (209µs+3.03ms) by Class::MOP::Method::Accessor::try {...} at line 142 of Class/MOP/Method/Accessor.pm, avg 61µs/call # 22 times (79µs+381µs) by Class::MOP::Method::Accessor::try {...} at line 112 of Class/MOP/Method/Accessor.pm, avg 21µs/call
sub _inline_get_value {
3027515µs my $self = shift;
30375253µs753.41ms return $self->_inline_instance_get(@_) . ';';
# spent 3.41ms making 75 calls to Class::MOP::Attribute::_inline_instance_get, avg 45µs/call
304}
305
306
# spent 3.67ms (801µs+2.87) within Class::MOP::Attribute::_inline_instance_get which was called 78 times, avg 47µs/call: # 75 times (763µs+2.65ms) by Class::MOP::Attribute::_inline_get_value at line 303, avg 45µs/call # 3 times (38µs+219µs) by Moose::Meta::Attribute::_inline_get_value at line 874 of Moose/Meta/Attribute.pm, avg 86µs/call
sub _inline_instance_get {
307789µs my $self = shift;
3087819µs my ($instance) = @_;
309
31078302µs1562.29ms my $mi = $self->associated_class->get_meta_instance;
# spent 2.23ms making 78 calls to Class::MOP::Class::get_meta_instance, avg 29µs/call # spent 54µs making 78 calls to Class::MOP::Attribute::associated_class, avg 690ns/call
31178461µs156578µs return $mi->inline_get_slot_value($instance, $self->name);
# spent 523µs making 78 calls to Class::MOP::Instance::inline_get_slot_value, avg 7µs/call # spent 54µs making 78 calls to Class::MOP::Mixin::AttributeCore::name, avg 695ns/call
312}
313
314
# spent 316µs (135+181) within Class::MOP::Attribute::has_value which was called 12 times, avg 26µs/call: # 12 times (135µs+181µs) by Moose::Meta::Mixin::AttributeCore::has_handles or Moose::Meta::Mixin::AttributeCore::has_trigger or Moose::Meta::Mixin::AttributeCore::has_type_constraint at line 195 of Class/MOP/Method/Accessor.pm, avg 26µs/call
sub has_value {
315122µs my $self = shift;
316123µs my ($instance) = @_;
317
3181229µs24148µs my $mi = Class::MOP::Class->initialize(ref($instance))->get_meta_instance;
# spent 76µs making 9 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 8µs/call # spent 67µs making 12 calls to Class::MOP::Class::initialize, avg 6µs/call # spent 5µs making 3 calls to Class::MOP::Class::get_meta_instance, avg 2µs/call
3191275µs2433µs return $mi->is_slot_initialized($instance, $self->name);
# spent 25µs making 12 calls to Class::MOP::Instance::is_slot_initialized, avg 2µs/call # spent 8µs making 12 calls to Class::MOP::Mixin::AttributeCore::name, avg 708ns/call
320}
321
322
# spent 426µs (71+355) within Class::MOP::Attribute::_inline_has_value which was called 16 times, avg 27µs/call: # 16 times (71µs+355µs) by Class::MOP::Method::Accessor::try {...} at line 204 of Class/MOP/Method/Accessor.pm, avg 27µs/call
sub _inline_has_value {
323165µs my $self = shift;
3241658µs16355µs return $self->_inline_instance_has(@_) . ';';
# spent 355µs making 16 calls to Class::MOP::Attribute::_inline_instance_has, avg 22µs/call
325}
326
327
# spent 355µs (179+176) within Class::MOP::Attribute::_inline_instance_has which was called 16 times, avg 22µs/call: # 16 times (179µs+176µs) by Class::MOP::Attribute::_inline_has_value at line 324, avg 22µs/call
sub _inline_instance_has {
328162µs my $self = shift;
329165µs my ($instance) = @_;
330
3311668µs3238µs my $mi = $self->associated_class->get_meta_instance;
# spent 28µs making 16 calls to Class::MOP::Class::get_meta_instance, avg 2µs/call # spent 11µs making 16 calls to Class::MOP::Attribute::associated_class, avg 675ns/call
33216103µs32137µs return $mi->inline_is_slot_initialized($instance, $self->name);
# spent 126µs making 16 calls to Class::MOP::Instance::inline_is_slot_initialized, avg 8µs/call # spent 11µs making 16 calls to Class::MOP::Mixin::AttributeCore::name, avg 712ns/call
333}
334
335sub clear_value {
336 my $self = shift;
337 my ($instance) = @_;
338
339 my $mi = Class::MOP::Class->initialize(ref($instance))->get_meta_instance;
340 return $mi->deinitialize_slot($instance, $self->name);
341}
342
343sub _inline_clear_value {
344 my $self = shift;
345 return $self->_inline_instance_clear(@_) . ';';
346}
347
348sub _inline_instance_clear {
349 my $self = shift;
350 my ($instance) = @_;
351
352 my $mi = $self->associated_class->get_meta_instance;
353 return $mi->inline_deinitialize_slot($instance, $self->name);
354}
355
356## load em up ...
357
358245515µs
# spent 286µs within Class::MOP::Attribute::accessor_metaclass which was called 245 times, avg 1µs/call: # 188 times (222µs+0s) by Class::MOP::Attribute::try {...} at line 389, avg 1µs/call # 57 times (64µs+0s) by Class::MOP::Attribute::_process_accessors at line 372, avg 1µs/call
sub accessor_metaclass { 'Class::MOP::Method::Accessor' }
359
360
# spent 82.4ms (12.2+70.2) within Class::MOP::Attribute::_process_accessors which was called 248 times, avg 332µs/call: # 150 times (9.26ms+36.9ms) by Class::MOP::Attribute::install_accessors at line 428, avg 308µs/call # 45 times (1.36ms+12.2ms) by Class::MOP::Attribute::install_accessors at line 424, avg 301µs/call # 42 times (1.21ms+7.93ms) by Class::MOP::Attribute::install_accessors at line 436, avg 218µs/call # 8 times (233µs+1.65ms) by Class::MOP::Attribute::install_accessors at line 432, avg 235µs/call # 3 times (106µs+11.6ms) by Moose::Meta::Attribute::_process_accessors at line 1078 of Moose/Meta/Attribute.pm, avg 3.89ms/call
sub _process_accessors {
361248131µs my ($self, $type, $accessor, $generate_as_inline_methods) = @_;
362
3632481.50ms248160µs my $method_ctx = { %{ $self->definition_context || {} } };
# spent 160µs making 248 calls to Class::MOP::Mixin::AttributeCore::definition_context, avg 644ns/call
364
36524869µs if (ref($accessor)) {
3665717µs (ref($accessor) eq 'HASH')
367 || confess "bad accessor/reader/writer/predicate/clearer format, must be a HASH ref";
3685772µs my ($name, $method) = %{$accessor};
369
3705794µs57718µs $method_ctx->{description} = $self->_accessor_description($name, $type);
# spent 718µs making 57 calls to Class::MOP::Attribute::_accessor_description, avg 13µs/call
371
372575.35ms2853.29ms $method = $self->accessor_metaclass->wrap(
# spent 3.14ms making 57 calls to Class::MOP::Method::wrap, avg 55µs/call # spent 64µs making 57 calls to Class::MOP::Attribute::accessor_metaclass, avg 1µs/call # spent 58µs making 114 calls to Class::MOP::Attribute::associated_class, avg 508ns/call # spent 31µs making 57 calls to Class::MOP::Package::name, avg 537ns/call
373 $method,
374 attribute => $self,
375 package_name => $self->associated_class->name,
376 name => $name,
377 associated_metaclass => $self->associated_class,
378 definition_context => $method_ctx,
379 );
3805763µs57131µs $self->associate_method($method);
# spent 131µs making 57 calls to Class::MOP::Attribute::associate_method, avg 2µs/call
38157160µs return ($name, $method);
382 }
383 else {
384191619µs285192µs my $inline_me = ($generate_as_inline_methods && $self->associated_class->instance_metaclass->is_inlinable);
# spent 86µs making 95 calls to Class::MOP::Instance::is_inlinable, avg 907ns/call # spent 57µs making 95 calls to Class::MOP::Attribute::associated_class, avg 599ns/call # spent 48µs making 95 calls to Class::MOP::Class::instance_metaclass, avg 511ns/call
3851917µs my $method;
386 try {
387191343µs1912.42ms $method_ctx->{description} = $self->_accessor_description($accessor, $type);
# spent 2.42ms making 191 calls to Class::MOP::Attribute::_accessor_description, avg 13µs/call
388
3891912.09ms95543.9ms $method = $self->accessor_metaclass->new(
# spent 43.4ms making 188 calls to Class::MOP::Method::Accessor::new, avg 231µs/call # spent 222µs making 188 calls to Class::MOP::Attribute::accessor_metaclass, avg 1µs/call # spent 199µs making 382 calls to Class::MOP::Attribute::associated_class, avg 521ns/call # spent 98µs making 191 calls to Class::MOP::Package::name, avg 513ns/call # spent 11µs making 3 calls to Moose::Meta::Method::Accessor::new, avg 4µs/call # spent 5µs making 3 calls to Moose::Meta::Attribute::accessor_metaclass, avg 2µs/call
390 attribute => $self,
391 is_inline => $inline_me,
392 accessor_type => $type,
393 package_name => $self->associated_class->name,
394 name => $accessor,
395 associated_metaclass => $self->associated_class,
396 definition_context => $method_ctx,
397 );
398 }
399 catch {
400 confess "Could not create the '$type' method for " . $self->name . " because : $_";
4011912.53ms38240.3ms };
# spent 64.6ms making 191 calls to Try::Tiny::try, avg 338µs/call, recursion: max depth 1, sum of overlapping time 24.9ms # spent 620µs making 191 calls to Try::Tiny::catch, avg 3µs/call
402191316µs191514µs $self->associate_method($method);
# spent 514µs making 191 calls to Class::MOP::Attribute::associate_method, avg 3µs/call
403191539µs return ($accessor, $method);
404 }
405}
406
407
# spent 3.13ms (2.62+513µs) within Class::MOP::Attribute::_accessor_description which was called 248 times, avg 13µs/call: # 191 times (2.02ms+397µs) by Class::MOP::Attribute::try {...} at line 387, avg 13µs/call # 57 times (601µs+116µs) by Class::MOP::Attribute::_process_accessors at line 370, avg 13µs/call
sub _accessor_description {
40824857µs my $self = shift;
40924876µs my ($name, $type) = @_;
410
4112481.54ms496323µs my $desc = "$type " . $self->associated_class->name . "::$name";
# spent 162µs making 248 calls to Class::MOP::Attribute::associated_class, avg 652ns/call # spent 161µs making 248 calls to Class::MOP::Package::name, avg 649ns/call
412248913µs354190µs if ( $name ne $self->name ) {
# spent 190µs making 354 calls to Class::MOP::Mixin::AttributeCore::name, avg 538ns/call
413 $desc .= " of attribute " . $self->name;
414 }
415
416248703µs return $desc;
417}
418
419
# spent 125ms (10.3+115) within Class::MOP::Attribute::install_accessors which was called 200 times, avg 625µs/call: # 122 times (8.37ms+41.5ms) by Class::MOP::Class::try {...} at line 891 of Class/MOP/Class.pm, avg 409µs/call # 75 times (1.82ms+56.0ms) by Class::MOP::Class::_inline_accessors at line 1413 of Class/MOP/Class.pm, avg 771µs/call # 3 times (120µs+17.2ms) by Moose::Meta::Attribute::install_accessors at line 1017 of Moose/Meta/Attribute.pm, avg 5.77ms/call
sub install_accessors {
42020045µs my $self = shift;
42120022µs my $inline = shift;
422200601µs200141µs my $class = $self->associated_class;
# spent 141µs making 200 calls to Class::MOP::Attribute::associated_class, avg 705ns/call
423
424200536µs33825.6ms $class->add_method(
# spent 13.6ms making 45 calls to Class::MOP::Attribute::_process_accessors, avg 301µs/call # spent 7.97ms making 1 call to Moose::Meta::Attribute::_process_accessors # spent 3.76ms making 46 calls to Class::MOP::Mixin::HasMethods::add_method, avg 82µs/call # spent 327µs making 200 calls to Class::MOP::Mixin::AttributeCore::has_accessor, avg 2µs/call # spent 30µs making 46 calls to Class::MOP::Mixin::AttributeCore::accessor, avg 650ns/call
425 $self->_process_accessors('accessor' => $self->accessor(), $inline)
426 ) if $self->has_accessor();
427
4282001.06ms65667.9ms $class->add_method(
# spent 46.2ms making 150 calls to Class::MOP::Attribute::_process_accessors, avg 308µs/call # spent 17.3ms making 152 calls to Class::MOP::Mixin::HasMethods::add_method, avg 114µs/call # spent 4.01ms making 2 calls to Moose::Meta::Attribute::_process_accessors, avg 2.01ms/call # spent 277µs making 200 calls to Class::MOP::Mixin::AttributeCore::has_reader, avg 1µs/call # spent 97µs making 152 calls to Class::MOP::Mixin::AttributeCore::reader, avg 636ns/call
429 $self->_process_accessors('reader' => $self->reader(), $inline)
430 ) if $self->has_reader();
431
432200356µs2242.82ms $class->add_method(
# spent 1.88ms making 8 calls to Class::MOP::Attribute::_process_accessors, avg 235µs/call # spent 611µs making 8 calls to Class::MOP::Mixin::HasMethods::add_method, avg 76µs/call # spent 326µs making 200 calls to Class::MOP::Mixin::AttributeCore::has_writer, avg 2µs/call # spent 6µs making 8 calls to Class::MOP::Mixin::AttributeCore::writer, avg 725ns/call
433 $self->_process_accessors('writer' => $self->writer(), $inline)
434 ) if $self->has_writer();
435
436200467µs32618.0ms $class->add_method(
# spent 9.14ms making 42 calls to Class::MOP::Attribute::_process_accessors, avg 218µs/call # spent 8.59ms making 42 calls to Class::MOP::Mixin::HasMethods::add_method, avg 204µs/call # spent 240µs making 200 calls to Class::MOP::Mixin::AttributeCore::has_predicate, avg 1µs/call # spent 26µs making 42 calls to Class::MOP::Mixin::AttributeCore::predicate, avg 614ns/call
437 $self->_process_accessors('predicate' => $self->predicate(), $inline)
438 ) if $self->has_predicate();
439
440200244µs200246µs $class->add_method(
# spent 246µs making 200 calls to Class::MOP::Mixin::AttributeCore::has_clearer, avg 1µs/call
441 $self->_process_accessors('clearer' => $self->clearer(), $inline)
442 ) if $self->has_clearer();
443
444200464µs return;
445}
446
447{
4481200ns my $_remove_accessor = sub {
449 my ($accessor, $class) = @_;
450 if (ref($accessor) && ref($accessor) eq 'HASH') {
451 ($accessor) = keys %{$accessor};
452 }
453 my $method = $class->get_method($accessor);
454 $class->remove_method($accessor)
455 if (ref($method) && $method->isa('Class::MOP::Method::Accessor'));
45614µs };
457
458 sub remove_accessors {
459 my $self = shift;
460 # TODO:
461 # we really need to make sure to remove from the
462 # associates methods here as well. But this is
463 # such a slimly used method, I am not worried
464 # about it right now.
465 $_remove_accessor->($self->accessor(), $self->associated_class()) if $self->has_accessor();
466 $_remove_accessor->($self->reader(), $self->associated_class()) if $self->has_reader();
467 $_remove_accessor->($self->writer(), $self->associated_class()) if $self->has_writer();
468 $_remove_accessor->($self->predicate(), $self->associated_class()) if $self->has_predicate();
469 $_remove_accessor->($self->clearer(), $self->associated_class()) if $self->has_clearer();
470 return;
471 }
472
473}
474
47515µs1;
476
477# ABSTRACT: Attribute Meta Object
478
479__END__