Filename | /usr/local/lib/perl/5.14.2/Moose/Meta/Method/Delegation.pm |
Statements | Executed 1038 statements in 2.21ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
36 | 1 | 1 | 514µs | 1.89ms | new | Moose::Meta::Method::Delegation::
36 | 1 | 1 | 401µs | 1.08ms | _initialize_body | Moose::Meta::Method::Delegation::
36 | 1 | 1 | 294µs | 624µs | _get_delegate_accessor | Moose::Meta::Method::Delegation::
36 | 1 | 1 | 213µs | 213µs | _new | Moose::Meta::Method::Delegation::
36 | 1 | 1 | 37µs | 37µs | delegate_to_method | Moose::Meta::Method::Delegation::
36 | 1 | 1 | 32µs | 32µs | associated_attribute | Moose::Meta::Method::Delegation::
1 | 1 | 1 | 9µs | 36µs | BEGIN@13 | Moose::Meta::Method::Delegation::
1 | 1 | 1 | 8µs | 8µs | BEGIN@3 | Moose::Meta::Method::Delegation::
1 | 1 | 1 | 8µs | 11µs | BEGIN@10 | Moose::Meta::Method::Delegation::
1 | 1 | 1 | 7µs | 35µs | BEGIN@14 | Moose::Meta::Method::Delegation::
1 | 1 | 1 | 7µs | 71µs | BEGIN@16 | Moose::Meta::Method::Delegation::
1 | 1 | 1 | 6µs | 12µs | BEGIN@11 | Moose::Meta::Method::Delegation::
2 | 1 | 1 | 3µs | 3µs | curried_arguments | Moose::Meta::Method::Delegation::
0 | 0 | 0 | 0s | 0s | __ANON__[:111] | Moose::Meta::Method::Delegation::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | package Moose::Meta::Method::Delegation; | ||||
3 | # spent 8µs within Moose::Meta::Method::Delegation::BEGIN@3 which was called:
# once (8µs+0s) by Moose::Meta::Attribute::BEGIN@22 at line 5 | ||||
4 | 1 | 5µs | $Moose::Meta::Method::Delegation::AUTHORITY = 'cpan:STEVAN'; | ||
5 | 1 | 29µs | 1 | 8µs | } # spent 8µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@3 |
6 | { | ||||
7 | 2 | 1µs | $Moose::Meta::Method::Delegation::VERSION = '2.1005'; | ||
8 | } | ||||
9 | |||||
10 | 2 | 21µs | 2 | 14µs | # spent 11µs (8+3) within Moose::Meta::Method::Delegation::BEGIN@10 which was called:
# once (8µs+3µs) by Moose::Meta::Attribute::BEGIN@22 at line 10 # spent 11µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@10
# spent 3µs making 1 call to strict::import |
11 | 2 | 22µs | 2 | 17µs | # spent 12µs (6+5) within Moose::Meta::Method::Delegation::BEGIN@11 which was called:
# once (6µs+5µs) by Moose::Meta::Attribute::BEGIN@22 at line 11 # spent 12µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@11
# spent 5µs making 1 call to warnings::import |
12 | |||||
13 | 2 | 27µs | 2 | 63µs | # spent 36µs (9+27) within Moose::Meta::Method::Delegation::BEGIN@13 which was called:
# once (9µs+27µs) by Moose::Meta::Attribute::BEGIN@22 at line 13 # spent 36µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@13
# spent 27µs making 1 call to Exporter::import |
14 | 2 | 26µs | 2 | 62µs | # spent 35µs (7+28) within Moose::Meta::Method::Delegation::BEGIN@14 which was called:
# once (7µs+28µs) by Moose::Meta::Attribute::BEGIN@22 at line 14 # spent 35µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@14
# spent 28µs making 1 call to Exporter::import |
15 | |||||
16 | 1 | 65µs | # spent 71µs (7+65) within Moose::Meta::Method::Delegation::BEGIN@16 which was called:
# once (7µs+65µs) by Moose::Meta::Attribute::BEGIN@22 at line 17 # spent 65µs making 1 call to base::import | ||
17 | 2 | 458µs | 1 | 71µs | 'Class::MOP::Method::Generated'; # spent 71µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@16 |
18 | |||||
19 | |||||
20 | # spent 1.89ms (514µs+1.38) within Moose::Meta::Method::Delegation::new which was called 36 times, avg 53µs/call:
# 36 times (514µs+1.38ms) by Moose::Meta::Attribute::_make_delegation_method at line 1247 of Moose/Meta/Attribute.pm, avg 53µs/call | ||||
21 | 432 | 557µs | my $class = shift; | ||
22 | my %options = @_; | ||||
23 | |||||
24 | ( exists $options{attribute} ) | ||||
25 | || confess "You must supply an attribute to construct with"; | ||||
26 | |||||
27 | 72 | 50µs | ( blessed( $options{attribute} ) # spent 26µs making 36 calls to Scalar::Util::blessed, avg 728ns/call
# spent 24µs making 36 calls to UNIVERSAL::isa, avg 667ns/call | ||
28 | && $options{attribute}->isa('Moose::Meta::Attribute') ) | ||||
29 | || confess | ||||
30 | "You must supply an attribute which is a 'Moose::Meta::Attribute' instance"; | ||||
31 | |||||
32 | ( $options{package_name} && $options{name} ) | ||||
33 | || confess | ||||
34 | "You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT"; | ||||
35 | |||||
36 | ( $options{delegate_to_method} && ( !ref $options{delegate_to_method} ) | ||||
37 | || ( 'CODE' eq ref $options{delegate_to_method} ) ) | ||||
38 | || confess | ||||
39 | 'You must supply a delegate_to_method which is a method name or a CODE reference'; | ||||
40 | |||||
41 | exists $options{curried_arguments} | ||||
42 | || ( $options{curried_arguments} = [] ); | ||||
43 | |||||
44 | ( $options{curried_arguments} && | ||||
45 | ( 'ARRAY' eq ref $options{curried_arguments} ) ) | ||||
46 | || confess 'You must supply a curried_arguments which is an ARRAY reference'; | ||||
47 | |||||
48 | 36 | 213µs | my $self = $class->_new( \%options ); # spent 213µs making 36 calls to Moose::Meta::Method::Delegation::_new, avg 6µs/call | ||
49 | |||||
50 | 36 | 31µs | weaken( $self->{'attribute'} ); # spent 31µs making 36 calls to Scalar::Util::weaken, avg 850ns/call | ||
51 | |||||
52 | 36 | 1.08ms | $self->_initialize_body; # spent 1.08ms making 36 calls to Moose::Meta::Method::Delegation::_initialize_body, avg 30µs/call | ||
53 | |||||
54 | return $self; | ||||
55 | } | ||||
56 | |||||
57 | # spent 213µs within Moose::Meta::Method::Delegation::_new which was called 36 times, avg 6µs/call:
# 36 times (213µs+0s) by Moose::Meta::Method::Delegation::new at line 48, avg 6µs/call | ||||
58 | 108 | 244µs | my $class = shift; | ||
59 | my $options = @_ == 1 ? $_[0] : {@_}; | ||||
60 | |||||
61 | return bless $options, $class; | ||||
62 | } | ||||
63 | |||||
64 | 2 | 6µs | # spent 3µs within Moose::Meta::Method::Delegation::curried_arguments which was called 2 times, avg 1µs/call:
# 2 times (3µs+0s) by MongoDB::Connection::get_database or MongoDB::Connection::query_timeout at line 109, avg 1µs/call | ||
65 | |||||
66 | 36 | 65µs | # spent 32µs within Moose::Meta::Method::Delegation::associated_attribute which was called 36 times, avg 883ns/call:
# 36 times (32µs+0s) by Moose::Meta::Method::Delegation::_get_delegate_accessor at line 116, avg 883ns/call | ||
67 | |||||
68 | 36 | 71µs | # spent 37µs within Moose::Meta::Method::Delegation::delegate_to_method which was called 36 times, avg 1µs/call:
# 36 times (37µs+0s) by Moose::Meta::Method::Delegation::_initialize_body at line 73, avg 1µs/call | ||
69 | |||||
70 | # spent 1.08ms (401µs+682µs) within Moose::Meta::Method::Delegation::_initialize_body which was called 36 times, avg 30µs/call:
# 36 times (401µs+682µs) by Moose::Meta::Method::Delegation::new at line 52, avg 30µs/call | ||||
71 | 216 | 390µs | my $self = shift; | ||
72 | |||||
73 | 36 | 37µs | my $method_to_call = $self->delegate_to_method; # spent 37µs making 36 calls to Moose::Meta::Method::Delegation::delegate_to_method, avg 1µs/call | ||
74 | return $self->{body} = $method_to_call | ||||
75 | if ref $method_to_call; | ||||
76 | |||||
77 | 36 | 624µs | my $accessor = $self->_get_delegate_accessor; # spent 624µs making 36 calls to Moose::Meta::Method::Delegation::_get_delegate_accessor, avg 17µs/call | ||
78 | |||||
79 | 36 | 21µs | my $handle_name = $self->name; # spent 21µs making 36 calls to Class::MOP::Method::name, avg 572ns/call | ||
80 | |||||
81 | # NOTE: we used to do a goto here, but the goto didn't handle | ||||
82 | # failure correctly (it just returned nothing), so I took that | ||||
83 | # out. However, the more I thought about it, the less I liked it | ||||
84 | # doing the goto, and I preferred the act of delegation being | ||||
85 | # actually represented in the stack trace. - SL | ||||
86 | # not inlining this, since it won't really speed things up at | ||||
87 | # all... the only thing that would end up different would be | ||||
88 | # interpolating in $method_to_call, and a bunch of things in the | ||||
89 | # error handling that mostly never gets called - doy | ||||
90 | $self->{body} = sub { | ||||
91 | 12 | 25µs | my $instance = shift; | ||
92 | 2 | 4µs | my $proxy = $instance->$accessor(); # spent 4µs making 2 calls to MongoDB::Connection::_client, avg 2µs/call | ||
93 | |||||
94 | 2 | 1µs | my $error # spent 1µs making 2 calls to Scalar::Util::blessed, avg 700ns/call | ||
95 | = !defined $proxy ? ' is not defined' | ||||
96 | : ref($proxy) && !blessed($proxy) ? qq{ is not an object (got '$proxy')} | ||||
97 | : undef; | ||||
98 | |||||
99 | if ($error) { | ||||
100 | $self->throw_error( | ||||
101 | "Cannot delegate $handle_name to $method_to_call because " | ||||
102 | . "the value of " | ||||
103 | . $self->associated_attribute->name | ||||
104 | . $error, | ||||
105 | method_name => $method_to_call, | ||||
106 | object => $instance | ||||
107 | ); | ||||
108 | } | ||||
109 | 2 | 3µs | 2 | 3µs | unshift @_, @{ $self->curried_arguments }; # spent 3µs making 2 calls to Moose::Meta::Method::Delegation::curried_arguments, avg 1µs/call |
110 | 2 | 36µs | $proxy->$method_to_call(@_); # spent 25µs making 1 call to MongoDB::MongoClient::get_database
# spent 12µs making 1 call to MongoDB::MongoClient::query_timeout | ||
111 | }; | ||||
112 | } | ||||
113 | |||||
114 | # spent 624µs (294+330) within Moose::Meta::Method::Delegation::_get_delegate_accessor which was called 36 times, avg 17µs/call:
# 36 times (294µs+330µs) by Moose::Meta::Method::Delegation::_initialize_body at line 77, avg 17µs/call | ||||
115 | 180 | 258µs | my $self = shift; | ||
116 | 36 | 32µs | my $attr = $self->associated_attribute; # spent 32µs making 36 calls to Moose::Meta::Method::Delegation::associated_attribute, avg 883ns/call | ||
117 | |||||
118 | # NOTE: | ||||
119 | # always use a named method when | ||||
120 | # possible, if you use the method | ||||
121 | # ref and there are modifiers on | ||||
122 | # the accessors then it will not | ||||
123 | # pick up the modifiers too. Only | ||||
124 | # the named method will assure that | ||||
125 | # we also have any modifiers run. | ||||
126 | # - SL | ||||
127 | 72 | 281µs | my $accessor = $attr->has_read_method # spent 144µs making 36 calls to Class::MOP::Mixin::AttributeCore::has_read_method, avg 4µs/call
# spent 138µs making 36 calls to Class::MOP::Attribute::get_read_method, avg 4µs/call | ||
128 | ? $attr->get_read_method | ||||
129 | : $attr->get_read_method_ref; | ||||
130 | |||||
131 | 36 | 17µs | $accessor = $accessor->body if Scalar::Util::blessed $accessor; # spent 17µs making 36 calls to Scalar::Util::blessed, avg 481ns/call | ||
132 | |||||
133 | return $accessor; | ||||
134 | } | ||||
135 | |||||
136 | 1 | 3µs | 1; | ||
137 | |||||
138 | # ABSTRACT: A Moose Method metaclass for delegation methods | ||||
139 | |||||
140 | __END__ |