← 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/Class/MOP/Method.pm
StatementsExecuted 3621 statements in 4.79ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
205442.34ms11.4msClass::MOP::Method::::wrapClass::MOP::Method::wrap
37811750µs891µsClass::MOP::Method::::attach_to_classClass::MOP::Method::attach_to_class
8711263µs8.22msClass::MOP::Method::::_newClass::MOP::Method::_new
2622186µs225µsClass::MOP::Method::::cloneClass::MOP::Method::clone
1689687µs87µsClass::MOP::Method::::__ANON__[:16]Class::MOP::Method::__ANON__[:16]
11112µs56µsClass::MOP::Method::::BEGIN@15Class::MOP::Method::BEGIN@15
1118µs10µsClass::MOP::Method::::BEGIN@4Class::MOP::Method::BEGIN@4
1118µs444µsClass::MOP::Method::::BEGIN@9Class::MOP::Method::BEGIN@9
1117µs10µsClass::MOP::Method::::BEGIN@5Class::MOP::Method::BEGIN@5
1115µs28µsClass::MOP::Method::::BEGIN@7Class::MOP::Method::BEGIN@7
111600ns600nsClass::MOP::Method::::is_stubClass::MOP::Method::is_stub (xsub)
0000s0sClass::MOP::Method::::__ANON__[:15]Class::MOP::Method::__ANON__[:15]
0000s0sClass::MOP::Method::::__ANON__[:17]Class::MOP::Method::__ANON__[:17]
0000s0sClass::MOP::Method::::detach_from_classClass::MOP::Method::detach_from_class
0000s0sClass::MOP::Method::::executeClass::MOP::Method::execute
0000s0sClass::MOP::Method::::fully_qualified_nameClass::MOP::Method::fully_qualified_name
0000s0sClass::MOP::Method::::original_fully_qualified_nameClass::MOP::Method::original_fully_qualified_name
0000s0sClass::MOP::Method::::original_nameClass::MOP::Method::original_name
0000s0sClass::MOP::Method::::original_package_nameClass::MOP::Method::original_package_name
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Class::MOP::Method;
21200nsour $VERSION = '2.1605';
3
4214µs211µs
# spent 10µs (8+1) within Class::MOP::Method::BEGIN@4 which was called: # once (8µs+1µs) by parent::import at line 4
use strict;
# spent 10µs making 1 call to Class::MOP::Method::BEGIN@4 # spent 1µs making 1 call to strict::import
5218µs213µs
# spent 10µs (7+3) within Class::MOP::Method::BEGIN@5 which was called: # once (7µs+3µs) by parent::import at line 5
use warnings;
# spent 10µs making 1 call to Class::MOP::Method::BEGIN@5 # spent 3µs making 1 call to warnings::import
6
7232µs251µs
# spent 28µs (5+23) within Class::MOP::Method::BEGIN@7 which was called: # once (5µs+23µs) by parent::import at line 7
use Scalar::Util 'weaken', 'reftype', 'blessed';
# spent 28µs making 1 call to Class::MOP::Method::BEGIN@7 # spent 23µs making 1 call to Exporter::import
8
9267µs2444µs
# spent 444µs (8+437) within Class::MOP::Method::BEGIN@9 which was called: # once (8µs+437µs) by parent::import at line 9
use parent 'Class::MOP::Object';
# spent 444µs making 1 call to Class::MOP::Method::BEGIN@9 # spent 436µs making 1 call to parent::import, recursion: max depth 1, sum of overlapping time 436µs
10
11# NOTE:
12# if poked in the right way,
13# they should act like CODE refs.
14use overload
15
# spent 56µs (12+44) within Class::MOP::Method::BEGIN@15 which was called: # once (12µs+44µs) by parent::import at line 18
'&{}' => sub { $_[0]->body },
16168204µs
# spent 87µs within Class::MOP::Method::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Class/MOP/Method.pm:16] which was called 168 times, avg 515ns/call: # 88 times (48µs+0s) by Class::MOP::Mixin::HasMethods::get_method at line 112 of Class/MOP/Mixin/HasMethods.pm, avg 544ns/call # 43 times (21µs+0s) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 479ns/call # 30 times (15µs+0s) by Class::MOP::Method::Inlined::can_be_inlined at line 37 of Class/MOP/Method/Inlined.pm, avg 490ns/call # 2 times (1µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 22 of Class/MOP/Mixin/HasMethods.pm, avg 650ns/call # once (1µs+0s) by Moose::Meta::Class::_inline_BUILDARGS at line 327 of Moose/Meta/Class.pm # once (600ns+0s) by Class::MOP::Class::_inline_destructor at line 1494 of Class/MOP/Class.pm # once (200ns+0s) by Class::MOP::Mixin::HasMethods::has_method at line 100 of Class/MOP/Mixin/HasMethods.pm # once (100ns+0s) by Moose::Meta::Attribute::_process_accessors at line 1035 of Moose/Meta/Attribute.pm # once (100ns+0s) by Moose::Meta::Attribute::_process_accessors at line 1023 of Moose/Meta/Attribute.pm
'bool' => sub { 1 },
17 '""' => sub { overload::StrVal($_[0]) },
182346µs2100µs fallback => 1;
# spent 56µs making 1 call to Class::MOP::Method::BEGIN@15 # spent 44µs making 1 call to overload::import
19
20# construction
21
22
# spent 11.4ms (2.34+9.06) within Class::MOP::Method::wrap which was called 205 times, avg 56µs/call: # 70 times (1.05ms+357µs) by Class::MOP::Attribute::_process_accessors at line 390 of Class/MOP/Attribute.pm, avg 20µs/call # 67 times (595µs+262µs) by Class::MOP::Mixin::HasMethods::wrap_method_body at line 40 of Class/MOP/Mixin/HasMethods.pm, avg 13µs/call # 43 times (383µs+155µs) by Class::MOP::Method::Wrapped::wrap at line 97 of Class/MOP/Method/Wrapped.pm, avg 12µs/call # 25 times (312µs+8.29ms) by Class::MOP::Method::Meta::wrap at line 58 of Class/MOP/Method/Meta.pm, avg 344µs/call
sub wrap {
23205158µs my ( $class, @args ) = @_;
24
25205103µs unshift @args, 'body' if @args % 2 == 1;
26
27205192µs my %params = @args;
2820542µs my $code = $params{body};
29
30205573µs410105µs if (blessed($code) && $code->isa(__PACKAGE__)) {
# spent 55µs making 205 calls to Scalar::Util::reftype, avg 268ns/call # spent 50µs making 205 calls to Scalar::Util::blessed, avg 244ns/call
31 my $method = $code->clone;
32 delete $params{body};
33 Class::MOP::class_of($class)->rebless_instance($method, %params);
34 return $method;
35 }
36 elsif (!ref $code || 'CODE' ne reftype($code)) {
37 $class->_throw_exception( WrapTakesACodeRefToBless => params => \%params,
38 class => $class,
39 code => $code
40 );
41 }
42
43 ($params{package_name} && $params{name})
4420553µs || $class->_throw_exception( PackageNameAndNameParamsNotGivenToWrap => params => \%params,
45 class => $class,
46 code => $code
47 );
48
49205217µs2058.88ms my $self = $class->_new(\%params);
# spent 8.22ms making 87 calls to Class::MOP::Method::_new, avg 94µs/call # spent 274µs making 70 calls to Class::MOP::Method::Accessor::_new, avg 4µs/call # spent 249µs making 5 calls to Moose::Meta::Method::_new, avg 50µs/call # spent 136µs making 43 calls to Class::MOP::Method::Wrapped::_new, avg 3µs/call
50
51205761µs16284µs weaken($self->{associated_metaclass}) if $self->{associated_metaclass};
# spent 84µs making 162 calls to Scalar::Util::weaken, avg 519ns/call
52
53205369µs return $self;
54}
55
56
# spent 8.22ms (263µs+7.95) within Class::MOP::Method::_new which was called 87 times, avg 94µs/call: # 87 times (263µs+7.95ms) by Class::MOP::Method::wrap at line 49, avg 94µs/call
sub _new {
578715µs my $class = shift;
58
5987112µs487.95ms return Class::MOP::Class->initialize($class)->new_object(@_)
# spent 5.18ms making 24 calls to Class::MOP::Class::initialize, avg 216µs/call # spent 2.77ms making 24 calls to Class::MOP::Class::new_object, avg 116µs/call
60 if $class ne __PACKAGE__;
61
626315µs my $params = @_ == 1 ? $_[0] : {@_};
63
64 return bless {
65 'body' => $params->{body},
66 'associated_metaclass' => $params->{associated_metaclass},
67 'package_name' => $params->{package_name},
68 'name' => $params->{name},
69 'original_method' => $params->{original_method},
7063159µs } => $class;
71}
72
73## accessors
74
75612µssub associated_metaclass { shift->{'associated_metaclass'} }
76
77
# spent 891µs (750+142) within Class::MOP::Method::attach_to_class which was called 378 times, avg 2µs/call: # 378 times (750µs+142µs) by Class::MOP::Mixin::HasMethods::add_method at line 63 of Class/MOP/Mixin/HasMethods.pm, avg 2µs/call
sub attach_to_class {
7837866µs my ( $self, $class ) = @_;
79378144µs $self->{associated_metaclass} = $class;
80378875µs378142µs weaken($self->{associated_metaclass});
# spent 142µs making 378 calls to Scalar::Util::weaken, avg 375ns/call
81}
82
83sub detach_from_class {
84 my $self = shift;
85 delete $self->{associated_metaclass};
86}
87
88sub fully_qualified_name {
89 my $self = shift;
90 $self->package_name . '::' . $self->name;
91}
92
93sub original_method { (shift)->{'original_method'} }
94
952632µssub _set_original_method { $_[0]->{'original_method'} = $_[1] }
96
97# It's possible that this could cause a loop if there is a circular
98# reference in here. That shouldn't ever happen in normal
99# circumstances, since original method only gets set when clone is
100# called. We _could_ check for such a loop, but it'd involve some sort
101# of package-lexical variable, and wouldn't be terribly subclassable.
102sub original_package_name {
103 my $self = shift;
104
105 $self->original_method
106 ? $self->original_method->original_package_name
107 : $self->package_name;
108}
109
110sub original_name {
111 my $self = shift;
112
113 $self->original_method
114 ? $self->original_method->original_name
115 : $self->name;
116}
117
118sub original_fully_qualified_name {
119 my $self = shift;
120
121 $self->original_method
122 ? $self->original_method->original_fully_qualified_name
123 : $self->fully_qualified_name;
124}
125
126sub execute {
127 my $self = shift;
128 $self->body->(@_);
129}
130
131# We used to go through use Class::MOP::Class->clone_instance to do this, but
132# this was awfully slow. This method may be called a number of times when
133# classes are loaded (especially during Moose role application), so it is
134# worth optimizing. - DR
135
# spent 225µs (186+39) within Class::MOP::Method::clone which was called 26 times, avg 9µs/call: # 13 times (117µs+27µs) by Class::MOP::MiniTrait::apply at line 25 of Class/MOP/MiniTrait.pm, avg 11µs/call # 13 times (69µs+12µs) by Class::MOP::Mixin::HasMethods::add_method at line 56 of Class/MOP/Mixin/HasMethods.pm, avg 6µs/call
sub clone {
136265µs my $self = shift;
137
1382698µs2610µs my $clone = bless { %{$self}, @_ }, blessed($self);
# spent 10µs making 26 calls to Scalar::Util::blessed, avg 373ns/call
1392650µs269µs weaken($clone->{associated_metaclass}) if $clone->{associated_metaclass};
# spent 9µs making 26 calls to Scalar::Util::weaken, avg 346ns/call
140
1412623µs2620µs $clone->_set_original_method($self);
# spent 20µs making 26 calls to Class::MOP::Method::_set_original_method, avg 781ns/call
142
1432631µs return $clone;
144}
145
14612µs1;
147
148# ABSTRACT: Method Meta Object
149
150__END__
 
# spent 600ns within Class::MOP::Method::is_stub which was called: # once (600ns+0s) by Moose::Meta::Attribute::_process_accessors at line 1035 of Moose/Meta/Attribute.pm
sub Class::MOP::Method::is_stub; # xsub