← Index
NYTProf Performance Profile   « line view »
For /home/ss5/perl5/perlbrew/perls/perl-5.22.0/bin/benchmarkanything-storage
  Run on Mon Jan 29 16:55:34 2018
Reported on Mon Jan 29 16:57:06 2018

Filename/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Meta/Method/Delegation.pm
StatementsExecuted 68 statements in 469µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
21166µs137µsMoose::Meta::Method::Delegation::::newMoose::Meta::Method::Delegation::new
21121µs65µsMoose::Meta::Method::Delegation::::_initialize_bodyMoose::Meta::Method::Delegation::_initialize_body
21119µs41µsMoose::Meta::Method::Delegation::::_get_delegate_accessorMoose::Meta::Method::Delegation::_get_delegate_accessor
1119µs11µsMoose::Meta::Method::Delegation::::BEGIN@4Moose::Meta::Method::Delegation::BEGIN@4
1115µs93µsMoose::Meta::Method::Delegation::::BEGIN@12Moose::Meta::Method::Delegation::BEGIN@12
1115µs8µsMoose::Meta::Method::Delegation::::BEGIN@5Moose::Meta::Method::Delegation::BEGIN@5
1114µs24µsMoose::Meta::Method::Delegation::::BEGIN@9Moose::Meta::Method::Delegation::BEGIN@9
1114µs25µsMoose::Meta::Method::Delegation::::BEGIN@7Moose::Meta::Method::Delegation::BEGIN@7
2114µs4µsMoose::Meta::Method::Delegation::::_newMoose::Meta::Method::Delegation::_new
2112µs2µsMoose::Meta::Method::Delegation::::delegate_to_methodMoose::Meta::Method::Delegation::delegate_to_method
2111µs1µsMoose::Meta::Method::Delegation::::associated_attributeMoose::Meta::Method::Delegation::associated_attribute
0000s0sMoose::Meta::Method::Delegation::::__ANON__[:111]Moose::Meta::Method::Delegation::__ANON__[:111]
0000s0sMoose::Meta::Method::Delegation::::curried_argumentsMoose::Meta::Method::Delegation::curried_arguments
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Moose::Meta::Method::Delegation;
21200nsour $VERSION = '2.1605';
3
4215µs212µs
# spent 11µs (9+1) within Moose::Meta::Method::Delegation::BEGIN@4 which was called: # once (9µs+1µs) by Moose::Meta::Attribute::BEGIN@14 at line 4
use strict;
# spent 11µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@4 # spent 2µs making 1 call to strict::import
5214µs212µs
# spent 8µs (5+3) within Moose::Meta::Method::Delegation::BEGIN@5 which was called: # once (5µs+3µs) by Moose::Meta::Attribute::BEGIN@14 at line 5
use warnings;
# spent 8µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@5 # spent 3µs making 1 call to warnings::import
6
7218µs247µs
# spent 25µs (4+21) within Moose::Meta::Method::Delegation::BEGIN@7 which was called: # once (4µs+21µs) by Moose::Meta::Attribute::BEGIN@14 at line 7
use Scalar::Util 'blessed', 'weaken';
# spent 25µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@7 # spent 22µs making 1 call to Exporter::import
8
912µs120µs
# spent 24µs (4+20) within Moose::Meta::Method::Delegation::BEGIN@9 which was called: # once (4µs+20µs) by Moose::Meta::Attribute::BEGIN@14 at line 10
use parent 'Moose::Meta::Method',
# spent 20µs making 1 call to parent::import
10114µs124µs 'Class::MOP::Method::Generated';
# spent 24µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@9
11
122290µs2180µs
# spent 93µs (5+88) within Moose::Meta::Method::Delegation::BEGIN@12 which was called: # once (5µs+88µs) by Moose::Meta::Attribute::BEGIN@14 at line 12
use Moose::Util 'throw_exception';
# spent 93µs making 1 call to Moose::Meta::Method::Delegation::BEGIN@12 # spent 88µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
13
14
# spent 137µs (66+71) within Moose::Meta::Method::Delegation::new which was called 2 times, avg 68µs/call: # 2 times (66µs+71µs) by Moose::Meta::Attribute::_make_delegation_method at line 1236 of Moose/Meta/Attribute.pm, avg 68µs/call
sub new {
152400ns my $class = shift;
1623µs my %options = @_;
17
18 ( exists $options{attribute} )
192700ns || throw_exception( MustSupplyAnAttributeToConstructWith => params => \%options,
20 class => $class
21 );
22
23 ( blessed( $options{attribute} )
2428µs42µs && $options{attribute}->isa('Moose::Meta::Attribute') )
# spent 1µs making 2 calls to Scalar::Util::blessed, avg 500ns/call # spent 1µs making 2 calls to UNIVERSAL::isa, avg 500ns/call
25 || throw_exception( MustSupplyAMooseMetaAttributeInstance => params => \%options,
26 class => $class
27 );
28
29 ( $options{package_name} && $options{name} )
302800ns || throw_exception( MustSupplyPackageNameAndName => params => \%options,
31 class => $class
32 );
33
34 ( $options{delegate_to_method} && ( !ref $options{delegate_to_method} )
352800ns || ( 'CODE' eq ref $options{delegate_to_method} ) )
36 || throw_exception( MustSupplyADelegateToMethod => params => \%options,
37 class => $class
38 );
39
40 exists $options{curried_arguments}
412200ns || ( $options{curried_arguments} = [] );
42
43 ( $options{curried_arguments} &&
4421µs ( 'ARRAY' eq ref $options{curried_arguments} ) )
45 || throw_exception( MustSupplyArrayRefAsCurriedArguments => params => \%options,
46 class_name => $class
47 );
48
4922µs24µs my $self = $class->_new( \%options );
# spent 4µs making 2 calls to Moose::Meta::Method::Delegation::_new, avg 2µs/call
50
51241µs2700ns weaken( $self->{'attribute'} );
# spent 700ns making 2 calls to Scalar::Util::weaken, avg 350ns/call
52
5322µs265µs $self->_initialize_body;
# spent 65µs making 2 calls to Moose::Meta::Method::Delegation::_initialize_body, avg 32µs/call
54
5523µs return $self;
56}
57
58
# spent 4µs within Moose::Meta::Method::Delegation::_new which was called 2 times, avg 2µs/call: # 2 times (4µs+0s) by Moose::Meta::Method::Delegation::new at line 49, avg 2µs/call
sub _new {
592600ns my $class = shift;
6021µs my $options = @_ == 1 ? $_[0] : {@_};
61
6225µs return bless $options, $class;
63}
64
65sub curried_arguments { (shift)->{'curried_arguments'} }
66
6723µs
# spent 1µs within Moose::Meta::Method::Delegation::associated_attribute which was called 2 times, avg 650ns/call: # 2 times (1µs+0s) by Moose::Meta::Method::Delegation::_get_delegate_accessor at line 116, avg 650ns/call
sub associated_attribute { (shift)->{'attribute'} }
68
6923µs
# spent 2µs within Moose::Meta::Method::Delegation::delegate_to_method which was called 2 times, avg 900ns/call: # 2 times (2µs+0s) by Moose::Meta::Method::Delegation::_initialize_body at line 74, avg 900ns/call
sub delegate_to_method { (shift)->{'delegate_to_method'} }
70
71
# spent 65µs (21+44) within Moose::Meta::Method::Delegation::_initialize_body which was called 2 times, avg 32µs/call: # 2 times (21µs+44µs) by Moose::Meta::Method::Delegation::new at line 53, avg 32µs/call
sub _initialize_body {
722700ns my $self = shift;
73
7422µs22µs my $method_to_call = $self->delegate_to_method;
# spent 2µs making 2 calls to Moose::Meta::Method::Delegation::delegate_to_method, avg 900ns/call
752400ns return $self->{body} = $method_to_call
76 if ref $method_to_call;
77
7822µs241µs my $accessor = $self->_get_delegate_accessor;
# spent 41µs making 2 calls to Moose::Meta::Method::Delegation::_get_delegate_accessor, avg 20µs/call
79
8026µs21µs my $handle_name = $self->name;
# spent 1µs making 2 calls to Class::MOP::Method::name, avg 500ns/call
81
82 # NOTE: we used to do a goto here, but the goto didn't handle
83 # failure correctly (it just returned nothing), so I took that
84 # out. However, the more I thought about it, the less I liked it
85 # doing the goto, and I preferred the act of delegation being
86 # actually represented in the stack trace. - SL
87 # not inlining this, since it won't really speed things up at
88 # all... the only thing that would end up different would be
89 # interpolating in $method_to_call, and a bunch of things in the
90 # error handling that mostly never gets called - doy
91 $self->{body} = sub {
92 my $instance = shift;
93 my $proxy = $instance->$accessor();
94
95 if( !defined $proxy ) {
96 throw_exception( AttributeValueIsNotDefined => method => $self,
97 instance => $instance,
98 attribute => $self->associated_attribute,
99 );
100 }
101 elsif( ref($proxy) && !blessed($proxy) ) {
102 throw_exception( AttributeValueIsNotAnObject => method => $self,
103 instance => $instance,
104 attribute => $self->associated_attribute,
105 given_value => $proxy
106 );
107 }
108
109 unshift @_, @{ $self->curried_arguments };
110 $proxy->$method_to_call(@_);
11128µs };
112}
113
114
# spent 41µs (19+22) within Moose::Meta::Method::Delegation::_get_delegate_accessor which was called 2 times, avg 20µs/call: # 2 times (19µs+22µs) by Moose::Meta::Method::Delegation::_initialize_body at line 78, avg 20µs/call
sub _get_delegate_accessor {
1152400ns my $self = shift;
11622µs21µs my $attr = $self->associated_attribute;
# spent 1µs making 2 calls to Moose::Meta::Method::Delegation::associated_attribute, avg 650ns/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
12727µs420µs my $accessor = $attr->has_read_method
# spent 11µs making 2 calls to Class::MOP::Attribute::get_read_method, avg 6µs/call # spent 9µs making 2 calls to Class::MOP::Mixin::AttributeCore::has_read_method, avg 5µs/call
128 ? $attr->get_read_method
129 : $attr->get_read_method_ref;
130
13123µs2400ns $accessor = $accessor->body if Scalar::Util::blessed $accessor;
# spent 400ns making 2 calls to Scalar::Util::blessed, avg 200ns/call
132
13324µs return $accessor;
134}
135
13612µs1;
137
138# ABSTRACT: A Moose Method metaclass for delegation methods
139
140__END__