| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Method/Delegation.pm |
| Statements | Executed 91 statements in 4.16ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 580µs | 580µs | Moose::Meta::Method::Delegation::_new |
| 28 | 2 | 1 | 301µs | 301µs | Moose::Meta::Method::Delegation::curried_arguments |
| 17 | 4 | 3 | 194µs | 194µs | Moose::Meta::Method::Delegation::delegate_to_method |
| 1 | 1 | 1 | 140µs | 1.15ms | Moose::Meta::Method::Delegation::new |
| 1 | 1 | 1 | 122µs | 291µs | Moose::Meta::Method::Delegation::_get_delegate_accessor |
| 1 | 1 | 1 | 100µs | 407µs | Moose::Meta::Method::Delegation::_initialize_body |
| 1 | 1 | 1 | 76µs | 96µs | Moose::Meta::Method::Delegation::BEGIN@4 |
| 1 | 1 | 1 | 45µs | 495µs | Moose::Meta::Method::Delegation::BEGIN@14 |
| 1 | 1 | 1 | 40µs | 110µs | Moose::Meta::Method::Delegation::BEGIN@5 |
| 1 | 1 | 1 | 39µs | 201µs | Moose::Meta::Method::Delegation::BEGIN@8 |
| 1 | 1 | 1 | 39µs | 222µs | Moose::Meta::Method::Delegation::BEGIN@7 |
| 1 | 1 | 1 | 8µs | 8µs | Moose::Meta::Method::Delegation::associated_attribute |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Delegation::__ANON__[:109] |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | package Moose::Meta::Method::Delegation; | ||||
| 3 | |||||
| 4 | 3 | 103µs | 2 | 115µs | # spent 96µs (76+20) within Moose::Meta::Method::Delegation::BEGIN@4 which was called:
# once (76µs+20µs) by Moose::Meta::Attribute::BEGIN@18 at line 4 # spent 96µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@4
# spent 20µs making 1 call to strict::import |
| 5 | 3 | 105µs | 2 | 180µs | # spent 110µs (40+70) within Moose::Meta::Method::Delegation::BEGIN@5 which was called:
# once (40µs+70µs) by Moose::Meta::Attribute::BEGIN@18 at line 5 # spent 110µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@5
# spent 70µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 3 | 114µs | 2 | 404µs | # spent 222µs (39+182) within Moose::Meta::Method::Delegation::BEGIN@7 which was called:
# once (39µs+182µs) by Moose::Meta::Attribute::BEGIN@18 at line 7 # spent 222µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@7
# spent 182µs making 1 call to Exporter::import |
| 8 | 3 | 219µs | 2 | 362µs | # spent 201µs (39+161) within Moose::Meta::Method::Delegation::BEGIN@8 which was called:
# once (39µs+161µs) by Moose::Meta::Attribute::BEGIN@18 at line 8 # spent 201µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@8
# spent 161µs making 1 call to Exporter::import |
| 9 | |||||
| 10 | 1 | 5µs | our $VERSION = '1.19'; | ||
| 11 | 1 | 61µs | $VERSION = eval $VERSION; # spent 11µs executing statements in string eval | ||
| 12 | 1 | 4µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 13 | |||||
| 14 | 1 | 37µs | 1 | 450µs | # spent 495µs (45+449) within Moose::Meta::Method::Delegation::BEGIN@14 which was called:
# once (45µs+449µs) by Moose::Meta::Attribute::BEGIN@18 at line 15 # spent 450µs making 1 call to base::import |
| 15 | 2 | 1.81ms | 1 | 495µs | 'Class::MOP::Method::Generated'; # spent 495µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@14 |
| 16 | |||||
| 17 | |||||
| 18 | # spent 1.15ms (140µs+1.01) within Moose::Meta::Method::Delegation::new which was called:
# once (140µs+1.01ms) by Moose::Meta::Attribute::_make_delegation_method at line 864 of Moose/Meta/Attribute.pm | ||||
| 19 | 1 | 5µs | my $class = shift; | ||
| 20 | 1 | 12µs | my %options = @_; | ||
| 21 | |||||
| 22 | 1 | 3µs | ( exists $options{attribute} ) | ||
| 23 | || confess "You must supply an attribute to construct with"; | ||||
| 24 | |||||
| 25 | 1 | 43µs | 2 | 13µs | ( blessed( $options{attribute} ) # spent 6µs making 1 call to Scalar::Util::blessed
# spent 6µs making 1 call to UNIVERSAL::isa |
| 26 | && $options{attribute}->isa('Moose::Meta::Attribute') ) | ||||
| 27 | || confess | ||||
| 28 | "You must supply an attribute which is a 'Moose::Meta::Attribute' instance"; | ||||
| 29 | |||||
| 30 | 1 | 4µs | ( $options{package_name} && $options{name} ) | ||
| 31 | || confess | ||||
| 32 | "You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT"; | ||||
| 33 | |||||
| 34 | 1 | 4µs | ( $options{delegate_to_method} && ( !ref $options{delegate_to_method} ) | ||
| 35 | || ( 'CODE' eq ref $options{delegate_to_method} ) ) | ||||
| 36 | || confess | ||||
| 37 | 'You must supply a delegate_to_method which is a method name or a CODE reference'; | ||||
| 38 | |||||
| 39 | 1 | 3µs | exists $options{curried_arguments} | ||
| 40 | || ( $options{curried_arguments} = [] ); | ||||
| 41 | |||||
| 42 | 1 | 5µs | ( $options{curried_arguments} && | ||
| 43 | ( 'ARRAY' eq ref $options{curried_arguments} ) ) | ||||
| 44 | || confess 'You must supply a curried_arguments which is an ARRAY reference'; | ||||
| 45 | |||||
| 46 | 1 | 14µs | 1 | 580µs | my $self = $class->_new( \%options ); # spent 580µs making 1 call to Moose::Meta::Method::Delegation::_new |
| 47 | |||||
| 48 | 1 | 25µs | 1 | 7µs | weaken( $self->{'attribute'} ); # spent 7µs making 1 call to Scalar::Util::weaken |
| 49 | |||||
| 50 | 1 | 11µs | 1 | 407µs | $self->_initialize_body; # spent 407µs making 1 call to Moose::Meta::Method::Delegation::_initialize_body |
| 51 | |||||
| 52 | 1 | 17µs | return $self; | ||
| 53 | } | ||||
| 54 | |||||
| 55 | # spent 580µs within Moose::Meta::Method::Delegation::_new which was called:
# once (580µs+0s) by Moose::Meta::Method::Delegation::new at line 46 | ||||
| 56 | 1 | 4µs | my $class = shift; | ||
| 57 | 1 | 4µs | my $options = @_ == 1 ? $_[0] : {@_}; | ||
| 58 | |||||
| 59 | 1 | 584µs | return bless $options, $class; | ||
| 60 | } | ||||
| 61 | |||||
| 62 | 28 | 453µs | # spent 301µs within Moose::Meta::Method::Delegation::curried_arguments which was called 28 times, avg 11µs/call:
# 14 times (159µs+0s) by Moose::Meta::Method::Accessor::Native::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Method/Accessor/Native.pm:136] at line 121 of Moose/Meta/Method/Accessor/Native.pm, avg 11µs/call
# 14 times (142µs+0s) by Moose::Meta::Method::Accessor::Native::_inline_curried_arguments at line 56 of Moose/Meta/Method/Accessor/Native.pm, avg 10µs/call | ||
| 63 | |||||
| 64 | 1 | 18µs | # spent 8µs within Moose::Meta::Method::Delegation::associated_attribute which was called:
# once (8µs+0s) by Moose::Meta::Method::Delegation::_get_delegate_accessor at line 114 | ||
| 65 | |||||
| 66 | 17 | 283µs | # spent 194µs within Moose::Meta::Method::Delegation::delegate_to_method which was called 17 times, avg 11µs/call:
# 9 times (109µs+0s) by Moose::Meta::Method::Accessor::Native::_inline_check_argument_count at line 81 of Moose/Meta/Method/Accessor/Native.pm, avg 12µs/call
# 5 times (58µs+0s) by Moose::Meta::Method::Accessor::Native::_inline_check_argument_count at line 67 of Moose/Meta/Method/Accessor/Native.pm, avg 12µs/call
# 2 times (17µs+0s) by Moose::Meta::Method::Accessor::Native::Hash::_inline_check_var_is_valid_key at line 15 of Moose/Meta/Method/Accessor/Native/Hash.pm, avg 9µs/call
# once (10µs+0s) by Moose::Meta::Method::Delegation::_initialize_body at line 71 | ||
| 67 | |||||
| 68 | # spent 407µs (100+307) within Moose::Meta::Method::Delegation::_initialize_body which was called:
# once (100µs+307µs) by Moose::Meta::Method::Delegation::new at line 50 | ||||
| 69 | 1 | 3µs | my $self = shift; | ||
| 70 | |||||
| 71 | 1 | 11µs | 1 | 10µs | my $method_to_call = $self->delegate_to_method; # spent 10µs making 1 call to Moose::Meta::Method::Delegation::delegate_to_method |
| 72 | 1 | 2µs | return $self->{body} = $method_to_call | ||
| 73 | if ref $method_to_call; | ||||
| 74 | |||||
| 75 | 1 | 11µs | 1 | 291µs | my $accessor = $self->_get_delegate_accessor; # spent 291µs making 1 call to Moose::Meta::Method::Delegation::_get_delegate_accessor |
| 76 | |||||
| 77 | 1 | 36µs | 1 | 6µs | my $handle_name = $self->name; # spent 6µs making 1 call to Class::MOP::Method::name |
| 78 | |||||
| 79 | # NOTE: we used to do a goto here, but the goto didn't handle | ||||
| 80 | # failure correctly (it just returned nothing), so I took that | ||||
| 81 | # out. However, the more I thought about it, the less I liked it | ||||
| 82 | # doing the goto, and I preferred the act of delegation being | ||||
| 83 | # actually represented in the stack trace. - SL | ||||
| 84 | # not inlining this, since it won't really speed things up at | ||||
| 85 | # all... the only thing that would end up different would be | ||||
| 86 | # interpolating in $method_to_call, and a bunch of things in the | ||||
| 87 | # error handling that mostly never gets called - doy | ||||
| 88 | $self->{body} = sub { | ||||
| 89 | my $instance = shift; | ||||
| 90 | my $proxy = $instance->$accessor(); | ||||
| 91 | |||||
| 92 | my $error | ||||
| 93 | = !defined $proxy ? ' is not defined' | ||||
| 94 | : ref($proxy) && !blessed($proxy) ? qq{ is not an object (got '$proxy')} | ||||
| 95 | : undef; | ||||
| 96 | |||||
| 97 | if ($error) { | ||||
| 98 | $self->throw_error( | ||||
| 99 | "Cannot delegate $handle_name to $method_to_call because " | ||||
| 100 | . "the value of " | ||||
| 101 | . $self->associated_attribute->name | ||||
| 102 | . $error, | ||||
| 103 | method_name => $method_to_call, | ||||
| 104 | object => $instance | ||||
| 105 | ); | ||||
| 106 | } | ||||
| 107 | unshift @_, @{ $self->curried_arguments }; | ||||
| 108 | $proxy->$method_to_call(@_); | ||||
| 109 | 1 | 31µs | }; | ||
| 110 | } | ||||
| 111 | |||||
| 112 | # spent 291µs (122+170) within Moose::Meta::Method::Delegation::_get_delegate_accessor which was called:
# once (122µs+170µs) by Moose::Meta::Method::Delegation::_initialize_body at line 75 | ||||
| 113 | 1 | 3µs | my $self = shift; | ||
| 114 | 1 | 10µs | 1 | 8µs | my $attr = $self->associated_attribute; # spent 8µs making 1 call to Moose::Meta::Method::Delegation::associated_attribute |
| 115 | |||||
| 116 | # NOTE: | ||||
| 117 | # always use a named method when | ||||
| 118 | # possible, if you use the method | ||||
| 119 | # ref and there are modifiers on | ||||
| 120 | # the accessors then it will not | ||||
| 121 | # pick up the modifiers too. Only | ||||
| 122 | # the named method will assure that | ||||
| 123 | # we also have any modifiers run. | ||||
| 124 | # - SL | ||||
| 125 | 1 | 49µs | 2 | 156µs | my $accessor = $attr->has_read_method # spent 92µs making 1 call to Class::MOP::Attribute::get_read_method
# spent 64µs making 1 call to Class::MOP::Mixin::AttributeCore::has_read_method |
| 126 | ? $attr->get_read_method | ||||
| 127 | : $attr->get_read_method_ref; | ||||
| 128 | |||||
| 129 | 1 | 21µs | 1 | 5µs | $accessor = $accessor->body if Scalar::Util::blessed $accessor; # spent 5µs making 1 call to Scalar::Util::blessed |
| 130 | |||||
| 131 | 1 | 19µs | return $accessor; | ||
| 132 | } | ||||
| 133 | |||||
| 134 | 1 | 12µs | 1; | ||
| 135 | |||||
| 136 | __END__ |