Filename | /opt/perl-5.18.1/lib/site_perl/5.18.1/darwin-thread-multi-2level/Class/MOP/Method.pm |
Statements | Executed 3292 statements in 13.8ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
191 | 4 | 4 | 5.02ms | 12.4ms | wrap | Class::MOP::Method::
363 | 1 | 1 | 1.45ms | 1.79ms | attach_to_class | Class::MOP::Method::
85 | 1 | 1 | 489µs | 5.67ms | _new | Class::MOP::Method::
28 | 2 | 2 | 387µs | 476µs | clone | Class::MOP::Method::
1 | 1 | 1 | 17µs | 21µs | BEGIN@11 | Class::MOP::Method::
1 | 1 | 1 | 16µs | 52µs | BEGIN@21 | Class::MOP::Method::
1 | 1 | 1 | 11µs | 11µs | BEGIN@3 | Class::MOP::Method::
1 | 1 | 1 | 9µs | 40µs | BEGIN@13 | Class::MOP::Method::
1 | 1 | 1 | 9µs | 958µs | BEGIN@16 | Class::MOP::Method::
1 | 1 | 1 | 9µs | 47µs | BEGIN@14 | Class::MOP::Method::
1 | 1 | 1 | 8µs | 23µs | BEGIN@10 | Class::MOP::Method::
1 | 1 | 1 | 7µs | 7µs | is_stub (xsub) | Class::MOP::Method::
0 | 0 | 0 | 0s | 0s | __ANON__[:21] | Class::MOP::Method::
0 | 0 | 0 | 0s | 0s | detach_from_class | 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 | |||||
2 | package Class::MOP::Method; | ||||
3 | # spent 11µs within Class::MOP::Method::BEGIN@3 which was called:
# once (11µs+0s) by base::import at line 5 | ||||
4 | 1 | 7µs | $Class::MOP::Method::AUTHORITY = 'cpan:STEVAN'; | ||
5 | 1 | 40µs | 1 | 11µs | } # spent 11µs making 1 call to Class::MOP::Method::BEGIN@3 |
6 | { | ||||
7 | 2 | 1µs | $Class::MOP::Method::VERSION = '2.1005'; | ||
8 | } | ||||
9 | |||||
10 | 2 | 29µs | 2 | 39µs | # spent 23µs (8+15) within Class::MOP::Method::BEGIN@10 which was called:
# once (8µs+15µs) by base::import at line 10 # spent 23µs making 1 call to Class::MOP::Method::BEGIN@10
# spent 15µs making 1 call to strict::import |
11 | 2 | 37µs | 2 | 26µs | # spent 21µs (17+4) within Class::MOP::Method::BEGIN@11 which was called:
# once (17µs+4µs) by base::import at line 11 # spent 21µs making 1 call to Class::MOP::Method::BEGIN@11
# spent 4µs making 1 call to warnings::import |
12 | |||||
13 | 2 | 42µs | 2 | 70µs | # spent 40µs (9+30) within Class::MOP::Method::BEGIN@13 which was called:
# once (9µs+30µs) by base::import at line 13 # spent 40µs making 1 call to Class::MOP::Method::BEGIN@13
# spent 30µs making 1 call to Exporter::import |
14 | 2 | 34µs | 2 | 85µs | # spent 47µs (9+38) within Class::MOP::Method::BEGIN@14 which was called:
# once (9µs+38µs) by base::import at line 14 # spent 47µs making 1 call to Class::MOP::Method::BEGIN@14
# spent 38µs making 1 call to Exporter::import |
15 | |||||
16 | 2 | 73µs | 2 | 958µs | # spent 958µs (9+949) within Class::MOP::Method::BEGIN@16 which was called:
# once (9µs+949µs) by base::import at line 16 # spent 958µs making 1 call to Class::MOP::Method::BEGIN@16
# spent 949µs making 1 call to base::import, recursion: max depth 1, sum of overlapping time 949µs |
17 | |||||
18 | # NOTE: | ||||
19 | # if poked in the right way, | ||||
20 | # they should act like CODE refs. | ||||
21 | 2 | 742µs | 2 | 89µs | # spent 52µs (16+37) within Class::MOP::Method::BEGIN@21 which was called:
# once (16µs+37µs) by base::import at line 21 # spent 52µs making 1 call to Class::MOP::Method::BEGIN@21
# spent 37µs making 1 call to overload::import |
22 | |||||
23 | # construction | ||||
24 | |||||
25 | # spent 12.4ms (5.02+7.40) within Class::MOP::Method::wrap which was called 191 times, avg 65µs/call:
# 65 times (1.21ms+605µs) by Class::MOP::Mixin::HasMethods::wrap_method_body at line 48 of Class/MOP/Mixin/HasMethods.pm, avg 28µs/call
# 57 times (2.47ms+663µs) by Class::MOP::Attribute::_process_accessors at line 372 of Class/MOP/Attribute.pm, avg 55µs/call
# 44 times (888µs+356µs) by Class::MOP::Method::Wrapped::wrap at line 94 of Class/MOP/Method/Wrapped.pm, avg 28µs/call
# 25 times (447µs+5.78ms) by Class::MOP::Method::Meta::wrap at line 62 of Class/MOP/Method/Meta.pm, avg 249µs/call | ||||
26 | 191 | 370µs | my ( $class, @args ) = @_; | ||
27 | |||||
28 | 191 | 156µs | unshift @args, 'body' if @args % 2 == 1; | ||
29 | |||||
30 | 191 | 369µs | my %params = @args; | ||
31 | 191 | 56µs | my $code = $params{body}; | ||
32 | |||||
33 | 191 | 1.04ms | 382 | 224µs | if (blessed($code) && $code->isa(__PACKAGE__)) { # spent 114µs making 191 calls to Scalar::Util::blessed, avg 599ns/call
# spent 110µs making 191 calls to Scalar::Util::reftype, avg 573ns/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 | |||||
43 | 191 | 72µs | ($params{package_name} && $params{name}) | ||
44 | || confess "You must supply the package_name and name parameters"; | ||||
45 | |||||
46 | 191 | 315µs | 191 | 6.95ms | my $self = $class->_new(\%params); # spent 5.67ms making 85 calls to Class::MOP::Method::_new, avg 67µs/call
# spent 493µs making 5 calls to Moose::Meta::Method::_new, avg 99µs/call
# spent 481µs making 57 calls to Class::MOP::Method::Accessor::_new, avg 8µs/call
# spent 305µs making 44 calls to Class::MOP::Method::Wrapped::_new, avg 7µs/call |
47 | |||||
48 | 191 | 2.06ms | 147 | 228µs | weaken($self->{associated_metaclass}) if $self->{associated_metaclass}; # spent 228µs making 147 calls to Scalar::Util::weaken, avg 2µs/call |
49 | |||||
50 | 191 | 5.32ms | return $self; | ||
51 | } | ||||
52 | |||||
53 | # spent 5.67ms (489µs+5.18) within Class::MOP::Method::_new which was called 85 times, avg 67µs/call:
# 85 times (489µs+5.18ms) by Class::MOP::Method::wrap at line 46, avg 67µs/call | ||||
54 | 85 | 20µs | my $class = shift; | ||
55 | |||||
56 | 85 | 111µs | 48 | 5.18ms | return Class::MOP::Class->initialize($class)->new_object(@_) # spent 4.28ms making 24 calls to Class::MOP::Class::new_object, avg 178µs/call
# spent 901µs making 24 calls to Class::MOP::Class::initialize, avg 38µs/call |
57 | if $class ne __PACKAGE__; | ||||
58 | |||||
59 | 61 | 20µs | my $params = @_ == 1 ? $_[0] : {@_}; | ||
60 | |||||
61 | 61 | 352µ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 | |||||
72 | 8 | 32µs | sub associated_metaclass { shift->{'associated_metaclass'} } | ||
73 | |||||
74 | # spent 1.79ms (1.45+339µs) within Class::MOP::Method::attach_to_class which was called 363 times, avg 5µs/call:
# 363 times (1.45ms+339µs) by Class::MOP::Mixin::HasMethods::add_method at line 71 of Class/MOP/Mixin/HasMethods.pm, avg 5µs/call | ||||
75 | 363 | 98µs | my ( $self, $class ) = @_; | ||
76 | 363 | 213µs | $self->{associated_metaclass} = $class; | ||
77 | 363 | 1.71ms | 363 | 339µs | weaken($self->{associated_metaclass}); # spent 339µs making 363 calls to Scalar::Util::weaken, avg 935ns/call |
78 | } | ||||
79 | |||||
80 | sub detach_from_class { | ||||
81 | my $self = shift; | ||||
82 | delete $self->{associated_metaclass}; | ||||
83 | } | ||||
84 | |||||
85 | sub fully_qualified_name { | ||||
86 | my $self = shift; | ||||
87 | $self->package_name . '::' . $self->name; | ||||
88 | } | ||||
89 | |||||
90 | sub original_method { (shift)->{'original_method'} } | ||||
91 | |||||
92 | 28 | 68µs | sub _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. | ||||
99 | sub 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 | |||||
107 | sub original_name { | ||||
108 | my $self = shift; | ||||
109 | |||||
110 | $self->original_method | ||||
111 | ? $self->original_method->original_name | ||||
112 | : $self->name; | ||||
113 | } | ||||
114 | |||||
115 | sub 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 | |||||
123 | sub 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 476µs (387+89) within Class::MOP::Method::clone which was called 28 times, avg 17µs/call:
# 14 times (201µs+49µs) by Class::MOP::MiniTrait::apply at line 29 of Class/MOP/MiniTrait.pm, avg 18µs/call
# 14 times (186µs+39µs) by Class::MOP::Mixin::HasMethods::add_method at line 64 of Class/MOP/Mixin/HasMethods.pm, avg 16µs/call | ||||
133 | 28 | 6µs | my $self = shift; | ||
134 | |||||
135 | 28 | 226µs | 28 | 26µs | my $clone = bless { %{$self}, @_ }, blessed($self); # spent 26µs making 28 calls to Scalar::Util::blessed, avg 932ns/call |
136 | 28 | 89µs | 28 | 22µs | weaken($clone->{associated_metaclass}) if $clone->{associated_metaclass}; # spent 22µs making 28 calls to Scalar::Util::weaken, avg 786ns/call |
137 | |||||
138 | 28 | 32µs | 28 | 41µs | $clone->_set_original_method($self); # spent 41µs making 28 calls to Class::MOP::Method::_set_original_method, avg 1µs/call |
139 | |||||
140 | 28 | 63µs | return $clone; | ||
141 | } | ||||
142 | |||||
143 | 1 | 3µs | 1; | ||
144 | |||||
145 | # ABSTRACT: Method Meta Object | ||||
146 | |||||
147 | __END__ | ||||
# spent 7µs within Class::MOP::Method::is_stub which was called:
# once (7µs+0s) by Moose::Meta::Attribute::_process_accessors at line 1057 of Moose/Meta/Attribute.pm |