Profile of Class/MOP/Method/Accessor.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For xt/tapper-mcp-scheduler-with-db-longrun.t
Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:22:44 2012

Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Method/Accessor.pm
Statements | Executed 4835 statements in 15.1ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
197 | 2 | 2 | 4.38ms | 47.5ms | Class::MOP::Method::Accessor::::newClass::MOP::Method::Accessor::new
254 | 3 | 3 | 3.53ms | 7.28ms | Class::MOP::Method::Accessor::::_newClass::MOP::Method::Accessor::_new
197 | 1 | 1 | 1.93ms | 36.8ms | Class::MOP::Method::Accessor::::_initialize_bodyClass::MOP::Method::Accessor::_initialize_body
56 | 2 | 2 | 694µs | 16.2ms | Class::MOP::Method::Accessor::::_generate_reader_method_inlineClass::MOP::Method::Accessor::_generate_reader_method_inline
56 | 1 | 1 | 640µs | 14.6ms | Class::MOP::Method::Accessor::::__ANON__[:154]Class::MOP::Method::Accessor::__ANON__[:154]
28 | 2 | 2 | 414µs | 13.8ms | Class::MOP::Method::Accessor::::_generate_accessor_method_inlineClass::MOP::Method::Accessor::_generate_accessor_method_inline
53 | 1 | 1 | 332µs | 387µs | Class::MOP::Method::Accessor::::_generate_reader_methodClass::MOP::Method::Accessor::_generate_reader_method
28 | 1 | 1 | 328µs | 12.9ms | Class::MOP::Method::Accessor::::__ANON__[:120]Class::MOP::Method::Accessor::__ANON__[:120]
16 | 1 | 1 | 188µs | 2.97ms | Class::MOP::Method::Accessor::::_generate_predicate_method_inlineClass::MOP::Method::Accessor::_generate_predicate_method_inline
22 | 1 | 1 | 140µs | 163µs | Class::MOP::Method::Accessor::::_generate_accessor_methodClass::MOP::Method::Accessor::_generate_accessor_method
16 | 1 | 1 | 119µs | 2.54ms | Class::MOP::Method::Accessor::::__ANON__[:209]Class::MOP::Method::Accessor::__ANON__[:209]
53 | 1 | 1 | 106µs | 106µs | Class::MOP::Method::Accessor::::_inline_throw_errorClass::MOP::Method::Accessor::_inline_throw_error
16 | 1 | 1 | 95µs | 109µs | Class::MOP::Method::Accessor::::_generate_predicate_methodClass::MOP::Method::Accessor::_generate_predicate_method
3 | 1 | 1 | 40µs | 564µs | Class::MOP::Method::Accessor::::_generate_writer_method_inlineClass::MOP::Method::Accessor::_generate_writer_method_inline
3 | 1 | 1 | 25µs | 480µs | Class::MOP::Method::Accessor::::__ANON__[:184]Class::MOP::Method::Accessor::__ANON__[:184]
3 | 1 | 1 | 21µs | 24µs | Class::MOP::Method::Accessor::::_generate_writer_methodClass::MOP::Method::Accessor::_generate_writer_method
1 | 1 | 1 | 8µs | 4.62ms | Class::MOP::Method::Accessor::::BEGIN@17Class::MOP::Method::Accessor::BEGIN@17
1 | 1 | 1 | 8µs | 8µs | Class::MOP::Method::Accessor::::BEGIN@3Class::MOP::Method::Accessor::BEGIN@3
1 | 1 | 1 | 7µs | 44µs | Class::MOP::Method::Accessor::::BEGIN@15Class::MOP::Method::Accessor::BEGIN@15
1 | 1 | 1 | 7µs | 18µs | Class::MOP::Method::Accessor::::BEGIN@11Class::MOP::Method::Accessor::BEGIN@11
1 | 1 | 1 | 7µs | 10µs | Class::MOP::Method::Accessor::::BEGIN@10Class::MOP::Method::Accessor::BEGIN@10
1 | 1 | 1 | 6µs | 28µs | Class::MOP::Method::Accessor::::BEGIN@13Class::MOP::Method::Accessor::BEGIN@13
1 | 1 | 1 | 6µs | 30µs | Class::MOP::Method::Accessor::::BEGIN@14Class::MOP::Method::Accessor::BEGIN@14
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Accessor::::__ANON__[:104]Class::MOP::Method::Accessor::__ANON__[:104]
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Accessor::::__ANON__[:123]Class::MOP::Method::Accessor::__ANON__[:123]
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Accessor::::__ANON__[:134]Class::MOP::Method::Accessor::__ANON__[:134]
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Accessor::::__ANON__[:157]Class::MOP::Method::Accessor::__ANON__[:157]
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Accessor::::__ANON__[:171]Class::MOP::Method::Accessor::__ANON__[:171]
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Accessor::::__ANON__[:187]Class::MOP::Method::Accessor::__ANON__[:187]
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Accessor::::__ANON__[:196]Class::MOP::Method::Accessor::__ANON__[:196]
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Accessor::::__ANON__[:212]Class::MOP::Method::Accessor::__ANON__[:212]
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Accessor::::__ANON__[:221]Class::MOP::Method::Accessor::__ANON__[:221]
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Accessor::::__ANON__[:234]Class::MOP::Method::Accessor::__ANON__[:234]
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Accessor::::__ANON__[:237]Class::MOP::Method::Accessor::__ANON__[:237]
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Accessor::::_generate_clearer_methodClass::MOP::Method::Accessor::_generate_clearer_method
0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Accessor::::_generate_clearer_method_inlineClass::MOP::Method::Accessor::_generate_clearer_method_inline

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 |  |  |  |  | # spent 8µs within Class::MOP::Method::Accessor::BEGIN@3 which was called: # once (8µs+0s) by Class::MOP::Class::BEGIN@15 at line 5 BEGIN {
4 | 1 | 5µs |  |  | $Class::MOP::Method::Accessor::AUTHORITY = 'cpan:STEVAN';
5 | 1 | 21µs | 1 | 8µs | } # spent 8µs making 1 call to Class::MOP::Method::Accessor::BEGIN@3
6 |  |  |  |  | {
7 | 2 | 2µs |  |  | $Class::MOP::Method::Accessor::VERSION = '2.0602';
8 |  |  |  |  | }
9 |  |  |  |  |
10 | 3 | 20µs | 2 | 12µs | # spent 10µs (7+2) within Class::MOP::Method::Accessor::BEGIN@10 which was called: # once (7µs+2µs) by Class::MOP::Class::BEGIN@15 at line 10 use strict; # spent 10µs making 1 call to Class::MOP::Method::Accessor::BEGIN@10 # spent 2µs making 1 call to strict::import
11 | 3 | 18µs | 2 | 28µs | # spent 18µs (7+10) within Class::MOP::Method::Accessor::BEGIN@11 which was called: # once (7µs+10µs) by Class::MOP::Class::BEGIN@15 at line 11 use warnings; # spent 18µs making 1 call to Class::MOP::Method::Accessor::BEGIN@11 # spent 10µs making 1 call to warnings::import
12 |  |  |  |  |
13 | 3 | 19µs | 2 | 50µs | # spent 28µs (6+22) within Class::MOP::Method::Accessor::BEGIN@13 which was called: # once (6µs+22µs) by Class::MOP::Class::BEGIN@15 at line 13 use Carp 'confess'; # spent 28µs making 1 call to Class::MOP::Method::Accessor::BEGIN@13 # spent 22µs making 1 call to Exporter::import
14 | 3 | 16µs | 2 | 54µs | # spent 30µs (6+24) within Class::MOP::Method::Accessor::BEGIN@14 which was called: # once (6µs+24µs) by Class::MOP::Class::BEGIN@15 at line 14 use Scalar::Util 'blessed', 'weaken'; # spent 30µs making 1 call to Class::MOP::Method::Accessor::BEGIN@14 # spent 24µs making 1 call to Exporter::import
15 | 3 | 21µs | 2 | 80µs | # spent 44µs (7+37) within Class::MOP::Method::Accessor::BEGIN@15 which was called: # once (7µs+37µs) by Class::MOP::Class::BEGIN@15 at line 15 use Try::Tiny; # spent 44µs making 1 call to Class::MOP::Method::Accessor::BEGIN@15 # spent 36µs making 1 call to Exporter::import
16 |  |  |  |  |
17 | 3 | 992µs | 2 | 9.23ms | # spent 4.62ms (8µs+4.61) within Class::MOP::Method::Accessor::BEGIN@17 which was called: # once (8µs+4.61ms) by Class::MOP::Class::BEGIN@15 at line 17 use base 'Class::MOP::Method::Generated'; # spent 4.62ms making 1 call to Class::MOP::Method::Accessor::BEGIN@17 # spent 4.61ms making 1 call to base::import
18 |  |  |  |  |
19 |  |  |  |  | # spent 47.5ms (4.38+43.1) within Class::MOP::Method::Accessor::new which was called 197 times, avg 241µs/call: # 188 times (4.06ms+29.2ms) by Class::MOP::Attribute::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Attribute.pm:398] at line 389 of Class/MOP/Attribute.pm, avg 177µs/call # 9 times (313µs+13.9ms) by Class::MOP::Attribute::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Attribute.pm:398] at line 20 of Moose/Meta/Method/Accessor.pm, avg 1.58ms/call sub new {
20 | 1970 | 4.74ms |  |  | my $class = shift;
21 |  |  |  |  | my %options = @_;
22 |  |  |  |  |
23 |  |  |  |  | (exists $options{attribute})
24 |  |  |  |  | || confess "You must supply an attribute to construct with";
25 |  |  |  |  |
26 |  |  |  |  | (exists $options{accessor_type})
27 |  |  |  |  | || confess "You must supply an accessor_type to construct with";
28 |  |  |  |  |
29 |  |  | 394 | 344µs | (blessed($options{attribute}) && $options{attribute}->isa('Class::MOP::Attribute')) # spent 172µs making 197 calls to UNIVERSAL::isa, avg 876ns/call # spent 172µs making 197 calls to Scalar::Util::blessed, avg 873ns/call
30 |  |  |  |  | || confess "You must supply an attribute which is a 'Class::MOP::Attribute' instance";
31 |  |  |  |  |
32 |  |  |  |  | ($options{package_name} && $options{name})
33 |  |  |  |  | || confess "You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT";
34 |  |  |  |  |
35 |  |  | 197 | 1.90ms | my $self = $class->_new(\%options); # spent 1.88ms making 188 calls to Class::MOP::Method::Accessor::_new, avg 10µs/call # spent 18µs making 9 calls to Moose::Meta::Method::Accessor::_new, avg 2µs/call
36 |  |  |  |  |
37 |  |  |  |  | # we don't want this creating
38 |  |  |  |  | # a cycle in the code, if not
39 |  |  |  |  | # needed
40 |  |  | 197 | 219µs | weaken($self->{'attribute'}); # spent 219µs making 197 calls to Scalar::Util::weaken, avg 1µs/call
41 |  |  |  |  |
42 |  |  | 197 | 36.8ms | $self->_initialize_body; # spent 36.8ms making 197 calls to Class::MOP::Method::Accessor::_initialize_body, avg 187µs/call
43 |  |  |  |  |
44 |  |  |  |  | return $self;
45 |  |  |  |  | }
46 |  |  |  |  |
47 |  |  |  |  | # spent 7.28ms (3.53+3.75) within Class::MOP::Method::Accessor::_new which was called 254 times, avg 29µs/call: # 188 times (1.88ms+0s) by Class::MOP::Method::Accessor::new at line 35, avg 10µs/call # 57 times (1.57ms+0s) by Class::MOP::Method::wrap at line 46 of Class/MOP/Method.pm, avg 27µs/call # 9 times (82µs+3.75ms) by Class::MOP::Method::Accessor::new at line 24 of Moose/Meta/Method/Accessor.pm, avg 426µs/call sub _new {
48 | 998 | 3.76ms |  |  | my $class = shift;
49 |  |  |  |  |
50 |  |  | 18 | 3.75ms | return Class::MOP::Class->initialize($class)->new_object(@_) # spent 3.20ms making 9 calls to Class::MOP::Class::new_object, avg 355µs/call # spent 555µs making 9 calls to Class::MOP::Class::initialize, avg 62µs/call
51 |  |  |  |  | if $class ne __PACKAGE__;
52 |  |  |  |  |
53 |  |  |  |  | my $params = @_ == 1 ? $_[0] : {@_};
54 |  |  |  |  |
55 |  |  |  |  | return bless {
56 |  |  |  |  | # inherited from Class::MOP::Method
57 |  |  |  |  | body => $params->{body},
58 |  |  |  |  | associated_metaclass => $params->{associated_metaclass},
59 |  |  |  |  | package_name => $params->{package_name},
60 |  |  |  |  | name => $params->{name},
61 |  |  |  |  | original_method => $params->{original_method},
62 |  |  |  |  |
63 |  |  |  |  | # inherit from Class::MOP::Generated
64 |  |  |  |  | is_inline => $params->{is_inline} || 0,
65 |  |  |  |  | definition_context => $params->{definition_context},
66 |  |  |  |  |
67 |  |  |  |  | # defined in this class
68 |  |  |  |  | attribute => $params->{attribute},
69 |  |  |  |  | accessor_type => $params->{accessor_type},
70 |  |  |  |  | } => $class;
71 |  |  |  |  | }
72 |  |  |  |  |
73 |  |  |  |  | ## accessors
74 |  |  |  |  |
75 | 221 | 545µs |  |  | sub associated_attribute { (shift)->{'attribute'} }
76 | 197 | 422µs |  |  | sub accessor_type { (shift)->{'accessor_type'} }
77 |  |  |  |  |
78 |  |  |  |  | ## factory
79 |  |  |  |  |
80 |  |  |  |  | # spent 36.8ms (1.93+34.9) within Class::MOP::Method::Accessor::_initialize_body which was called 197 times, avg 187µs/call: # 197 times (1.93ms+34.9ms) by Class::MOP::Method::Accessor::new at line 42, avg 187µs/call sub _initialize_body {
81 | 591 | 1.86ms |  |  | my $self = shift;
82 |  |  |  |  |
83 |  |  | 394 | 395µs | my $method_name = join "_" => ( # spent 239µs making 197 calls to Class::MOP::Method::Accessor::accessor_type, avg 1µs/call # spent 156µs making 197 calls to Class::MOP::Method::Generated::is_inline, avg 791ns/call
84 |  |  |  |  | '_generate',
85 |  |  |  |  | $self->accessor_type,
86 |  |  |  |  | 'method',
87 |  |  |  |  | ($self->is_inline ? 'inline' : ())
88 |  |  |  |  | );
89 |  |  |  |  |
90 |  |  | 197 | 34.5ms | $self->{'body'} = $self->$method_name(); # spent 14.3ms making 54 calls to Class::MOP::Method::Accessor::_generate_reader_method_inline, avg 264µs/call # spent 7.09ms making 6 calls to Moose::Meta::Method::Accessor::_generate_accessor_method, avg 1.18ms/call # spent 6.90ms making 22 calls to Class::MOP::Method::Accessor::_generate_accessor_method_inline, avg 314µs/call # spent 2.97ms making 16 calls to Class::MOP::Method::Accessor::_generate_predicate_method_inline, avg 185µs/call # spent 2.00ms making 2 calls to Moose::Meta::Method::Accessor::_generate_reader_method, avg 1.00ms/call # spent 564µs making 3 calls to Class::MOP::Method::Accessor::_generate_writer_method_inline, avg 188µs/call # spent 387µs making 53 calls to Class::MOP::Method::Accessor::_generate_reader_method, avg 7µs/call # spent 163µs making 22 calls to Class::MOP::Method::Accessor::_generate_accessor_method, avg 7µs/call # spent 109µs making 16 calls to Class::MOP::Method::Accessor::_generate_predicate_method, avg 7µs/call # spent 24µs making 3 calls to Class::MOP::Method::Accessor::_generate_writer_method, avg 8µs/call
91 |  |  |  |  | }
92 |  |  |  |  |
93 |  |  |  |  | ## generators
94 |  |  |  |  |
95 |  |  |  |  | # spent 163µs (140+23) within Class::MOP::Method::Accessor::_generate_accessor_method which was called 22 times, avg 7µs/call: # 22 times (140µs+23µs) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 7µs/call sub _generate_accessor_method {
96 | 66 | 135µs |  |  | my $self = shift;
97 |  |  | 22 | 23µs | my $attr = $self->associated_attribute; # spent 23µs making 22 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
98 |  |  |  |  |
99 |  |  |  |  | return sub {
100 |  |  |  |  | if (@_ >= 2) {
101 |  |  |  |  | $attr->set_value($_[0], $_[1]);
102 |  |  |  |  | }
103 |  |  |  |  | $attr->get_value($_[0]);
104 |  |  |  |  | };
105 |  |  |  |  | }
106 |  |  |  |  |
107 |  |  |  |  | # spent 13.8ms (414µs+13.4) within Class::MOP::Method::Accessor::_generate_accessor_method_inline which was called 28 times, avg 493µs/call: # 22 times (319µs+6.59ms) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 314µs/call # 6 times (96µs+6.81ms) by Moose::Meta::Method::Accessor::_generate_accessor_method at line 74 of Moose/Meta/Method/Accessor.pm, avg 1.15ms/call sub _generate_accessor_method_inline {
108 | 84 | 296µs |  |  | my $self = shift;
109 |  |  | 28 | 30µs | my $attr = $self->associated_attribute; # spent 30µs making 28 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
110 |  |  |  |  |
111 |  |  |  |  | # spent 12.9ms (328µs+12.6) within Class::MOP::Method::Accessor::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Method/Accessor.pm:120] which was called 28 times, avg 461µs/call: # 28 times (328µs+12.6ms) by Try::Tiny::try at line 71 of Try/Tiny.pm, avg 461µs/call return try {
112 | 28 | 246µs | 84 | 12.6ms | $self->_compile_code([ # spent 3.71ms making 22 calls to Class::MOP::Method::Generated::_compile_code, avg 169µs/call # spent 3.09ms making 6 calls to Moose::Meta::Attribute::_inline_set_value, avg 514µs/call # spent 2.83ms making 6 calls to Moose::Meta::Method::Accessor::_compile_code, avg 472µs/call # spent 1.83ms making 22 calls to Class::MOP::Attribute::_inline_set_value, avg 83µs/call # spent 668µs making 6 calls to Moose::Meta::Attribute::_inline_get_value, avg 111µs/call # spent 447µs making 22 calls to Class::MOP::Attribute::_inline_get_value, avg 20µs/call
113 |  |  |  |  | 'sub {',
114 |  |  |  |  | 'if (@_ > 1) {',
115 |  |  |  |  | $attr->_inline_set_value('$_[0]', '$_[1]'),
116 |  |  |  |  | '}',
117 |  |  |  |  | $attr->_inline_get_value('$_[0]'),
118 |  |  |  |  | '}',
119 |  |  |  |  | ]);
120 |  |  |  |  | }
121 |  |  |  |  | catch {
122 |  |  |  |  | confess "Could not generate inline accessor because : $_";
123 |  |  | 56 | 68µs | }; # spent 68µs making 28 calls to Try::Tiny::catch, avg 2µs/call # spent 13.3ms making 28 calls to Try::Tiny::try, avg 475µs/call, recursion: max depth 2, sum of overlapping time 13.3ms
124 |  |  |  |  | }
125 |  |  |  |  |
126 |  |  |  |  | # spent 387µs (332+55) within Class::MOP::Method::Accessor::_generate_reader_method which was called 53 times, avg 7µs/call: # 53 times (332µs+55µs) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 7µs/call sub _generate_reader_method {
127 | 159 | 318µs |  |  | my $self = shift;
128 |  |  | 53 | 55µs | my $attr = $self->associated_attribute; # spent 55µs making 53 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
129 |  |  |  |  |
130 |  |  |  |  | return sub {
131 | 24 | 52µs |  |  | confess "Cannot assign a value to a read-only accessor"
132 |  |  |  |  | if @_ > 1;
133 |  |  | 12 | 339µs | $attr->get_value($_[0]); # spent 339µs making 12 calls to Class::MOP::Attribute::get_value, avg 28µs/call
134 |  |  |  |  | };
135 |  |  |  |  | }
136 |  |  |  |  |
137 |  |  |  |  | # spent 16.2ms (694µs+15.5) within Class::MOP::Method::Accessor::_generate_reader_method_inline which was called 56 times, avg 289µs/call: # 54 times (642µs+13.6ms) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 264µs/call # 2 times (52µs+1.88ms) by Moose::Meta::Method::Accessor::_generate_reader_method at line 62 of Moose/Meta/Method/Accessor.pm, avg 967µs/call sub _generate_reader_method_inline {
138 | 168 | 525µs |  |  | my $self = shift;
139 |  |  | 56 | 58µs | my $attr = $self->associated_attribute; # spent 58µs making 56 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
140 |  |  |  |  |
141 |  |  |  |  | # spent 14.6ms (640µs+14.0) within Class::MOP::Method::Accessor::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Method/Accessor.pm:154] which was called 56 times, avg 261µs/call: # 56 times (640µs+14.0ms) by Try::Tiny::try at line 71 of Try/Tiny.pm, avg 261µs/call return try {
142 | 56 | 444µs | 168 | 14.0ms | $self->_compile_code([ # spent 8.35ms making 53 calls to Class::MOP::Method::Generated::_compile_code, avg 158µs/call # spent 3.00ms making 53 calls to Class::MOP::Attribute::_inline_get_value, avg 57µs/call # spent 1.19ms making 3 calls to Moose::Meta::Method::Accessor::_compile_code, avg 398µs/call # spent 722µs making 3 calls to Moose::Meta::Method::_inline_throw_error, avg 241µs/call # spent 583µs making 3 calls to Moose::Meta::Attribute::_inline_get_value, avg 194µs/call # spent 106µs making 53 calls to Class::MOP::Method::Accessor::_inline_throw_error, avg 2µs/call
143 |  |  |  |  | 'sub {',
144 |  |  |  |  | 'if (@_ > 1) {',
145 |  |  |  |  | # XXX: this is a hack, but our error stuff is terrible
146 |  |  |  |  | $self->_inline_throw_error(
147 |  |  |  |  | '"Cannot assign a value to a read-only accessor"',
148 |  |  |  |  | 'data => \@_'
149 |  |  |  |  | ) . ';',
150 |  |  |  |  | '}',
151 |  |  |  |  | $attr->_inline_get_value('$_[0]'),
152 |  |  |  |  | '}',
153 |  |  |  |  | ]);
154 |  |  |  |  | }
155 |  |  |  |  | catch {
156 |  |  |  |  | confess "Could not generate inline reader because : $_";
157 |  |  | 112 | 130µs | }; # spent 130µs making 56 calls to Try::Tiny::catch, avg 2µs/call # spent 15.3ms making 56 calls to Try::Tiny::try, avg 273µs/call, recursion: max depth 2, sum of overlapping time 15.3ms
158 |  |  |  |  | }
159 |  |  |  |  |
160 |  |  |  |  | # spent 106µs within Class::MOP::Method::Accessor::_inline_throw_error which was called 53 times, avg 2µs/call: # 53 times (106µs+0s) by Class::MOP::Method::Accessor::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Method/Accessor.pm:154] at line 142, avg 2µs/call sub _inline_throw_error {
161 | 106 | 218µs |  |  | my $self = shift;
162 |  |  |  |  | return 'Carp::confess ' . $_[0];
163 |  |  |  |  | }
164 |  |  |  |  |
165 |  |  |  |  | # spent 24µs (21+3) within Class::MOP::Method::Accessor::_generate_writer_method which was called 3 times, avg 8µs/call: # 3 times (21µs+3µs) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 8µs/call sub _generate_writer_method {
166 | 9 | 19µs |  |  | my $self = shift;
167 |  |  | 3 | 3µs | my $attr = $self->associated_attribute; # spent 3µs making 3 calls to Class::MOP::Method::Accessor::associated_attribute, avg 867ns/call
168 |  |  |  |  |
169 |  |  |  |  | return sub {
170 |  |  |  |  | $attr->set_value($_[0], $_[1]);
171 |  |  |  |  | };
172 |  |  |  |  | }
173 |  |  |  |  |
174 |  |  |  |  | # spent 564µs (40+524) within Class::MOP::Method::Accessor::_generate_writer_method_inline which was called 3 times, avg 188µs/call: # 3 times (40µs+524µs) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 188µs/call sub _generate_writer_method_inline {
175 | 9 | 28µs |  |  | my $self = shift;
176 |  |  | 3 | 3µs | my $attr = $self->associated_attribute; # spent 3µs making 3 calls to Class::MOP::Method::Accessor::associated_attribute, avg 900ns/call
177 |  |  |  |  |
178 |  |  |  |  | # spent 480µs (25+455) within Class::MOP::Method::Accessor::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Method/Accessor.pm:184] which was called 3 times, avg 160µs/call: # 3 times (25µs+455µs) by Try::Tiny::try at line 71 of Try/Tiny.pm, avg 160µs/call return try {
179 | 3 | 21µs | 6 | 455µs | $self->_compile_code([ # spent 375µs making 3 calls to Class::MOP::Method::Generated::_compile_code, avg 125µs/call # spent 79µs making 3 calls to Class::MOP::Attribute::_inline_set_value, avg 26µs/call
180 |  |  |  |  | 'sub {',
181 |  |  |  |  | $attr->_inline_set_value('$_[0]', '$_[1]'),
182 |  |  |  |  | '}',
183 |  |  |  |  | ]);
184 |  |  |  |  | }
185 |  |  |  |  | catch {
186 |  |  |  |  | confess "Could not generate inline writer because : $_";
187 |  |  | 6 | 6µs | }; # spent 6µs making 3 calls to Try::Tiny::catch, avg 2µs/call # spent 515µs making 3 calls to Try::Tiny::try, avg 172µs/call, recursion: max depth 1, sum of overlapping time 515µs
188 |  |  |  |  | }
189 |  |  |  |  |
190 |  |  |  |  | # spent 109µs (95+14) within Class::MOP::Method::Accessor::_generate_predicate_method which was called 16 times, avg 7µs/call: # 16 times (95µs+14µs) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 7µs/call sub _generate_predicate_method {
191 | 48 | 90µs |  |  | my $self = shift;
192 |  |  | 16 | 14µs | my $attr = $self->associated_attribute; # spent 14µs making 16 calls to Class::MOP::Method::Accessor::associated_attribute, avg 894ns/call
193 |  |  |  |  |
194 |  |  |  |  | return sub {
195 | 12 | 54µs | 12 | 274µs | $attr->has_value($_[0]) # spent 274µs making 12 calls to Class::MOP::Attribute::has_value, avg 23µs/call
196 |  |  |  |  | };
197 |  |  |  |  | }
198 |  |  |  |  |
199 |  |  |  |  | # spent 2.97ms (188µs+2.78) within Class::MOP::Method::Accessor::_generate_predicate_method_inline which was called 16 times, avg 185µs/call: # 16 times (188µs+2.78ms) by Class::MOP::Method::Accessor::_initialize_body at line 90, avg 185µs/call sub _generate_predicate_method_inline {
200 | 48 | 143µs |  |  | my $self = shift;
201 |  |  | 16 | 17µs | my $attr = $self->associated_attribute; # spent 17µs making 16 calls to Class::MOP::Method::Accessor::associated_attribute, avg 1µs/call
202 |  |  |  |  |
203 |  |  |  |  | # spent 2.54ms (119µs+2.42) within Class::MOP::Method::Accessor::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Method/Accessor.pm:209] which was called 16 times, avg 159µs/call: # 16 times (119µs+2.42ms) by Try::Tiny::try at line 71 of Try/Tiny.pm, avg 159µs/call return try {
204 | 16 | 96µs | 32 | 2.42ms | $self->_compile_code([ # spent 2.03ms making 16 calls to Class::MOP::Method::Generated::_compile_code, avg 127µs/call # spent 392µs making 16 calls to Class::MOP::Attribute::_inline_has_value, avg 24µs/call
205 |  |  |  |  | 'sub {',
206 |  |  |  |  | $attr->_inline_has_value('$_[0]'),
207 |  |  |  |  | '}',
208 |  |  |  |  | ]);
209 |  |  |  |  | }
210 |  |  |  |  | catch {
211 |  |  |  |  | confess "Could not generate inline predicate because : $_";
212 |  |  | 32 | 36µs | }; # spent 36µs making 16 calls to Try::Tiny::catch, avg 2µs/call # spent 2.73ms making 16 calls to Try::Tiny::try, avg 170µs/call, recursion: max depth 1, sum of overlapping time 2.73ms
213 |  |  |  |  | }
214 |  |  |  |  |
215 |  |  |  |  | sub _generate_clearer_method {
216 |  |  |  |  | my $self = shift;
217 |  |  |  |  | my $attr = $self->associated_attribute;
218 |  |  |  |  |
219 |  |  |  |  | return sub {
220 |  |  |  |  | $attr->clear_value($_[0])
221 |  |  |  |  | };
222 |  |  |  |  | }
223 |  |  |  |  |
224 |  |  |  |  | sub _generate_clearer_method_inline {
225 |  |  |  |  | my $self = shift;
226 |  |  |  |  | my $attr = $self->associated_attribute;
227 |  |  |  |  |
228 |  |  |  |  | return try {
229 |  |  |  |  | $self->_compile_code([
230 |  |  |  |  | 'sub {',
231 |  |  |  |  | $attr->_inline_clear_value('$_[0]'),
232 |  |  |  |  | '}',
233 |  |  |  |  | ]);
234 |  |  |  |  | }
235 |  |  |  |  | catch {
236 |  |  |  |  | confess "Could not generate inline clearer because : $_";
237 |  |  |  |  | };
238 |  |  |  |  | }
239 |  |  |  |  |
240 | 1 | 5µs |  |  | 1;
241 |  |  |  |  |
242 |  |  |  |  | # ABSTRACT: Method Meta Object for accessors
243 |  |  |  |  |
- - |  |  |  |  |
246 |  |  |  |  | =pod
247 |  |  |  |  |
248 |  |  |  |  | =head1 NAME
249 |  |  |  |  |
250 |  |  |  |  | Class::MOP::Method::Accessor - Method Meta Object for accessors
251 |  |  |  |  |
252 |  |  |  |  | =head1 VERSION
253 |  |  |  |  |
254 |  |  |  |  | version 2.0602
255 |  |  |  |  |
256 |  |  |  |  | =head1 SYNOPSIS
257 |  |  |  |  |
258 |  |  |  |  | use Class::MOP::Method::Accessor;
259 |  |  |  |  |
260 |  |  |  |  | my $reader = Class::MOP::Method::Accessor->new(
261 |  |  |  |  | attribute => $attribute,
262 |  |  |  |  | is_inline => 1,
263 |  |  |  |  | accessor_type => 'reader',
264 |  |  |  |  | );
265 |  |  |  |  |
266 |  |  |  |  | $reader->body->execute($instance); # call the reader method
267 |  |  |  |  |
268 |  |  |  |  | =head1 DESCRIPTION
269 |  |  |  |  |
270 |  |  |  |  | This is a subclass of C<Class::MOP::Method> which is used by
271 |  |  |  |  | C<Class::MOP::Attribute> to generate accessor code. It handles
272 |  |  |  |  | generation of readers, writers, predicates and clearers. For each type
273 |  |  |  |  | of method, it can either create a subroutine reference, or actually
274 |  |  |  |  | inline code by generating a string and C<eval>'ing it.
275 |  |  |  |  |
276 |  |  |  |  | =head1 METHODS
277 |  |  |  |  |
278 |  |  |  |  | =over 4
279 |  |  |  |  |
280 |  |  |  |  | =item B<< Class::MOP::Method::Accessor->new(%options) >>
281 |  |  |  |  |
282 |  |  |  |  | This returns a new C<Class::MOP::Method::Accessor> based on the
283 |  |  |  |  | C<%options> provided.
284 |  |  |  |  |
285 |  |  |  |  | =over 4
286 |  |  |  |  |
287 |  |  |  |  | =item * attribute
288 |  |  |  |  |
289 |  |  |  |  | This is the C<Class::MOP::Attribute> for which accessors are being
290 |  |  |  |  | generated. This option is required.
291 |  |  |  |  |
292 |  |  |  |  | =item * accessor_type
293 |  |  |  |  |
294 |  |  |  |  | This is a string which should be one of "reader", "writer",
295 |  |  |  |  | "accessor", "predicate", or "clearer". This is the type of method
296 |  |  |  |  | being generated. This option is required.
297 |  |  |  |  |
298 |  |  |  |  | =item * is_inline
299 |  |  |  |  |
300 |  |  |  |  | This indicates whether or not the accessor should be inlined. This
301 |  |  |  |  | defaults to false.
302 |  |  |  |  |
303 |  |  |  |  | =item * name
304 |  |  |  |  |
305 |  |  |  |  | The method name (without a package name). This is required.
306 |  |  |  |  |
307 |  |  |  |  | =item * package_name
308 |  |  |  |  |
309 |  |  |  |  | The package name for the method. This is required.
310 |  |  |  |  |
311 |  |  |  |  | =back
312 |  |  |  |  |
313 |  |  |  |  | =item B<< $metamethod->accessor_type >>
314 |  |  |  |  |
315 |  |  |  |  | Returns the accessor type which was passed to C<new>.
316 |  |  |  |  |
317 |  |  |  |  | =item B<< $metamethod->is_inline >>
318 |  |  |  |  |
319 |  |  |  |  | Returns a boolean indicating whether or not the accessor is inlined.
320 |  |  |  |  |
321 |  |  |  |  | =item B<< $metamethod->associated_attribute >>
322 |  |  |  |  |
323 |  |  |  |  | This returns the L<Class::MOP::Attribute> object which was passed to
324 |  |  |  |  | C<new>.
325 |  |  |  |  |
326 |  |  |  |  | =item B<< $metamethod->body >>
327 |  |  |  |  |
328 |  |  |  |  | The method itself is I<generated> when the accessor object is
329 |  |  |  |  | constructed.
330 |  |  |  |  |
331 |  |  |  |  | =back
332 |  |  |  |  |
333 |  |  |  |  | =head1 AUTHOR
334 |  |  |  |  |
335 |  |  |  |  | Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details.
336 |  |  |  |  |
337 |  |  |  |  | =head1 COPYRIGHT AND LICENSE
338 |  |  |  |  |
339 |  |  |  |  | This software is copyright (c) 2012 by Infinity Interactive, Inc..
340 |  |  |  |  |
341 |  |  |  |  | This is free software; you can redistribute it and/or modify it under
342 |  |  |  |  | the same terms as the Perl 5 programming language system itself.
343 |  |  |  |  |
344 |  |  |  |  | =cut
345 |  |  |  |  |
346 |  |  |  |  |
347 |  |  |  |  | __END__