← 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:12 2010

File /usr/local/lib/perl/5.10.0/Moose/Meta/Method/Overridden.pm
Statements Executed 4049
Total Time 0.0104913 seconds
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
411129µs1.67msMoose::Meta::Method::Overridden::::newMoose::Meta::Method::Overridden::new
0000s0sMoose::Meta::Method::Overridden::::BEGINMoose::Meta::Method::Overridden::BEGIN
0000s0sMoose::Meta::Method::Overridden::::__ANON__[:37]Moose::Meta::Method::Overridden::__ANON__[:37]
LineStmts.Exclusive
Time
Avg.Code
1package Moose::Meta::Method::Overridden;
2
3323µs8µsuse strict;
# spent 7µs making 1 call to strict::import
4359µs20µsuse warnings;
# spent 24µs making 1 call to warnings::import
5
61700ns700nsour $VERSION = '1.15';
7119µs19µs$VERSION = eval $VERSION;
81600ns600nsour $AUTHORITY = 'cpan:STEVAN';
9
103238µs79µsuse base 'Moose::Meta::Method';
# spent 4.14ms making 1 call to base::import
11
12
# spent 1.67ms (129µs+1.54) within Moose::Meta::Method::Overridden::new which was called 4 times, avg 418µs/call: # 4 times (129µs+1.54ms) by Moose::Meta::Class::add_override_method_modifier at line 313 of /usr/local/lib/perl/5.10.0/Moose/Meta/Class.pm, avg 418µs/call
sub new {
13422µs5µs my ( $class, %args ) = @_;
14
15 # the package can be overridden by roles
16 # it is really more like body's compilation stash
17 # this is where we need to override the definition of super() so that the
18 # body of the code can call the right overridden version
19428µs7µs my $super_package = $args{package} || $args{class}->name;
# spent 15µs making 4 calls to Class::MOP::Package::name, avg 4µs/call
20
2145µs1µs my $name = $args{name};
22
23427µs7µs my $super = $args{class}->find_next_method_by_name($name);
# spent 953µs making 4 calls to Class::MOP::Class::find_next_method_by_name, avg 238µs/call
24
2542µs525ns (defined $super)
26 || $class->throw_error("You cannot override '$name' because it has no super method", data => $name);
27
28422µs5µs my $super_body = $super->body;
# spent 16µs making 4 calls to Class::MOP::Method::body, avg 4µs/call
29
3045µs1µs my $method = $args{method};
31
32 my $body = sub {
3310001.07ms1µs local $Moose::SUPER_PACKAGE = $super_package;
3410003.17ms3µs local @Moose::SUPER_ARGS = @_;
351000382µs382ns local $Moose::SUPER_BODY = $super_body;
3610005.34ms5µs return $method->(@_);
37422µs6µs };
38
39 # FIXME do we need this make sure this works for next::method?
40 # subname "${super_package}::${name}", $method;
41
42 # FIXME store additional attrs
43450µs12µs $class->wrap(
# spent 545µs making 4 calls to Class::MOP::Method::wrap, avg 136µs/call # spent 14µs making 4 calls to Class::MOP::Package::name, avg 4µs/call
44 $body,
45 package_name => $args{class}->name,
46 name => $name
47 );
48}
49
5018µs8µs1;
51
52__END__
53
54=pod
55
56=head1 NAME
57
58Moose::Meta::Method::Overridden - A Moose Method metaclass for overridden methods
59
60=head1 DESCRIPTION
61
62This class implements method overriding logic for the L<Moose>
63C<override> keyword.
64
65The overriding subroutine's parent will be invoked explicitly using
66the C<super> keyword from the parent class's method definition.
67
68=head1 METHODS
69
70=over 4
71
72=item B<< Moose::Meta::Method::Overridden->new(%options) >>
73
74This constructs a new object. It accepts the following options:
75
76=over 8
77
78=item * class
79
80The metaclass object for the class in which the override is being
81declared. This option is required.
82
83=item * name
84
85The name of the method which we are overriding. This method must exist
86in one of the class's superclasses. This option is required.
87
88=item * method
89
90The subroutine reference which implements the overriding. This option
91is required.
92
93=back
94
95=back
96
97=head1 BUGS
98
99See L<Moose/BUGS> for details on reporting bugs.
100
101=head1 AUTHOR
102
103Yuval Kogman E<lt>nothingmuch@cpan.orgE<gt>
104
105=head1 COPYRIGHT AND LICENSE
106
107Copyright 2006-2010 by Infinity Interactive, Inc.
108
109L<http://www.iinteractive.com>
110
111This library is free software; you can redistribute it and/or modify
112it under the same terms as Perl itself.
113
114=cut