Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Class/MOP/Method/Meta.pm |
Statements | Executed 1035 statements in 6.40ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
55 | 2 | 2 | 4.08ms | 20.3ms | wrap | Class::MOP::Method::Meta::
55 | 1 | 1 | 275µs | 306µs | _generate_meta_method | Class::MOP::Method::Meta::
1 | 1 | 1 | 7µs | 7µs | BEGIN@3 | Class::MOP::Method::Meta::
1 | 1 | 1 | 6µs | 1.47ms | BEGIN@18 | Class::MOP::Method::Meta::
1 | 1 | 1 | 5µs | 29µs | BEGIN@16 | Class::MOP::Method::Meta::
1 | 1 | 1 | 5µs | 26µs | BEGIN@14 | Class::MOP::Method::Meta::
1 | 1 | 1 | 5µs | 15µs | BEGIN@10 | Class::MOP::Method::Meta::
1 | 1 | 1 | 5µs | 8µs | BEGIN@11 | Class::MOP::Method::Meta::
1 | 1 | 1 | 5µs | 25µs | BEGIN@13 | Class::MOP::Method::Meta::
0 | 0 | 0 | 0s | 0s | __ANON__[:49] | Class::MOP::Method::Meta::
0 | 0 | 0 | 0s | 0s | _is_caller_mop_internal | Class::MOP::Method::Meta::
0 | 0 | 0 | 0s | 0s | _make_compatible_with | Class::MOP::Method::Meta::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | package Class::MOP::Method::Meta; | ||||
3 | # spent 7µs within Class::MOP::Method::Meta::BEGIN@3 which was called:
# once (7µs+0s) by Class::MOP::Mixin::HasMethods::BEGIN@12 at line 5 | ||||
4 | 1 | 7µs | $Class::MOP::Method::Meta::AUTHORITY = 'cpan:STEVAN'; | ||
5 | 1 | 29µs | 1 | 7µs | } # spent 7µs making 1 call to Class::MOP::Method::Meta::BEGIN@3 |
6 | { | ||||
7 | 2 | 800ns | $Class::MOP::Method::Meta::VERSION = '2.1005'; | ||
8 | } | ||||
9 | |||||
10 | 2 | 18µs | 2 | 24µs | # spent 15µs (5+10) within Class::MOP::Method::Meta::BEGIN@10 which was called:
# once (5µs+10µs) by Class::MOP::Mixin::HasMethods::BEGIN@12 at line 10 # spent 15µs making 1 call to Class::MOP::Method::Meta::BEGIN@10
# spent 10µs making 1 call to strict::import |
11 | 2 | 19µs | 2 | 11µs | # spent 8µs (5+3) within Class::MOP::Method::Meta::BEGIN@11 which was called:
# once (5µs+3µs) by Class::MOP::Mixin::HasMethods::BEGIN@12 at line 11 # spent 8µs making 1 call to Class::MOP::Method::Meta::BEGIN@11
# spent 3µs making 1 call to warnings::import |
12 | |||||
13 | 2 | 21µs | 2 | 45µs | # spent 25µs (5+20) within Class::MOP::Method::Meta::BEGIN@13 which was called:
# once (5µs+20µs) by Class::MOP::Mixin::HasMethods::BEGIN@12 at line 13 # spent 25µs making 1 call to Class::MOP::Method::Meta::BEGIN@13
# spent 20µs making 1 call to Exporter::import |
14 | 2 | 29µs | 2 | 48µs | # spent 26µs (5+21) within Class::MOP::Method::Meta::BEGIN@14 which was called:
# once (5µs+21µs) by Class::MOP::Mixin::HasMethods::BEGIN@12 at line 14 # spent 26µs making 1 call to Class::MOP::Method::Meta::BEGIN@14
# spent 21µs making 1 call to Exporter::import |
15 | |||||
16 | 2 | 22µs | 2 | 53µs | # spent 29µs (5+24) within Class::MOP::Method::Meta::BEGIN@16 which was called:
# once (5µs+24µs) by Class::MOP::Mixin::HasMethods::BEGIN@12 at line 16 # spent 29µs making 1 call to Class::MOP::Method::Meta::BEGIN@16
# spent 24µs making 1 call to constant::import |
17 | |||||
18 | 2 | 249µs | 2 | 2.93ms | # spent 1.47ms (6µs+1.46) within Class::MOP::Method::Meta::BEGIN@18 which was called:
# once (6µs+1.46ms) by Class::MOP::Mixin::HasMethods::BEGIN@12 at line 18 # spent 1.47ms making 1 call to Class::MOP::Method::Meta::BEGIN@18
# spent 1.46ms making 1 call to base::import |
19 | |||||
20 | sub _is_caller_mop_internal { | ||||
21 | my $self = shift; | ||||
22 | my ($caller) = @_; | ||||
23 | return $caller =~ /^(?:Class::MOP|metaclass)(?:::|$)/; | ||||
24 | } | ||||
25 | |||||
26 | # spent 306µs (275+31) within Class::MOP::Method::Meta::_generate_meta_method which was called 55 times, avg 6µs/call:
# 55 times (275µs+31µs) by Class::MOP::Method::Meta::wrap at line 61, avg 6µs/call | ||||
27 | 55 | 12µs | my $method_self = shift; | ||
28 | 55 | 7µs | my $metaclass = shift; | ||
29 | 55 | 102µs | 55 | 31µs | weaken($metaclass); # spent 31µs making 55 calls to Scalar::Util::weaken, avg 560ns/call |
30 | |||||
31 | sub { | ||||
32 | # this will be compiled out if the env var wasn't set | ||||
33 | if (DEBUG_NO_META) { | ||||
34 | confess "'meta' method called by MOP internals" | ||||
35 | # it's okay to call meta methods on metaclasses, since we | ||||
36 | # explicitly ask for them | ||||
37 | if !$_[0]->isa('Class::MOP::Object') | ||||
38 | && !$_[0]->isa('Class::MOP::Mixin') | ||||
39 | # it's okay if the test itself calls ->meta, we only care about | ||||
40 | # if the mop internals call ->meta | ||||
41 | && $method_self->_is_caller_mop_internal(scalar caller); | ||||
42 | } | ||||
43 | # we must re-initialize so that it | ||||
44 | # works as expected in subclasses, | ||||
45 | # since metaclass instances are | ||||
46 | # singletons, this is not really a | ||||
47 | # big deal anyway. | ||||
48 | 414 | 1.70ms | 828 | 4.64ms | $metaclass->initialize(blessed($_[0]) || $_[0]) # spent 4.50ms making 414 calls to Class::MOP::Class::initialize, avg 11µs/call, recursion: max depth 1, sum of overlapping time 49µs
# spent 186µs making 414 calls to Scalar::Util::blessed, avg 448ns/call |
49 | 55 | 3.67ms | }; | ||
50 | } | ||||
51 | |||||
52 | # spent 20.3ms (4.08+16.2) within Class::MOP::Method::Meta::wrap which was called 55 times, avg 369µs/call:
# 32 times (3.82ms+9.96ms) by Moose::Meta::Method::Meta::wrap at line 26 of Moose/Meta/Method/Meta.pm, avg 431µs/call
# 23 times (266µs+6.25ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 33 of Class/MOP/Mixin/HasMethods.pm, avg 283µs/call | ||||
53 | 55 | 61µs | my ($class, @args) = @_; | ||
54 | |||||
55 | 55 | 23µs | unshift @args, 'body' if @args % 2 == 1; | ||
56 | 55 | 61µs | my %params = @args; | ||
57 | 55 | 9µs | confess "Overriding the body of meta methods is not allowed" | ||
58 | if $params{body}; | ||||
59 | |||||
60 | 55 | 62µs | 55 | 454µs | my $metaclass_class = $params{associated_metaclass}->meta; # spent 287µs making 36 calls to Class::MOP::Object::meta, avg 8µs/call
# spent 167µs making 19 calls to Moose::Meta::Role::meta, avg 9µs/call |
61 | 55 | 80µs | 55 | 306µs | $params{body} = $class->_generate_meta_method($metaclass_class); # spent 306µs making 55 calls to Class::MOP::Method::Meta::_generate_meta_method, avg 6µs/call |
62 | 55 | 219µs | 55 | 15.5ms | return $class->SUPER::wrap(%params); # spent 15.5ms making 55 calls to Class::MOP::Method::wrap, avg 281µs/call |
63 | } | ||||
64 | |||||
65 | sub _make_compatible_with { | ||||
66 | my $self = shift; | ||||
67 | my ($other) = @_; | ||||
68 | |||||
69 | # XXX: this is pretty gross. the issue here is that CMOP::Method::Meta | ||||
70 | # objects are subclasses of CMOP::Method, but when we get to moose, they'll | ||||
71 | # need to be compatible with Moose::Meta::Method, which isn't possible. the | ||||
72 | # right solution here is to make ::Meta into a role that gets applied to | ||||
73 | # whatever the method_metaclass happens to be and get rid of | ||||
74 | # _meta_method_metaclass entirely, but that's not going to happen until | ||||
75 | # we ditch cmop and get roles into the bootstrapping, so. i'm not | ||||
76 | # maintaining the previous behavior of turning them into instances of the | ||||
77 | # new method_metaclass because that's equally broken, and at least this way | ||||
78 | # any issues will at least be detectable and potentially fixable. -doy | ||||
79 | return $self unless $other->_is_compatible_with($self->_real_ref_name); | ||||
80 | |||||
81 | return $self->SUPER::_make_compatible_with(@_); | ||||
82 | } | ||||
83 | |||||
84 | 1 | 2µs | 1; | ||
85 | |||||
86 | # ABSTRACT: Method Meta Object for C<meta> methods | ||||
87 | |||||
88 | __END__ |