Filename | /Users/ap13/perl5/lib/perl5/darwin-2level/Class/MOP/Method.pm |
Statements | Executed 4592 statements in 12.3ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
233 | 4 | 4 | 5.37ms | 21.7ms | wrap | Class::MOP::Method::
633 | 1 | 1 | 2.83ms | 3.37ms | attach_to_class | Class::MOP::Method::
85 | 1 | 1 | 740µs | 6.75ms | _new | Class::MOP::Method::
32 | 2 | 2 | 637µs | 793µs | clone | Class::MOP::Method::
1 | 1 | 1 | 13µs | 25µs | BEGIN@4 | Class::MOP::Method::
1 | 1 | 1 | 13µs | 52µs | BEGIN@14 | Class::MOP::Method::
1 | 1 | 1 | 11µs | 829µs | BEGIN@9 | Class::MOP::Method::
1 | 1 | 1 | 8µs | 12µs | BEGIN@5 | Class::MOP::Method::
1 | 1 | 1 | 7µs | 37µs | BEGIN@7 | Class::MOP::Method::
2 | 1 | 1 | 5µs | 5µs | detach_from_class | Class::MOP::Method::
1 | 1 | 1 | 900ns | 900ns | is_stub (xsub) | Class::MOP::Method::
0 | 0 | 0 | 0s | 0s | __ANON__[:14] | Class::MOP::Method::
0 | 0 | 0 | 0s | 0s | execute | Class::MOP::Method::
0 | 0 | 0 | 0s | 0s | fully_qualified_name | Class::MOP::Method::
0 | 0 | 0 | 0s | 0s | original_fully_qualified_name | Class::MOP::Method::
0 | 0 | 0 | 0s | 0s | original_name | Class::MOP::Method::
0 | 0 | 0 | 0s | 0s | original_package_name | Class::MOP::Method::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Class::MOP::Method; | ||||
2 | 1 | 1µs | our $VERSION = '2.1403'; | ||
3 | |||||
4 | 2 | 22µs | 2 | 38µs | # spent 25µs (13+12) within Class::MOP::Method::BEGIN@4 which was called:
# once (13µs+12µs) by parent::import at line 4 # spent 25µs making 1 call to Class::MOP::Method::BEGIN@4
# spent 12µs making 1 call to strict::import |
5 | 2 | 26µs | 2 | 16µs | # spent 12µs (8+4) within Class::MOP::Method::BEGIN@5 which was called:
# once (8µs+4µs) by parent::import at line 5 # spent 12µs making 1 call to Class::MOP::Method::BEGIN@5
# spent 4µs making 1 call to warnings::import |
6 | |||||
7 | 2 | 24µs | 2 | 67µs | # spent 37µs (7+30) within Class::MOP::Method::BEGIN@7 which was called:
# once (7µs+30µs) by parent::import at line 7 # spent 37µs making 1 call to Class::MOP::Method::BEGIN@7
# spent 30µs making 1 call to Exporter::import |
8 | |||||
9 | 2 | 60µs | 2 | 829µs | # spent 829µs (11+819) within Class::MOP::Method::BEGIN@9 which was called:
# once (11µs+819µs) by parent::import at line 9 # spent 829µs making 1 call to Class::MOP::Method::BEGIN@9
# spent 819µs making 1 call to parent::import, recursion: max depth 1, sum of overlapping time 819µs |
10 | |||||
11 | # NOTE: | ||||
12 | # if poked in the right way, | ||||
13 | # they should act like CODE refs. | ||||
14 | 2 | 954µs | 2 | 91µs | # spent 52µs (13+39) within Class::MOP::Method::BEGIN@14 which was called:
# once (13µs+39µs) by parent::import at line 14 # spent 52µs making 1 call to Class::MOP::Method::BEGIN@14
# spent 39µs making 1 call to overload::import |
15 | |||||
16 | # construction | ||||
17 | |||||
18 | # spent 21.7ms (5.37+16.3) within Class::MOP::Method::wrap which was called 233 times, avg 93µs/call:
# 75 times (1.60ms+1.55ms) by Class::MOP::Mixin::HasMethods::wrap_method_body at line 40 of Class/MOP/Mixin/HasMethods.pm, avg 42µs/call
# 70 times (2.00ms+2.33ms) by Class::MOP::Attribute::_process_accessors at line 390 of Class/MOP/Attribute.pm, avg 62µs/call
# 44 times (893µs+11.7ms) by Class::MOP::Method::Meta::wrap at line 58 of Class/MOP/Method/Meta.pm, avg 286µs/call
# 44 times (877µs+758µs) by Class::MOP::Method::Wrapped::wrap at line 90 of Class/MOP/Method/Wrapped.pm, avg 37µs/call | ||||
19 | 233 | 582µs | my ( $class, @args ) = @_; | ||
20 | |||||
21 | 233 | 229µs | unshift @args, 'body' if @args % 2 == 1; | ||
22 | |||||
23 | 233 | 494µs | my %params = @args; | ||
24 | 233 | 87µs | my $code = $params{body}; | ||
25 | |||||
26 | 233 | 1.52ms | 466 | 362µs | if (blessed($code) && $code->isa(__PACKAGE__)) { # spent 193µs making 233 calls to Scalar::Util::blessed, avg 829ns/call
# spent 169µs making 233 calls to Scalar::Util::reftype, avg 724ns/call |
27 | my $method = $code->clone; | ||||
28 | delete $params{body}; | ||||
29 | Class::MOP::class_of($class)->rebless_instance($method, %params); | ||||
30 | return $method; | ||||
31 | } | ||||
32 | elsif (!ref $code || 'CODE' ne reftype($code)) { | ||||
33 | $class->_throw_exception( WrapTakesACodeRefToBless => params => \%params, | ||||
34 | class => $class, | ||||
35 | code => $code | ||||
36 | ); | ||||
37 | } | ||||
38 | |||||
39 | 233 | 128µs | ($params{package_name} && $params{name}) | ||
40 | || $class->_throw_exception( PackageNameAndNameParamsNotGivenToWrap => params => \%params, | ||||
41 | class => $class, | ||||
42 | code => $code | ||||
43 | ); | ||||
44 | |||||
45 | 233 | 827µs | 233 | 15.7ms | my $self = $class->_new(\%params); # spent 6.75ms making 85 calls to Class::MOP::Method::_new, avg 79µs/call
# spent 5.78ms making 29 calls to Moose::Meta::Method::_new, avg 199µs/call
# spent 2.06ms making 70 calls to Class::MOP::Method::Accessor::_new, avg 29µs/call
# spent 697µs making 44 calls to Class::MOP::Method::Wrapped::_new, avg 16µs/call
# spent 385µs making 5 calls to Moose::Meta::Role::Method::_new, avg 77µs/call |
46 | |||||
47 | 233 | 847µs | 189 | 290µs | weaken($self->{associated_metaclass}) if $self->{associated_metaclass}; # spent 290µs making 189 calls to Scalar::Util::weaken, avg 2µs/call |
48 | |||||
49 | 233 | 1.05ms | return $self; | ||
50 | } | ||||
51 | |||||
52 | # spent 6.75ms (740µs+6.01) within Class::MOP::Method::_new which was called 85 times, avg 79µs/call:
# 85 times (740µs+6.01ms) by Class::MOP::Method::wrap at line 45, avg 79µs/call | ||||
53 | 85 | 32µs | my $class = shift; | ||
54 | |||||
55 | 85 | 158µs | 48 | 6.01ms | return Class::MOP::Class->initialize($class)->new_object(@_) # spent 4.94ms making 24 calls to Class::MOP::Class::new_object, avg 206µs/call
# spent 1.08ms making 24 calls to Class::MOP::Class::initialize, avg 45µs/call |
56 | if $class ne __PACKAGE__; | ||||
57 | |||||
58 | 61 | 33µs | my $params = @_ == 1 ? $_[0] : {@_}; | ||
59 | |||||
60 | 61 | 559µs | return bless { | ||
61 | 'body' => $params->{body}, | ||||
62 | 'associated_metaclass' => $params->{associated_metaclass}, | ||||
63 | 'package_name' => $params->{package_name}, | ||||
64 | 'name' => $params->{name}, | ||||
65 | 'original_method' => $params->{original_method}, | ||||
66 | } => $class; | ||||
67 | } | ||||
68 | |||||
69 | ## accessors | ||||
70 | |||||
71 | 96 | 257µs | sub associated_metaclass { shift->{'associated_metaclass'} } | ||
72 | |||||
73 | # spent 3.37ms (2.83+542µs) within Class::MOP::Method::attach_to_class which was called 633 times, avg 5µs/call:
# 633 times (2.83ms+542µs) by Class::MOP::Mixin::HasMethods::add_method at line 63 of Class/MOP/Mixin/HasMethods.pm, avg 5µs/call | ||||
74 | 633 | 350µs | my ( $self, $class ) = @_; | ||
75 | 633 | 382µs | $self->{associated_metaclass} = $class; | ||
76 | 633 | 2.86ms | 633 | 542µs | weaken($self->{associated_metaclass}); # spent 542µs making 633 calls to Scalar::Util::weaken, avg 856ns/call |
77 | } | ||||
78 | |||||
79 | # spent 5µs within Class::MOP::Method::detach_from_class which was called 2 times, avg 2µs/call:
# 2 times (5µs+0s) by Class::MOP::Mixin::HasMethods::remove_method at line 146 of Class/MOP/Mixin/HasMethods.pm, avg 2µs/call | ||||
80 | 2 | 600ns | my $self = shift; | ||
81 | 2 | 16µs | delete $self->{associated_metaclass}; | ||
82 | } | ||||
83 | |||||
84 | sub fully_qualified_name { | ||||
85 | my $self = shift; | ||||
86 | $self->package_name . '::' . $self->name; | ||||
87 | } | ||||
88 | |||||
89 | sub original_method { (shift)->{'original_method'} } | ||||
90 | |||||
91 | 32 | 93µs | sub _set_original_method { $_[0]->{'original_method'} = $_[1] } | ||
92 | |||||
93 | # It's possible that this could cause a loop if there is a circular | ||||
94 | # reference in here. That shouldn't ever happen in normal | ||||
95 | # circumstances, since original method only gets set when clone is | ||||
96 | # called. We _could_ check for such a loop, but it'd involve some sort | ||||
97 | # of package-lexical variable, and wouldn't be terribly subclassable. | ||||
98 | sub original_package_name { | ||||
99 | my $self = shift; | ||||
100 | |||||
101 | $self->original_method | ||||
102 | ? $self->original_method->original_package_name | ||||
103 | : $self->package_name; | ||||
104 | } | ||||
105 | |||||
106 | sub original_name { | ||||
107 | my $self = shift; | ||||
108 | |||||
109 | $self->original_method | ||||
110 | ? $self->original_method->original_name | ||||
111 | : $self->name; | ||||
112 | } | ||||
113 | |||||
114 | sub original_fully_qualified_name { | ||||
115 | my $self = shift; | ||||
116 | |||||
117 | $self->original_method | ||||
118 | ? $self->original_method->original_fully_qualified_name | ||||
119 | : $self->fully_qualified_name; | ||||
120 | } | ||||
121 | |||||
122 | sub execute { | ||||
123 | my $self = shift; | ||||
124 | $self->body->(@_); | ||||
125 | } | ||||
126 | |||||
127 | # We used to go through use Class::MOP::Class->clone_instance to do this, but | ||||
128 | # this was awfully slow. This method may be called a number of times when | ||||
129 | # classes are loaded (especially during Moose role application), so it is | ||||
130 | # worth optimizing. - DR | ||||
131 | # spent 793µs (637+157) within Class::MOP::Method::clone which was called 32 times, avg 25µs/call:
# 19 times (355µs+97µs) by Class::MOP::Mixin::HasMethods::add_method at line 56 of Class/MOP/Mixin/HasMethods.pm, avg 24µs/call
# 13 times (282µs+59µs) by Class::MOP::MiniTrait::apply at line 25 of Class/MOP/MiniTrait.pm, avg 26µs/call | ||||
132 | 32 | 12µs | my $self = shift; | ||
133 | |||||
134 | 32 | 405µs | 32 | 33µs | my $clone = bless { %{$self}, @_ }, blessed($self); # spent 33µs making 32 calls to Scalar::Util::blessed, avg 1µs/call |
135 | 32 | 148µs | 32 | 51µs | weaken($clone->{associated_metaclass}) if $clone->{associated_metaclass}; # spent 51µs making 32 calls to Scalar::Util::weaken, avg 2µs/call |
136 | |||||
137 | 32 | 60µs | 32 | 73µs | $clone->_set_original_method($self); # spent 73µs making 32 calls to Class::MOP::Method::_set_original_method, avg 2µs/call |
138 | |||||
139 | 32 | 78µs | return $clone; | ||
140 | } | ||||
141 | |||||
142 | 1 | 6µs | 1; | ||
143 | |||||
144 | # ABSTRACT: Method Meta Object | ||||
145 | |||||
146 | __END__ | ||||
# spent 900ns within Class::MOP::Method::is_stub which was called:
# once (900ns+0s) by Moose::Meta::Attribute::_process_accessors at line 1035 of Moose/Meta/Attribute.pm |