Profile of /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP/Method/Accessor.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For 05.Domain_and_Item.t
Run on Tue May 4 17:21:41 2010
Reported on Tue May 4 17:22:32 2010

File | /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP/Method/Accessor.pm
Statements Executed | 6563
Statement Execution Time | 20.1ms

Subroutines — ordered by exclusive time
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
276 | 1 | 1 | 10.5ms | 76.2ms | Class::MOP::Method::Accessor::::newClass::MOP::Method::Accessor::new
276 | 1 | 1 | 2.58ms | 59.5ms | Class::MOP::Method::Accessor::::_initialize_bodyClass::MOP::Method::Accessor::_initialize_body
223 | 2 | 2 | 2.09ms | 2.09ms | Class::MOP::Method::Accessor::::_newClass::MOP::Method::Accessor::_new
52 | 1 | 1 | 918µs | 4.39ms | Class::MOP::Method::Accessor::::_generate_reader_method_inlineClass::MOP::Method::Accessor::_generate_reader_method_inline
880 | 27 | 3 | 816µs | 816µs | Class::MOP::Method::Accessor::::associated_attributeClass::MOP::Method::Accessor::associated_attribute
31 | 2 | 2 | 631µs | 2.44ms | Class::MOP::Method::Accessor::::_generate_predicate_method_inlineClass::MOP::Method::Accessor::_generate_predicate_method_inline
15 | 1 | 1 | 308µs | 1.47ms | Class::MOP::Method::Accessor::::_generate_accessor_method_inlineClass::MOP::Method::Accessor::_generate_accessor_method_inline
52 | 1 | 1 | 306µs | 353µs | Class::MOP::Method::Accessor::::_generate_reader_methodClass::MOP::Method::Accessor::_generate_reader_method
276 | 1 | 1 | 296µs | 296µs | Class::MOP::Method::Accessor::::accessor_typeClass::MOP::Method::Accessor::accessor_type
3 | 1 | 1 | 102µs | 295µs | Class::MOP::Method::Accessor::::_generate_clearer_method_inlineClass::MOP::Method::Accessor::_generate_clearer_method_inline
15 | 1 | 1 | 86µs | 98µs | Class::MOP::Method::Accessor::::_generate_accessor_methodClass::MOP::Method::Accessor::_generate_accessor_method
3 | 1 | 1 | 68µs | 258µs | Class::MOP::Method::Accessor::::_generate_writer_method_inlineClass::MOP::Method::Accessor::_generate_writer_method_inline
13 | 1 | 1 | 63µs | 73µs | Class::MOP::Method::Accessor::::_generate_predicate_methodClass::MOP::Method::Accessor::_generate_predicate_method
3 | 1 | 1 | 20µs | 22µs | Class::MOP::Method::Accessor::::_generate_writer_methodClass::MOP::Method::Accessor::_generate_writer_method
1 | 1 | 1 | 14µs | 17µs | Class::MOP::Method::Accessor::::BEGIN@4Class::MOP::Method::Accessor::BEGIN@4
1 | 1 | 1 | 7µs | 17µs | Class::MOP::Method::Accessor::::BEGIN@5Class::MOP::Method::Accessor::BEGIN@5
1 | 1 | 1 | 7µs | 37µs | Class::MOP::Method::Accessor::::BEGIN@8Class::MOP::Method::Accessor::BEGIN@8
1 | 1 | 1 | 6µs | 1.64ms | Class::MOP::Method::Accessor::::BEGIN@14Class::MOP::Method::Accessor::BEGIN@14
1 | 1 | 1 | 6µs | 32µs | Class::MOP::Method::Accessor::::BEGIN@7Class::MOP::Method::Accessor::BEGIN@7
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Accessor::::__ANON__[:105]Class::MOP::Method::Accessor::__ANON__[:105]
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Accessor::::__ANON__[:113]Class::MOP::Method::Accessor::__ANON__[:113]
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Accessor::::__ANON__[:120]Class::MOP::Method::Accessor::__ANON__[:120]
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Accessor::::__ANON__[:127]Class::MOP::Method::Accessor::__ANON__[:127]
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Accessor::::__ANON__[:97]Class::MOP::Method::Accessor::__ANON__[:97]
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Accessor::::_generate_clearer_methodClass::MOP::Method::Accessor::_generate_clearer_method

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  |
2 |  |  |  |  | package Class::MOP::Method::Accessor;
3 |  |  |  |  |
4 | 3 | 26µs | 2 | 20µs | # spent 17µs (14+3) within Class::MOP::Method::Accessor::BEGIN@4 which was called # once (14µs+3µs) by Class::MOP::Class::BEGIN@9 at line 4 use strict; # spent 17µs making 1 call to Class::MOP::Method::Accessor::BEGIN@4 # spent 3µs making 1 call to strict::import
5 | 3 | 22µs | 2 | 27µs | # spent 17µs (7+10) within Class::MOP::Method::Accessor::BEGIN@5 which was called # once (7µs+10µs) by Class::MOP::Class::BEGIN@9 at line 5 use warnings; # spent 17µs making 1 call to Class::MOP::Method::Accessor::BEGIN@5 # spent 10µs making 1 call to warnings::import
6 |  |  |  |  |
7 | 3 | 24µs | 2 | 58µs | # spent 32µs (6+26) within Class::MOP::Method::Accessor::BEGIN@7 which was called # once (6µs+26µs) by Class::MOP::Class::BEGIN@9 at line 7 use Carp 'confess'; # spent 32µs making 1 call to Class::MOP::Method::Accessor::BEGIN@7 # spent 26µs making 1 call to Exporter::import
8 | 3 | 43µs | 2 | 67µs | # spent 37µs (7+30) within Class::MOP::Method::Accessor::BEGIN@8 which was called # once (7µs+30µs) by Class::MOP::Class::BEGIN@9 at line 8 use Scalar::Util 'blessed', 'weaken'; # spent 37µs making 1 call to Class::MOP::Method::Accessor::BEGIN@8 # spent 30µs making 1 call to Exporter::import
9 |  |  |  |  |
10 | 1 | 700ns |  |  | our $VERSION = '0.98';
11 | 1 | 14µs |  |  | $VERSION = eval $VERSION;
12 | 1 | 300ns |  |  | our $AUTHORITY = 'cpan:STEVAN';
13 |  |  |  |  |
14 | 3 | 888µs | 2 | 3.27ms | # spent 1.64ms (6µs+1.63) within Class::MOP::Method::Accessor::BEGIN@14 which was called # once (6µs+1.63ms) by Class::MOP::Class::BEGIN@9 at line 14 use base 'Class::MOP::Method::Generated'; # spent 1.64ms making 1 call to Class::MOP::Method::Accessor::BEGIN@14 # spent 1.63ms making 1 call to base::import
15 |  |  |  |  |
16 |  |  |  |  | # spent 76.2ms (10.5+65.7) within Class::MOP::Method::Accessor::new which was called 276 times, avg 276µs/call: # 276 times (10.5ms+65.7ms) by Class::MOP::Attribute::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP/Attribute.pm:340] at line 332 of Class/MOP/Attribute.pm, avg 276µs/call sub new {
17 | 2760 | 10.7ms |  |  | my $class = shift;
18 |  |  |  |  | my %options = @_;
19 |  |  |  |  |
20 |  |  |  |  | (exists $options{attribute})
21 |  |  |  |  | || confess "You must supply an attribute to construct with";
22 |  |  |  |  |
23 |  |  |  |  | (exists $options{accessor_type})
24 |  |  |  |  | || confess "You must supply an accessor_type to construct with";
25 |  |  |  |  |
26 |  |  |  |  | (blessed($options{attribute}) && $options{attribute}->isa('Class::MOP::Attribute')) # spent 229µs making 276 calls to UNIVERSAL::isa, avg 832ns/call # spent 208µs making 276 calls to Scalar::Util::blessed, avg 754ns/call
27 |  |  |  |  | || confess "You must supply an attribute which is a 'Class::MOP::Attribute' instance";
28 |  |  |  |  |
29 |  |  |  |  | ($options{package_name} && $options{name})
30 |  |  |  |  | || confess "You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT";
31 |  |  |  |  |
32 |  |  |  |  | my $self = $class->_new(\%options); # spent 2.97ms making 108 calls to Moose::Meta::Method::Accessor::_new, avg 27µs/call # spent 1.45ms making 166 calls to Class::MOP::Method::Accessor::_new, avg 9µs/call # spent 1.04ms making 2 calls to Class::MOP::Method::_new, avg 520µs/call
33 |  |  |  |  |
34 |  |  |  |  | # we don't want this creating
35 |  |  |  |  | # a cycle in the code, if not
36 |  |  |  |  | # needed
37 |  |  |  |  | weaken($self->{'attribute'}); # spent 344µs making 276 calls to Scalar::Util::weaken, avg 1µs/call
38 |  |  |  |  |
39 |  |  |  |  | $self->_initialize_body; # spent 59.5ms making 276 calls to Class::MOP::Method::Accessor::_initialize_body, avg 216µs/call
40 |  |  |  |  |
41 |  |  |  |  | return $self;
42 |  |  |  |  | }
43 |  |  |  |  |
44 |  |  |  |  | # spent 2.09ms within Class::MOP::Method::Accessor::_new which was called 223 times, avg 9µs/call: # 166 times (1.45ms+0s) by Class::MOP::Method::Accessor::new at line 32, avg 9µs/call # 57 times (649µs+0s) by Class::MOP::Method::wrap at line 44 of Class/MOP/Method.pm, avg 11µs/call sub _new {
45 | 892 | 2.24ms |  |  | my $class = shift;
46 |  |  |  |  |
47 |  |  |  |  | return Class::MOP::Class->initialize($class)->new_object(@_)
48 |  |  |  |  | if $class ne __PACKAGE__;
49 |  |  |  |  |
50 |  |  |  |  | my $params = @_ == 1 ? $_[0] : {@_};
51 |  |  |  |  |
52 |  |  |  |  | return bless {
53 |  |  |  |  | # inherited from Class::MOP::Method
54 |  |  |  |  | body => $params->{body},
55 |  |  |  |  | associated_metaclass => $params->{associated_metaclass},
56 |  |  |  |  | package_name => $params->{package_name},
57 |  |  |  |  | name => $params->{name},
58 |  |  |  |  | original_method => $params->{original_method},
59 |  |  |  |  |
60 |  |  |  |  | # inherit from Class::MOP::Generated
61 |  |  |  |  | is_inline => $params->{is_inline} || 0,
62 |  |  |  |  | definition_context => $params->{definition_context},
63 |  |  |  |  |
64 |  |  |  |  | # defined in this class
65 |  |  |  |  | attribute => $params->{attribute},
66 |  |  |  |  | accessor_type => $params->{accessor_type},
67 |  |  |  |  | } => $class;
68 |  |  |  |  | }
69 |  |  |  |  |
70 |  |  |  |  | ## accessors
71 |  |  |  |  |
72 | 880 | 1.77ms |  |  | # spent 816µs within Class::MOP::Method::Accessor::associated_attribute which was called 880 times, avg 928ns/call: # 89 times (106µs+0s) by Moose::Meta::Method::Accessor::_inline_check_lazy at line 158 of Moose/Meta/Method/Accessor.pm, avg 1µs/call # 89 times (80µs+0s) by Moose::Meta::Method::Accessor::_inline_auto_deref at line 277 of Moose/Meta/Method/Accessor.pm, avg 902ns/call # 89 times (75µs+0s) by Moose::Meta::Method::Accessor::_eval_code at line 24 of Moose/Meta/Method/Accessor.pm, avg 837ns/call # 89 times (68µs+0s) by Moose::Meta::Method::Accessor::_inline_get at line 250 of Moose/Meta/Method/Accessor.pm, avg 761ns/call # 68 times (77µs+0s) by Moose::Meta::Method::Accessor::_generate_reader_method_inline at line 91 of Moose/Meta/Method/Accessor.pm, avg 1µs/call # 52 times (47µs+0s) by Class::MOP::Method::Accessor::_generate_reader_method at line 101, avg 902ns/call # 52 times (46µs+0s) by Class::MOP::Method::Accessor::_generate_reader_method_inline at line 153, avg 877ns/call # 42 times (39µs+0s) by Moose::Meta::Method::Accessor::_inline_store at line 216 of Moose/Meta/Method/Accessor.pm, avg 921ns/call # 42 times (33µs+0s) by Moose::Meta::Method::Accessor::_value_needs_copy at line 110 of Moose/Meta/Method/Accessor.pm, avg 795ns/call # 38 times (36µs+0s) by Moose::Meta::Method::Accessor::_inline_check_coercion at line 138 of Moose/Meta/Method/Accessor.pm, avg 937ns/call # 38 times (34µs+0s) by Moose::Meta::Method::Accessor::_inline_check_constraint at line 126 of Moose/Meta/Method/Accessor.pm, avg 887ns/call # 31 times (27µs+0s) by Class::MOP::Method::Accessor::_generate_predicate_method_inline at line 188, avg 868ns/call # 22 times (18µs+0s) by Moose::Meta::Method::Accessor::_inline_has at line 268 of Moose/Meta/Method/Accessor.pm, avg 841ns/call # 21 times (26µs+0s) by Moose::Meta::Method::Accessor::_inline_trigger at line 243 of Moose/Meta/Method/Accessor.pm, avg 1µs/call # 21 times (22µs+0s) by Moose::Meta::Method::Accessor::_generate_accessor_method_inline at line 48 of Moose/Meta/Method/Accessor.pm, avg 1µs/call # 21 times (17µs+0s) by Moose::Meta::Method::Accessor::_inline_check_required at line 146 of Moose/Meta/Method/Accessor.pm, avg 819ns/call # 20 times (19µs+0s) by Moose::Meta::Method::Accessor::_inline_get_old_value_for_trigger at line 229 of Moose/Meta/Method/Accessor.pm, avg 945ns/call # 15 times (13µs+0s) by Class::MOP::Method::Accessor::_generate_accessor_method_inline at line 134, avg 873ns/call # 15 times (13µs+0s) by Class::MOP::Method::Accessor::_generate_accessor_method at line 93, avg 840ns/call # 13 times (10µs+0s) by Class::MOP::Method::Accessor::_generate_predicate_method at line 117, avg 808ns/call # 3 times (3µs+0s) by Class::MOP::Method::Accessor::_generate_clearer_method_inline at line 205, avg 867ns/call # 3 times (3µs+0s) by Class::MOP::Method::Accessor::_generate_writer_method_inline at line 171, avg 867ns/call # 3 times (2µs+0s) by Class::MOP::Method::Accessor::_generate_writer_method at line 110, avg 800ns/call # once (1µs+0s) by MooseX::ClassAttribute::Meta::Method::Accessor::_inline_get at line 61 of MooseX/ClassAttribute/Meta/Method/Accessor.pm # once (1µs+0s) by MooseX::ClassAttribute::Meta::Method::Accessor::_inline_get_old_value_for_trigger at line 107 of MooseX/ClassAttribute/Meta/Method/Accessor.pm # once (900ns+0s) by MooseX::ClassAttribute::Meta::Method::Accessor::_inline_store at line 46 of MooseX/ClassAttribute/Meta/Method/Accessor.pm # once (800ns+0s) by MooseX::ClassAttribute::Meta::Method::Accessor::_inline_check_lazy at line 99 of MooseX/ClassAttribute/Meta/Method/Accessor.pm sub associated_attribute { (shift)->{'attribute'} }
73 | 276 | 535µs |  |  | # spent 296µs within Class::MOP::Method::Accessor::accessor_type which was called 276 times, avg 1µs/call: # 276 times (296µs+0s) by Class::MOP::Method::Accessor::_initialize_body at line 80, avg 1µs/call sub accessor_type { (shift)->{'accessor_type'} }
74 |  |  |  |  |
75 |  |  |  |  | ## factory
76 |  |  |  |  |
77 |  |  |  |  | # spent 59.5ms (2.58+56.9) within Class::MOP::Method::Accessor::_initialize_body which was called 276 times, avg 216µs/call: # 276 times (2.58ms+56.9ms) by Class::MOP::Method::Accessor::new at line 39, avg 216µs/call sub _initialize_body {
78 | 828 | 1.92ms |  |  | my $self = shift;
79 |  |  |  |  |
80 |  |  |  |  | my $method_name = join "_" => ( # spent 315µs making 276 calls to Class::MOP::Method::Generated::is_inline, avg 1µs/call # spent 296µs making 276 calls to Class::MOP::Method::Accessor::accessor_type, avg 1µs/call
81 |  |  |  |  | '_generate',
82 |  |  |  |  | $self->accessor_type,
83 |  |  |  |  | 'method',
84 |  |  |  |  | ($self->is_inline ? 'inline' : ())
85 |  |  |  |  | );
86 |  |  |  |  |
87 |  |  |  |  | $self->{'body'} = $self->$method_name(); # spent 33.8ms making 67 calls to Moose::Meta::Method::Accessor::_generate_reader_method, avg 505µs/call # spent 12.5ms making 21 calls to Moose::Meta::Method::Accessor::_generate_accessor_method, avg 596µs/call # spent 4.39ms making 52 calls to Class::MOP::Method::Accessor::_generate_reader_method_inline, avg 84µs/call # spent 1.55ms making 18 calls to Moose::Meta::Method::Accessor::_generate_predicate_method, avg 86µs/call # spent 1.47ms making 15 calls to Class::MOP::Method::Accessor::_generate_accessor_method_inline, avg 98µs/call # spent 999µs making 13 calls to Class::MOP::Method::Accessor::_generate_predicate_method_inline, avg 77µs/call # spent 430µs making 1 call to Moose::Meta::Method::Accessor::_generate_reader_method_inline # spent 353µs making 52 calls to Class::MOP::Method::Accessor::_generate_reader_method, avg 7µs/call # spent 324µs making 3 calls to Moose::Meta::Method::Accessor::_generate_clearer_method, avg 108µs/call # spent 258µs making 3 calls to Class::MOP::Method::Accessor::_generate_writer_method_inline, avg 86µs/call # spent 98µs making 15 calls to Class::MOP::Method::Accessor::_generate_accessor_method, avg 7µs/call # spent 73µs making 13 calls to Class::MOP::Method::Accessor::_generate_predicate_method, avg 6µs/call # spent 22µs making 3 calls to Class::MOP::Method::Accessor::_generate_writer_method, avg 7µs/call
88 |  |  |  |  | }
89 |  |  |  |  |
90 |  |  |  |  | ## generators
91 |  |  |  |  |
92 |  |  |  |  | # spent 98µs (86+13) within Class::MOP::Method::Accessor::_generate_accessor_method which was called 15 times, avg 7µs/call: # 15 times (86µs+13µs) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 7µs/call sub _generate_accessor_method {
93 | 30 | 79µs | 15 | 13µs | my $attr = (shift)->associated_attribute; # spent 13µs making 15 calls to Class::MOP::Method::Accessor::associated_attribute, avg 840ns/call
94 |  |  |  |  | return sub {
95 |  |  |  |  | $attr->set_value($_[0], $_[1]) if scalar(@_) == 2;
96 |  |  |  |  | $attr->get_value($_[0]);
97 |  |  |  |  | };
98 |  |  |  |  | }
99 |  |  |  |  |
100 |  |  |  |  | # spent 353µs (306+47) within Class::MOP::Method::Accessor::_generate_reader_method which was called 52 times, avg 7µs/call: # 52 times (306µs+47µs) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 7µs/call sub _generate_reader_method {
101 | 104 | 281µs | 52 | 47µs | my $attr = (shift)->associated_attribute; # spent 47µs making 52 calls to Class::MOP::Method::Accessor::associated_attribute, avg 902ns/call
102 |  |  |  |  | return sub {
103 | 12 | 27µs |  |  | confess "Cannot assign a value to a read-only accessor" if @_ > 1;
104 |  |  |  |  | $attr->get_value($_[0]); # spent 161µs making 6 calls to Class::MOP::Attribute::get_value, avg 27µs/call
105 |  |  |  |  | };
106 |  |  |  |  | }
107 |  |  |  |  |
108 |  |  |  |  |
109 |  |  |  |  | # spent 22µs (20+2) within Class::MOP::Method::Accessor::_generate_writer_method which was called 3 times, avg 7µs/call: # 3 times (20µs+2µs) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 7µs/call sub _generate_writer_method {
110 | 6 | 16µs | 3 | 2µs | my $attr = (shift)->associated_attribute; # spent 2µs making 3 calls to Class::MOP::Method::Accessor::associated_attribute, avg 800ns/call
111 |  |  |  |  | return sub {
112 |  |  |  |  | $attr->set_value($_[0], $_[1]);
113 |  |  |  |  | };
114 |  |  |  |  | }
115 |  |  |  |  |
116 |  |  |  |  | # spent 73µs (63+10) within Class::MOP::Method::Accessor::_generate_predicate_method which was called 13 times, avg 6µs/call: # 13 times (63µs+10µs) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 6µs/call sub _generate_predicate_method {
117 | 26 | 54µs | 13 | 10µs | my $attr = (shift)->associated_attribute; # spent 10µs making 13 calls to Class::MOP::Method::Accessor::associated_attribute, avg 808ns/call
118 |  |  |  |  | return sub {
119 | 2 | 9µs | 2 | 57µs | $attr->has_value($_[0]) # spent 57µs making 2 calls to Class::MOP::Attribute::has_value, avg 29µs/call
120 |  |  |  |  | };
121 |  |  |  |  | }
122 |  |  |  |  |
123 |  |  |  |  | sub _generate_clearer_method {
124 |  |  |  |  | my $attr = (shift)->associated_attribute;
125 |  |  |  |  | return sub {
126 |  |  |  |  | $attr->clear_value($_[0])
127 |  |  |  |  | };
128 |  |  |  |  | }
129 |  |  |  |  |
130 |  |  |  |  | ## Inline methods
131 |  |  |  |  |
132 |  |  |  |  | # spent 1.47ms (308µs+1.16) within Class::MOP::Method::Accessor::_generate_accessor_method_inline which was called 15 times, avg 98µs/call: # 15 times (308µs+1.16ms) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 98µs/call sub _generate_accessor_method_inline {
133 | 105 | 209µs |  |  | my $self = shift;
134 |  |  |  |  | my $attr = $self->associated_attribute; # spent 13µs making 15 calls to Class::MOP::Method::Accessor::associated_attribute, avg 873ns/call
135 |  |  |  |  | my $attr_name = $attr->name; # spent 10µs making 15 calls to Class::MOP::Mixin::AttributeCore::name, avg 673ns/call
136 |  |  |  |  | my $meta_instance = $attr->associated_class->instance_metaclass; # spent 29µs making 15 calls to Class::MOP::Class::instance_metaclass, avg 2µs/call # spent 14µs making 15 calls to Class::MOP::Attribute::associated_class, avg 907ns/call
137 |  |  |  |  |
138 |  |  |  |  | my ( $code, $e ) = $self->_eval_closure( # spent 912µs making 15 calls to Class::MOP::Method::Generated::_eval_closure, avg 61µs/call # spent 104µs making 15 calls to Class::MOP::Instance::inline_set_slot_value, avg 7µs/call # spent 75µs making 15 calls to Class::MOP::Instance::inline_get_slot_value, avg 5µs/call
139 |  |  |  |  | {},
140 |  |  |  |  | 'sub {'
141 |  |  |  |  | . $meta_instance->inline_set_slot_value('$_[0]', $attr_name, '$_[1]')
142 |  |  |  |  | . ' if scalar(@_) == 2; '
143 |  |  |  |  | . $meta_instance->inline_get_slot_value('$_[0]', $attr_name)
144 |  |  |  |  | . '}'
145 |  |  |  |  | );
146 |  |  |  |  | confess "Could not generate inline accessor because : $e" if $e;
147 |  |  |  |  |
148 |  |  |  |  | return $code;
149 |  |  |  |  | }
150 |  |  |  |  |
151 |  |  |  |  | # spent 4.39ms (918µs+3.47) within Class::MOP::Method::Accessor::_generate_reader_method_inline which was called 52 times, avg 84µs/call: # 52 times (918µs+3.47ms) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 84µs/call sub _generate_reader_method_inline {
152 | 364 | 624µs |  |  | my $self = shift;
153 |  |  |  |  | my $attr = $self->associated_attribute; # spent 46µs making 52 calls to Class::MOP::Method::Accessor::associated_attribute, avg 877ns/call
154 |  |  |  |  | my $attr_name = $attr->name; # spent 36µs making 52 calls to Class::MOP::Mixin::AttributeCore::name, avg 687ns/call
155 |  |  |  |  | my $meta_instance = $attr->associated_class->instance_metaclass; # spent 53µs making 52 calls to Class::MOP::Class::instance_metaclass, avg 1µs/call # spent 48µs making 52 calls to Class::MOP::Attribute::associated_class, avg 921ns/call
156 |  |  |  |  |
157 |  |  |  |  | my ( $code, $e ) = $self->_eval_closure( # spent 2.98ms making 52 calls to Class::MOP::Method::Generated::_eval_closure, avg 57µs/call # spent 309µs making 52 calls to Class::MOP::Instance::inline_get_slot_value, avg 6µs/call
158 |  |  |  |  | {},
159 |  |  |  |  | 'sub {'
160 |  |  |  |  | . 'confess "Cannot assign a value to a read-only accessor" if @_ > 1;'
161 |  |  |  |  | . $meta_instance->inline_get_slot_value('$_[0]', $attr_name)
162 |  |  |  |  | . '}'
163 |  |  |  |  | );
164 |  |  |  |  | confess "Could not generate inline reader because : $e" if $e;
165 |  |  |  |  |
166 |  |  |  |  | return $code;
167 |  |  |  |  | }
168 |  |  |  |  |
169 |  |  |  |  | # spent 258µs (68+189) within Class::MOP::Method::Accessor::_generate_writer_method_inline which was called 3 times, avg 86µs/call: # 3 times (68µs+189µs) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 86µs/call sub _generate_writer_method_inline {
170 | 21 | 46µs |  |  | my $self = shift;
171 |  |  |  |  | my $attr = $self->associated_attribute; # spent 3µs making 3 calls to Class::MOP::Method::Accessor::associated_attribute, avg 867ns/call
172 |  |  |  |  | my $attr_name = $attr->name; # spent 2µs making 3 calls to Class::MOP::Mixin::AttributeCore::name, avg 600ns/call
173 |  |  |  |  | my $meta_instance = $attr->associated_class->instance_metaclass; # spent 3µs making 3 calls to Class::MOP::Class::instance_metaclass, avg 967ns/call # spent 2µs making 3 calls to Class::MOP::Attribute::associated_class, avg 833ns/call
174 |  |  |  |  |
175 |  |  |  |  | my ( $code, $e ) = $self->_eval_closure( # spent 160µs making 3 calls to Class::MOP::Method::Generated::_eval_closure, avg 53µs/call # spent 19µs making 3 calls to Class::MOP::Instance::inline_set_slot_value, avg 6µs/call
176 |  |  |  |  | {},
177 |  |  |  |  | 'sub {'
178 |  |  |  |  | . $meta_instance->inline_set_slot_value('$_[0]', $attr_name, '$_[1]')
179 |  |  |  |  | . '}'
180 |  |  |  |  | );
181 |  |  |  |  | confess "Could not generate inline writer because : $e" if $e;
182 |  |  |  |  |
183 |  |  |  |  | return $code;
184 |  |  |  |  | }
185 |  |  |  |  |
186 |  |  |  |  | # spent 2.44ms (631µs+1.81) within Class::MOP::Method::Accessor::_generate_predicate_method_inline which was called 31 times, avg 79µs/call: # 18 times (388µs+1.06ms) by Moose::Meta::Method::Accessor::_generate_predicate_method at line 117 of Moose/Meta/Method/Accessor.pm, avg 80µs/call # 13 times (243µs+756µs) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 77µs/call sub _generate_predicate_method_inline {
187 | 217 | 448µs |  |  | my $self = shift;
188 |  |  |  |  | my $attr = $self->associated_attribute; # spent 27µs making 31 calls to Class::MOP::Method::Accessor::associated_attribute, avg 868ns/call
189 |  |  |  |  | my $attr_name = $attr->name; # spent 19µs making 31 calls to Class::MOP::Mixin::AttributeCore::name, avg 629ns/call
190 |  |  |  |  | my $meta_instance = $attr->associated_class->instance_metaclass; # spent 34µs making 31 calls to Class::MOP::Class::instance_metaclass, avg 1µs/call # spent 29µs making 31 calls to Class::MOP::Attribute::associated_class, avg 932ns/call
191 |  |  |  |  |
192 |  |  |  |  | my ( $code, $e ) = $self->_eval_closure( # spent 1.49ms making 31 calls to Class::MOP::Method::Generated::_eval_closure, avg 48µs/call # spent 209µs making 31 calls to Class::MOP::Instance::inline_is_slot_initialized, avg 7µs/call
193 |  |  |  |  | {},
194 |  |  |  |  | 'sub {'
195 |  |  |  |  | . $meta_instance->inline_is_slot_initialized('$_[0]', $attr_name)
196 |  |  |  |  | . '}'
197 |  |  |  |  | );
198 |  |  |  |  | confess "Could not generate inline predicate because : $e" if $e;
199 |  |  |  |  |
200 |  |  |  |  | return $code;
201 |  |  |  |  | }
202 |  |  |  |  |
203 |  |  |  |  | # spent 295µs (102+193) within Class::MOP::Method::Accessor::_generate_clearer_method_inline which was called 3 times, avg 98µs/call: # 3 times (102µs+193µs) by Moose::Meta::Method::Accessor::_generate_clearer_method at line 118 of Moose/Meta/Method/Accessor.pm, avg 98µs/call sub _generate_clearer_method_inline {
204 | 21 | 68µs |  |  | my $self = shift;
205 |  |  |  |  | my $attr = $self->associated_attribute; # spent 3µs making 3 calls to Class::MOP::Method::Accessor::associated_attribute, avg 867ns/call
206 |  |  |  |  | my $attr_name = $attr->name; # spent 2µs making 3 calls to Class::MOP::Mixin::AttributeCore::name, avg 633ns/call
207 |  |  |  |  | my $meta_instance = $attr->associated_class->instance_metaclass; # spent 3µs making 3 calls to Class::MOP::Class::instance_metaclass, avg 1µs/call # spent 3µs making 3 calls to Class::MOP::Attribute::associated_class, avg 1µs/call
208 |  |  |  |  |
209 |  |  |  |  | my ( $code, $e ) = $self->_eval_closure( # spent 155µs making 3 calls to Class::MOP::Method::Generated::_eval_closure, avg 52µs/call # spent 27µs making 3 calls to Class::MOP::Instance::inline_deinitialize_slot, avg 9µs/call
210 |  |  |  |  | {},
211 |  |  |  |  | 'sub {'
212 |  |  |  |  | . $meta_instance->inline_deinitialize_slot('$_[0]', $attr_name)
213 |  |  |  |  | . '}'
214 |  |  |  |  | );
215 |  |  |  |  | confess "Could not generate inline clearer because : $e" if $e;
216 |  |  |  |  |
217 |  |  |  |  | return $code;
218 |  |  |  |  | }
219 |  |  |  |  |
220 | 1 | 4µs |  |  | 1;
221 |  |  |  |  |
222 |  |  |  |  | __END__
223 |  |  |  |  |
224 |  |  |  |  | =pod
225 |  |  |  |  |
226 |  |  |  |  | =head1 NAME
227 |  |  |  |  |
228 |  |  |  |  | Class::MOP::Method::Accessor - Method Meta Object for accessors
229 |  |  |  |  |
230 |  |  |  |  | =head1 SYNOPSIS
231 |  |  |  |  |
232 |  |  |  |  | use Class::MOP::Method::Accessor;
233 |  |  |  |  |
234 |  |  |  |  | my $reader = Class::MOP::Method::Accessor->new(
235 |  |  |  |  | attribute => $attribute,
236 |  |  |  |  | is_inline => 1,
237 |  |  |  |  | accessor_type => 'reader',
238 |  |  |  |  | );
239 |  |  |  |  |
240 |  |  |  |  | $reader->body->execute($instance); # call the reader method
241 |  |  |  |  |
242 |  |  |  |  | =head1 DESCRIPTION
243 |  |  |  |  |
244 |  |  |  |  | This is a subclass of <Class::MOP::Method> which is used by
245 |  |  |  |  | C<Class::MOP::Attribute> to generate accessor code. It handles
246 |  |  |  |  | generation of readers, writers, predicates and clearers. For each type
247 |  |  |  |  | of method, it can either create a subroutine reference, or actually
248 |  |  |  |  | inline code by generating a string and C<eval>'ing it.
249 |  |  |  |  |
250 |  |  |  |  | =head1 METHODS
251 |  |  |  |  |
252 |  |  |  |  | =over 4
253 |  |  |  |  |
254 |  |  |  |  | =item B<< Class::MOP::Method::Accessor->new(%options) >>
255 |  |  |  |  |
256 |  |  |  |  | This returns a new C<Class::MOP::Method::Accessor> based on the
257 |  |  |  |  | C<%options> provided.
258 |  |  |  |  |
259 |  |  |  |  | =over 4
260 |  |  |  |  |
261 |  |  |  |  | =item * attribute
262 |  |  |  |  |
263 |  |  |  |  | This is the C<Class::MOP::Attribute> for which accessors are being
264 |  |  |  |  | generated. This option is required.
265 |  |  |  |  |
266 |  |  |  |  | =item * accessor_type
267 |  |  |  |  |
268 |  |  |  |  | This is a string which should be one of "reader", "writer",
269 |  |  |  |  | "accessor", "predicate", or "clearer". This is the type of method
270 |  |  |  |  | being generated. This option is required.
271 |  |  |  |  |
272 |  |  |  |  | =item * is_inline
273 |  |  |  |  |
274 |  |  |  |  | This indicates whether or not the accessor should be inlined. This
275 |  |  |  |  | defaults to false.
276 |  |  |  |  |
277 |  |  |  |  | =item * name
278 |  |  |  |  |
279 |  |  |  |  | The method name (without a package name). This is required.
280 |  |  |  |  |
281 |  |  |  |  | =item * package_name
282 |  |  |  |  |
283 |  |  |  |  | The package name for the method. This is required.
284 |  |  |  |  |
285 |  |  |  |  | =back
286 |  |  |  |  |
287 |  |  |  |  | =item B<< $metamethod->accessor_type >>
288 |  |  |  |  |
289 |  |  |  |  | Returns the accessor type which was passed to C<new>.
290 |  |  |  |  |
291 |  |  |  |  | =item B<< $metamethod->is_inline >>
292 |  |  |  |  |
293 |  |  |  |  | Returns a boolean indicating whether or not the accessor is inlined.
294 |  |  |  |  |
295 |  |  |  |  | =item B<< $metamethod->associated_attribute >>
296 |  |  |  |  |
297 |  |  |  |  | This returns the L<Class::MOP::Attribute> object which was passed to
298 |  |  |  |  | C<new>.
299 |  |  |  |  |
300 |  |  |  |  | =item B<< $metamethod->body >>
301 |  |  |  |  |
302 |  |  |  |  | The method itself is I<generated> when the accessor object is
303 |  |  |  |  | constructed.
304 |  |  |  |  |
305 |  |  |  |  | =back
306 |  |  |  |  |
307 |  |  |  |  | =head1 AUTHORS
308 |  |  |  |  |
309 |  |  |  |  | Stevan Little E<lt>stevan@iinteractive.comE<gt>
310 |  |  |  |  |
311 |  |  |  |  | =head1 COPYRIGHT AND LICENSE
312 |  |  |  |  |
313 |  |  |  |  | Copyright 2006-2010 by Infinity Interactive, Inc.
314 |  |  |  |  |
315 |  |  |  |  | L<http://www.iinteractive.com>
316 |  |  |  |  |
317 |  |  |  |  | This library is free software; you can redistribute it and/or modify
318 |  |  |  |  | it under the same terms as Perl itself.
319 |  |  |  |  |
320 |  |  |  |  | =cut
321 |  |  |  |  |