← Index
Performance Profile   « block view • line view • sub view »
For t/test-parsing
  Run on Sun Nov 14 09:49:57 2010
Reported on Sun Nov 14 09:50:09 2010

File /usr/local/lib/perl/5.10.0/Class/MOP/Method/Meta.pm
Statements Executed 752
Total Time 0.00364349999999999 seconds
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
3122859µs15.2msClass::MOP::Method::Meta::::wrapClass::MOP::Method::Meta::wrap
3111349µs349µsClass::MOP::Method::Meta::::_generate_meta_methodClass::MOP::Method::Meta::_generate_meta_method
0000s0sClass::MOP::Method::Meta::::BEGINClass::MOP::Method::Meta::BEGIN
0000s0sClass::MOP::Method::Meta::::__ANON__[:45]Class::MOP::Method::Meta::__ANON__[:45]
0000s0sClass::MOP::Method::Meta::::_is_caller_mop_internalClass::MOP::Method::Meta::_is_caller_mop_internal
0000s0sClass::MOP::Method::Meta::::_make_compatible_withClass::MOP::Method::Meta::_make_compatible_with
LineStmts.Exclusive
Time
Avg.Code
1
2package Class::MOP::Method::Meta;
3
4326µs9µsuse strict;
# spent 9µs making 1 call to strict::import
5330µs10µsuse warnings;
# spent 25µs making 1 call to warnings::import
6
7324µs8µsuse Carp 'confess';
# spent 38µs making 1 call to Exporter::import
8379µs26µsuse Scalar::Util 'blessed';
# spent 35µs making 1 call to Exporter::import
9
101800ns800nsour $VERSION = '1.09';
11119µs19µs$VERSION = eval $VERSION;
121600ns600nsour $AUTHORITY = 'cpan:STEVAN';
13
14339µs13µsuse constant DEBUG_NO_META => $ENV{DEBUG_NO_META} ? 1 : 0;
# spent 54µs making 1 call to constant::import
15
163339µs113µsuse base 'Class::MOP::Method';
# spent 2.15ms making 1 call to base::import
17
18sub _is_caller_mop_internal {
19 my $self = shift;
20 my ($caller) = @_;
21 return $caller =~ /^(?:Class::MOP|metaclass)(?:::|$)/;
22}
23
24
# spent 349µs within Class::MOP::Method::Meta::_generate_meta_method which was called 31 times, avg 11µs/call: # 31 times (349µs+0s) by Class::MOP::Method::Meta::wrap at line 57, avg 11µs/call
sub _generate_meta_method {
2593263µs3µs my $method_self = shift;
26 my $metaclass = shift;
27 sub {
28 # this will be compiled out if the env var wasn't set
294201.79ms4µs 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 $metaclass->initialize(blessed($_[0]) || $_[0])
# spent 7.71ms making 210 calls to Class::MOP::Class::initialize, avg 36µs/call, max recursion depth 1 # spent 598µs making 210 calls to Scalar::Util::blessed, avg 3µs/call
45 };
46}
47
48
# spent 15.2ms (859µs+14.3) within Class::MOP::Method::Meta::wrap which was called 31 times, avg 491µs/call: # 23 times (634µs+8.96ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 30 of /usr/local/lib/perl/5.10.0/Class/MOP/Mixin/HasMethods.pm, avg 417µs/call # 8 times (224µs+5.39ms) by Moose::Meta::Method::Meta::wrap at line 24 of /usr/local/lib/perl/5.10.0/Moose/Meta/Method/Meta.pm, avg 702µs/call
sub wrap {
492171.03ms5µs 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 my $metaclass_class = $params{associated_metaclass}->meta;
# spent 670µs making 31 calls to Class::MOP::Object::meta, avg 22µs/call
57 $params{body} = $class->_generate_meta_method($metaclass_class);
# spent 349µs making 31 calls to Class::MOP::Method::Meta::_generate_meta_method, avg 11µs/call
58 return $class->SUPER::wrap(%params);
# spent 13.3ms making 31 calls to Class::MOP::Method::wrap, avg 430µs/call
59}
60
61sub _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
8014µs4µs1;
81
82__END__
83
84=pod
85
86=head1 NAME
87
88Class::MOP::Method::Meta - Method Meta Object for C<meta> methods
89
90=head1 DESCRIPTION
91
92This is a L<Class::MOP::Method> subclass which represents C<meta>
93methods installed into classes by Class::MOP.
94
95=head1 METHODS
96
97=over 4
98
99=item B<< Class::MOP::Method::Wrapped->wrap($metamethod, %options) >>
100
101This is the constructor. It accepts a L<Class::MOP::Method> object and
102a hash of options. The options accepted are identical to the ones
103accepted by L<Class::MOP::Method>, except that C<body> cannot be passed
104(it will be generated automatically).
105
106=back
107
108=head1 AUTHORS
109
110Jesse Luehrs E<lt>doy at tozt dot netE<gt>
111
112=head1 COPYRIGHT AND LICENSE
113
114Copyright 2006-2010 by Infinity Interactive, Inc.
115
116L<http://www.iinteractive.com>
117
118This library is free software; you can redistribute it and/or modify
119it under the same terms as Perl itself.
120
121=cut
122