| Filename | /home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Attribute.pm |
| Statements | Executed 25980 statements in 398ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 418 | 5 | 2 | 56.5ms | 1.00s | Class::MOP::Attribute::_process_accessors |
| 308 | 3 | 2 | 50.6ms | 1.36s | Class::MOP::Attribute::install_accessors |
| 1069 | 2 | 1 | 50.4ms | 83.3ms | Class::MOP::Attribute::_set_initial_slot_value |
| 1264 | 1 | 1 | 37.1ms | 144ms | Class::MOP::Attribute::initialize_instance_slot |
| 575 | 2 | 2 | 32.8ms | 123ms | Class::MOP::Attribute::_inline_instance_set |
| 361 | 1 | 1 | 29.0ms | 883ms | Class::MOP::Attribute::__ANON__[:401] |
| 239 | 50 | 4 | 22.5ms | 80.7ms | Class::MOP::Attribute::new |
| 1058 | 1 | 1 | 18.4ms | 23.7ms | Class::MOP::Attribute::slots |
| 556 | 5 | 3 | 12.8ms | 133ms | Class::MOP::Attribute::_inline_set_value |
| 196 | 3 | 3 | 12.2ms | 114ms | Class::MOP::Attribute::_inline_instance_get |
| 239 | 1 | 1 | 10.7ms | 15.2ms | Class::MOP::Attribute::attach_to_class |
| 446 | 3 | 2 | 7.72ms | 7.72ms | Class::MOP::Attribute::associate_method |
| 116 | 1 | 1 | 6.52ms | 10.7ms | Class::MOP::Attribute::_new |
| 62 | 2 | 2 | 3.96ms | 8.52ms | Class::MOP::Attribute::_inline_instance_has |
| 64 | 2 | 2 | 3.67ms | 10.2ms | Class::MOP::Attribute::has_value |
| 35 | 1 | 1 | 2.02ms | 5.57ms | Class::MOP::Attribute::get_raw_value |
| 225 | 2 | 1 | 2.01ms | 2.01ms | Class::MOP::Attribute::accessor_metaclass |
| 29 | 1 | 1 | 1.83ms | 4.62ms | Class::MOP::Attribute::_inline_instance_clear |
| 68 | 2 | 1 | 1.83ms | 21.7ms | Class::MOP::Attribute::_inline_get_value |
| 43 | 1 | 1 | 1.12ms | 7.10ms | Class::MOP::Attribute::_inline_has_value |
| 29 | 1 | 1 | 768µs | 5.39ms | Class::MOP::Attribute::_inline_clear_value |
| 35 | 2 | 2 | 613µs | 6.18ms | Class::MOP::Attribute::get_value |
| 23 | 1 | 1 | 604µs | 728µs | Class::MOP::Attribute::get_read_method |
| 11 | 1 | 1 | 565µs | 2.16ms | Class::MOP::Attribute::set_initial_value |
| 1 | 1 | 1 | 74µs | 93µs | Class::MOP::Attribute::BEGIN@4 |
| 1 | 1 | 1 | 40µs | 109µs | Class::MOP::Attribute::BEGIN@5 |
| 1 | 1 | 1 | 39µs | 213µs | Class::MOP::Attribute::BEGIN@11 |
| 1 | 1 | 1 | 39µs | 194µs | Class::MOP::Attribute::BEGIN@10 |
| 1 | 1 | 1 | 38µs | 464µs | Class::MOP::Attribute::BEGIN@17 |
| 1 | 1 | 1 | 38µs | 217µs | Class::MOP::Attribute::BEGIN@9 |
| 1 | 1 | 1 | 24µs | 24µs | Class::MOP::Attribute::BEGIN@7 |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Attribute::__ANON__[:167] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Attribute::__ANON__[:196] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Attribute::__ANON__[:216] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Attribute::__ANON__[:404] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Attribute::__ANON__[:447] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Attribute::_make_initializer_writer_callback |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Attribute::clear_value |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Attribute::detach_from_class |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Attribute::get_read_method_ref |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Attribute::get_write_method |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Attribute::get_write_method_ref |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Attribute::remove_accessors |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Attribute::set_raw_value |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Attribute::set_value |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | package Class::MOP::Attribute; | ||||
| 3 | |||||
| 4 | 3 | 102µs | 2 | 112µs | # spent 93µs (74+19) within Class::MOP::Attribute::BEGIN@4 which was called:
# once (74µs+19µs) by Class::MOP::BEGIN@20 at line 4 # spent 93µs making 1 call to Class::MOP::Attribute::BEGIN@4
# spent 19µs making 1 call to strict::import |
| 5 | 3 | 100µs | 2 | 179µs | # spent 109µ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 # spent 109µs making 1 call to Class::MOP::Attribute::BEGIN@5
# spent 70µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 3 | 94µs | 1 | 24µs | # spent 24µs within Class::MOP::Attribute::BEGIN@7 which was called:
# once (24µs+0s) by Class::MOP::BEGIN@20 at line 7 # spent 24µs making 1 call to Class::MOP::Attribute::BEGIN@7 |
| 8 | |||||
| 9 | 3 | 116µs | 2 | 396µs | # spent 217µs (38+179) within Class::MOP::Attribute::BEGIN@9 which was called:
# once (38µs+179µs) by Class::MOP::BEGIN@20 at line 9 # spent 217µs making 1 call to Class::MOP::Attribute::BEGIN@9
# spent 179µs making 1 call to Exporter::import |
| 10 | 3 | 95µs | 2 | 348µs | # spent 194µs (39+155) within Class::MOP::Attribute::BEGIN@10 which was called:
# once (39µs+155µs) by Class::MOP::BEGIN@20 at line 10 # spent 194µs making 1 call to Class::MOP::Attribute::BEGIN@10
# spent 155µs making 1 call to Exporter::import |
| 11 | 3 | 205µs | 2 | 386µs | # spent 213µs (39+173) within Class::MOP::Attribute::BEGIN@11 which was called:
# once (39µs+173µs) by Class::MOP::BEGIN@20 at line 11 # spent 213µs making 1 call to Class::MOP::Attribute::BEGIN@11
# spent 173µs making 1 call to Exporter::import |
| 12 | |||||
| 13 | 1 | 6µs | our $VERSION = '1.11'; | ||
| 14 | 1 | 74µs | $VERSION = eval $VERSION; # spent 12µs executing statements in string eval | ||
| 15 | 1 | 4µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 16 | |||||
| 17 | 3 | 7.52ms | 2 | 890µs | # spent 464µs (38+426) within Class::MOP::Attribute::BEGIN@17 which was called:
# once (38µs+426µs) by Class::MOP::BEGIN@20 at line 17 # spent 464µs making 1 call to Class::MOP::Attribute::BEGIN@17
# spent 426µs making 1 call to base::import |
| 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 80.7ms (22.5+58.1) within Class::MOP::Attribute::new which was called 239 times, avg 338µs/call:
# 124 times (12.5ms+51.1ms) by Moose::Meta::Attribute::new at line 80 of Moose/Meta/Attribute.pm, avg 513µs/call
# 67 times (6.04ms+4.09ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 18 of Class/MOP/Mixin/HasAttributes.pm, avg 151µs/call
# once (159µs+111µs) by Moose::Exporter::BEGIN@11 at line 421 of Class/MOP.pm
# once (147µs+94µs) by Moose::Exporter::BEGIN@11 at line 435 of Class/MOP.pm
# once (186µs+53µs) by Moose::Exporter::BEGIN@11 at line 341 of Class/MOP.pm
# once (118µs+94µs) by Moose::Exporter::BEGIN@11 at line 193 of Class/MOP.pm
# once (116µs+71µs) by Moose::Exporter::BEGIN@11 at line 374 of Class/MOP.pm
# once (89µs+88µs) by Moose::Exporter::BEGIN@11 at line 414 of Class/MOP.pm
# once (91µs+80µs) by Moose::Exporter::BEGIN@11 at line 616 of Class/MOP.pm
# once (96µs+75µs) by Moose::Exporter::BEGIN@11 at line 511 of Class/MOP.pm
# once (75µs+94µs) by Moose::Exporter::BEGIN@11 at line 567 of Class/MOP.pm
# once (92µs+63µs) by Moose::Exporter::BEGIN@11 at line 384 of Class/MOP.pm
# once (90µs+64µs) by Moose::Exporter::BEGIN@11 at line 235 of Class/MOP.pm
# once (93µs+60µs) by Moose::Exporter::BEGIN@11 at line 365 of Class/MOP.pm
# once (89µs+64µs) by Moose::Exporter::BEGIN@11 at line 338 of Class/MOP.pm
# once (88µs+65µs) by Moose::Exporter::BEGIN@11 at line 303 of Class/MOP.pm
# once (88µs+62µs) by Moose::Exporter::BEGIN@11 at line 277 of Class/MOP.pm
# once (75µs+74µs) by Moose::Exporter::BEGIN@11 at line 521 of Class/MOP.pm
# once (85µs+62µs) by Moose::Exporter::BEGIN@11 at line 322 of Class/MOP.pm
# once (90µs+56µs) by Moose::Exporter::BEGIN@11 at line 400 of Class/MOP.pm
# once (70µs+75µs) by Moose::Exporter::BEGIN@11 at line 656 of Class/MOP.pm
# once (72µs+70µs) by Moose::Exporter::BEGIN@11 at line 493 of Class/MOP.pm
# once (73µs+68µs) by Moose::Exporter::BEGIN@11 at line 428 of Class/MOP.pm
# once (73µs+68µs) by Moose::Exporter::BEGIN@11 at line 469 of Class/MOP.pm
# once (72µs+68µs) by Moose::Exporter::BEGIN@11 at line 462 of Class/MOP.pm
# once (75µs+65µs) by Moose::Exporter::BEGIN@11 at line 208 of Class/MOP.pm
# once (72µs+67µs) by Moose::Exporter::BEGIN@11 at line 441 of Class/MOP.pm
# once (71µs+65µs) by Moose::Exporter::BEGIN@11 at line 455 of Class/MOP.pm
# once (71µs+65µs) by Moose::Exporter::BEGIN@11 at line 483 of Class/MOP.pm
# once (69µs+66µs) by Moose::Exporter::BEGIN@11 at line 476 of Class/MOP.pm
# once (70µs+65µs) by Moose::Exporter::BEGIN@11 at line 448 of Class/MOP.pm
# once (82µs+52µs) by Moose::Exporter::BEGIN@11 at line 601 of Class/MOP.pm
# once (75µs+58µs) by Moose::Exporter::BEGIN@11 at line 196 of Class/MOP.pm
# once (79µs+47µs) by Moose::BEGIN@19 at line 43 of Moose/Meta/Class.pm
# once (70µs+49µs) by Moose::Exporter::BEGIN@11 at line 539 of Class/MOP.pm
# once (74µs+45µs) by Moose::Exporter::BEGIN@11 at line 238 of Class/MOP.pm
# once (75µs+44µs) by Moose::Exporter::BEGIN@11 at line 356 of Class/MOP.pm
# once (72µs+44µs) by Moose::Exporter::BEGIN@11 at line 584 of Class/MOP.pm
# once (71µs+44µs) by Moose::Exporter::BEGIN@11 at line 635 of Class/MOP.pm
# once (71µs+43µs) by Moose::Exporter::BEGIN@11 at line 619 of Class/MOP.pm
# once (70µs+44µs) by Moose::Exporter::BEGIN@11 at line 662 of Class/MOP.pm
# once (70µs+43µs) by Moose::Exporter::BEGIN@11 at line 545 of Class/MOP.pm
# once (69µs+44µs) by Moose::Exporter::BEGIN@11 at line 560 of Class/MOP.pm
# once (71µs+43µs) by Moose::Exporter::BEGIN@11 at line 253 of Class/MOP.pm
# once (71µs+43µs) by Moose::Exporter::BEGIN@11 at line 574 of Class/MOP.pm
# once (70µs+43µs) by Moose::Exporter::BEGIN@11 at line 593 of Class/MOP.pm
# once (69µs+43µs) by Moose::Exporter::BEGIN@11 at line 533 of Class/MOP.pm
# once (70µs+42µs) by Moose::Exporter::BEGIN@11 at line 527 of Class/MOP.pm
# once (69µs+43µs) by Moose::Exporter::BEGIN@11 at line 641 of Class/MOP.pm
# once (67µs+42µs) by Moose::Exporter::BEGIN@11 at line 650 of Class/MOP.pm | ||||
| 29 | 2151 | 20.3ms | my ( $class, @args ) = @_; | ||
| 30 | |||||
| 31 | unshift @args, "name" if @args % 2 == 1; | ||||
| 32 | my %options = @args; | ||||
| 33 | |||||
| 34 | my $name = $options{name}; | ||||
| 35 | |||||
| 36 | (defined $name) | ||||
| 37 | || confess "You must provide a name for the attribute"; | ||||
| 38 | |||||
| 39 | $options{init_arg} = $name | ||||
| 40 | if not exists $options{init_arg}; | ||||
| 41 | 258 | 1.64ms | if(exists $options{builder}){ | ||
| 42 | confess("builder must be a defined scalar value which is a method name") | ||||
| 43 | if ref $options{builder} || !(defined $options{builder}); | ||||
| 44 | confess("Setting both default and builder is not allowed.") | ||||
| 45 | if exists $options{default}; | ||||
| 46 | } else { | ||||
| 47 | 50 | 1.05ms | ($class->is_default_a_coderef(\%options)) # spent 1.05ms making 50 calls to Class::MOP::Mixin::AttributeCore::is_default_a_coderef, avg 21µ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 | } | ||||
| 52 | 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 | |||||
| 56 | 239 | 57.1ms | $class->_new(\%options); # spent 46.4ms making 123 calls to Moose::Meta::Attribute::_new, avg 377µs/call
# spent 10.7ms making 116 calls to Class::MOP::Attribute::_new, avg 92µs/call | ||
| 57 | } | ||||
| 58 | |||||
| 59 | # spent 10.7ms (6.52+4.15) within Class::MOP::Attribute::_new which was called 116 times, avg 92µs/call:
# 116 times (6.52ms+4.15ms) by Class::MOP::Attribute::new at line 56, avg 92µs/call | ||||
| 60 | 462 | 7.00ms | my $class = shift; | ||
| 61 | |||||
| 62 | 2 | 4.15ms | return Class::MOP::Class->initialize($class)->new_object(@_) # spent 4.11ms 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 | |||||
| 65 | my $options = @_ == 1 ? $_[0] : {@_}; | ||||
| 66 | |||||
| 67 | 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. | ||||
| 99 | sub 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 144ms (37.1+107) within Class::MOP::Attribute::initialize_instance_slot which was called 1264 times, avg 114µs/call:
# 1264 times (37.1ms+107ms) by Class::MOP::Class::_construct_instance at line 579 of Class/MOP/Class.pm, avg 114µs/call | ||||
| 108 | 3792 | 35.6ms | my ($self, $meta_instance, $instance, $params) = @_; | ||
| 109 | 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) | ||||
| 115 | 1541 | 107ms | if(defined $init_arg and exists $params->{$init_arg}){ # spent 82.3ms making 1058 calls to Class::MOP::Attribute::_set_initial_slot_value, avg 78µs/call
# spent 24.8ms making 483 calls to Class::MOP::Mixin::AttributeCore::default, avg 51µs/call | ||
| 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 83.3ms (50.4+32.9) within Class::MOP::Attribute::_set_initial_slot_value which was called 1069 times, avg 78µs/call:
# 1058 times (49.8ms+32.5ms) by Class::MOP::Attribute::initialize_instance_slot at line 115, avg 78µs/call
# 11 times (571µs+353µs) by Class::MOP::Attribute::set_initial_value at line 259, avg 84µs/call | ||||
| 144 | 3207 | 50.6ms | my ($self, $meta_instance, $instance, $value) = @_; | ||
| 145 | |||||
| 146 | 1069 | 5.36ms | my $slot_name = $self->name; # spent 5.36ms making 1069 calls to Class::MOP::Mixin::AttributeCore::name, avg 5µs/call | ||
| 147 | |||||
| 148 | 2138 | 27.5ms | return $meta_instance->set_slot_value($instance, $slot_name, $value) # spent 16.8ms making 1069 calls to Class::MOP::Instance::set_slot_value, avg 16µs/call
# spent 10.7ms making 1069 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 10µs/call | ||
| 149 | unless $self->has_initializer; | ||||
| 150 | |||||
| 151 | my $callback = $self->_make_initializer_writer_callback( | ||||
| 152 | $meta_instance, $instance, $slot_name | ||||
| 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 | |||||
| 161 | sub _make_initializer_writer_callback { | ||||
| 162 | my $self = shift; | ||||
| 163 | my ($meta_instance, $instance, $slot_name) = @_; | ||||
| 164 | |||||
| 165 | return sub { | ||||
| 166 | $meta_instance->set_slot_value($instance, $slot_name, $_[0]); | ||||
| 167 | }; | ||||
| 168 | } | ||||
| 169 | |||||
| 170 | # spent 728µs (604+124) within Class::MOP::Attribute::get_read_method which was called 23 times, avg 32µs/call:
# 23 times (604µs+124µs) by Moose::Meta::Method::Delegation::_get_delegate_accessor at line 125 of Moose/Meta/Method/Delegation.pm, avg 32µs/call | ||||
| 171 | 69 | 763µs | my $self = shift; | ||
| 172 | 23 | 124µs | my $reader = $self->reader || $self->accessor; # spent 124µs making 23 calls to Class::MOP::Mixin::AttributeCore::reader, avg 5µs/call | ||
| 173 | # normal case ... | ||||
| 174 | return $reader unless ref $reader; | ||||
| 175 | # the HASH ref case | ||||
| 176 | my ($name) = %$reader; | ||||
| 177 | return $name; | ||||
| 178 | } | ||||
| 179 | |||||
| 180 | sub get_write_method { | ||||
| 181 | my $self = shift; | ||||
| 182 | my $writer = $self->writer || $self->accessor; | ||||
| 183 | # normal case ... | ||||
| 184 | return $writer unless ref $writer; | ||||
| 185 | # the HASH ref case | ||||
| 186 | my ($name) = %$writer; | ||||
| 187 | return $name; | ||||
| 188 | } | ||||
| 189 | |||||
| 190 | sub get_read_method_ref { | ||||
| 191 | my $self = shift; | ||||
| 192 | if ((my $reader = $self->get_read_method) && $self->associated_class) { | ||||
| 193 | return $self->associated_class->get_method($reader); | ||||
| 194 | } | ||||
| 195 | else { | ||||
| 196 | my $code = sub { $self->get_value(@_) }; | ||||
| 197 | if (my $class = $self->associated_class) { | ||||
| 198 | return $class->method_metaclass->wrap( | ||||
| 199 | $code, | ||||
| 200 | package_name => $class->name, | ||||
| 201 | name => '__ANON__' | ||||
| 202 | ); | ||||
| 203 | } | ||||
| 204 | else { | ||||
| 205 | return $code; | ||||
| 206 | } | ||||
| 207 | } | ||||
| 208 | } | ||||
| 209 | |||||
| 210 | sub get_write_method_ref { | ||||
| 211 | my $self = shift; | ||||
| 212 | if ((my $writer = $self->get_write_method) && $self->associated_class) { | ||||
| 213 | return $self->associated_class->get_method($writer); | ||||
| 214 | } | ||||
| 215 | else { | ||||
| 216 | my $code = sub { $self->set_value(@_) }; | ||||
| 217 | if (my $class = $self->associated_class) { | ||||
| 218 | return $class->method_metaclass->wrap( | ||||
| 219 | $code, | ||||
| 220 | package_name => $class->name, | ||||
| 221 | name => '__ANON__' | ||||
| 222 | ); | ||||
| 223 | } | ||||
| 224 | else { | ||||
| 225 | return $code; | ||||
| 226 | } | ||||
| 227 | } | ||||
| 228 | } | ||||
| 229 | |||||
| 230 | # slots | ||||
| 231 | |||||
| 232 | 1058 | 25.6ms | 1058 | 5.35ms | # spent 23.7ms (18.4+5.35) within Class::MOP::Attribute::slots which was called 1058 times, avg 22µs/call:
# 1058 times (18.4ms+5.35ms) by Class::MOP::Instance::BUILDARGS at line 31 of Class/MOP/Instance.pm, avg 22µs/call # spent 5.35ms making 1058 calls to Class::MOP::Mixin::AttributeCore::name, avg 5µs/call |
| 233 | |||||
| 234 | # class association | ||||
| 235 | |||||
| 236 | # spent 15.2ms (10.7+4.47) within Class::MOP::Attribute::attach_to_class which was called 239 times, avg 64µs/call:
# 239 times (10.7ms+4.47ms) by Class::MOP::Class::_attach_attribute at line 920 of Class/MOP/Class.pm, avg 64µs/call | ||||
| 237 | 717 | 15.5ms | my ($self, $class) = @_; | ||
| 238 | 478 | 2.69ms | (blessed($class) && $class->isa('Class::MOP::Class')) # spent 1.35ms making 239 calls to Scalar::Util::blessed, avg 6µs/call
# spent 1.34ms making 239 calls to UNIVERSAL::isa, avg 6µs/call | ||
| 239 | || confess "You must pass a Class::MOP::Class instance (or a subclass)"; | ||||
| 240 | 239 | 1.78ms | weaken($self->{'associated_class'} = $class); # spent 1.78ms making 239 calls to Scalar::Util::weaken, avg 7µs/call | ||
| 241 | } | ||||
| 242 | |||||
| 243 | sub detach_from_class { | ||||
| 244 | my $self = shift; | ||||
| 245 | $self->{'associated_class'} = undef; | ||||
| 246 | } | ||||
| 247 | |||||
| 248 | # method association | ||||
| 249 | |||||
| 250 | # spent 7.72ms within Class::MOP::Attribute::associate_method which was called 446 times, avg 17µs/call:
# 361 times (6.35ms+0s) by Class::MOP::Attribute::_process_accessors at line 405, avg 18µs/call
# 57 times (911µs+0s) by Class::MOP::Attribute::_process_accessors at line 377, avg 16µs/call
# 28 times (459µs+0s) by Moose::Meta::Attribute::install_delegation at line 988 of Moose/Meta/Attribute.pm, avg 16µs/call | ||||
| 251 | 892 | 8.65ms | my ($self, $method) = @_; | ||
| 252 | push @{$self->{'associated_methods'}} => $method; | ||||
| 253 | } | ||||
| 254 | |||||
| 255 | ## Slot management | ||||
| 256 | |||||
| 257 | # spent 2.16ms (565µs+1.60) within Class::MOP::Attribute::set_initial_value which was called 11 times, avg 197µs/call:
# 11 times (565µs+1.60ms) by Moose::Meta::Attribute::initialize_instance_slot at line 490 of Moose/Meta/Attribute.pm, avg 197µs/call | ||||
| 258 | 22 | 486µs | my ($self, $instance, $value) = @_; | ||
| 259 | 33 | 1.60ms | $self->_set_initial_slot_value( # spent 924µs making 11 calls to Class::MOP::Attribute::_set_initial_slot_value, avg 84µs/call
# spent 447µs making 11 calls to Class::MOP::Class::initialize, avg 41µs/call
# spent 116µs making 9 calls to Class::MOP::Class::get_meta_instance, avg 13µs/call
# spent 113µs making 2 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 56µs/call | ||
| 260 | Class::MOP::Class->initialize(ref($instance))->get_meta_instance, | ||||
| 261 | $instance, | ||||
| 262 | $value | ||||
| 263 | ); | ||||
| 264 | } | ||||
| 265 | |||||
| 266 | sub set_value { shift->set_raw_value(@_) } | ||||
| 267 | |||||
| 268 | sub set_raw_value { | ||||
| 269 | my $self = shift; | ||||
| 270 | my ($instance, $value) = @_; | ||||
| 271 | |||||
| 272 | my $mi = Class::MOP::Class->initialize(ref($instance))->get_meta_instance; | ||||
| 273 | return $mi->set_slot_value($instance, $self->name, $value); | ||||
| 274 | } | ||||
| 275 | |||||
| 276 | # spent 133ms (12.8+121) within Class::MOP::Attribute::_inline_set_value which was called 556 times, avg 240µs/call:
# 254 times (5.52ms+48.9ms) by Class::MOP::Class::_inline_init_attr_from_constructor at line 684 of Class/MOP/Class.pm, avg 214µs/call
# 195 times (4.83ms+49.0ms) by Moose::Meta::Attribute::_inline_set_value at line 579 of Moose/Meta/Attribute.pm, avg 276µs/call
# 89 times (1.98ms+14.2ms) by Class::MOP::Class::_inline_init_attr_from_default at line 705 of Class/MOP/Class.pm, avg 181µs/call
# 15 times (370µs+8.05ms) by Class::MOP::Method::Accessor::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Method/Accessor.pm:118] at line 110 of Class/MOP/Method/Accessor.pm, avg 561µs/call
# 3 times (73µs+390µs) by Class::MOP::Method::Accessor::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Method/Accessor.pm:182] at line 177 of Class/MOP/Method/Accessor.pm, avg 154µs/call | ||||
| 277 | 1112 | 12.7ms | my $self = shift; | ||
| 278 | 556 | 121ms | return $self->_inline_instance_set(@_) . ';'; # spent 121ms making 556 calls to Class::MOP::Attribute::_inline_instance_set, avg 217µs/call | ||
| 279 | } | ||||
| 280 | |||||
| 281 | # spent 123ms (32.8+90.3) within Class::MOP::Attribute::_inline_instance_set which was called 575 times, avg 214µs/call:
# 556 times (31.6ms+88.9ms) by Class::MOP::Attribute::_inline_set_value at line 278, avg 217µs/call
# 19 times (1.25ms+1.32ms) by Moose::Meta::Attribute::_inline_init_slot at line 839 of Moose/Meta/Attribute.pm, avg 136µs/call | ||||
| 282 | 2300 | 37.3ms | my $self = shift; | ||
| 283 | my ($instance, $value) = @_; | ||||
| 284 | |||||
| 285 | 1150 | 62.3ms | my $mi = $self->associated_class->get_meta_instance; # spent 35.0ms making 341 calls to Class::MOP::Class::get_meta_instance, avg 103µs/call
# spent 24.3ms making 234 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 104µs/call
# spent 2.98ms making 575 calls to Class::MOP::Attribute::associated_class, avg 5µs/call | ||
| 286 | 1150 | 28.0ms | return $mi->inline_set_slot_value($instance, $self->name, $value); # spent 24.9ms making 575 calls to Class::MOP::Instance::inline_set_slot_value, avg 43µs/call
# spent 3.09ms making 575 calls to Class::MOP::Mixin::AttributeCore::name, avg 5µs/call | ||
| 287 | } | ||||
| 288 | |||||
| 289 | 35 | 605µs | 35 | 5.57ms | # spent 6.18ms (613µs+5.57) within Class::MOP::Attribute::get_value which was called 35 times, avg 177µs/call:
# 21 times (347µs+3.31ms) by Moose::Meta::Attribute::clone at line 240 of Moose/Meta/Attribute.pm, avg 174µs/call
# 14 times (265µs+2.26ms) 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 or Moose::Meta::Mixin::AttributeCore::type_constraint at line 131 of Class/MOP/Method/Accessor.pm, avg 180µs/call # spent 5.57ms making 35 calls to Class::MOP::Attribute::get_raw_value, avg 159µs/call |
| 290 | |||||
| 291 | # spent 5.57ms (2.02+3.55) within Class::MOP::Attribute::get_raw_value which was called 35 times, avg 159µs/call:
# 35 times (2.02ms+3.55ms) by Class::MOP::Attribute::get_value at line 289, avg 159µs/call | ||||
| 292 | 140 | 2.03ms | my $self = shift; | ||
| 293 | my ($instance) = @_; | ||||
| 294 | |||||
| 295 | 70 | 2.91ms | my $mi = Class::MOP::Class->initialize(ref($instance))->get_meta_instance; # spent 1.56ms making 32 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 49µs/call
# spent 1.32ms making 35 calls to Class::MOP::Class::initialize, avg 38µs/call
# spent 37µs making 3 calls to Class::MOP::Class::get_meta_instance, avg 12µs/call | ||
| 296 | 70 | 635µs | return $mi->get_slot_value($instance, $self->name); # spent 446µs making 35 calls to Class::MOP::Instance::get_slot_value, avg 13µs/call
# spent 190µs making 35 calls to Class::MOP::Mixin::AttributeCore::name, avg 5µs/call | ||
| 297 | } | ||||
| 298 | |||||
| 299 | # spent 21.7ms (1.83+19.9) within Class::MOP::Attribute::_inline_get_value which was called 68 times, avg 319µs/call:
# 53 times (1.43ms+18.0ms) by Class::MOP::Method::Accessor::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Method/Accessor.pm:152] at line 140 of Class/MOP/Method/Accessor.pm, avg 368µs/call
# 15 times (391µs+1.82ms) by Class::MOP::Method::Accessor::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Method/Accessor.pm:118] at line 110 of Class/MOP/Method/Accessor.pm, avg 148µs/call | ||||
| 300 | 136 | 1.86ms | my $self = shift; | ||
| 301 | 68 | 19.9ms | return $self->_inline_instance_get(@_) . ';'; # spent 19.9ms making 68 calls to Class::MOP::Attribute::_inline_instance_get, avg 292µs/call | ||
| 302 | } | ||||
| 303 | |||||
| 304 | # spent 114ms (12.2+102) within Class::MOP::Attribute::_inline_instance_get which was called 196 times, avg 580µs/call:
# 123 times (7.75ms+85.5ms) by Moose::Meta::Attribute::_inline_get_value at line 748 of Moose/Meta/Attribute.pm, avg 758µs/call
# 68 times (4.19ms+15.7ms) by Class::MOP::Attribute::_inline_get_value at line 301, avg 292µs/call
# 5 times (305µs+357µs) by Moose::Meta::Method::Accessor::_get_value at line 121 of Moose/Meta/Method/Accessor.pm, avg 132µs/call | ||||
| 305 | 784 | 14.2ms | my $self = shift; | ||
| 306 | my ($instance) = @_; | ||||
| 307 | |||||
| 308 | 392 | 91.0ms | my $mi = $self->associated_class->get_meta_instance; # spent 89.9ms making 196 calls to Class::MOP::Class::get_meta_instance, avg 459µs/call
# spent 1.13ms making 196 calls to Class::MOP::Attribute::associated_class, avg 6µs/call | ||
| 309 | 392 | 10.5ms | return $mi->inline_get_slot_value($instance, $self->name); # spent 9.29ms making 196 calls to Class::MOP::Instance::inline_get_slot_value, avg 47µs/call
# spent 1.20ms making 196 calls to Class::MOP::Mixin::AttributeCore::name, avg 6µs/call | ||
| 310 | } | ||||
| 311 | |||||
| 312 | # spent 10.2ms (3.67+6.58) within Class::MOP::Attribute::has_value which was called 64 times, avg 160µs/call:
# 56 times (3.17ms+5.72ms) by Moose::Meta::Attribute::clone at line 236 of Moose/Meta/Attribute.pm, avg 159µs/call
# 8 times (500µs+858µ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 193 of Class/MOP/Method/Accessor.pm, avg 170µs/call | ||||
| 313 | 256 | 3.58ms | my $self = shift; | ||
| 314 | my ($instance) = @_; | ||||
| 315 | |||||
| 316 | 128 | 5.39ms | my $mi = Class::MOP::Class->initialize(ref($instance))->get_meta_instance; # spent 3.04ms making 63 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 48µs/call
# spent 2.34ms making 64 calls to Class::MOP::Class::initialize, avg 36µs/call
# spent 14µs making 1 call to Class::MOP::Class::get_meta_instance | ||
| 317 | 128 | 1.19ms | return $mi->is_slot_initialized($instance, $self->name); # spent 844µs making 64 calls to Class::MOP::Instance::is_slot_initialized, avg 13µs/call
# spent 348µs making 64 calls to Class::MOP::Mixin::AttributeCore::name, avg 5µs/call | ||
| 318 | } | ||||
| 319 | |||||
| 320 | # spent 7.10ms (1.12+5.98) within Class::MOP::Attribute::_inline_has_value which was called 43 times, avg 165µs/call:
# 43 times (1.12ms+5.98ms) by Class::MOP::Method::Accessor::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Method/Accessor.pm:207] at line 202 of Class/MOP/Method/Accessor.pm, avg 165µs/call | ||||
| 321 | 86 | 1.13ms | my $self = shift; | ||
| 322 | 43 | 5.98ms | return $self->_inline_instance_has(@_) . ';'; # spent 5.98ms making 43 calls to Class::MOP::Attribute::_inline_instance_has, avg 139µs/call | ||
| 323 | } | ||||
| 324 | |||||
| 325 | # spent 8.52ms (3.96+4.57) within Class::MOP::Attribute::_inline_instance_has which was called 62 times, avg 137µs/call:
# 43 times (2.74ms+3.24ms) by Class::MOP::Attribute::_inline_has_value at line 322, avg 139µs/call
# 19 times (1.21ms+1.33ms) by Moose::Meta::Attribute::_inline_check_lazy at line 764 of Moose/Meta/Attribute.pm, avg 134µs/call | ||||
| 326 | 248 | 4.46ms | my $self = shift; | ||
| 327 | my ($instance) = @_; | ||||
| 328 | |||||
| 329 | 124 | 1.19ms | my $mi = $self->associated_class->get_meta_instance; # spent 840µs making 62 calls to Class::MOP::Class::get_meta_instance, avg 14µs/call
# spent 355µs making 62 calls to Class::MOP::Attribute::associated_class, avg 6µs/call | ||
| 330 | 124 | 3.37ms | return $mi->inline_is_slot_initialized($instance, $self->name); # spent 3.01ms making 62 calls to Class::MOP::Instance::inline_is_slot_initialized, avg 49µs/call
# spent 360µs making 62 calls to Class::MOP::Mixin::AttributeCore::name, avg 6µs/call | ||
| 331 | } | ||||
| 332 | |||||
| 333 | sub clear_value { | ||||
| 334 | my $self = shift; | ||||
| 335 | my ($instance) = @_; | ||||
| 336 | |||||
| 337 | my $mi = Class::MOP::Class->initialize(ref($instance))->get_meta_instance; | ||||
| 338 | return $mi->deinitialize_slot($instance, $self->name); | ||||
| 339 | } | ||||
| 340 | |||||
| 341 | # spent 5.39ms (768µs+4.62) within Class::MOP::Attribute::_inline_clear_value which was called 29 times, avg 186µs/call:
# 29 times (768µs+4.62ms) by Class::MOP::Method::Accessor::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Method/Accessor.pm:232] at line 227 of Class/MOP/Method/Accessor.pm, avg 186µs/call | ||||
| 342 | 58 | 772µs | my $self = shift; | ||
| 343 | 29 | 4.62ms | return $self->_inline_instance_clear(@_) . ';'; # spent 4.62ms making 29 calls to Class::MOP::Attribute::_inline_instance_clear, avg 159µs/call | ||
| 344 | } | ||||
| 345 | |||||
| 346 | # spent 4.62ms (1.83+2.79) within Class::MOP::Attribute::_inline_instance_clear which was called 29 times, avg 159µs/call:
# 29 times (1.83ms+2.79ms) by Class::MOP::Attribute::_inline_clear_value at line 343, avg 159µs/call | ||||
| 347 | 116 | 2.03ms | my $self = shift; | ||
| 348 | my ($instance) = @_; | ||||
| 349 | |||||
| 350 | 58 | 1.16ms | my $mi = $self->associated_class->get_meta_instance; # spent 1.00ms making 29 calls to Class::MOP::Class::get_meta_instance, avg 34µs/call
# spent 160µs making 29 calls to Class::MOP::Attribute::associated_class, avg 6µs/call | ||
| 351 | 58 | 1.63ms | return $mi->inline_deinitialize_slot($instance, $self->name); # spent 1.46ms making 29 calls to Class::MOP::Instance::inline_deinitialize_slot, avg 50µs/call
# spent 167µs making 29 calls to Class::MOP::Mixin::AttributeCore::name, avg 6µs/call | ||
| 352 | } | ||||
| 353 | |||||
| 354 | ## load em up ... | ||||
| 355 | |||||
| 356 | 225 | 3.13ms | # spent 2.01ms within Class::MOP::Attribute::accessor_metaclass which was called 225 times, avg 9µs/call:
# 168 times (1.46ms+0s) by Class::MOP::Attribute::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Attribute.pm:401] at line 393, avg 9µs/call
# 57 times (554µs+0s) by Class::MOP::Attribute::_process_accessors at line 371, avg 10µs/call | ||
| 357 | |||||
| 358 | # spent 1.00s (56.5ms+948ms) within Class::MOP::Attribute::_process_accessors which was called 418 times, avg 2.40ms/call:
# 193 times (27.4ms+721ms) by Moose::Meta::Attribute::_process_accessors at line 944 of Moose/Meta/Attribute.pm, avg 3.88ms/call
# 150 times (19.3ms+144ms) by Class::MOP::Attribute::install_accessors at line 419, avg 1.09ms/call
# 36 times (4.52ms+31.0ms) by Class::MOP::Attribute::install_accessors at line 427, avg 986µs/call
# 31 times (4.17ms+44.3ms) by Class::MOP::Attribute::install_accessors at line 415, avg 1.56ms/call
# 8 times (1.02ms+7.68ms) by Class::MOP::Attribute::install_accessors at line 423, avg 1.09ms/call | ||||
| 359 | 1672 | 15.6ms | my ($self, $type, $accessor, $generate_as_inline_methods) = @_; | ||
| 360 | |||||
| 361 | my $method_ctx; | ||||
| 362 | |||||
| 363 | 418 | 2.42ms | if ( my $ctx = $self->definition_context ) { # spent 2.42ms making 418 calls to Class::MOP::Mixin::AttributeCore::definition_context, avg 6µs/call | ||
| 364 | $method_ctx = { %$ctx }; | ||||
| 365 | } | ||||
| 366 | |||||
| 367 | 2090 | 42.3ms | if (ref($accessor)) { | ||
| 368 | (ref($accessor) eq 'HASH') | ||||
| 369 | || confess "bad accessor/reader/writer/predicate/clearer format, must be a HASH ref"; | ||||
| 370 | my ($name, $method) = %{$accessor}; | ||||
| 371 | 228 | 13.8ms | $method = $self->accessor_metaclass->wrap( # spent 12.7ms making 57 calls to Class::MOP::Method::wrap, avg 222µs/call
# spent 554µs making 57 calls to Class::MOP::Attribute::accessor_metaclass, avg 10µs/call
# spent 307µs making 57 calls to Class::MOP::Attribute::associated_class, avg 5µs/call
# spent 302µs making 57 calls to Class::MOP::Package::name, avg 5µs/call | ||
| 372 | $method, | ||||
| 373 | package_name => $self->associated_class->name, | ||||
| 374 | name => $name, | ||||
| 375 | definition_context => $method_ctx, | ||||
| 376 | ); | ||||
| 377 | 57 | 911µs | $self->associate_method($method); # spent 911µs making 57 calls to Class::MOP::Attribute::associate_method, avg 16µs/call | ||
| 378 | return ($name, $method); | ||||
| 379 | } | ||||
| 380 | else { | ||||
| 381 | 255 | 1.50ms | my $inline_me = ($generate_as_inline_methods && $self->associated_class->instance_metaclass->is_inlinable); # spent 646µs making 85 calls to Class::MOP::Instance::is_inlinable, avg 8µs/call
# spent 426µs making 85 calls to Class::MOP::Attribute::associated_class, avg 5µs/call
# spent 426µs making 85 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call | ||
| 382 | my $method; | ||||
| 383 | # spent 883ms (29.0+854) within Class::MOP::Attribute::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Attribute.pm:401] which was called 361 times, avg 2.44ms/call:
# 361 times (29.0ms+854ms) by Try::Tiny::try at line 76 of Try/Tiny.pm, avg 2.44ms/call | ||||
| 384 | 1295 | 32.1ms | if ( $method_ctx ) { | ||
| 385 | my $desc = "accessor $accessor"; | ||||
| 386 | 264 | 1.44ms | if ( $accessor ne $self->name ) { # spent 1.44ms making 264 calls to Class::MOP::Mixin::AttributeCore::name, avg 5µs/call | ||
| 387 | $desc .= " of attribute " . $self->name; | ||||
| 388 | } | ||||
| 389 | |||||
| 390 | $method_ctx->{description} = $desc; | ||||
| 391 | } | ||||
| 392 | |||||
| 393 | 1444 | 852ms | $method = $self->accessor_metaclass->new( # spent 845ms making 361 calls to Class::MOP::Method::Accessor::new, avg 2.34ms/call
# spent 2.03ms making 361 calls to Class::MOP::Attribute::associated_class, avg 6µs/call
# spent 1.86ms making 361 calls to Class::MOP::Package::name, avg 5µs/call
# spent 1.76ms making 193 calls to Moose::Meta::Attribute::accessor_metaclass, avg 9µs/call
# spent 1.46ms making 168 calls to Class::MOP::Attribute::accessor_metaclass, avg 9µs/call | ||
| 394 | attribute => $self, | ||||
| 395 | is_inline => $inline_me, | ||||
| 396 | accessor_type => $type, | ||||
| 397 | package_name => $self->associated_class->name, | ||||
| 398 | name => $accessor, | ||||
| 399 | definition_context => $method_ctx, | ||||
| 400 | ); | ||||
| 401 | } | ||||
| 402 | catch { | ||||
| 403 | confess "Could not create the '$type' method for " . $self->name . " because : $_"; | ||||
| 404 | 722 | 174ms | }; # spent 916ms making 361 calls to Try::Tiny::try, avg 2.54ms/call, recursion: max depth 2, sum of overlapping time 749ms
# spent 7.61ms making 361 calls to Try::Tiny::catch, avg 21µs/call | ||
| 405 | 361 | 6.35ms | $self->associate_method($method); # spent 6.35ms making 361 calls to Class::MOP::Attribute::associate_method, avg 18µs/call | ||
| 406 | return ($accessor, $method); | ||||
| 407 | } | ||||
| 408 | } | ||||
| 409 | |||||
| 410 | # spent 1.36s (50.6ms+1.31) within Class::MOP::Attribute::install_accessors which was called 308 times, avg 4.42ms/call:
# 125 times (22.4ms+946ms) by Moose::Meta::Attribute::install_accessors at line 884 of Moose/Meta/Attribute.pm, avg 7.75ms/call
# 115 times (18.1ms+145ms) by Class::MOP::Class::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Class.pm:932] at line 931 of Class/MOP/Class.pm, avg 1.42ms/call
# 68 times (10.1ms+221ms) by Class::MOP::Class::_inline_accessors at line 1446 of Class/MOP/Class.pm, avg 3.40ms/call | ||||
| 411 | 2772 | 49.6ms | my $self = shift; | ||
| 412 | my $inline = shift; | ||||
| 413 | 308 | 2.05ms | my $class = $self->associated_class; # spent 2.05ms making 308 calls to Class::MOP::Attribute::associated_class, avg 7µs/call | ||
| 414 | |||||
| 415 | 479 | 219ms | $class->add_method( # spent 141ms making 26 calls to Moose::Meta::Attribute::_process_accessors, avg 5.41ms/call
# spent 48.4ms making 31 calls to Class::MOP::Attribute::_process_accessors, avg 1.56ms/call
# spent 26.1ms making 57 calls to Class::MOP::Mixin::HasMethods::add_method, avg 458µs/call
# spent 3.74ms making 308 calls to Class::MOP::Mixin::AttributeCore::has_accessor, avg 12µs/call
# spent 386µs making 57 calls to Class::MOP::Mixin::AttributeCore::accessor, avg 7µs/call | ||
| 416 | $self->_process_accessors('accessor' => $self->accessor(), $inline) | ||||
| 417 | ) if $self->has_accessor(); | ||||
| 418 | |||||
| 419 | 1049 | 738ms | $class->add_method( # spent 460ms making 97 calls to Moose::Meta::Attribute::_process_accessors, avg 4.75ms/call
# spent 164ms making 150 calls to Class::MOP::Attribute::_process_accessors, avg 1.09ms/call
# spent 109ms making 247 calls to Class::MOP::Mixin::HasMethods::add_method, avg 441µs/call
# spent 3.66ms making 308 calls to Class::MOP::Mixin::AttributeCore::has_reader, avg 12µs/call
# spent 1.48ms making 247 calls to Class::MOP::Mixin::AttributeCore::reader, avg 6µs/call | ||
| 420 | $self->_process_accessors('reader' => $self->reader(), $inline) | ||||
| 421 | ) if $self->has_reader(); | ||||
| 422 | |||||
| 423 | 365 | 65.2ms | $class->add_method( # spent 44.4ms making 11 calls to Moose::Meta::Attribute::_process_accessors, avg 4.03ms/call
# spent 8.70ms making 8 calls to Class::MOP::Attribute::_process_accessors, avg 1.09ms/call
# spent 8.24ms making 19 calls to Class::MOP::Mixin::HasMethods::add_method, avg 434µs/call
# spent 3.81ms making 308 calls to Class::MOP::Mixin::AttributeCore::has_writer, avg 12µs/call
# spent 106µs making 19 calls to Class::MOP::Mixin::AttributeCore::writer, avg 6µs/call | ||
| 424 | $self->_process_accessors('writer' => $self->writer(), $inline) | ||||
| 425 | ) if $self->has_writer(); | ||||
| 426 | |||||
| 427 | 506 | 172ms | $class->add_method( # spent 104ms making 30 calls to Moose::Meta::Attribute::_process_accessors, avg 3.45ms/call
# spent 35.5ms making 36 calls to Class::MOP::Attribute::_process_accessors, avg 986µs/call
# spent 28.7ms making 66 calls to Class::MOP::Mixin::HasMethods::add_method, avg 434µs/call
# spent 3.50ms making 308 calls to Class::MOP::Mixin::AttributeCore::has_predicate, avg 11µs/call
# spent 368µs making 66 calls to Class::MOP::Mixin::AttributeCore::predicate, avg 6µs/call | ||
| 428 | $self->_process_accessors('predicate' => $self->predicate(), $inline) | ||||
| 429 | ) if $self->has_predicate(); | ||||
| 430 | |||||
| 431 | 395 | 116ms | $class->add_method( # spent 99.4ms making 29 calls to Moose::Meta::Attribute::_process_accessors, avg 3.43ms/call
# spent 13.0ms making 29 calls to Class::MOP::Mixin::HasMethods::add_method, avg 447µs/call
# spent 3.27ms making 308 calls to Class::MOP::Mixin::AttributeCore::has_clearer, avg 11µs/call
# spent 168µs making 29 calls to Class::MOP::Mixin::AttributeCore::clearer, avg 6µs/call | ||
| 432 | $self->_process_accessors('clearer' => $self->clearer(), $inline) | ||||
| 433 | ) if $self->has_clearer(); | ||||
| 434 | |||||
| 435 | return; | ||||
| 436 | } | ||||
| 437 | |||||
| 438 | { | ||||
| 439 | 1 | 4µs | my $_remove_accessor = sub { | ||
| 440 | my ($accessor, $class) = @_; | ||||
| 441 | if (ref($accessor) && ref($accessor) eq 'HASH') { | ||||
| 442 | ($accessor) = keys %{$accessor}; | ||||
| 443 | } | ||||
| 444 | my $method = $class->get_method($accessor); | ||||
| 445 | $class->remove_method($accessor) | ||||
| 446 | if (ref($method) && $method->isa('Class::MOP::Method::Accessor')); | ||||
| 447 | 1 | 12µs | }; | ||
| 448 | |||||
| 449 | sub remove_accessors { | ||||
| 450 | my $self = shift; | ||||
| 451 | # TODO: | ||||
| 452 | # we really need to make sure to remove from the | ||||
| 453 | # associates methods here as well. But this is | ||||
| 454 | # such a slimly used method, I am not worried | ||||
| 455 | # about it right now. | ||||
| 456 | $_remove_accessor->($self->accessor(), $self->associated_class()) if $self->has_accessor(); | ||||
| 457 | $_remove_accessor->($self->reader(), $self->associated_class()) if $self->has_reader(); | ||||
| 458 | $_remove_accessor->($self->writer(), $self->associated_class()) if $self->has_writer(); | ||||
| 459 | $_remove_accessor->($self->predicate(), $self->associated_class()) if $self->has_predicate(); | ||||
| 460 | $_remove_accessor->($self->clearer(), $self->associated_class()) if $self->has_clearer(); | ||||
| 461 | return; | ||||
| 462 | } | ||||
| 463 | |||||
| 464 | } | ||||
| 465 | |||||
| 466 | 1 | 15µs | 1; | ||
| 467 | |||||
| 468 | __END__ |