← Index
Performance Profile   « block view • line view • sub view »
For t/test-parsing
  Run on Sun Nov 14 09:49:57 2010
Reported on Sun Nov 14 09:50:10 2010

File /usr/local/lib/perl/5.10.0/Class/MOP/Mixin/AttributeCore.pm
Statements Executed 4782
Total Time 0.0115779 seconds
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
447442.46ms3.83msClass::MOP::Mixin::AttributeCore::::defaultClass::MOP::Mixin::AttributeCore::default
236331.74ms1.74msClass::MOP::Mixin::AttributeCore::::is_default_a_coderefClass::MOP::Mixin::AttributeCore::is_default_a_coderef
0000s0sClass::MOP::Mixin::AttributeCore::::BEGINClass::MOP::Mixin::AttributeCore::BEGIN
0000s0sClass::MOP::Mixin::AttributeCore::::has_read_methodClass::MOP::Mixin::AttributeCore::has_read_method
0000s0sClass::MOP::Mixin::AttributeCore::::has_write_methodClass::MOP::Mixin::AttributeCore::has_write_method
LineStmts.Exclusive
Time
Avg.Code
1package Class::MOP::Mixin::AttributeCore;
2
3332µs10µsuse strict;
# spent 10µs making 1 call to strict::import
4370µs23µsuse warnings;
# spent 26µs making 1 call to warnings::import
5
61900ns900nsour $VERSION = '1.09';
7120µs20µs$VERSION = eval $VERSION;
81600ns600nsour $AUTHORITY = 'cpan:STEVAN';
9
10330µs10µsuse Scalar::Util 'blessed';
# spent 39µs making 1 call to Exporter::import
11
123702µs234µsuse base 'Class::MOP::Mixin';
# spent 427µs making 1 call to base::import
13
14191525µs3µssub has_accessor { defined $_[0]->{'accessor'} }
15191521µs3µssub has_reader { defined $_[0]->{'reader'} }
16191502µs3µssub has_writer { defined $_[0]->{'writer'} }
17191440µs2µssub has_predicate { defined $_[0]->{'predicate'} }
18191389µs2µssub has_clearer { defined $_[0]->{'clearer'} }
19185684µs4µssub has_builder { defined $_[0]->{'builder'} }
20sub has_init_arg { defined $_[0]->{'init_arg'} }
21284511µs2µssub has_default { exists $_[0]->{'default'} }
22302702µs2µssub has_initializer { defined $_[0]->{'initializer'} }
23sub has_insertion_order { defined $_[0]->{'insertion_order'} }
24
253887µs2µssub accessor { $_[0]->{'accessor'} }
26151366µs2µssub reader { $_[0]->{'reader'} }
27917µs2µssub writer { $_[0]->{'writer'} }
283677µs2µssub predicate { $_[0]->{'predicate'} }
29sub clearer { $_[0]->{'clearer'} }
30sub builder { $_[0]->{'builder'} }
315461.80ms3µssub init_arg { $_[0]->{'init_arg'} }
32sub initializer { $_[0]->{'initializer'} }
33234549µs2µssub definition_context { $_[0]->{'definition_context'} }
34sub insertion_order { $_[0]->{'insertion_order'} }
35123178µs1µssub _set_insertion_order { $_[0]->{'insertion_order'} = $_[1] }
36
37sub has_read_method { $_[0]->has_reader || $_[0]->has_accessor }
38sub has_write_method { $_[0]->has_writer || $_[0]->has_accessor }
39
40
# spent 1.74ms within Class::MOP::Mixin::AttributeCore::is_default_a_coderef which was called 236 times, avg 7µs/call: # 114 times (949µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 53, avg 8µs/call # 93 times (559µs+0s) by Class::MOP::Method::Constructor::_generate_default_value at line 183 of /usr/local/lib/perl/5.10.0/Class/MOP/Method/Constructor.pm, avg 6µs/call # 29 times (228µs+0s) by Class::MOP::Attribute::new at line 47 of /usr/local/lib/perl/5.10.0/Class/MOP/Attribute.pm, avg 8µs/call
sub is_default_a_coderef {
41 # Uber hack because it is called from CMOP::Attribute constructor as
42 # $class->is_default_a_coderef(\%options)
436281.23ms2µs my ($value) = ref $_[0] ? $_[0]->{'default'} : $_[1]->{'default'};
44
45 return unless ref($value);
46
47 return ref($value) eq 'CODE'
48 || ( blessed($value) && $value->isa('Class::MOP::Method') );
49}
50
51
# spent 3.83ms (2.46+1.37) within Class::MOP::Mixin::AttributeCore::default which was called 447 times, avg 9µs/call: # 265 times (1.44ms+0s) by Class::MOP::Method::Constructor::_generate_constructor_method_inline at line 98 of /usr/local/lib/perl/5.10.0/Class/MOP/Method/Constructor.pm, avg 5µs/call # 114 times (621µs+1.37ms) by Class::MOP::Attribute::initialize_instance_slot at line 115 of /usr/local/lib/perl/5.10.0/Class/MOP/Attribute.pm, avg 18µs/call # 58 times (340µs+0s) by Class::MOP::Class::_immutable_metaclass at line 1195 of /usr/local/lib/perl/5.10.0/Class/MOP/Class.pm, avg 6µs/call # 10 times (58µs+0s) by Moose::Meta::Method::Constructor::_initialize_body at line 98 of /usr/local/lib/perl/5.10.0/Moose/Meta/Method/Constructor.pm, avg 6µs/call
sub default {
5212752.14ms2µs my ( $self, $instance ) = @_;
53 if ( defined $instance && $self->is_default_a_coderef ) {
54 # if the default is a CODE ref, then we pass in the instance and
55 # default can return a value based on that instance. Somewhat crude,
56 # but works.
57 return $self->{'default'}->($instance);
58 }
59 $self->{'default'};
60}
61
6217µs7µs1;
63
64__END__
65
66=pod
67
68=head1 NAME
69
70Class::MOP::Mixin::AttributeCore - Core attributes shared by attribute metaclasses
71
72=head1 DESCRIPTION
73
74This class implements the core attributes (aka properties) shared by all
75attributes. See the L<Class::MOP::Attribute> documentation for API details.
76
77=head1 AUTHORS
78
79Dave Rolsky E<lt>autarch@urth.orgE<gt>
80
81=head1 COPYRIGHT AND LICENSE
82
83Copyright 2006-2010 by Infinity Interactive, Inc.
84
85L<http://www.iinteractive.com>
86
87This library is free software; you can redistribute it and/or modify
88it under the same terms as Perl itself.
89
90=cut