← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:45:08 2010
Reported on Wed Nov 17 22:13:31 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP/Attribute.pm
StatementsExecuted 41202 statements in 570ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
400211188ms309msClass::MOP::Attribute::::_set_initial_slot_valueClass::MOP::Attribute::_set_initial_slot_value
470411145ms573msClass::MOP::Attribute::::initialize_instance_slotClass::MOP::Attribute::initialize_instance_slot
3135242.7ms515msClass::MOP::Attribute::::_process_accessorsClass::MOP::Attribute::_process_accessors
2553241.3ms806msClass::MOP::Attribute::::install_accessorsClass::MOP::Attribute::install_accessors
4634326.7ms95.8msClass::MOP::Attribute::::inline_setClass::MOP::Attribute::inline_set
11023219.2ms24.7msClass::MOP::Attribute::::slotsClass::MOP::Attribute::slots
2561119.2ms422msClass::MOP::Attribute::::__ANON__[:342]Class::MOP::Attribute::__ANON__[:342]
18650416.5ms145msClass::MOP::Attribute::::newClass::MOP::Attribute::new
154329.26ms90.5msClass::MOP::Attribute::::inline_getClass::MOP::Attribute::inline_get
187117.92ms11.3msClass::MOP::Attribute::::attach_to_classClass::MOP::Attribute::attach_to_class
328326.06ms6.06msClass::MOP::Attribute::::associate_methodClass::MOP::Attribute::associate_method
115115.77ms10.1msClass::MOP::Attribute::::_newClass::MOP::Attribute::_new
98115.11ms23.0msClass::MOP::Attribute::::set_initial_valueClass::MOP::Attribute::set_initial_value
72432.93ms4.15msClass::MOP::Attribute::::get_read_methodClass::MOP::Attribute::get_read_method
224211.89ms1.89msClass::MOP::Attribute::::accessor_metaclassClass::MOP::Attribute::accessor_metaclass
31221.88ms4.13msClass::MOP::Attribute::::inline_hasClass::MOP::Attribute::inline_has
811450µs1.23msClass::MOP::Attribute::::get_raw_valueClass::MOP::Attribute::get_raw_value
211177µs452µsClass::MOP::Attribute::::has_valueClass::MOP::Attribute::has_value
811139µs1.37msClass::MOP::Attribute::::get_valueClass::MOP::Attribute::get_value
211122µs337µsClass::MOP::Attribute::::set_raw_valueClass::MOP::Attribute::set_raw_value
11172µs92µsClass::MOP::Attribute::::BEGIN@4Class::MOP::Attribute::BEGIN@4
11167µs480µsClass::MOP::Attribute::::BEGIN@17Class::MOP::Attribute::BEGIN@17
21141µs378µsClass::MOP::Attribute::::set_valueClass::MOP::Attribute::set_value
11140µs218µsClass::MOP::Attribute::::BEGIN@11Class::MOP::Attribute::BEGIN@11
11140µs110µsClass::MOP::Attribute::::BEGIN@5Class::MOP::Attribute::BEGIN@5
11138µs198µsClass::MOP::Attribute::::BEGIN@10Class::MOP::Attribute::BEGIN@10
11136µs194µsClass::MOP::Attribute::::BEGIN@9Class::MOP::Attribute::BEGIN@9
11123µs23µsClass::MOP::Attribute::::BEGIN@7Class::MOP::Attribute::BEGIN@7
0000s0sClass::MOP::Attribute::::__ANON__[:153]Class::MOP::Attribute::__ANON__[:153]
0000s0sClass::MOP::Attribute::::__ANON__[:190]Class::MOP::Attribute::__ANON__[:190]
0000s0sClass::MOP::Attribute::::__ANON__[:210]Class::MOP::Attribute::__ANON__[:210]
0000s0sClass::MOP::Attribute::::__ANON__[:345]Class::MOP::Attribute::__ANON__[:345]
0000s0sClass::MOP::Attribute::::__ANON__[:388]Class::MOP::Attribute::__ANON__[:388]
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_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::::inline_clearClass::MOP::Attribute::inline_clear
0000s0sClass::MOP::Attribute::::remove_accessorsClass::MOP::Attribute::remove_accessors
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
43102µs2111µs
# spent 92µs (72+20) within Class::MOP::Attribute::BEGIN@4 which was called: # once (72µs+20µs) by Class::MOP::BEGIN@20 at line 4
use strict;
# spent 92µs making 1 call to Class::MOP::Attribute::BEGIN@4 # spent 20µs making 1 call to strict::import
53100µs2180µs
# spent 110µs (40+70) within Class::MOP::Attribute::BEGIN@5 which was called: # once (40µs+70µs) by Class::MOP::BEGIN@20 at line 5
use warnings;
# spent 110µs making 1 call to Class::MOP::Attribute::BEGIN@5 # spent 70µs making 1 call to warnings::import
6
7394µs123µs
# spent 23µs within Class::MOP::Attribute::BEGIN@7 which was called: # once (23µs+0s) by Class::MOP::BEGIN@20 at line 7
use Class::MOP::Method::Accessor;
# spent 23µs making 1 call to Class::MOP::Attribute::BEGIN@7
8
93112µs2352µs
# spent 194µs (36+158) within Class::MOP::Attribute::BEGIN@9 which was called: # once (36µs+158µs) by Class::MOP::BEGIN@20 at line 9
use Carp 'confess';
# spent 194µs making 1 call to Class::MOP::Attribute::BEGIN@9 # spent 158µs making 1 call to Exporter::import
103105µs2357µs
# spent 198µs (38+159) within Class::MOP::Attribute::BEGIN@10 which was called: # once (38µs+159µs) by Class::MOP::BEGIN@20 at line 10
use Scalar::Util 'blessed', 'weaken';
# spent 198µs making 1 call to Class::MOP::Attribute::BEGIN@10 # spent 159µs making 1 call to Exporter::import
113248µs2395µs
# spent 218µs (40+177) within Class::MOP::Attribute::BEGIN@11 which was called: # once (40µs+177µs) by Class::MOP::BEGIN@20 at line 11
use Try::Tiny;
# spent 218µs making 1 call to Class::MOP::Attribute::BEGIN@11 # spent 177µs making 1 call to Exporter::import
12
1315µsour $VERSION = '1.11';
14171µs$VERSION = eval $VERSION;
# spent 12µs executing statements in string eval
1514µsour $AUTHORITY = 'cpan:STEVAN';
16
1737.13ms2480µs
# spent 480µs (67+413) within Class::MOP::Attribute::BEGIN@17 which was called: # once (67µs+413µs) by Class::MOP::BEGIN@20 at line 17
use base 'Class::MOP::Object', 'Class::MOP::Mixin::AttributeCore';
# spent 480µs making 1 call to Class::MOP::Attribute::BEGIN@17 # spent 413µs making 1 call to base::import, recursion: max depth 1, sum of overlapping time 413µs
18
19# NOTE: (meta-circularity)
20# This method will be replaced in the
21# boostrap section of Class::MOP, by
22# a new version which uses the
23# &Class::MOP::Class::construct_instance
24# method to build an attribute meta-object
25# which itself is described with attribute
26# meta-objects.
27# - Ain't meta-circularity grand? :)
28
# spent 145ms (16.5+129) within Class::MOP::Attribute::new which was called 186 times, avg 782µs/call: # 72 times (7.21ms+123ms) by Moose::Meta::Attribute::new at line 75 of Moose/Meta/Attribute.pm, avg 1.80ms/call # 66 times (5.57ms+3.77ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 21 of Class/MOP/Mixin/HasAttributes.pm, avg 142µs/call # once (126µs+116µs) by MooseX::Types::Combine::BEGIN@12 at line 193 of Class/MOP.pm # once (177µs+65µs) by MooseX::Types::Combine::BEGIN@12 at line 303 of Class/MOP.pm # once (72µs+108µs) by MooseX::Types::Combine::BEGIN@12 at line 635 of Class/MOP.pm # once (88µs+82µs) by MooseX::Types::Combine::BEGIN@12 at line 235 of Class/MOP.pm # once (90µs+66µs) by MooseX::Types::Combine::BEGIN@12 at line 322 of Class/MOP.pm # once (89µs+64µs) by MooseX::Types::Combine::BEGIN@12 at line 616 of Class/MOP.pm # once (90µs+63µs) by MooseX::Types::Combine::BEGIN@12 at line 511 of Class/MOP.pm # once (87µs+65µs) by MooseX::Types::Combine::BEGIN@12 at line 338 of Class/MOP.pm # once (87µs+62µs) by MooseX::Types::Combine::BEGIN@12 at line 277 of Class/MOP.pm # once (99µs+45µs) by MooseX::Types::Combine::BEGIN@12 at line 400 of Class/MOP.pm # once (72µs+71µs) by MooseX::Types::Combine::BEGIN@12 at line 253 of Class/MOP.pm # once (68µs+66µs) by MooseX::Types::Combine::BEGIN@12 at line 435 of Class/MOP.pm # once (87µs+47µs) by MooseX::Types::Combine::BEGIN@12 at line 341 of Class/MOP.pm # once (68µs+60µs) by MooseX::Types::Combine::BEGIN@12 at line 521 of Class/MOP.pm # once (78µs+47µs) by Moose::BEGIN@19 at line 43 of Moose/Meta/Class.pm # once (69µs+56µs) by MooseX::Types::Combine::BEGIN@12 at line 593 of Class/MOP.pm # once (75µs+46µs) by MooseX::Types::Combine::BEGIN@12 at line 208 of Class/MOP.pm # once (75µs+45µs) by MooseX::Types::Combine::BEGIN@12 at line 196 of Class/MOP.pm # once (70µs+49µs) by MooseX::Types::Combine::BEGIN@12 at line 662 of Class/MOP.pm # once (72µs+45µs) by MooseX::Types::Combine::BEGIN@12 at line 365 of Class/MOP.pm # once (72µs+44µs) by MooseX::Types::Combine::BEGIN@12 at line 567 of Class/MOP.pm # once (71µs+44µs) by MooseX::Types::Combine::BEGIN@12 at line 374 of Class/MOP.pm # once (71µs+43µs) by MooseX::Types::Combine::BEGIN@12 at line 238 of Class/MOP.pm # once (70µs+44µs) by MooseX::Types::Combine::BEGIN@12 at line 356 of Class/MOP.pm # once (71µs+43µs) by MooseX::Types::Combine::BEGIN@12 at line 414 of Class/MOP.pm # once (70µs+44µs) by MooseX::Types::Combine::BEGIN@12 at line 455 of Class/MOP.pm # once (70µs+43µs) by MooseX::Types::Combine::BEGIN@12 at line 448 of Class/MOP.pm # once (70µs+43µs) by MooseX::Types::Combine::BEGIN@12 at line 476 of Class/MOP.pm # once (70µs+43µs) by MooseX::Types::Combine::BEGIN@12 at line 469 of Class/MOP.pm # once (71µs+42µs) by MooseX::Types::Combine::BEGIN@12 at line 421 of Class/MOP.pm # once (71µs+42µs) by MooseX::Types::Combine::BEGIN@12 at line 441 of Class/MOP.pm # once (71µs+42µs) by MooseX::Types::Combine::BEGIN@12 at line 428 of Class/MOP.pm # once (69µs+43µs) by MooseX::Types::Combine::BEGIN@12 at line 574 of Class/MOP.pm # once (70µs+42µs) by MooseX::Types::Combine::BEGIN@12 at line 545 of Class/MOP.pm # once (69µs+43µs) by MooseX::Types::Combine::BEGIN@12 at line 493 of Class/MOP.pm # once (68µs+43µs) by MooseX::Types::Combine::BEGIN@12 at line 527 of Class/MOP.pm # once (68µs+43µs) by MooseX::Types::Combine::BEGIN@12 at line 656 of Class/MOP.pm # once (69µs+42µs) by MooseX::Types::Combine::BEGIN@12 at line 584 of Class/MOP.pm # once (70µs+41µs) by MooseX::Types::Combine::BEGIN@12 at line 462 of Class/MOP.pm # once (68µs+43µs) by MooseX::Types::Combine::BEGIN@12 at line 619 of Class/MOP.pm # once (69µs+41µs) by MooseX::Types::Combine::BEGIN@12 at line 483 of Class/MOP.pm # once (67µs+43µs) by MooseX::Types::Combine::BEGIN@12 at line 533 of Class/MOP.pm # once (69µs+41µs) by MooseX::Types::Combine::BEGIN@12 at line 384 of Class/MOP.pm # once (66µs+43µs) by MooseX::Types::Combine::BEGIN@12 at line 560 of Class/MOP.pm # once (68µs+42µs) by MooseX::Types::Combine::BEGIN@12 at line 601 of Class/MOP.pm # once (67µs+42µs) by MooseX::Types::Combine::BEGIN@12 at line 641 of Class/MOP.pm # once (68µs+41µs) by MooseX::Types::Combine::BEGIN@12 at line 650 of Class/MOP.pm # once (67µs+42µs) by MooseX::Types::Combine::BEGIN@12 at line 539 of Class/MOP.pm
sub new {
291862.25ms my ( $class, @args ) = @_;
30
311861.65ms unshift @args, "name" if @args % 2 == 1;
321861.95ms my %options = @args;
33
34186782µs my $name = $options{name};
35
36186456µs (defined $name)
37 || confess "You must provide a name for the attribute";
38
391861.11ms $options{init_arg} = $name
40 if not exists $options{init_arg};
411861.07ms if(exists $options{builder}){
42933µs confess("builder must be a defined scalar value which is a method name")
43 if ref $options{builder} || !(defined $options{builder});
44922µs confess("Setting both default and builder is not allowed.")
45 if exists $options{default};
46 } else {
471771.16ms33665µs ($class->is_default_a_coderef(\%options))
# spent 665µs making 33 calls to Class::MOP::Mixin::AttributeCore::is_default_a_coderef, avg 20µs/call
48 || confess("References are not allowed as default values, you must ".
49 "wrap the default of '$name' in a CODE reference (ex: sub { [] } and not [])")
50 if exists $options{default} && ref $options{default};
51 }
52186610µs if( $options{required} and not( defined($options{builder}) || defined($options{init_arg}) || exists $options{default} ) ) {
53 confess("A required attribute must have either 'init_arg', 'builder', or 'default'");
54 }
55
561865.00ms186128ms $class->_new(\%options);
# spent 118ms making 70 calls to Moose::Meta::Attribute::_new, avg 1.68ms/call # spent 10.1ms making 115 calls to Class::MOP::Attribute::_new, avg 88µs/call # spent 331µs making 1 call to MooseX::Role::Parameterized::Meta::Parameter::_new
57}
58
59
# spent 10.1ms (5.77+4.31) within Class::MOP::Attribute::_new which was called 115 times, avg 88µs/call: # 115 times (5.77ms+4.31ms) by Class::MOP::Attribute::new at line 56, avg 88µs/call
sub _new {
60115401µs my $class = shift;
61
62115368µs24.31ms return Class::MOP::Class->initialize($class)->new_object(@_)
# spent 4.27ms making 1 call to Class::MOP::Class::new_object # spent 40µs making 1 call to Class::MOP::Class::initialize
63 if $class ne __PACKAGE__;
64
65114402µs my $options = @_ == 1 ? $_[0] : {@_};
66
671145.04ms bless {
68 'name' => $options->{name},
69 'accessor' => $options->{accessor},
70 'reader' => $options->{reader},
71 'writer' => $options->{writer},
72 'predicate' => $options->{predicate},
73 'clearer' => $options->{clearer},
74 'builder' => $options->{builder},
75 'init_arg' => $options->{init_arg},
76 exists $options->{default}
77 ? ('default' => $options->{default})
78 : (),
79 'initializer' => $options->{initializer},
80 'definition_context' => $options->{definition_context},
81 # keep a weakened link to the
82 # class we are associated with
83 'associated_class' => undef,
84 # and a list of the methods
85 # associated with this attr
86 'associated_methods' => [],
87 # this let's us keep track of
88 # our order inside the associated
89 # class
90 'insertion_order' => undef,
91 }, $class;
92}
93
94# NOTE:
95# this is a primative (and kludgy) clone operation
96# for now, it will be replaced in the Class::MOP
97# bootstrap with a proper one, however we know
98# that this one will work fine for now.
99sub clone {
100 my $self = shift;
101 my %options = @_;
102 (blessed($self))
103 || confess "Can only clone an instance";
104 return bless { %{$self}, %options } => ref($self);
105}
106
107
# spent 573ms (145+428) within Class::MOP::Attribute::initialize_instance_slot which was called 4704 times, avg 122µs/call: # 4704 times (145ms+428ms) by Class::MOP::Class::_construct_instance at line 603 of Class/MOP/Class.pm, avg 122µs/call
sub initialize_instance_slot {
108470416.3ms my ($self, $meta_instance, $instance, $params) = @_;
109470417.6ms my $init_arg = $self->{'init_arg'};
110
111 # try to fetch the init arg from the %params ...
112
113 # if nothing was in the %params, we can use the
114 # attribute's default value (if it has one)
1154704105ms6236427ms if(defined $init_arg and exists $params->{$init_arg}){
# spent 309ms making 4002 calls to Class::MOP::Attribute::_set_initial_slot_value, avg 77µs/call # spent 119ms making 2234 calls to Class::MOP::Mixin::AttributeCore::default, avg 53µs/call, recursion: max depth 1, sum of overlapping time 1.55ms
116 $self->_set_initial_slot_value(
117 $meta_instance,
118 $instance,
119 $params->{$init_arg},
120 );
121 }
122 elsif (exists $self->{'default'}) {
123 $self->_set_initial_slot_value(
124 $meta_instance,
125 $instance,
126 $self->default($instance),
127 );
128 }
129 elsif (defined( my $builder = $self->{'builder'})) {
130 if ($builder = $instance->can($builder)) {
131 $self->_set_initial_slot_value(
132 $meta_instance,
133 $instance,
134 $instance->$builder,
135 );
136 }
137 else {
138 confess(ref($instance)." does not support builder method '". $self->{'builder'} ."' for attribute '" . $self->name . "'");
139 }
140 }
141}
142
143
# spent 309ms (188+121) within Class::MOP::Attribute::_set_initial_slot_value which was called 4002 times, avg 77µs/call: # 4002 times (188ms+121ms) by Class::MOP::Attribute::initialize_instance_slot at line 115, avg 77µs/call
sub _set_initial_slot_value {
144400215.3ms my ($self, $meta_instance, $instance, $value) = @_;
145
146400267.3ms400219.4ms my $slot_name = $self->name;
# spent 19.4ms making 4002 calls to Class::MOP::Mixin::AttributeCore::name, avg 5µs/call
147
1484002106ms8004102ms return $meta_instance->set_slot_value($instance, $slot_name, $value)
# spent 63.0ms making 4002 calls to Class::MOP::Instance::set_slot_value, avg 16µs/call # spent 39.0ms making 4002 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 10µs/call
149 unless $self->has_initializer;
150
151 my $callback = sub {
152 $meta_instance->set_slot_value($instance, $slot_name, $_[0]);
153 };
154
155 my $initializer = $self->initializer;
156
157 # most things will just want to set a value, so make it first arg
158 $instance->$initializer($value, $callback, $self);
159}
160
161183324.3mssub associated_class { $_[0]->{'associated_class'} }
162711.03mssub associated_methods { $_[0]->{'associated_methods'} }
163
164
# spent 4.15ms (2.93+1.22) within Class::MOP::Attribute::get_read_method which was called 72 times, avg 58µs/call: # 42 times (1.99ms+868µs) by Moose::Util::MetaRole::_make_new_metaclass at line 122 of Moose/Util/MetaRole.pm, avg 68µs/call # 21 times (680µs+233µs) by Markdent::Role::Event::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Markdent/Role/Event.pm:88] at line 48 of Markdent/Role/Event.pm, avg 43µs/call # 8 times (214µs+71µs) by Markdent::Role::Event::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Markdent/Role/Event.pm:88] at line 58 of Markdent/Role/Event.pm, avg 36µs/call # once (46µs+46µs) by Moose::Meta::Method::Delegation::_get_delegate_accessor at line 125 of Moose/Meta/Method/Delegation.pm
sub get_read_method {
16572248µs my $self = shift;
166721.37ms1111.22ms my $reader = $self->reader || $self->accessor;
# spent 775µs making 72 calls to Class::MOP::Mixin::AttributeCore::reader, avg 11µs/call # spent 442µs making 39 calls to Class::MOP::Mixin::AttributeCore::accessor, avg 11µs/call
167 # normal case ...
168721.01ms return $reader unless ref $reader;
169 # the HASH ref case
170425µs my ($name) = %$reader;
171461µs return $name;
172}
173
174sub get_write_method {
175 my $self = shift;
176 my $writer = $self->writer || $self->accessor;
177 # normal case ...
178 return $writer unless ref $writer;
179 # the HASH ref case
180 my ($name) = %$writer;
181 return $name;
182}
183
184sub get_read_method_ref {
185 my $self = shift;
186 if ((my $reader = $self->get_read_method) && $self->associated_class) {
187 return $self->associated_class->get_method($reader);
188 }
189 else {
190 my $code = sub { $self->get_value(@_) };
191 if (my $class = $self->associated_class) {
192 return $class->method_metaclass->wrap(
193 $code,
194 package_name => $class->name,
195 name => '__ANON__'
196 );
197 }
198 else {
199 return $code;
200 }
201 }
202}
203
204sub get_write_method_ref {
205 my $self = shift;
206 if ((my $writer = $self->get_write_method) && $self->associated_class) {
207 return $self->associated_class->get_method($writer);
208 }
209 else {
210 my $code = sub { $self->set_value(@_) };
211 if (my $class = $self->associated_class) {
212 return $class->method_metaclass->wrap(
213 $code,
214 package_name => $class->name,
215 name => '__ANON__'
216 );
217 }
218 else {
219 return $code;
220 }
221 }
222}
223
224# slots
225
226110226.7ms11025.50ms
# spent 24.7ms (19.2+5.50) within Class::MOP::Attribute::slots which was called 1102 times, avg 22µs/call: # 1006 times (17.4ms+4.97ms) by Class::MOP::Instance::BUILDARGS at line 31 of Class/MOP/Instance.pm, avg 22µs/call # 94 times (1.77ms+522µs) by Moose::Meta::Attribute::inline_set at line 699 of Moose/Meta/Attribute.pm, avg 24µs/call # 2 times (34µs+9µs) by Moose::Meta::Attribute::inline_set at line 701 of Moose/Meta/Attribute.pm, avg 21µs/call
sub slots { (shift)->name }
# spent 5.50ms making 1102 calls to Class::MOP::Mixin::AttributeCore::name, avg 5µs/call
227
228# class association
229
230
# spent 11.3ms (7.92+3.37) within Class::MOP::Attribute::attach_to_class which was called 187 times, avg 60µs/call: # 187 times (7.92ms+3.37ms) by Class::MOP::Class::_attach_attribute at line 778 of Class/MOP/Class.pm, avg 60µs/call
sub attach_to_class {
231187571µs my ($self, $class) = @_;
2321875.76ms3741.99ms (blessed($class) && $class->isa('Class::MOP::Class'))
# spent 1.02ms making 187 calls to Scalar::Util::blessed, avg 5µs/call # spent 972µs making 187 calls to UNIVERSAL::isa, avg 5µs/call
233 || confess "You must pass a Class::MOP::Class instance (or a subclass)";
2341875.23ms1871.37ms weaken($self->{'associated_class'} = $class);
# spent 1.37ms making 187 calls to Scalar::Util::weaken, avg 7µs/call
235}
236
237sub detach_from_class {
238 my $self = shift;
239 $self->{'associated_class'} = undef;
240}
241
242# method association
243
244
# spent 6.06ms within Class::MOP::Attribute::associate_method which was called 328 times, avg 18µs/call: # 256 times (4.94ms+0s) by Class::MOP::Attribute::_process_accessors at line 346, avg 19µs/call # 57 times (854µs+0s) by Class::MOP::Attribute::_process_accessors at line 318, avg 15µs/call # 15 times (265µs+0s) by Moose::Meta::Attribute::install_delegation at line 743 of Moose/Meta/Attribute.pm, avg 18µs/call
sub associate_method {
2453281.22ms my ($self, $method) = @_;
2463285.46ms push @{$self->{'associated_methods'}} => $method;
247}
248
249## Slot management
250
251
# spent 23.0ms (5.11+17.9) within Class::MOP::Attribute::set_initial_value which was called 98 times, avg 234µs/call: # 98 times (5.11ms+17.9ms) by Moose::Meta::Attribute::initialize_instance_slot at line 485 of Moose/Meta/Attribute.pm, avg 234µs/call
sub set_initial_value {
25298389µs my ($self, $instance, $value) = @_;
253984.25ms29417.9ms $self->_set_initial_slot_value(
# spent 8.30ms making 98 calls to Moose::Meta::Attribute::_set_initial_slot_value, avg 85µs/call # spent 4.96ms making 86 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::get_meta_instance, avg 58µs/call # spent 4.44ms making 98 calls to Class::MOP::Class::initialize, avg 45µs/call # spent 156µs making 12 calls to Class::MOP::Class::get_meta_instance, avg 13µs/call
254 Class::MOP::Class->initialize(ref($instance))->get_meta_instance,
255 $instance,
256 $value
257 );
258}
259
260237µs2337µs
# spent 378µs (41+337) within Class::MOP::Attribute::set_value which was called 2 times, avg 189µs/call: # 2 times (41µs+337µs) by Class::MOP::Class::_clone_instance at line 682 of Class/MOP/Class.pm, avg 189µs/call
sub set_value { shift->set_raw_value(@_) }
# spent 337µs making 2 calls to Class::MOP::Attribute::set_raw_value, avg 169µs/call
2618148µs81.23ms
# spent 1.37ms (139µs+1.23) within Class::MOP::Attribute::get_value which was called 8 times, avg 171µs/call: # 8 times (139µs+1.23ms) by Moose::Meta::Mixin::AttributeCore::is_lazy or Moose::Meta::Mixin::AttributeCore::is_weak_ref or Moose::Meta::Mixin::AttributeCore::should_auto_deref or Moose::Meta::Mixin::AttributeCore::type_constraint at line 104 of Class/MOP/Method/Accessor.pm, avg 171µs/call
sub get_value { shift->get_raw_value(@_) }
# spent 1.23ms making 8 calls to Class::MOP::Attribute::get_raw_value, avg 154µs/call
262
263
# spent 337µs (122+215) within Class::MOP::Attribute::set_raw_value which was called 2 times, avg 169µs/call: # 2 times (122µs+215µs) by Class::MOP::Attribute::set_value at line 260, avg 169µs/call
sub set_raw_value {
26428µs my ($self, $instance, $value) = @_;
265
2662109µs8215µs Class::MOP::Class->initialize(ref($instance))
# spent 98µs making 2 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 49µs/call # spent 76µs making 2 calls to Class::MOP::Class::initialize, avg 38µs/call # spent 29µs making 2 calls to Class::MOP::Instance::set_slot_value, avg 14µs/call # spent 11µs making 2 calls to Class::MOP::Mixin::AttributeCore::name, avg 6µs/call
267 ->get_meta_instance
268 ->set_slot_value($instance, $self->name, $value);
269}
270
271
# spent 1.23ms (450µs+782µs) within Class::MOP::Attribute::get_raw_value which was called 8 times, avg 154µs/call: # 8 times (450µs+782µs) by Class::MOP::Attribute::get_value at line 261, avg 154µs/call
sub get_raw_value {
272825µs my ($self, $instance) = @_;
273
2748403µs32782µs Class::MOP::Class->initialize(ref($instance))
# spent 306µs making 8 calls to Class::MOP::Class::initialize, avg 38µs/call # spent 284µs making 5 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 57µs/call # spent 112µs making 8 calls to Class::MOP::Instance::get_slot_value, avg 14µs/call # spent 43µs making 8 calls to Class::MOP::Mixin::AttributeCore::name, avg 5µs/call # spent 36µs making 3 calls to Class::MOP::Class::get_meta_instance, avg 12µs/call
275 ->get_meta_instance
276 ->get_slot_value($instance, $self->name);
277}
278
279
# spent 452µs (177+275) within Class::MOP::Attribute::has_value which was called 2 times, avg 226µs/call: # 2 times (177µs+275µs) by Moose::Meta::Mixin::AttributeCore::has_handles at line 119 of Class/MOP/Method/Accessor.pm, avg 226µs/call
sub has_value {
28029µs my ($self, $instance) = @_;
281
2822162µs8275µs Class::MOP::Class->initialize(ref($instance))
# spent 116µs making 2 calls to Class::MOP::Class::initialize, avg 58µs/call # spent 87µs making 1 call to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance # spent 40µs making 2 calls to Class::MOP::Instance::is_slot_initialized, avg 20µs/call # spent 18µs making 2 calls to Class::MOP::Mixin::AttributeCore::name, avg 9µs/call # spent 14µs making 1 call to Class::MOP::Class::get_meta_instance
283 ->get_meta_instance
284 ->is_slot_initialized($instance, $self->name);
285}
286
287sub clear_value {
288 my ($self, $instance) = @_;
289
290 Class::MOP::Class->initialize(ref($instance))
291 ->get_meta_instance
292 ->deinitialize_slot($instance, $self->name);
293}
294
295## load em up ...
296
2972242.94ms
# spent 1.89ms within Class::MOP::Attribute::accessor_metaclass which was called 224 times, avg 8µs/call: # 167 times (1.35ms+0s) by Class::MOP::Attribute::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP/Attribute.pm:342] at line 334, avg 8µs/call # 57 times (536µs+0s) by Class::MOP::Attribute::_process_accessors at line 312, avg 9µs/call
sub accessor_metaclass { 'Class::MOP::Method::Accessor' }
298
299
# spent 515ms (42.7+472) within Class::MOP::Attribute::_process_accessors which was called 313 times, avg 1.65ms/call: # 149 times (18.9ms+102ms) by Class::MOP::Attribute::install_accessors at line 360, avg 812µs/call # 89 times (13.6ms+311ms) by Moose::Meta::Attribute::_process_accessors at line 683 of Moose/Meta/Attribute.pm, avg 3.65ms/call # 36 times (4.70ms+21.9ms) by Class::MOP::Attribute::install_accessors at line 368, avg 739µs/call # 31 times (4.50ms+32.3ms) by Class::MOP::Attribute::install_accessors at line 356, avg 1.19ms/call # 8 times (1.00ms+4.76ms) by Class::MOP::Attribute::install_accessors at line 364, avg 720µs/call
sub _process_accessors {
3003131.59ms my ($self, $type, $accessor, $generate_as_inline_methods) = @_;
301
302313539µs my $method_ctx;
303
3043135.10ms3133.38ms if ( my $ctx = $self->definition_context ) {
# spent 3.38ms making 313 calls to Class::MOP::Mixin::AttributeCore::definition_context, avg 11µs/call
305 $method_ctx = { %$ctx };
306 }
307
308313782µs if (ref($accessor)) {
30957151µs (ref($accessor) eq 'HASH')
310 || confess "bad accessor/reader/writer/predicate/clearer format, must be a HASH ref";
31157476µs my ($name, $method) = %{$accessor};
312572.56ms2289.73ms $method = $self->accessor_metaclass->wrap(
# spent 8.38ms making 57 calls to Class::MOP::Method::wrap, avg 147µs/call # spent 536µs making 57 calls to Class::MOP::Attribute::accessor_metaclass, avg 9µs/call # spent 465µs making 57 calls to Class::MOP::Attribute::associated_class, avg 8µs/call # spent 344µs making 57 calls to Class::MOP::Package::name, avg 6µs/call
313 $method,
314 package_name => $self->associated_class->name,
315 name => $name,
316 definition_context => $method_ctx,
317 );
31857637µs57854µs $self->associate_method($method);
# spent 854µs making 57 calls to Class::MOP::Attribute::associate_method, avg 15µs/call
31957800µs return ($name, $method);
320 }
321 else {
3222563.09ms2522.31ms my $inline_me = ($generate_as_inline_methods && $self->associated_class->instance_metaclass->is_inlinable);
# spent 926µs making 84 calls to Class::MOP::Class::instance_metaclass, avg 11µs/call # spent 705µs making 84 calls to Class::MOP::Attribute::associated_class, avg 8µs/call # spent 684µs making 84 calls to Class::MOP::Instance::is_inlinable, avg 8µs/call
323256454µs my $method;
324
# spent 422ms (19.2+403) within Class::MOP::Attribute::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP/Attribute.pm:342] which was called 256 times, avg 1.65ms/call: # 256 times (19.2ms+403ms) by Try::Tiny::try at line 76 of Try/Tiny.pm, avg 1.65ms/call
try {
325256723µs if ( $method_ctx ) {
32687475µs my $desc = "accessor $accessor";
327872.27ms104656µs if ( $accessor ne $self->name ) {
# spent 656µs making 104 calls to Class::MOP::Mixin::AttributeCore::name, avg 6µs/call
328 $desc .= " of attribute " . $self->name;
329 }
330
33187566µs $method_ctx->{description} = $desc;
332 }
333
33425615.0ms1024402ms $method = $self->accessor_metaclass->new(
# spent 396ms making 256 calls to Class::MOP::Method::Accessor::new, avg 1.55ms/call # spent 2.30ms making 256 calls to Class::MOP::Attribute::associated_class, avg 9µs/call # spent 1.66ms making 256 calls to Class::MOP::Package::name, avg 6µs/call # spent 1.35ms making 167 calls to Class::MOP::Attribute::accessor_metaclass, avg 8µs/call # spent 951µs making 89 calls to Moose::Meta::Attribute::accessor_metaclass, avg 11µs/call
335 attribute => $self,
336 is_inline => $inline_me,
337 accessor_type => $type,
338 package_name => $self->associated_class->name,
339 name => $accessor,
340 definition_context => $method_ctx,
341 );
342 }
343 catch {
344 confess "Could not create the '$type' method for " . $self->name . " because : $_";
34525614.6ms5125.09ms };
# spent 5.09ms making 256 calls to Try::Tiny::catch, avg 20µs/call # spent 446ms making 256 calls to Try::Tiny::try, avg 1.74ms/call, recursion: max depth 2, sum of overlapping time 446ms
3462564.43ms2564.94ms $self->associate_method($method);
# spent 4.94ms making 256 calls to Class::MOP::Attribute::associate_method, avg 19µs/call
3472564.23ms return ($accessor, $method);
348 }
349}
350
351
# spent 806ms (41.3+765) within Class::MOP::Attribute::install_accessors which was called 255 times, avg 3.16ms/call: # 115 times (17.6ms+150ms) by Class::MOP::Class::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP/Class.pm:790] at line 789 of Class/MOP/Class.pm, avg 1.45ms/call # 73 times (13.4ms+452ms) by Moose::Meta::Attribute::install_accessors at line 623 of Moose/Meta/Attribute.pm, avg 6.37ms/call # 67 times (10.4ms+163ms) by Class::MOP::Class::_inline_accessors at line 1305 of Class/MOP/Class.pm, avg 2.59ms/call
sub install_accessors {
352255768µs my $self = shift;
353255553µs my $inline = shift;
3542552.95ms2552.36ms my $class = $self->associated_class;
# spent 2.36ms making 255 calls to Class::MOP::Attribute::associated_class, avg 9µs/call
355
3562554.60ms372118ms $class->add_method(
# spent 53.0ms making 8 calls to Moose::Meta::Attribute::_process_accessors, avg 6.62ms/call # spent 36.8ms making 31 calls to Class::MOP::Attribute::_process_accessors, avg 1.19ms/call # spent 24.8ms making 39 calls to Class::MOP::Mixin::HasMethods::add_method, avg 636µs/call # spent 2.96ms making 255 calls to Class::MOP::Mixin::AttributeCore::has_accessor, avg 12µs/call # spent 414µs making 39 calls to Class::MOP::Mixin::AttributeCore::accessor, avg 11µs/call
357 $self->_process_accessors('accessor' => $self->accessor(), $inline)
358 ) if $self->has_accessor();
359
36025510.8ms897524ms $class->add_method(
# spent 296ms making 65 calls to Moose::Meta::Attribute::_process_accessors, avg 4.56ms/call # spent 121ms making 149 calls to Class::MOP::Attribute::_process_accessors, avg 812µs/call # spent 102ms making 214 calls to Class::MOP::Mixin::HasMethods::add_method, avg 474µs/call # spent 2.78ms making 255 calls to Class::MOP::Mixin::AttributeCore::has_reader, avg 11µs/call # spent 2.25ms making 214 calls to Class::MOP::Mixin::AttributeCore::reader, avg 11µs/call
361 $self->_process_accessors('reader' => $self->reader(), $inline)
362 ) if $self->has_reader();
363
3642554.42ms30653.0ms $class->add_method(
# spent 35.9ms making 9 calls to Moose::Meta::Attribute::_process_accessors, avg 3.99ms/call # spent 8.10ms making 17 calls to Class::MOP::Mixin::HasMethods::add_method, avg 476µs/call # spent 5.76ms making 8 calls to Class::MOP::Attribute::_process_accessors, avg 720µs/call # spent 3.12ms making 255 calls to Class::MOP::Mixin::AttributeCore::has_writer, avg 12µs/call # spent 183µs making 17 calls to Class::MOP::Mixin::AttributeCore::writer, avg 11µs/call
365 $self->_process_accessors('writer' => $self->writer(), $inline)
366 ) if $self->has_writer();
367
3682554.60ms38465.0ms $class->add_method(
# spent 26.6ms making 36 calls to Class::MOP::Attribute::_process_accessors, avg 739µs/call # spent 20.0ms making 43 calls to Class::MOP::Mixin::HasMethods::add_method, avg 466µs/call # spent 15.2ms making 7 calls to Moose::Meta::Attribute::_process_accessors, avg 2.17ms/call # spent 2.70ms making 255 calls to Class::MOP::Mixin::AttributeCore::has_predicate, avg 11µs/call # spent 449µs making 43 calls to Class::MOP::Mixin::AttributeCore::predicate, avg 10µs/call
369 $self->_process_accessors('predicate' => $self->predicate(), $inline)
370 ) if $self->has_predicate();
371
3722553.05ms2552.63ms $class->add_method(
# spent 2.63ms making 255 calls to Class::MOP::Mixin::AttributeCore::has_clearer, avg 10µs/call
373 $self->_process_accessors('clearer' => $self->clearer(), $inline)
374 ) if $self->has_clearer();
375
3762553.42ms return;
377}
378
379{
38014µs my $_remove_accessor = sub {
381 my ($accessor, $class) = @_;
382 if (ref($accessor) && ref($accessor) eq 'HASH') {
383 ($accessor) = keys %{$accessor};
384 }
385 my $method = $class->get_method($accessor);
386 $class->remove_method($accessor)
387 if (ref($method) && $method->isa('Class::MOP::Method::Accessor'));
388112µs };
389
390 sub remove_accessors {
391 my $self = shift;
392 # TODO:
393 # we really need to make sure to remove from the
394 # associates methods here as well. But this is
395 # such a slimly used method, I am not worried
396 # about it right now.
397 $_remove_accessor->($self->accessor(), $self->associated_class()) if $self->has_accessor();
398 $_remove_accessor->($self->reader(), $self->associated_class()) if $self->has_reader();
399 $_remove_accessor->($self->writer(), $self->associated_class()) if $self->has_writer();
400 $_remove_accessor->($self->predicate(), $self->associated_class()) if $self->has_predicate();
401 $_remove_accessor->($self->clearer(), $self->associated_class()) if $self->has_clearer();
402 return;
403 }
404
405}
406
407
# spent 90.5ms (9.26+81.2) within Class::MOP::Attribute::inline_get which was called 154 times, avg 587µs/call: # 87 times (5.39ms+65.3ms) by Moose::Meta::Method::Accessor::_inline_get at line 273 of Moose/Meta/Method/Accessor.pm, avg 813µs/call # 52 times (3.01ms+15.0ms) by Class::MOP::Method::Accessor::_generate_reader_method_inline at line 152 of Class/MOP/Method/Accessor.pm, avg 346µs/call # 15 times (860µs+917µs) by Class::MOP::Method::Accessor::_generate_accessor_method_inline at line 136 of Class/MOP/Method/Accessor.pm, avg 118µs/call
sub inline_get {
408154554µs my $self = shift;
409154536µs my ($instance) = @_;
410
4111548.31ms61681.2ms return $self->associated_class->get_meta_instance->inline_get_slot_value(
# spent 71.9ms making 154 calls to Class::MOP::Class::get_meta_instance, avg 467µs/call # spent 7.07ms making 154 calls to Class::MOP::Instance::inline_get_slot_value, avg 46µs/call # spent 1.27ms making 154 calls to Class::MOP::Attribute::associated_class, avg 8µs/call # spent 934µs making 154 calls to Class::MOP::Mixin::AttributeCore::name, avg 6µs/call
412 $instance, $self->name );
413}
414
415
# spent 95.8ms (26.7+69.1) within Class::MOP::Attribute::inline_set which was called 463 times, avg 207µs/call: # 339 times (19.8ms+50.1ms) by Class::MOP::Method::Constructor::_generate_slot_initializer at line 145 of Class/MOP/Method/Constructor.pm, avg 206µs/call # 106 times (5.91ms+11.5ms) by Moose::Meta::Method::Constructor::_generate_slot_assignment at line 302 of Moose/Meta/Method/Constructor.pm, avg 164µs/call # 15 times (873µs+7.35ms) by Class::MOP::Method::Accessor::_generate_accessor_method_inline at line 136 of Class/MOP/Method/Accessor.pm, avg 548µs/call # 3 times (176µs+219µs) by Class::MOP::Method::Accessor::_generate_writer_method_inline at line 167 of Class/MOP/Method/Accessor.pm, avg 132µs/call
sub inline_set {
4164631.29ms my $self = shift;
4174631.60ms my ( $instance, $value ) = @_;
418
41946323.5ms185269.1ms return $self->associated_class->get_meta_instance->inline_set_slot_value(
# spent 32.9ms making 335 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 98µs/call # spent 20.2ms making 463 calls to Class::MOP::Instance::inline_set_slot_value, avg 44µs/call # spent 9.34ms making 128 calls to Class::MOP::Class::get_meta_instance, avg 73µs/call # spent 3.98ms making 463 calls to Class::MOP::Attribute::associated_class, avg 9µs/call # spent 2.66ms making 463 calls to Class::MOP::Mixin::AttributeCore::name, avg 6µs/call
420 $instance, $self->name, $value );
421}
422
423
# spent 4.13ms (1.88+2.25) within Class::MOP::Attribute::inline_has which was called 31 times, avg 133µs/call: # 20 times (1.21ms+1.48ms) by Class::MOP::Method::Accessor::_generate_predicate_method_inline at line 180 of Class/MOP/Method/Accessor.pm, avg 135µs/call # 11 times (665µs+764µs) by Moose::Meta::Method::Accessor::_inline_has at line 279 of Moose/Meta/Method/Accessor.pm, avg 130µs/call
sub inline_has {
4243189µs my $self = shift;
42531116µs my ($instance) = @_;
426
427 return
428311.62ms1242.25ms $self->associated_class->get_meta_instance
# spent 1.42ms making 31 calls to Class::MOP::Instance::inline_is_slot_initialized, avg 46µs/call # spent 399µs making 31 calls to Class::MOP::Class::get_meta_instance, avg 13µs/call # spent 257µs making 31 calls to Class::MOP::Attribute::associated_class, avg 8µs/call # spent 172µs making 31 calls to Class::MOP::Mixin::AttributeCore::name, avg 6µs/call
429 ->inline_is_slot_initialized( $instance, $self->name );
430}
431
432sub inline_clear {
433 my $self = shift;
434 my ($instance) = @_;
435
436 return
437 $self->associated_class->get_meta_instance
438 ->inline_deinitialize_slot( $instance, $self->name );
439}
440
441115µs1;
442
443__END__