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

File /usr/local/lib/perl/5.10.0/Class/MOP/MiniTrait.pm
Statements Executed 185
Total Time 0.0015331 seconds
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
877685µs61.4msClass::MOP::MiniTrait::::applyClass::MOP::MiniTrait::apply
0000s0sClass::MOP::MiniTrait::::BEGINClass::MOP::MiniTrait::BEGIN
LineStmts.Exclusive
Time
Avg.Code
1package Class::MOP::MiniTrait;
2
3330µs10µsuse strict;
# spent 13µs making 1 call to strict::import
43192µs64µsuse warnings;
# spent 24µs making 1 call to warnings::import
5
61700ns700nsour $VERSION = '1.09';
7122µs22µs$VERSION = eval $VERSION;
81500ns500nsour $AUTHORITY = 'cpan:STEVAN';
9
10
# spent 61.4ms (685µs+60.7) within Class::MOP::MiniTrait::apply which was called 8 times, avg 7.67ms/call: # 2 times (387µs+44.2ms) by Class::MOP::Class::_immutable_metaclass at line 1219 of /usr/local/lib/perl/5.10.0/Class/MOP/Class.pm, avg 22.3ms/call # once (59µs+3.42ms) at line 14 of /usr/local/lib/perl/5.10.0/Moose/Meta/Method.pm # once (41µs+3.19ms) at line 31 of /usr/local/lib/perl/5.10.0/Moose/Meta/Class.pm # once (53µs+3.10ms) at line 24 of /usr/local/lib/perl/5.10.0/Moose/Meta/Attribute.pm # once (47µs+2.42ms) at line 29 of /usr/local/lib/perl/5.10.0/Moose/Meta/Role.pm # once (48µs+2.36ms) at line 15 of /usr/local/lib/perl/5.10.0/Moose/Meta/Instance.pm # once (49µs+1.96ms) at line 15 of /usr/local/lib/perl/5.10.0/Moose/Error/Default.pm
sub apply {
111741.28ms7µs my ( $to_class, $trait ) = @_;
12
13 for ( grep { !ref } $to_class, $trait ) {
14 Class::MOP::load_class($_);
# spent 2.68ms making 14 calls to Class::MOP::load_class, avg 191µs/call
15 $_ = Class::MOP::Class->initialize($_);
# spent 4.36ms making 14 calls to Class::MOP::Class::initialize, avg 311µs/call
16 }
17
18 for my $meth ( $trait->get_all_methods ) {
# spent 7.14ms making 8 calls to Class::MOP::Class::get_all_methods, avg 892µs/call
19 my $meth_name = $meth->name;
# spent 155µs making 56 calls to Class::MOP::Method::name, avg 3µs/call
20
21 if ( $to_class->find_method_by_name($meth_name) ) {
# spent 23.4ms making 46 calls to Class::MOP::Class::add_around_method_modifier, avg 510µs/call # spent 21.2ms making 56 calls to Class::MOP::Class::find_method_by_name, avg 378µs/call # spent 125µs making 46 calls to Class::MOP::Method::body, avg 3µs/call
22 $to_class->add_around_method_modifier( $meth_name, $meth->body );
23 }
24 else {
25 $to_class->add_method( $meth_name, $meth->clone );
# spent 1.31ms making 10 calls to Class::MOP::Mixin::HasMethods::add_method, avg 131µs/call # spent 300µs making 10 calls to Class::MOP::Method::clone, avg 30µs/call
26 }
27 }
28}
29
30# We can't load this with use, since it may be loaded and used from Class::MOP
31# (via CMOP::Class, etc). However, if for some reason this module is loaded
32# _without_ first loading Class::MOP we need to require Class::MOP so we can
33# use it and CMOP::Class.
341700ns700nsrequire Class::MOP;
35
3614µs4µs1;
37
38__END__
39
40=pod
41
42=head1 NAME
43
44Class::MOP::MiniTrait - Extremely limited trait application
45
46=head1 DESCRIPTION
47
48This package provides a single function, C<apply>, which does a half-assed job
49of applying a trait to a class. It exists solely for use inside Class::MOP and
50L<Moose> core classes.
51
52=head1 AUTHORS
53
54Stevan Little E<lt>stevan@iinteractive.comE<gt>
55
56=head1 COPYRIGHT AND LICENSE
57
58Copyright 2006-2010 by Infinity Interactive, Inc.
59
60L<http://www.iinteractive.com>
61
62This library is free software; you can redistribute it and/or modify
63it under the same terms as Perl itself.
64
65=cut
66