← Index
NYTProf Performance Profile   « block view • line view • sub view »
For ddd2.pl
  Run on Tue May 25 16:52:24 2010
Reported on Tue May 25 16:56:59 2010

File /project/perl/lib/Class/Accessor/Fast.pm
Statements Executed 3507
Statement Execution Time 59.2ms
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
343124545.0ms45.0msClass::Accessor::Fast::::__ANON__[:41]Class::Accessor::Fast::__ANON__[:41]
1411315µs315µsClass::Accessor::Fast::::make_accessorClass::Accessor::Fast::make_accessor
0000s0sClass::Accessor::Fast::::BEGINClass::Accessor::Fast::BEGIN
0000s0sClass::Accessor::Fast::::__ANON__[:53]Class::Accessor::Fast::__ANON__[:53]
0000s0sClass::Accessor::Fast::::__ANON__[:70]Class::Accessor::Fast::__ANON__[:70]
0000s0sClass::Accessor::Fast::::make_ro_accessorClass::Accessor::Fast::make_ro_accessor
0000s0sClass::Accessor::Fast::::make_wo_accessorClass::Accessor::Fast::make_wo_accessor
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Class::Accessor::Fast;
2392µs10suse base 'Class::Accessor';
# spent 269µs making 1 call to base::import, recursion: max depth 4, time 269µs
33662µs121µsuse strict;
# spent 21µs making 1 call to strict::import
416µs$Class::Accessor::Fast::VERSION = '0.30';
5
6=head1 NAME
7
8Class::Accessor::Fast - Faster, but less expandable, accessors
9
10=head1 SYNOPSIS
11
12 package Foo;
13 use base qw(Class::Accessor::Fast);
14
15 # The rest is the same as Class::Accessor but without set() and get().
16
17=head1 DESCRIPTION
18
19This is a faster but less expandable version of Class::Accessor.
20Class::Accessor's generated accessors require two method calls to accompish
21their task (one for the accessor, another for get() or set()).
22Class::Accessor::Fast eliminates calling set()/get() and does the access itself,
23resulting in a somewhat faster accessor.
24
25The downside is that you can't easily alter the behavior of your
26accessors, nor can your subclasses. Of course, should you need this
27later, you can always swap out Class::Accessor::Fast for
28Class::Accessor.
29
30Read the documentation for Class::Accessor for more info.
31
32=cut
33
34
# spent 315µs within Class::Accessor::Fast::make_accessor which was called 14 times, avg 23µs/call: # 14 times (315µs+0s) by Class::Accessor::_mk_accessors at line 166 of Class/Accessor.pm, avg 23µs/call
sub make_accessor {
351474µs my($class, $field) = @_;
36
37
# spent 45.0ms within Class::Accessor::Fast::__ANON__[/project/perl/lib/Class/Accessor/Fast.pm:41] which was called 3431 times, avg 13µs/call: # 3292 times (42.9ms+0s) by Class::DBI::Column::name_lc at line 64 of Class/DBI/Column.pm, avg 13µs/call # 15 times (208µs+0s) by Class::DBI::Relationship::_set_up_class_data at line 42 of Class/DBI/Relationship.pm, avg 14µs/call # 14 times (194µs+0s) by Class::DBI::Relationship::_add_triggers at line 53 of Class/DBI/Relationship.pm, avg 14µs/call # 12 times (155µs+0s) by Class::DBI::Relationship::HasA::_set_up_class_data at line 94 of Class/DBI/Relationship/HasA.pm, avg 13µs/call # 10 times (230µs+0s) by Class::DBI::_mk_column_accessors at line 345 of Class/DBI.pm, avg 23µs/call # 10 times (223µs+0s) by Class::DBI::_mk_column_accessors at line 346 of Class/DBI.pm, avg 22µs/call # 10 times (157µs+0s) by Class::DBI::mutator_name_for at line 391 of Class/DBI.pm, avg 16µs/call # 10 times (156µs+0s) by Class::DBI::accessor_name_for at line 382 of Class/DBI.pm, avg 16µs/call # 10 times (148µs+0s) by Class::DBI::_mk_column_accessors at line 333 of Class/DBI.pm, avg 15µs/call # 6 times (89µs+0s) by Class::DBI::Relationship::HasMany::_set_up_class_data at line 57 of Class/DBI/Relationship/HasMany.pm, avg 15µs/call # 6 times (78µs+0s) by Class::DBI::Relationship::HasA::triggers at line 19 of Class/DBI/Relationship/HasA.pm, avg 13µs/call # 6 times (77µs+0s) by Class::DBI::Relationship::HasA::_deflator at line 82 of Class/DBI/Relationship/HasA.pm, avg 13µs/call # 6 times (72µs+0s) by Class::DBI::Relationship::HasA::_inflator at line 33 of Class/DBI/Relationship/HasA.pm, avg 12µs/call # 4 times (48µs+0s) by Class::DBI::Relationship::HasMany::_hm_run_search at line 131 of Class/DBI/Relationship/HasMany.pm, avg 12µs/call # 3 times (48µs+0s) by Class::DBI::Relationship::HasA::triggers at line 20 of Class/DBI/Relationship/HasA.pm, avg 16µs/call # 2 times (29µs+0s) by Class::DBI::Relationship::_add_methods at line 62 of Class/DBI/Relationship.pm, avg 14µs/call # 2 times (29µs+0s) by Class::DBI::Relationship::HasMany::methods at line 80 of Class/DBI/Relationship/HasMany.pm, avg 14µs/call # 2 times (27µs+0s) by Class::DBI::Relationship::HasMany::triggers at line 71 of Class/DBI/Relationship/HasMany.pm, avg 14µs/call # 2 times (26µs+0s) by Class::DBI::Relationship::HasMany::triggers at line 64 of Class/DBI/Relationship/HasMany.pm, avg 13µs/call # 2 times (26µs+0s) by Class::DBI::Relationship::HasMany::_has_many_method at line 119 of Class/DBI/Relationship/HasMany.pm, avg 13µs/call # 2 times (25µs+0s) by Class::DBI::Relationship::HasA::__ANON__[/project/perl/lib/Class/DBI/Relationship/HasA.pm:77] at line 38 of Class/DBI/Relationship/HasA.pm, avg 12µs/call # 2 times (24µs+0s) by Class::DBI::Relationship::HasMany::triggers at line 68 of Class/DBI/Relationship/HasMany.pm, avg 12µs/call # 2 times (24µs+0s) by Class::DBI::Relationship::HasMany::_method_add_to at line 89 of Class/DBI/Relationship/HasMany.pm, avg 12µs/call # once (15µs+0s) by Class::DBI::Relationship::HasA::__ANON__[/project/perl/lib/Class/DBI/Relationship/HasA.pm:77] at line 37 of Class/DBI/Relationship/HasA.pm
return sub {
38343157.7ms return $_[0]->{$field} unless @_ > 1;
392094µs my $self = shift;
4020303µs $self->{$field} = (@_ == 1 ? $_[0] : [@_]);
4114287µs };
42}
43
44
45sub make_ro_accessor {
46 my($class, $field) = @_;
47
48 return sub {
49 return $_[0]->{$field} unless @_ > 1;
50 my $self = shift;
51 my $caller = caller;
52 $self->_croak("'$caller' cannot alter the value of '$field' on objects of class '$class'");
53 };
54}
55
56
57sub make_wo_accessor {
58 my($class, $field) = @_;
59
60 return sub {
61 my $self = shift;
62
63 unless (@_) {
64 my $caller = caller;
65 $self->_croak("'$caller' cannot access the value of '$field' on objects of class '$class'");
66 }
67 else {
68 return $self->{$field} = (@_ == 1 ? $_[0] : [@_]);
69 }
70 };
71}
72
73
74=head1 EFFICIENCY
75
76L<Class::Accessor/EFFICIENCY> for an efficiency comparison.
77
78=head1 AUTHORS
79
80Copyright 2005 Marty Pauley <marty+perl@kasei.com>
81
82This program is free software; you can redistribute it and/or modify it under
83the same terms as Perl itself. That means either (a) the GNU General Public
84License or (b) the Artistic License.
85
86=head2 ORIGINAL AUTHOR
87
88Michael G Schwern <schwern@pobox.com>
89
90=head1 SEE ALSO
91
92L<Class::Accessor>
93
94=cut
95
96112µs1;