| Filename | /home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Method/Meta.pm |
| Statements | Executed 1840 statements in 33.5ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 92 | 2 | 2 | 9.50ms | 159ms | Class::MOP::Method::Meta::wrap |
| 1 | 1 | 1 | 3.01ms | 4.31ms | Class::MOP::Method::Meta::BEGIN@14 |
| 92 | 1 | 1 | 2.58ms | 2.58ms | Class::MOP::Method::Meta::_generate_meta_method |
| 1 | 1 | 1 | 76µs | 92µs | Class::MOP::Method::Meta::BEGIN@4 |
| 1 | 1 | 1 | 41µs | 7.34ms | Class::MOP::Method::Meta::BEGIN@16 |
| 1 | 1 | 1 | 36µs | 100µs | Class::MOP::Method::Meta::BEGIN@5 |
| 1 | 1 | 1 | 36µs | 163µs | Class::MOP::Method::Meta::BEGIN@8 |
| 1 | 1 | 1 | 36µs | 194µs | Class::MOP::Method::Meta::BEGIN@7 |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Meta::__ANON__[:45] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Meta::_is_caller_mop_internal |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Meta::_make_compatible_with |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | package Class::MOP::Method::Meta; | ||||
| 3 | |||||
| 4 | 3 | 104µs | 2 | 108µs | # spent 92µs (76+16) within Class::MOP::Method::Meta::BEGIN@4 which was called:
# once (76µs+16µs) by Class::MOP::Mixin::HasMethods::BEGIN@6 at line 4 # spent 92µs making 1 call to Class::MOP::Method::Meta::BEGIN@4
# spent 16µs making 1 call to strict::import |
| 5 | 3 | 117µs | 2 | 164µs | # spent 100µs (36+64) within Class::MOP::Method::Meta::BEGIN@5 which was called:
# once (36µs+64µs) by Class::MOP::Mixin::HasMethods::BEGIN@6 at line 5 # spent 100µs making 1 call to Class::MOP::Method::Meta::BEGIN@5
# spent 64µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 3 | 136µs | 2 | 352µs | # spent 194µs (36+158) within Class::MOP::Method::Meta::BEGIN@7 which was called:
# once (36µs+158µs) by Class::MOP::Mixin::HasMethods::BEGIN@6 at line 7 # spent 194µs making 1 call to Class::MOP::Method::Meta::BEGIN@7
# spent 158µs making 1 call to Exporter::import |
| 8 | 3 | 234µs | 2 | 291µs | # spent 163µs (36+127) within Class::MOP::Method::Meta::BEGIN@8 which was called:
# once (36µs+127µs) by Class::MOP::Mixin::HasMethods::BEGIN@6 at line 8 # spent 163µs making 1 call to Class::MOP::Method::Meta::BEGIN@8
# spent 127µs making 1 call to Exporter::import |
| 9 | |||||
| 10 | 1 | 5µs | our $VERSION = '1.11'; | ||
| 11 | 1 | 73µs | $VERSION = eval $VERSION; # spent 10µs executing statements in string eval | ||
| 12 | 1 | 3µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 13 | |||||
| 14 | 3 | 519µs | 2 | 4.58ms | # spent 4.31ms (3.01+1.30) within Class::MOP::Method::Meta::BEGIN@14 which was called:
# once (3.01ms+1.30ms) by Class::MOP::Mixin::HasMethods::BEGIN@6 at line 14 # spent 4.31ms making 1 call to Class::MOP::Method::Meta::BEGIN@14
# spent 268µs making 1 call to constant::import |
| 15 | |||||
| 16 | 3 | 1.00ms | 2 | 14.6ms | # spent 7.34ms (41µs+7.30) within Class::MOP::Method::Meta::BEGIN@16 which was called:
# once (41µs+7.30ms) by Class::MOP::Mixin::HasMethods::BEGIN@6 at line 16 # spent 7.34ms making 1 call to Class::MOP::Method::Meta::BEGIN@16
# spent 7.30ms making 1 call to base::import |
| 17 | |||||
| 18 | sub _is_caller_mop_internal { | ||||
| 19 | my $self = shift; | ||||
| 20 | my ($caller) = @_; | ||||
| 21 | return $caller =~ /^(?:Class::MOP|metaclass)(?:::|$)/; | ||||
| 22 | } | ||||
| 23 | |||||
| 24 | # spent 2.58ms within Class::MOP::Method::Meta::_generate_meta_method which was called 92 times, avg 28µs/call:
# 92 times (2.58ms+0s) by Class::MOP::Method::Meta::wrap at line 57, avg 28µs/call | ||||
| 25 | 276 | 2.84ms | my $method_self = shift; | ||
| 26 | my $metaclass = shift; | ||||
| 27 | sub { | ||||
| 28 | # this will be compiled out if the env var wasn't set | ||||
| 29 | 898 | 19.4ms | if (DEBUG_NO_META) { | ||
| 30 | confess "'meta' method called by MOP internals" | ||||
| 31 | # it's okay to call meta methods on metaclasses, since we | ||||
| 32 | # explicitly ask for them | ||||
| 33 | if !$_[0]->isa('Class::MOP::Object') | ||||
| 34 | && !$_[0]->isa('Class::MOP::Mixin') | ||||
| 35 | # it's okay if the test itself calls ->meta, we only care about | ||||
| 36 | # if the mop internals call ->meta | ||||
| 37 | && $method_self->_is_caller_mop_internal(scalar caller); | ||||
| 38 | } | ||||
| 39 | # we must re-initialize so that it | ||||
| 40 | # works as expected in subclasses, | ||||
| 41 | # since metaclass instances are | ||||
| 42 | # singletons, this is not really a | ||||
| 43 | # big deal anyway. | ||||
| 44 | 898 | 39.6ms | $metaclass->initialize(blessed($_[0]) || $_[0]) # spent 38.3ms making 449 calls to Class::MOP::Class::initialize, avg 85µs/call, recursion: max depth 1, sum of overlapping time 1.40ms
# spent 2.73ms making 449 calls to Scalar::Util::blessed, avg 6µs/call | ||
| 45 | }; | ||||
| 46 | } | ||||
| 47 | |||||
| 48 | # spent 159ms (9.50+150) within Class::MOP::Method::Meta::wrap which was called 92 times, avg 1.73ms/call:
# 69 times (7.16ms+117ms) by Moose::Meta::Method::Meta::wrap at line 24 of Moose/Meta/Method/Meta.pm, avg 1.80ms/call
# 23 times (2.34ms+32.9ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 28 of Class/MOP/Mixin/HasMethods.pm, avg 1.53ms/call | ||||
| 49 | 644 | 9.04ms | my ($class, @args) = @_; | ||
| 50 | |||||
| 51 | unshift @args, 'body' if @args % 2 == 1; | ||||
| 52 | my %params = @args; | ||||
| 53 | confess "Overriding the body of meta methods is not allowed" | ||||
| 54 | if $params{body}; | ||||
| 55 | |||||
| 56 | 92 | 8.10ms | my $metaclass_class = $params{associated_metaclass}->meta; # spent 4.87ms making 57 calls to Class::MOP::Object::meta, avg 85µs/call
# spent 3.23ms making 35 calls to Moose::Meta::Role::meta, avg 92µs/call | ||
| 57 | 92 | 2.58ms | $params{body} = $class->_generate_meta_method($metaclass_class); # spent 2.58ms making 92 calls to Class::MOP::Method::Meta::_generate_meta_method, avg 28µs/call | ||
| 58 | 92 | 139ms | return $class->SUPER::wrap(%params); # spent 139ms making 92 calls to Class::MOP::Method::wrap, avg 1.51ms/call | ||
| 59 | } | ||||
| 60 | |||||
| 61 | sub _make_compatible_with { | ||||
| 62 | my $self = shift; | ||||
| 63 | my ($other) = @_; | ||||
| 64 | |||||
| 65 | # XXX: this is pretty gross. the issue here is that CMOP::Method::Meta | ||||
| 66 | # objects are subclasses of CMOP::Method, but when we get to moose, they'll | ||||
| 67 | # need to be compatible with Moose::Meta::Method, which isn't possible. the | ||||
| 68 | # right solution here is to make ::Meta into a role that gets applied to | ||||
| 69 | # whatever the method_metaclass happens to be and get rid of | ||||
| 70 | # _meta_method_metaclass entirely, but that's not going to happen until | ||||
| 71 | # we ditch cmop and get roles into the bootstrapping, so. i'm not | ||||
| 72 | # maintaining the previous behavior of turning them into instances of the | ||||
| 73 | # new method_metaclass because that's equally broken, and at least this way | ||||
| 74 | # any issues will at least be detectable and potentially fixable. -doy | ||||
| 75 | return $self unless $other->_is_compatible_with($self->_real_ref_name); | ||||
| 76 | |||||
| 77 | return $self->SUPER::_make_compatible_with(@_); | ||||
| 78 | } | ||||
| 79 | |||||
| 80 | 1 | 10µs | 1; | ||
| 81 | |||||
| 82 | __END__ |