← 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:32 2014

Filename/usr/local/lib/perl/5.14.2/Class/MOP/Method.pm
StatementsExecuted 3990 statements in 7.49ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
222443.14ms12.6msClass::MOP::Method::::wrapClass::MOP::Method::wrap
478111.59ms1.96msClass::MOP::Method::::attach_to_classClass::MOP::Method::attach_to_class
8511500µs4.83msClass::MOP::Method::::_newClass::MOP::Method::_new
2822331µs401µsClass::MOP::Method::::cloneClass::MOP::Method::clone
1119µs34µsClass::MOP::Method::::BEGIN@21Class::MOP::Method::BEGIN@21
1118µs8µsClass::MOP::Method::::BEGIN@3Class::MOP::Method::BEGIN@3
1117µs644µsClass::MOP::Method::::BEGIN@16Class::MOP::Method::BEGIN@16
1117µs9µsClass::MOP::Method::::BEGIN@10Class::MOP::Method::BEGIN@10
1117µs40µsClass::MOP::Method::::BEGIN@14Class::MOP::Method::BEGIN@14
1116µs11µsClass::MOP::Method::::BEGIN@11Class::MOP::Method::BEGIN@11
1116µs34µsClass::MOP::Method::::BEGIN@13Class::MOP::Method::BEGIN@13
1111µs1µsClass::MOP::Method::::is_stubClass::MOP::Method::is_stub (xsub)
0000s0sClass::MOP::Method::::__ANON__[:21]Class::MOP::Method::__ANON__[:21]
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
1
2package Class::MOP::Method;
3
# spent 8µs within Class::MOP::Method::BEGIN@3 which was called: # once (8µs+0s) by base::import at line 5
BEGIN {
414µs $Class::MOP::Method::AUTHORITY = 'cpan:STEVAN';
5128µs18µs}
# spent 8µs making 1 call to Class::MOP::Method::BEGIN@3
6{
721µs $Class::MOP::Method::VERSION = '2.1005';
8}
9
10220µs212µs
# spent 9µs (7+3) within Class::MOP::Method::BEGIN@10 which was called: # once (7µs+3µs) by base::import at line 10
use strict;
# spent 9µs making 1 call to Class::MOP::Method::BEGIN@10 # spent 3µs making 1 call to strict::import
11221µs215µs
# spent 11µs (6+5) within Class::MOP::Method::BEGIN@11 which was called: # once (6µs+5µs) by base::import at line 11
use warnings;
# spent 11µs making 1 call to Class::MOP::Method::BEGIN@11 # spent 4µs making 1 call to warnings::import
12
13228µs261µs
# spent 34µs (6+28) within Class::MOP::Method::BEGIN@13 which was called: # once (6µs+28µs) by base::import at line 13
use Carp 'confess';
# spent 34µs making 1 call to Class::MOP::Method::BEGIN@13 # spent 28µs making 1 call to Exporter::import
14224µs274µs
# spent 40µs (7+34) within Class::MOP::Method::BEGIN@14 which was called: # once (7µs+34µs) by base::import at line 14
use Scalar::Util 'weaken', 'reftype', 'blessed';
# spent 40µs making 1 call to Class::MOP::Method::BEGIN@14 # spent 34µs making 1 call to Exporter::import
15
16245µs2644µs
# spent 644µs (7+637) within Class::MOP::Method::BEGIN@16 which was called: # once (7µs+637µs) by base::import at line 16
use base 'Class::MOP::Object';
# spent 644µs making 1 call to Class::MOP::Method::BEGIN@16 # spent 637µs making 1 call to base::import, recursion: max depth 1, sum of overlapping time 637µs
17
18# NOTE:
19# if poked in the right way,
20# they should act like CODE refs.
212503µs259µs
# spent 34µs (9+25) within Class::MOP::Method::BEGIN@21 which was called: # once (9µs+25µs) by base::import at line 21
use overload '&{}' => sub { $_[0]->body }, fallback => 1;
# spent 34µs making 1 call to Class::MOP::Method::BEGIN@21 # spent 25µs making 1 call to overload::import
22
23# construction
24
25
# spent 12.6ms (3.14+9.44) within Class::MOP::Method::wrap which was called 222 times, avg 57µs/call: # 84 times (1.08ms+804µs) by Class::MOP::Mixin::HasMethods::wrap_method_body at line 48 of Class/MOP/Mixin/HasMethods.pm, avg 22µs/call # 57 times (909µs+1.36ms) by Class::MOP::Attribute::_process_accessors at line 372 of Class/MOP/Attribute.pm, avg 40µs/call # 46 times (629µs+564µs) by Class::MOP::Method::Wrapped::wrap at line 94 of Class/MOP/Method/Wrapped.pm, avg 26µs/call # 35 times (516µs+6.72ms) by Class::MOP::Method::Meta::wrap at line 62 of Class/MOP/Method/Meta.pm, avg 207µs/call
sub wrap {
26222396µs my ( $class, @args ) = @_;
27
28222181µs unshift @args, 'body' if @args % 2 == 1;
29
30222306µs my %params = @args;
3122262µs my $code = $params{body};
32
332221.00ms444248µs if (blessed($code) && $code->isa(__PACKAGE__)) {
# spent 148µs making 222 calls to Scalar::Util::blessed, avg 667ns/call # spent 100µs making 222 calls to Scalar::Util::reftype, avg 450ns/call
34 my $method = $code->clone;
35 delete $params{body};
36 Class::MOP::class_of($class)->rebless_instance($method, %params);
37 return $method;
38 }
39 elsif (!ref $code || 'CODE' ne reftype($code)) {
40 confess "You must supply a CODE reference to bless, not (" . ($code || 'undef') . ")";
41 }
42
4322280µs ($params{package_name} && $params{name})
44 || confess "You must supply the package_name and name parameters";
45
46222313µs2229.02ms my $self = $class->_new(\%params);
# spent 4.83ms making 85 calls to Class::MOP::Method::_new, avg 57µs/call # spent 2.44ms making 34 calls to Moose::Meta::Method::_new, avg 72µs/call # spent 1.23ms making 57 calls to Class::MOP::Method::Accessor::_new, avg 22µs/call # spent 507µs making 46 calls to Class::MOP::Method::Wrapped::_new, avg 11µs/call
47
48222570µs176177µs weaken($self->{associated_metaclass}) if $self->{associated_metaclass};
# spent 177µs making 176 calls to Scalar::Util::weaken, avg 1µs/call
49
50222600µs return $self;
51}
52
53
# spent 4.83ms (500µs+4.33) within Class::MOP::Method::_new which was called 85 times, avg 57µs/call: # 85 times (500µs+4.33ms) by Class::MOP::Method::wrap at line 46, avg 57µs/call
sub _new {
548526µs my $class = shift;
55
5685108µs484.33ms return Class::MOP::Class->initialize($class)->new_object(@_)
# spent 3.59ms making 24 calls to Class::MOP::Class::new_object, avg 150µs/call # spent 741µs making 24 calls to Class::MOP::Class::initialize, avg 31µs/call
57 if $class ne __PACKAGE__;
58
596124µs my $params = @_ == 1 ? $_[0] : {@_};
60
6161387µs return bless {
62 'body' => $params->{body},
63 'associated_metaclass' => $params->{associated_metaclass},
64 'package_name' => $params->{package_name},
65 'name' => $params->{name},
66 'original_method' => $params->{original_method},
67 } => $class;
68}
69
70## accessors
71
7254121µssub associated_metaclass { shift->{'associated_metaclass'} }
73
74
# spent 1.96ms (1.59+370µs) within Class::MOP::Method::attach_to_class which was called 478 times, avg 4µs/call: # 478 times (1.59ms+370µs) by Class::MOP::Mixin::HasMethods::add_method at line 71 of Class/MOP/Mixin/HasMethods.pm, avg 4µs/call
sub attach_to_class {
75478193µs my ( $self, $class ) = @_;
76478297µs $self->{associated_metaclass} = $class;
774781.73ms478370µs weaken($self->{associated_metaclass});
# spent 370µs making 478 calls to Scalar::Util::weaken, avg 774ns/call
78}
79
80sub detach_from_class {
81 my $self = shift;
82 delete $self->{associated_metaclass};
83}
84
85sub fully_qualified_name {
86 my $self = shift;
87 $self->package_name . '::' . $self->name;
88}
89
90sub original_method { (shift)->{'original_method'} }
91
922855µssub _set_original_method { $_[0]->{'original_method'} = $_[1] }
93
94# It's possible that this could cause a loop if there is a circular
95# reference in here. That shouldn't ever happen in normal
96# circumstances, since original method only gets set when clone is
97# called. We _could_ check for such a loop, but it'd involve some sort
98# of package-lexical variable, and wouldn't be terribly subclassable.
99sub original_package_name {
100 my $self = shift;
101
102 $self->original_method
103 ? $self->original_method->original_package_name
104 : $self->package_name;
105}
106
107sub original_name {
108 my $self = shift;
109
110 $self->original_method
111 ? $self->original_method->original_name
112 : $self->name;
113}
114
115sub original_fully_qualified_name {
116 my $self = shift;
117
118 $self->original_method
119 ? $self->original_method->original_fully_qualified_name
120 : $self->fully_qualified_name;
121}
122
123sub execute {
124 my $self = shift;
125 $self->body->(@_);
126}
127
128# We used to go through use Class::MOP::Class->clone_instance to do this, but
129# this was awfully slow. This method may be called a number of times when
130# classes are loaded (especially during Moose role application), so it is
131# worth optimizing. - DR
132
# spent 401µs (331+71) within Class::MOP::Method::clone which was called 28 times, avg 14µs/call: # 14 times (196µs+40µs) by Class::MOP::MiniTrait::apply at line 29 of Class/MOP/MiniTrait.pm, avg 17µs/call # 14 times (134µs+31µs) by Class::MOP::Mixin::HasMethods::add_method at line 65 of Class/MOP/Mixin/HasMethods.pm, avg 12µs/call
sub clone {
133286µs my $self = shift;
134
13556214µs2818µs my $clone = bless { %{$self}, @_ }, blessed($self);
# spent 18µs making 28 calls to Scalar::Util::blessed, avg 650ns/call
1362870µs2820µs weaken($clone->{associated_metaclass}) if $clone->{associated_metaclass};
# spent 20µs making 28 calls to Scalar::Util::weaken, avg 700ns/call
137
1382826µs2833µs $clone->_set_original_method($self);
# spent 33µs making 28 calls to Class::MOP::Method::_set_original_method, avg 1µs/call
139
1402848µs return $clone;
141}
142
14312µs1;
144
145# ABSTRACT: Method Meta Object
146
147__END__
 
# spent 1µs within Class::MOP::Method::is_stub which was called: # once (1µs+0s) by Moose::Meta::Attribute::_process_accessors at line 1057 of Moose/Meta/Attribute.pm
sub Class::MOP::Method::is_stub; # xsub