| Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Class/MOP/Attribute.pm |
| Statements | Executed 19337 statements in 51.0ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 753 | 2 | 1 | 7.30ms | 9.75ms | Class::MOP::Attribute::_set_initial_slot_value |
| 280 | 5 | 2 | 5.42ms | 106ms | Class::MOP::Attribute::_process_accessors |
| 128 | 3 | 3 | 4.35ms | 10.2ms | Class::MOP::Attribute::_inline_instance_get |
| 227 | 3 | 2 | 4.13ms | 139ms | Class::MOP::Attribute::install_accessors |
| 441 | 5 | 3 | 3.47ms | 14.8ms | Class::MOP::Attribute::_inline_set_value |
| 484 | 2 | 2 | 3.08ms | 12.0ms | Class::MOP::Attribute::_inline_instance_set |
| 966 | 1 | 1 | 2.66ms | 13.4ms | Class::MOP::Attribute::initialize_instance_slot |
| 280 | 2 | 1 | 1.95ms | 2.35ms | Class::MOP::Attribute::_accessor_description |
| 151 | 50 | 4 | 1.44ms | 5.54ms | Class::MOP::Attribute::new |
| 740 | 1 | 1 | 1.35ms | 1.61ms | Class::MOP::Attribute::slots |
| 123 | 1 | 1 | 798µs | 1.27ms | Class::MOP::Attribute::_new |
| 151 | 1 | 1 | 764µs | 1.02ms | Class::MOP::Attribute::attach_to_class |
| 306 | 3 | 2 | 506µs | 506µs | Class::MOP::Attribute::associate_method |
| 67 | 2 | 2 | 479µs | 944µs | Class::MOP::Attribute::_inline_instance_has |
| 75 | 2 | 1 | 193µs | 8.84ms | Class::MOP::Attribute::_inline_get_value |
| 245 | 2 | 1 | 176µs | 176µs | Class::MOP::Attribute::accessor_metaclass |
| 12 | 1 | 1 | 89µs | 210µs | Class::MOP::Attribute::has_value |
| 12 | 1 | 1 | 88µs | 207µs | Class::MOP::Attribute::get_raw_value |
| 24 | 1 | 1 | 70µs | 434µs | Class::MOP::Attribute::_inline_has_value |
| 4 | 1 | 1 | 34µs | 90µs | Class::MOP::Attribute::set_initial_value |
| 12 | 1 | 1 | 22µs | 229µs | Class::MOP::Attribute::get_value |
| 1 | 1 | 1 | 11µs | 36µs | Class::MOP::Attribute::BEGIN@17 |
| 1 | 1 | 1 | 8µs | 8µs | Class::MOP::Attribute::BEGIN@3 |
| 1 | 1 | 1 | 7µs | 11µs | Class::MOP::Attribute::BEGIN@11 |
| 1 | 1 | 1 | 6µs | 31µs | Class::MOP::Attribute::BEGIN@16 |
| 1 | 1 | 1 | 6µs | 32µs | Class::MOP::Attribute::BEGIN@15 |
| 1 | 1 | 1 | 6µs | 18µs | Class::MOP::Attribute::BEGIN@10 |
| 1 | 1 | 1 | 6µs | 96µs | Class::MOP::Attribute::BEGIN@19 |
| 1 | 1 | 1 | 4µs | 4µs | Class::MOP::Attribute::BEGIN@13 |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Attribute::__ANON__[:169] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Attribute::__ANON__[:198] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Attribute::__ANON__[:218] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Attribute::__ANON__[:398] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Attribute::__ANON__[:401] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Attribute::__ANON__[:456] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Attribute::_inline_clear_value |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Attribute::_inline_instance_clear |
| 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 |
| 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 | # spent 8µs within Class::MOP::Attribute::BEGIN@3 which was called:
# once (8µs+0s) by Class::MOP::BEGIN@27 at line 5 | ||||
| 4 | 1 | 4µs | $Class::MOP::Attribute::AUTHORITY = 'cpan:STEVAN'; | ||
| 5 | 1 | 28µs | 1 | 8µs | } # spent 8µs making 1 call to Class::MOP::Attribute::BEGIN@3 |
| 6 | { | ||||
| 7 | 2 | 900ns | $Class::MOP::Attribute::VERSION = '2.1005'; | ||
| 8 | } | ||||
| 9 | |||||
| 10 | 2 | 21µs | 2 | 31µs | # spent 18µs (6+12) within Class::MOP::Attribute::BEGIN@10 which was called:
# once (6µs+12µs) by Class::MOP::BEGIN@27 at line 10 # spent 18µs making 1 call to Class::MOP::Attribute::BEGIN@10
# spent 12µs making 1 call to strict::import |
| 11 | 2 | 20µs | 2 | 15µs | # spent 11µs (7+4) within Class::MOP::Attribute::BEGIN@11 which was called:
# once (7µs+4µs) by Class::MOP::BEGIN@27 at line 11 # spent 11µs making 1 call to Class::MOP::Attribute::BEGIN@11
# spent 4µs making 1 call to warnings::import |
| 12 | |||||
| 13 | 2 | 21µs | 1 | 4µs | # spent 4µs within Class::MOP::Attribute::BEGIN@13 which was called:
# once (4µs+0s) by Class::MOP::BEGIN@27 at line 13 # spent 4µs making 1 call to Class::MOP::Attribute::BEGIN@13 |
| 14 | |||||
| 15 | 2 | 29µs | 2 | 57µs | # spent 32µs (6+25) within Class::MOP::Attribute::BEGIN@15 which was called:
# once (6µs+25µs) by Class::MOP::BEGIN@27 at line 15 # spent 32µs making 1 call to Class::MOP::Attribute::BEGIN@15
# spent 25µs making 1 call to Exporter::import |
| 16 | 2 | 21µs | 2 | 56µs | # spent 31µs (6+25) within Class::MOP::Attribute::BEGIN@16 which was called:
# once (6µs+25µs) by Class::MOP::BEGIN@27 at line 16 # spent 31µs making 1 call to Class::MOP::Attribute::BEGIN@16
# spent 25µs making 1 call to Exporter::import |
| 17 | 2 | 24µs | 2 | 62µs | # spent 36µs (11+26) within Class::MOP::Attribute::BEGIN@17 which was called:
# once (11µs+26µs) by Class::MOP::BEGIN@27 at line 17 # spent 36µs making 1 call to Class::MOP::Attribute::BEGIN@17
# spent 26µs making 1 call to Exporter::import |
| 18 | |||||
| 19 | 2 | 1.86ms | 2 | 185µs | # spent 96µs (6+90) within Class::MOP::Attribute::BEGIN@19 which was called:
# once (6µs+90µs) by Class::MOP::BEGIN@27 at line 19 # spent 96µs making 1 call to Class::MOP::Attribute::BEGIN@19
# spent 90µ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 5.54ms (1.44+4.10) within Class::MOP::Attribute::new which was called 151 times, avg 37µs/call:
# 74 times (685µs+530µs) by Class::MOP::Mixin::HasAttributes::add_attribute at line 20 of Class/MOP/Mixin/HasAttributes.pm, avg 16µs/call
# 29 times (351µs+3.25ms) by Moose::Meta::Attribute::new at line 121 of Moose/Meta/Attribute.pm, avg 124µs/call
# once (16µs+10µs) by Moose::Exporter::BEGIN@13 at line 133 of Class/MOP.pm
# once (11µs+14µs) by Moose::Exporter::BEGIN@13 at line 178 of Class/MOP.pm
# once (13µs+9µs) by Moose::Exporter::BEGIN@13 at line 223 of Class/MOP.pm
# once (8µs+12µs) by Moose::Exporter::BEGIN@13 at line 460 of Class/MOP.pm
# once (12µs+8µs) by Moose::Exporter::BEGIN@13 at line 479 of Class/MOP.pm
# once (10µs+8µs) by Moose::Exporter::BEGIN@13 at line 250 of Class/MOP.pm
# once (10µs+8µs) by Moose::Exporter::BEGIN@13 at line 287 of Class/MOP.pm
# once (8µs+10µs) by Moose::Exporter::BEGIN@13 at line 401 of Class/MOP.pm
# once (10µs+8µs) by Moose::Exporter::BEGIN@13 at line 597 of Class/MOP.pm
# once (10µs+8µs) by Moose::Exporter::BEGIN@13 at line 270 of Class/MOP.pm
# once (8µs+9µs) by Moose::Exporter::BEGIN@13 at line 543 of Class/MOP.pm
# once (8µs+8µs) by Moose::Exporter::BEGIN@13 at line 198 of Class/MOP.pm
# once (8µs+8µs) by Moose::Exporter::BEGIN@13 at line 338 of Class/MOP.pm
# once (7µs+9µs) by Moose::Exporter::BEGIN@13 at line 562 of Class/MOP.pm
# once (7µs+8µs) by Moose::Exporter::BEGIN@13 at line 642 of Class/MOP.pm
# once (9µs+6µs) by Moose::Exporter::BEGIN@13 at line 137 of Class/MOP.pm
# once (8µs+6µs) by Moose::Exporter::BEGIN@13 at line 150 of Class/MOP.pm
# once (8µs+6µs) by Moose::Exporter::BEGIN@13 at line 386 of Class/MOP.pm
# once (8µs+6µs) by Moose::Exporter::BEGIN@13 at line 291 of Class/MOP.pm
# once (8µs+6µs) by Moose::BEGIN@27 at line 47 of Moose/Meta/Class.pm
# once (8µs+6µs) by Moose::Exporter::BEGIN@13 at line 182 of Class/MOP.pm
# once (8µs+6µs) by Moose::Exporter::BEGIN@13 at line 307 of Class/MOP.pm
# once (8µs+6µs) by Moose::Exporter::BEGIN@13 at line 490 of Class/MOP.pm
# once (8µs+6µs) by Moose::Exporter::BEGIN@13 at line 317 of Class/MOP.pm
# once (8µs+6µs) by Moose::Exporter::BEGIN@13 at line 327 of Class/MOP.pm
# once (8µs+6µs) by Moose::Exporter::BEGIN@13 at line 551 of Class/MOP.pm
# once (8µs+6µs) by Moose::Exporter::BEGIN@13 at line 433 of Class/MOP.pm
# once (8µs+5µs) by Moose::Exporter::BEGIN@13 at line 449 of Class/MOP.pm
# once (8µs+6µs) by Moose::Exporter::BEGIN@13 at line 497 of Class/MOP.pm
# once (8µs+6µs) by Moose::Exporter::BEGIN@13 at line 572 of Class/MOP.pm
# once (8µs+6µs) by Moose::Exporter::BEGIN@13 at line 504 of Class/MOP.pm
# once (8µs+6µs) by Moose::Exporter::BEGIN@13 at line 378 of Class/MOP.pm
# once (8µs+6µs) by Moose::Exporter::BEGIN@13 at line 518 of Class/MOP.pm
# once (8µs+6µs) by Moose::Exporter::BEGIN@13 at line 370 of Class/MOP.pm
# once (8µs+5µs) by Moose::Exporter::BEGIN@13 at line 417 of Class/MOP.pm
# once (8µs+5µs) by Moose::Exporter::BEGIN@13 at line 601 of Class/MOP.pm
# once (8µs+5µs) by Moose::Exporter::BEGIN@13 at line 511 of Class/MOP.pm
# once (8µs+5µs) by Moose::Exporter::BEGIN@13 at line 409 of Class/MOP.pm
# once (7µs+6µs) by Moose::Exporter::BEGIN@13 at line 355 of Class/MOP.pm
# once (8µs+5µs) by Moose::Exporter::BEGIN@13 at line 425 of Class/MOP.pm
# once (7µs+6µs) by Moose::Exporter::BEGIN@13 at line 394 of Class/MOP.pm
# once (7µs+5µs) by Moose::Exporter::BEGIN@13 at line 649 of Class/MOP.pm
# once (7µs+6µs) by Moose::Exporter::BEGIN@13 at line 534 of Class/MOP.pm
# once (7µs+5µs) by Moose::Exporter::BEGIN@13 at line 618 of Class/MOP.pm
# once (7µs+5µs) by Moose::Exporter::BEGIN@13 at line 635 of Class/MOP.pm
# once (7µs+5µs) by Moose::Exporter::BEGIN@13 at line 581 of Class/MOP.pm
# once (7µs+5µs) by Moose::Exporter::BEGIN@13 at line 441 of Class/MOP.pm
# once (7µs+5µs) by Moose::Exporter::BEGIN@13 at line 625 of Class/MOP.pm | ||||
| 31 | 151 | 168µs | my ( $class, @args ) = @_; | ||
| 32 | |||||
| 33 | 151 | 110µs | unshift @args, "name" if @args % 2 == 1; | ||
| 34 | 151 | 202µs | my %options = @args; | ||
| 35 | |||||
| 36 | 151 | 34µs | my $name = $options{name}; | ||
| 37 | |||||
| 38 | 151 | 16µs | (defined $name) | ||
| 39 | || confess "You must provide a name for the attribute"; | ||||
| 40 | |||||
| 41 | 151 | 74µs | $options{init_arg} = $name | ||
| 42 | if not exists $options{init_arg}; | ||||
| 43 | 151 | 38µs | if(exists $options{builder}){ | ||
| 44 | 12 | 5µs | confess("builder must be a defined scalar value which is a method name") | ||
| 45 | if ref $options{builder} || !(defined $options{builder}); | ||||
| 46 | 12 | 3µs | confess("Setting both default and builder is not allowed.") | ||
| 47 | if exists $options{default}; | ||||
| 48 | } else { | ||||
| 49 | 139 | 90µs | 35 | 78µs | ($class->is_default_a_coderef(\%options)) # spent 78µs making 35 calls to Class::MOP::Mixin::AttributeCore::is_default_a_coderef, avg 2µ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 | } | ||||
| 54 | 151 | 18µ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 | |||||
| 58 | 151 | 475µs | 151 | 4.02ms | $class->_new(\%options); # spent 2.75ms making 28 calls to Moose::Meta::Attribute::_new, avg 98µs/call
# spent 1.27ms making 123 calls to Class::MOP::Attribute::_new, avg 10µs/call |
| 59 | } | ||||
| 60 | |||||
| 61 | # spent 1.27ms (798µs+471µs) within Class::MOP::Attribute::_new which was called 123 times, avg 10µs/call:
# 123 times (798µs+471µs) by Class::MOP::Attribute::new at line 58, avg 10µs/call | ||||
| 62 | 123 | 13µs | my $class = shift; | ||
| 63 | |||||
| 64 | 123 | 26µs | 2 | 471µs | return Class::MOP::Class->initialize($class)->new_object(@_) # spent 467µs making 1 call to Class::MOP::Class::new_object
# spent 4µs making 1 call to Class::MOP::Class::initialize |
| 65 | if $class ne __PACKAGE__; | ||||
| 66 | |||||
| 67 | 122 | 29µs | my $options = @_ == 1 ? $_[0] : {@_}; | ||
| 68 | |||||
| 69 | 122 | 816µs | 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. | ||||
| 101 | sub 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 13.4ms (2.66+10.7) within Class::MOP::Attribute::initialize_instance_slot which was called 966 times, avg 14µs/call:
# 966 times (2.66ms+10.7ms) by Class::MOP::Class::_construct_instance at line 525 of Class/MOP/Class.pm, avg 14µs/call | ||||
| 110 | 966 | 184µs | my ($self, $meta_instance, $instance, $params) = @_; | ||
| 111 | 966 | 222µ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) | ||||
| 117 | 966 | 6.15ms | 937 | 10.7ms | if(defined $init_arg and exists $params->{$init_arg}){ # spent 9.72ms making 749 calls to Class::MOP::Attribute::_set_initial_slot_value, avg 13µs/call
# spent 1.02ms making 188 calls to Class::MOP::Mixin::AttributeCore::default, avg 5µ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 9.75ms (7.30+2.45) within Class::MOP::Attribute::_set_initial_slot_value which was called 753 times, avg 13µs/call:
# 749 times (7.27ms+2.44ms) by Class::MOP::Attribute::initialize_instance_slot at line 117, avg 13µs/call
# 4 times (23µs+12µs) by Class::MOP::Attribute::set_initial_value at line 261, avg 9µs/call | ||||
| 146 | 753 | 178µs | my ($self, $meta_instance, $instance, $value) = @_; | ||
| 147 | |||||
| 148 | 753 | 4.70ms | 753 | 310µs | my $slot_name = $self->name; # spent 310µs making 753 calls to Class::MOP::Mixin::AttributeCore::name, avg 411ns/call |
| 149 | |||||
| 150 | 753 | 1.73ms | 1506 | 2.15ms | return $meta_instance->set_slot_value($instance, $slot_name, $value) # spent 1.49ms making 753 calls to Class::MOP::Instance::set_slot_value, avg 2µs/call
# spent 652µs making 753 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 866ns/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 | |||||
| 163 | sub _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 | |||||
| 172 | sub 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 | |||||
| 182 | sub 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 | |||||
| 192 | sub 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 | |||||
| 212 | sub 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 | |||||
| 234 | 740 | 1.93ms | 740 | 264µs | # spent 1.61ms (1.35+264µs) within Class::MOP::Attribute::slots which was called 740 times, avg 2µs/call:
# 740 times (1.35ms+264µs) by Class::MOP::Instance::BUILDARGS at line 33 of Class/MOP/Instance.pm, avg 2µs/call # spent 264µs making 740 calls to Class::MOP::Mixin::AttributeCore::name, avg 357ns/call |
| 235 | |||||
| 236 | # class association | ||||
| 237 | |||||
| 238 | # spent 1.02ms (764µs+257µs) within Class::MOP::Attribute::attach_to_class which was called 151 times, avg 7µs/call:
# 151 times (764µs+257µs) by Class::MOP::Class::_attach_attribute at line 880 of Class/MOP/Class.pm, avg 7µs/call | ||||
| 239 | 151 | 16µs | my ($self, $class) = @_; | ||
| 240 | 151 | 554µs | 302 | 157µs | (blessed($class) && $class->isa('Class::MOP::Class')) # spent 84µs making 151 calls to Scalar::Util::blessed, avg 559ns/call
# spent 73µs making 151 calls to UNIVERSAL::isa, avg 481ns/call |
| 241 | || confess "You must pass a Class::MOP::Class instance (or a subclass)"; | ||||
| 242 | 151 | 507µs | 151 | 100µs | weaken($self->{'associated_class'} = $class); # spent 100µs making 151 calls to Scalar::Util::weaken, avg 662ns/call |
| 243 | } | ||||
| 244 | |||||
| 245 | sub detach_from_class { | ||||
| 246 | my $self = shift; | ||||
| 247 | $self->{'associated_class'} = undef; | ||||
| 248 | } | ||||
| 249 | |||||
| 250 | # method association | ||||
| 251 | |||||
| 252 | # spent 506µs within Class::MOP::Attribute::associate_method which was called 306 times, avg 2µs/call:
# 223 times (383µs+0s) by Class::MOP::Attribute::_process_accessors at line 402, avg 2µs/call
# 57 times (80µs+0s) by Class::MOP::Attribute::_process_accessors at line 380, avg 1µs/call
# 26 times (43µs+0s) by Moose::Meta::Attribute::install_delegation at line 1126 of Moose/Meta/Attribute.pm, avg 2µs/call | ||||
| 253 | 306 | 62µs | my ($self, $method) = @_; | ||
| 254 | 306 | 583µs | push @{$self->{'associated_methods'}} => $method; | ||
| 255 | } | ||||
| 256 | |||||
| 257 | ## Slot management | ||||
| 258 | |||||
| 259 | # spent 90µs (34+56) within Class::MOP::Attribute::set_initial_value which was called 4 times, avg 23µs/call:
# 4 times (34µs+56µs) by Moose::Meta::Attribute::initialize_instance_slot at line 538 of Moose/Meta/Attribute.pm, avg 23µs/call | ||||
| 260 | 4 | 1µs | my ($self, $instance, $value) = @_; | ||
| 261 | 4 | 20µs | 12 | 56µs | $self->_set_initial_slot_value( # spent 35µs making 4 calls to Class::MOP::Attribute::_set_initial_slot_value, avg 9µs/call
# spent 16µs making 4 calls to Class::MOP::Class::initialize, avg 4µs/call
# spent 5µs making 4 calls to Class::MOP::Class::get_meta_instance, avg 1µs/call |
| 262 | Class::MOP::Class->initialize(ref($instance))->get_meta_instance, | ||||
| 263 | $instance, | ||||
| 264 | $value | ||||
| 265 | ); | ||||
| 266 | } | ||||
| 267 | |||||
| 268 | sub set_value { shift->set_raw_value(@_) } | ||||
| 269 | |||||
| 270 | sub 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 14.8ms (3.47+11.4) within Class::MOP::Attribute::_inline_set_value which was called 441 times, avg 34µs/call:
# 273 times (3.05ms+5.46ms) by Class::MOP::Class::_inline_init_attr_from_constructor at line 630 of Class/MOP/Class.pm, avg 31µs/call
# 96 times (226µs+1.62ms) by Class::MOP::Class::_inline_init_attr_from_default at line 651 of Class/MOP/Class.pm, avg 19µs/call
# 47 times (130µs+3.21ms) by Moose::Meta::Attribute::_inline_set_value at line 628 of Moose/Meta/Attribute.pm, avg 71µs/call
# 22 times (57µs+1.04ms) by Class::MOP::Method::Accessor::try {...} at line 112 of Class/MOP/Method/Accessor.pm, avg 50µs/call
# 3 times (7µs+42µs) by Class::MOP::Method::Accessor::try {...} at line 179 of Class/MOP/Method/Accessor.pm, avg 16µs/call | ||||
| 279 | 441 | 45µs | my $self = shift; | ||
| 280 | 441 | 6.99ms | 441 | 11.4ms | return $self->_inline_instance_set(@_) . ';'; # spent 11.4ms making 441 calls to Class::MOP::Attribute::_inline_instance_set, avg 26µs/call |
| 281 | } | ||||
| 282 | |||||
| 283 | # spent 12.0ms (3.08+8.88) within Class::MOP::Attribute::_inline_instance_set which was called 484 times, avg 25µs/call:
# 441 times (2.79ms+8.59ms) by Class::MOP::Attribute::_inline_set_value at line 280, avg 26µs/call
# 43 times (296µs+297µs) by Moose::Meta::Attribute::_inline_init_slot at line 972 of Moose/Meta/Attribute.pm, avg 14µs/call | ||||
| 284 | 484 | 13µs | my $self = shift; | ||
| 285 | 484 | 83µs | my ($instance, $value) = @_; | ||
| 286 | |||||
| 287 | 484 | 1.13ms | 968 | 6.48ms | my $mi = $self->associated_class->get_meta_instance; # spent 3.65ms making 232 calls to Class::MOP::Class::get_meta_instance, avg 16µs/call
# spent 2.63ms making 252 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 10µs/call
# spent 196µs making 484 calls to Class::MOP::Attribute::associated_class, avg 405ns/call |
| 288 | 484 | 4.17ms | 968 | 2.41ms | return $mi->inline_set_slot_value($instance, $self->name, $value); # spent 2.17ms making 484 calls to Class::MOP::Instance::inline_set_slot_value, avg 4µs/call
# spent 233µs making 484 calls to Class::MOP::Mixin::AttributeCore::name, avg 482ns/call |
| 289 | } | ||||
| 290 | |||||
| 291 | 12 | 25µs | 12 | 207µs | # spent 229µs (22+207) within Class::MOP::Attribute::get_value which was called 12 times, avg 19µs/call:
# 12 times (22µs+207µ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 19µs/call # spent 207µs making 12 calls to Class::MOP::Attribute::get_raw_value, avg 17µs/call |
| 292 | |||||
| 293 | # spent 207µs (88+119) within Class::MOP::Attribute::get_raw_value which was called 12 times, avg 17µs/call:
# 12 times (88µs+119µs) by Class::MOP::Attribute::get_value at line 291, avg 17µs/call | ||||
| 294 | 12 | 1µs | my $self = shift; | ||
| 295 | 12 | 1µs | my ($instance) = @_; | ||
| 296 | |||||
| 297 | 12 | 18µs | 24 | 99µs | my $mi = Class::MOP::Class->initialize(ref($instance))->get_meta_instance; # spent 56µs making 10 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 6µs/call
# spent 41µs making 12 calls to Class::MOP::Class::initialize, avg 3µs/call
# spent 2µs making 2 calls to Class::MOP::Class::get_meta_instance, avg 1µs/call |
| 298 | 12 | 47µs | 24 | 21µs | return $mi->get_slot_value($instance, $self->name); # spent 14µs making 12 calls to Class::MOP::Instance::get_slot_value, avg 1µs/call
# spent 6µs making 12 calls to Class::MOP::Mixin::AttributeCore::name, avg 525ns/call |
| 299 | } | ||||
| 300 | |||||
| 301 | # spent 8.84ms (193µs+8.65) within Class::MOP::Attribute::_inline_get_value which was called 75 times, avg 118µs/call:
# 53 times (136µs+8.37ms) by Class::MOP::Method::Accessor::try {...} at line 142 of Class/MOP/Method/Accessor.pm, avg 161µs/call
# 22 times (57µs+275µs) by Class::MOP::Method::Accessor::try {...} at line 112 of Class/MOP/Method/Accessor.pm, avg 15µs/call | ||||
| 302 | 75 | 8µs | my $self = shift; | ||
| 303 | 75 | 157µs | 75 | 8.65ms | return $self->_inline_instance_get(@_) . ';'; # spent 8.65ms making 75 calls to Class::MOP::Attribute::_inline_instance_get, avg 115µs/call |
| 304 | } | ||||
| 305 | |||||
| 306 | # spent 10.2ms (4.35+5.89) within Class::MOP::Attribute::_inline_instance_get which was called 128 times, avg 80µs/call:
# 75 times (3.99ms+4.65ms) by Class::MOP::Attribute::_inline_get_value at line 303, avg 115µs/call
# 27 times (185µs+722µs) by Moose::Meta::Attribute::_inline_get_value at line 874 of Moose/Meta/Attribute.pm, avg 34µs/call
# 26 times (178µs+515µs) by Moose::Meta::Method::Accessor::_get_value at line 123 of Moose/Meta/Method/Accessor.pm, avg 27µs/call | ||||
| 307 | 128 | 12µs | my $self = shift; | ||
| 308 | 128 | 31µs | my ($instance) = @_; | ||
| 309 | |||||
| 310 | 128 | 3.80ms | 256 | 2.30ms | my $mi = $self->associated_class->get_meta_instance; # spent 2.25ms making 128 calls to Class::MOP::Class::get_meta_instance, avg 18µs/call
# spent 58µs making 128 calls to Class::MOP::Attribute::associated_class, avg 451ns/call |
| 311 | 128 | 496µs | 256 | 3.59ms | return $mi->inline_get_slot_value($instance, $self->name); # spent 3.52ms making 128 calls to Class::MOP::Instance::inline_get_slot_value, avg 28µs/call
# spent 64µs making 128 calls to Class::MOP::Mixin::AttributeCore::name, avg 497ns/call |
| 312 | } | ||||
| 313 | |||||
| 314 | # spent 210µs (89+121) within Class::MOP::Attribute::has_value which was called 12 times, avg 17µs/call:
# 12 times (89µs+121µ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 17µs/call | ||||
| 315 | 12 | 1µs | my $self = shift; | ||
| 316 | 12 | 2µs | my ($instance) = @_; | ||
| 317 | |||||
| 318 | 12 | 18µs | 24 | 97µs | my $mi = Class::MOP::Class->initialize(ref($instance))->get_meta_instance; # spent 49µs making 9 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 5µs/call
# spent 44µs making 12 calls to Class::MOP::Class::initialize, avg 4µs/call
# spent 3µs making 3 calls to Class::MOP::Class::get_meta_instance, avg 1µs/call |
| 319 | 12 | 55µs | 24 | 24µs | return $mi->is_slot_initialized($instance, $self->name); # spent 17µs making 12 calls to Class::MOP::Instance::is_slot_initialized, avg 1µs/call
# spent 7µs making 12 calls to Class::MOP::Mixin::AttributeCore::name, avg 567ns/call |
| 320 | } | ||||
| 321 | |||||
| 322 | # spent 434µs (70+365) within Class::MOP::Attribute::_inline_has_value which was called 24 times, avg 18µs/call:
# 24 times (70µs+365µs) by Class::MOP::Method::Accessor::try {...} at line 204 of Class/MOP/Method/Accessor.pm, avg 18µs/call | ||||
| 323 | 24 | 3µs | my $self = shift; | ||
| 324 | 24 | 57µs | 24 | 365µs | return $self->_inline_instance_has(@_) . ';'; # spent 365µs making 24 calls to Class::MOP::Attribute::_inline_instance_has, avg 15µs/call |
| 325 | } | ||||
| 326 | |||||
| 327 | # spent 944µs (479+465) within Class::MOP::Attribute::_inline_instance_has which was called 67 times, avg 14µs/call:
# 43 times (298µs+281µs) by Moose::Meta::Attribute::_inline_check_lazy at line 891 of Moose/Meta/Attribute.pm, avg 13µs/call
# 24 times (181µs+184µs) by Class::MOP::Attribute::_inline_has_value at line 324, avg 15µs/call | ||||
| 328 | 67 | 10µs | my $self = shift; | ||
| 329 | 67 | 11µs | my ($instance) = @_; | ||
| 330 | |||||
| 331 | 67 | 176µs | 134 | 102µs | my $mi = $self->associated_class->get_meta_instance; # spent 71µs making 67 calls to Class::MOP::Class::get_meta_instance, avg 1µs/call
# spent 30µs making 67 calls to Class::MOP::Attribute::associated_class, avg 455ns/call |
| 332 | 67 | 269µs | 134 | 363µs | return $mi->inline_is_slot_initialized($instance, $self->name); # spent 331µs making 67 calls to Class::MOP::Instance::inline_is_slot_initialized, avg 5µs/call
# spent 33µs making 67 calls to Class::MOP::Mixin::AttributeCore::name, avg 487ns/call |
| 333 | } | ||||
| 334 | |||||
| 335 | sub 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 | |||||
| 343 | sub _inline_clear_value { | ||||
| 344 | my $self = shift; | ||||
| 345 | return $self->_inline_instance_clear(@_) . ';'; | ||||
| 346 | } | ||||
| 347 | |||||
| 348 | sub _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 | |||||
| 358 | 245 | 326µs | sub accessor_metaclass { 'Class::MOP::Method::Accessor' } | ||
| 359 | |||||
| 360 | # spent 106ms (5.42+101) within Class::MOP::Attribute::_process_accessors which was called 280 times, avg 379µs/call:
# 150 times (2.93ms+27.1ms) by Class::MOP::Attribute::install_accessors at line 428, avg 200µs/call
# 45 times (889µs+8.35ms) by Class::MOP::Attribute::install_accessors at line 424, avg 205µs/call
# 42 times (776µs+5.28ms) by Class::MOP::Attribute::install_accessors at line 436, avg 144µs/call
# 35 times (671µs+58.9ms) by Moose::Meta::Attribute::_process_accessors at line 1078 of Moose/Meta/Attribute.pm, avg 1.70ms/call
# 8 times (147µs+1.09ms) by Class::MOP::Attribute::install_accessors at line 432, avg 155µs/call | ||||
| 361 | 280 | 98µs | my ($self, $type, $accessor, $generate_as_inline_methods) = @_; | ||
| 362 | |||||
| 363 | 280 | 1.15ms | 280 | 130µs | my $method_ctx = { %{ $self->definition_context || {} } }; # spent 130µs making 280 calls to Class::MOP::Mixin::AttributeCore::definition_context, avg 466ns/call |
| 364 | |||||
| 365 | 280 | 48µs | if (ref($accessor)) { | ||
| 366 | 57 | 10µs | (ref($accessor) eq 'HASH') | ||
| 367 | || confess "bad accessor/reader/writer/predicate/clearer format, must be a HASH ref"; | ||||
| 368 | 57 | 39µs | my ($name, $method) = %{$accessor}; | ||
| 369 | |||||
| 370 | 57 | 66µs | 57 | 482µs | $method_ctx->{description} = $self->_accessor_description($name, $type); # spent 482µs making 57 calls to Class::MOP::Attribute::_accessor_description, avg 8µs/call |
| 371 | |||||
| 372 | 57 | 381µs | 285 | 1.96ms | $method = $self->accessor_metaclass->wrap( # spent 1.85ms making 57 calls to Class::MOP::Method::wrap, avg 32µs/call
# spent 45µs making 114 calls to Class::MOP::Attribute::associated_class, avg 398ns/call
# spent 40µs making 57 calls to Class::MOP::Attribute::accessor_metaclass, avg 707ns/call
# spent 21µs making 57 calls to Class::MOP::Package::name, avg 368ns/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 | ); | ||||
| 380 | 57 | 42µs | 57 | 80µs | $self->associate_method($method); # spent 80µs making 57 calls to Class::MOP::Attribute::associate_method, avg 1µs/call |
| 381 | 57 | 105µs | return ($name, $method); | ||
| 382 | } | ||||
| 383 | else { | ||||
| 384 | 223 | 425µs | 285 | 145µs | my $inline_me = ($generate_as_inline_methods && $self->associated_class->instance_metaclass->is_inlinable); # spent 60µs making 95 calls to Class::MOP::Instance::is_inlinable, avg 635ns/call
# spent 45µs making 95 calls to Class::MOP::Attribute::associated_class, avg 473ns/call
# spent 40µs making 95 calls to Class::MOP::Class::instance_metaclass, avg 418ns/call |
| 385 | 223 | 600ns | my $method; | ||
| 386 | try { | ||||
| 387 | 223 | 255µs | 223 | 1.87ms | $method_ctx->{description} = $self->_accessor_description($accessor, $type); # spent 1.87ms making 223 calls to Class::MOP::Attribute::_accessor_description, avg 8µs/call |
| 388 | |||||
| 389 | 223 | 1.67ms | 1115 | 32.2ms | $method = $self->accessor_metaclass->new( # spent 31.7ms making 188 calls to Class::MOP::Method::Accessor::new, avg 169µs/call
# spent 174µs making 446 calls to Class::MOP::Attribute::associated_class, avg 389ns/call
# spent 136µs making 188 calls to Class::MOP::Attribute::accessor_metaclass, avg 723ns/call
# spent 80µs making 223 calls to Class::MOP::Package::name, avg 359ns/call
# spent 51µs making 35 calls to Moose::Meta::Method::Accessor::new, avg 1µs/call
# spent 28µs making 35 calls to Moose::Meta::Attribute::accessor_metaclass, avg 803ns/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 : $_"; | ||||
| 401 | 223 | 1.81ms | 446 | 33.1ms | }; # spent 97.0ms making 223 calls to Try::Tiny::try, avg 435µs/call, recursion: max depth 2, sum of overlapping time 64.4ms
# spent 484µs making 223 calls to Try::Tiny::catch, avg 2µs/call |
| 402 | 223 | 232µs | 223 | 383µs | $self->associate_method($method); # spent 383µs making 223 calls to Class::MOP::Attribute::associate_method, avg 2µs/call |
| 403 | 223 | 429µs | return ($accessor, $method); | ||
| 404 | } | ||||
| 405 | } | ||||
| 406 | |||||
| 407 | # spent 2.35ms (1.95+406µs) within Class::MOP::Attribute::_accessor_description which was called 280 times, avg 8µs/call:
# 223 times (1.55ms+324µs) by Class::MOP::Attribute::try {...} at line 387, avg 8µs/call
# 57 times (400µs+82µs) by Class::MOP::Attribute::_process_accessors at line 370, avg 8µs/call | ||||
| 408 | 280 | 30µs | my $self = shift; | ||
| 409 | 280 | 57µs | my ($name, $type) = @_; | ||
| 410 | |||||
| 411 | 280 | 1.14ms | 560 | 250µs | my $desc = "$type " . $self->associated_class->name . "::$name"; # spent 125µs making 280 calls to Class::MOP::Package::name, avg 447ns/call
# spent 125µs making 280 calls to Class::MOP::Attribute::associated_class, avg 445ns/call |
| 412 | 280 | 708µs | 394 | 156µs | if ( $name ne $self->name ) { # spent 156µs making 394 calls to Class::MOP::Mixin::AttributeCore::name, avg 396ns/call |
| 413 | $desc .= " of attribute " . $self->name; | ||||
| 414 | } | ||||
| 415 | |||||
| 416 | 280 | 513µs | return $desc; | ||
| 417 | } | ||||
| 418 | |||||
| 419 | # spent 139ms (4.13+134) within Class::MOP::Attribute::install_accessors which was called 227 times, avg 610µs/call:
# 122 times (2.30ms+23.5ms) by Class::MOP::Class::try {...} at line 891 of Class/MOP/Class.pm, avg 212µs/call
# 75 times (1.24ms+42.7ms) by Class::MOP::Class::_inline_accessors at line 1413 of Class/MOP/Class.pm, avg 586µs/call
# 30 times (590µs+68.1ms) by Moose::Meta::Attribute::install_accessors at line 1017 of Moose/Meta/Attribute.pm, avg 2.29ms/call | ||||
| 420 | 227 | 23µs | my $self = shift; | ||
| 421 | 227 | 24µs | my $inline = shift; | ||
| 422 | 227 | 478µs | 227 | 112µs | my $class = $self->associated_class; # spent 112µs making 227 calls to Class::MOP::Attribute::associated_class, avg 492ns/call |
| 423 | |||||
| 424 | 227 | 455µs | 428 | 60.1ms | $class->add_method( # spent 46.9ms making 22 calls to Moose::Meta::Attribute::_process_accessors, avg 2.13ms/call
# spent 9.24ms making 45 calls to Class::MOP::Attribute::_process_accessors, avg 205µs/call
# spent 3.66ms making 67 calls to Class::MOP::Mixin::HasMethods::add_method, avg 55µs/call
# spent 256µs making 227 calls to Class::MOP::Mixin::AttributeCore::has_accessor, avg 1µs/call
# spent 33µs making 67 calls to Class::MOP::Mixin::AttributeCore::accessor, avg 493ns/call |
| 425 | $self->_process_accessors('accessor' => $self->accessor(), $inline) | ||||
| 426 | ) if $self->has_accessor(); | ||||
| 427 | |||||
| 428 | 227 | 760µs | 692 | 54.7ms | $class->add_method( # spent 30.0ms making 150 calls to Class::MOP::Attribute::_process_accessors, avg 200µs/call
# spent 18.2ms making 155 calls to Class::MOP::Mixin::HasMethods::add_method, avg 118µs/call
# spent 6.13ms making 5 calls to Moose::Meta::Attribute::_process_accessors, avg 1.23ms/call
# spent 229µs making 227 calls to Class::MOP::Mixin::AttributeCore::has_reader, avg 1µs/call
# spent 80µs making 155 calls to Class::MOP::Mixin::AttributeCore::reader, avg 515ns/call |
| 429 | $self->_process_accessors('reader' => $self->reader(), $inline) | ||||
| 430 | ) if $self->has_reader(); | ||||
| 431 | |||||
| 432 | 227 | 251µs | 251 | 1.91ms | $class->add_method( # spent 1.24ms making 8 calls to Class::MOP::Attribute::_process_accessors, avg 155µs/call
# spent 411µs making 8 calls to Class::MOP::Mixin::HasMethods::add_method, avg 51µs/call
# spent 256µs making 227 calls to Class::MOP::Mixin::AttributeCore::has_writer, avg 1µs/call
# spent 4µs making 8 calls to Class::MOP::Mixin::AttributeCore::writer, avg 562ns/call |
| 433 | $self->_process_accessors('writer' => $self->writer(), $inline) | ||||
| 434 | ) if $self->has_writer(); | ||||
| 435 | |||||
| 436 | 227 | 364µs | 377 | 17.4ms | $class->add_method( # spent 8.56ms making 8 calls to Moose::Meta::Attribute::_process_accessors, avg 1.07ms/call
# spent 6.06ms making 42 calls to Class::MOP::Attribute::_process_accessors, avg 144µs/call
# spent 2.56ms making 50 calls to Class::MOP::Mixin::HasMethods::add_method, avg 51µs/call
# spent 186µs making 227 calls to Class::MOP::Mixin::AttributeCore::has_predicate, avg 821ns/call
# spent 25µs making 50 calls to Class::MOP::Mixin::AttributeCore::predicate, avg 504ns/call |
| 437 | $self->_process_accessors('predicate' => $self->predicate(), $inline) | ||||
| 438 | ) if $self->has_predicate(); | ||||
| 439 | |||||
| 440 | 227 | 175µs | 227 | 197µs | $class->add_method( # spent 197µs making 227 calls to Class::MOP::Mixin::AttributeCore::has_clearer, avg 869ns/call |
| 441 | $self->_process_accessors('clearer' => $self->clearer(), $inline) | ||||
| 442 | ) if $self->has_clearer(); | ||||
| 443 | |||||
| 444 | 227 | 356µs | return; | ||
| 445 | } | ||||
| 446 | |||||
| 447 | { | ||||
| 448 | 1 | 100ns | 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')); | ||||
| 456 | 1 | 2µ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 | |||||
| 475 | 1 | 3µs | 1; | ||
| 476 | |||||
| 477 | # ABSTRACT: Attribute Meta Object | ||||
| 478 | |||||
| 479 | __END__ |