← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mentat.storage.mongo.pl
  Run on Tue Jun 24 09:58:41 2014
Reported on Tue Jun 24 09:59:13 2014

Filename/usr/local/lib/perl/5.14.2/Moose/Meta/Method/Delegation.pm
StatementsExecuted 1038 statements in 2.21ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
3611514µs1.89msMoose::Meta::Method::Delegation::::newMoose::Meta::Method::Delegation::new
3611401µs1.08msMoose::Meta::Method::Delegation::::_initialize_bodyMoose::Meta::Method::Delegation::_initialize_body
3611294µs624µsMoose::Meta::Method::Delegation::::_get_delegate_accessorMoose::Meta::Method::Delegation::_get_delegate_accessor
3611213µs213µsMoose::Meta::Method::Delegation::::_newMoose::Meta::Method::Delegation::_new
361137µs37µsMoose::Meta::Method::Delegation::::delegate_to_methodMoose::Meta::Method::Delegation::delegate_to_method
361132µs32µsMoose::Meta::Method::Delegation::::associated_attributeMoose::Meta::Method::Delegation::associated_attribute
1119µs36µsMoose::Meta::Method::Delegation::::BEGIN@13Moose::Meta::Method::Delegation::BEGIN@13
1118µs8µsMoose::Meta::Method::Delegation::::BEGIN@3Moose::Meta::Method::Delegation::BEGIN@3
1118µs11µsMoose::Meta::Method::Delegation::::BEGIN@10Moose::Meta::Method::Delegation::BEGIN@10
1117µs35µsMoose::Meta::Method::Delegation::::BEGIN@14Moose::Meta::Method::Delegation::BEGIN@14
1117µs71µsMoose::Meta::Method::Delegation::::BEGIN@16Moose::Meta::Method::Delegation::BEGIN@16
1116µs12µsMoose::Meta::Method::Delegation::::BEGIN@11Moose::Meta::Method::Delegation::BEGIN@11
2113µs3µsMoose::Meta::Method::Delegation::::curried_argumentsMoose::Meta::Method::Delegation::curried_arguments
0000s0sMoose::Meta::Method::Delegation::::__ANON__[:111]Moose::Meta::Method::Delegation::__ANON__[:111]
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1
2package 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
BEGIN {
415µs $Moose::Meta::Method::Delegation::AUTHORITY = 'cpan:STEVAN';
5129µs18µs}
# spent 8µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@3
6{
721µs $Moose::Meta::Method::Delegation::VERSION = '2.1005';
8}
9
10221µs214µ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
use strict;
# spent 11µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@10 # spent 3µs making 1 call to strict::import
11222µs217µ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
use warnings;
# spent 12µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@11 # spent 5µs making 1 call to warnings::import
12
13227µs263µ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
use Carp 'confess';
# spent 36µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@13 # spent 27µs making 1 call to Exporter::import
14226µs262µ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
use Scalar::Util 'blessed', 'weaken';
# spent 35µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@14 # spent 28µs making 1 call to Exporter::import
15
16165µ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
use base 'Moose::Meta::Method',
# spent 65µs making 1 call to base::import
172458µs171µ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
sub new {
21432557µs my $class = shift;
22 my %options = @_;
23
24 ( exists $options{attribute} )
25 || confess "You must supply an attribute to construct with";
26
277250µ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
4836213µs my $self = $class->_new( \%options );
# spent 213µs making 36 calls to Moose::Meta::Method::Delegation::_new, avg 6µs/call
49
503631µs weaken( $self->{'attribute'} );
# spent 31µs making 36 calls to Scalar::Util::weaken, avg 850ns/call
51
52361.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
sub _new {
58108244µs my $class = shift;
59 my $options = @_ == 1 ? $_[0] : {@_};
60
61 return bless $options, $class;
62}
63
6426µ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
sub curried_arguments { (shift)->{'curried_arguments'} }
65
663665µ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
sub associated_attribute { (shift)->{'attribute'} }
67
683671µ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
sub delegate_to_method { (shift)->{'delegate_to_method'} }
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
sub _initialize_body {
71216390µs my $self = shift;
72
733637µ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
7736624µ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
793621µ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 {
911427µs my $instance = shift;
9224µs my $proxy = $instance->$accessor();
# spent 4µs making 2 calls to MongoDB::Connection::_client, avg 2µs/call
93
9421µ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 }
10923µs unshift @_, @{ $self->curried_arguments };
# spent 3µs making 2 calls to Moose::Meta::Method::Delegation::curried_arguments, avg 1µs/call
110236µ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
sub _get_delegate_accessor {
115180258µs my $self = shift;
1163632µ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
12772281µ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
1313617µ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
13613µs1;
137
138# ABSTRACT: A Moose Method metaclass for delegation methods
139
140__END__