File | /usr/local/lib/perl/5.10.0/Class/MOP/Mixin/AttributeCore.pm |
Statements Executed | 4782 |
Total Time | 0.0115779 seconds |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
447 | 4 | 4 | 2.46ms | 3.83ms | default | Class::MOP::Mixin::AttributeCore::
236 | 3 | 3 | 1.74ms | 1.74ms | is_default_a_coderef | Class::MOP::Mixin::AttributeCore::
0 | 0 | 0 | 0s | 0s | BEGIN | Class::MOP::Mixin::AttributeCore::
0 | 0 | 0 | 0s | 0s | has_read_method | Class::MOP::Mixin::AttributeCore::
0 | 0 | 0 | 0s | 0s | has_write_method | Class::MOP::Mixin::AttributeCore::
Line | Stmts. | Exclusive Time | Avg. | Code |
---|---|---|---|---|
1 | package Class::MOP::Mixin::AttributeCore; | |||
2 | ||||
3 | 3 | 32µs | 10µs | use strict; # spent 10µs making 1 call to strict::import |
4 | 3 | 70µs | 23µs | use warnings; # spent 26µs making 1 call to warnings::import |
5 | ||||
6 | 1 | 900ns | 900ns | our $VERSION = '1.09'; |
7 | 1 | 20µs | 20µs | $VERSION = eval $VERSION; |
8 | 1 | 600ns | 600ns | our $AUTHORITY = 'cpan:STEVAN'; |
9 | ||||
10 | 3 | 30µs | 10µs | use Scalar::Util 'blessed'; # spent 39µs making 1 call to Exporter::import |
11 | ||||
12 | 3 | 702µs | 234µs | use base 'Class::MOP::Mixin'; # spent 427µs making 1 call to base::import |
13 | ||||
14 | 191 | 525µs | 3µs | sub has_accessor { defined $_[0]->{'accessor'} } |
15 | 191 | 521µs | 3µs | sub has_reader { defined $_[0]->{'reader'} } |
16 | 191 | 502µs | 3µs | sub has_writer { defined $_[0]->{'writer'} } |
17 | 191 | 440µs | 2µs | sub has_predicate { defined $_[0]->{'predicate'} } |
18 | 191 | 389µs | 2µs | sub has_clearer { defined $_[0]->{'clearer'} } |
19 | 185 | 684µs | 4µs | sub has_builder { defined $_[0]->{'builder'} } |
20 | sub has_init_arg { defined $_[0]->{'init_arg'} } | |||
21 | 284 | 511µs | 2µs | sub has_default { exists $_[0]->{'default'} } |
22 | 302 | 702µs | 2µs | sub has_initializer { defined $_[0]->{'initializer'} } |
23 | sub has_insertion_order { defined $_[0]->{'insertion_order'} } | |||
24 | ||||
25 | 38 | 87µs | 2µs | sub accessor { $_[0]->{'accessor'} } |
26 | 151 | 366µs | 2µs | sub reader { $_[0]->{'reader'} } |
27 | 9 | 17µs | 2µs | sub writer { $_[0]->{'writer'} } |
28 | 36 | 77µs | 2µs | sub predicate { $_[0]->{'predicate'} } |
29 | sub clearer { $_[0]->{'clearer'} } | |||
30 | sub builder { $_[0]->{'builder'} } | |||
31 | 546 | 1.80ms | 3µs | sub init_arg { $_[0]->{'init_arg'} } |
32 | sub initializer { $_[0]->{'initializer'} } | |||
33 | 234 | 549µs | 2µs | sub definition_context { $_[0]->{'definition_context'} } |
34 | sub insertion_order { $_[0]->{'insertion_order'} } | |||
35 | 123 | 178µs | 1µs | sub _set_insertion_order { $_[0]->{'insertion_order'} = $_[1] } |
36 | ||||
37 | sub has_read_method { $_[0]->has_reader || $_[0]->has_accessor } | |||
38 | sub 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 | |||
41 | # Uber hack because it is called from CMOP::Attribute constructor as | |||
42 | # $class->is_default_a_coderef(\%options) | |||
43 | 628 | 1.23ms | 2µ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 | |||
52 | 1275 | 2.14ms | 2µs | my ( $self, $instance ) = @_; |
53 | if ( defined $instance && $self->is_default_a_coderef ) { # spent 949µs making 114 calls to Class::MOP::Mixin::AttributeCore::is_default_a_coderef, avg 8µs/call
# spent 60µs making 8 calls to Class::MOP::__ANON__[/usr/local/lib/perl/5.10.0/Class/MOP.pm:233], avg 8µs/call
# spent 58µs making 8 calls to Class::MOP::__ANON__[/usr/local/lib/perl/5.10.0/Class/MOP.pm:320], avg 7µs/call
# spent 57µs making 8 calls to Moose::Meta::Class::__ANON__[/usr/local/lib/perl/5.10.0/Moose/Meta/Class.pm:35], avg 7µs/call
# spent 53µs making 8 calls to Class::MOP::__ANON__[/usr/local/lib/perl/5.10.0/Class/MOP.pm:301], avg 7µs/call
# spent 53µs making 8 calls to Moose::Meta::Class::__ANON__[/usr/local/lib/perl/5.10.0/Moose/Meta/Class.pm:40], avg 7µs/call
# spent 45µs making 8 calls to Class::MOP::__ANON__[/usr/local/lib/perl/5.10.0/Class/MOP.pm:191], avg 6µs/call
# spent 43µs making 8 calls to Class::MOP::__ANON__[/usr/local/lib/perl/5.10.0/Class/MOP.pm:336], avg 5µs/call
# spent 41µs making 8 calls to Class::MOP::__ANON__[/usr/local/lib/perl/5.10.0/Class/MOP.pm:275], avg 5µs/call
# spent 8µs making 1 call to Class::MOP::__ANON__[/usr/local/lib/perl/5.10.0/Class/MOP.pm:509]
# spent 7µs making 1 call to Moose::Meta::TypeConstraint::Registry::__ANON__[/usr/local/lib/perl/5.10.0/Moose/Meta/TypeConstraint/Registry.pm:24] | |||
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 | ||||
62 | 1 | 7µs | 7µs | 1; |
63 | ||||
64 | __END__ | |||
65 | ||||
66 | =pod | |||
67 | ||||
68 | =head1 NAME | |||
69 | ||||
70 | Class::MOP::Mixin::AttributeCore - Core attributes shared by attribute metaclasses | |||
71 | ||||
72 | =head1 DESCRIPTION | |||
73 | ||||
74 | This class implements the core attributes (aka properties) shared by all | |||
75 | attributes. See the L<Class::MOP::Attribute> documentation for API details. | |||
76 | ||||
77 | =head1 AUTHORS | |||
78 | ||||
79 | Dave Rolsky E<lt>autarch@urth.orgE<gt> | |||
80 | ||||
81 | =head1 COPYRIGHT AND LICENSE | |||
82 | ||||
83 | Copyright 2006-2010 by Infinity Interactive, Inc. | |||
84 | ||||
85 | L<http://www.iinteractive.com> | |||
86 | ||||
87 | This library is free software; you can redistribute it and/or modify | |||
88 | it under the same terms as Perl itself. | |||
89 | ||||
90 | =cut |