File | /usr/local/lib/perl/5.10.0/Class/MOP/MiniTrait.pm |
Statements Executed | 185 |
Total Time | 0.0015331 seconds |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
8 | 7 | 7 | 685µs | 61.4ms | apply | Class::MOP::MiniTrait::
0 | 0 | 0 | 0s | 0s | BEGIN | Class::MOP::MiniTrait::
Line | Stmts. | Exclusive Time | Avg. | Code |
---|---|---|---|---|
1 | package Class::MOP::MiniTrait; | |||
2 | ||||
3 | 3 | 30µs | 10µs | use strict; # spent 13µs making 1 call to strict::import |
4 | 3 | 192µs | 64µs | use warnings; # spent 24µs making 1 call to warnings::import |
5 | ||||
6 | 1 | 700ns | 700ns | our $VERSION = '1.09'; |
7 | 1 | 22µs | 22µs | $VERSION = eval $VERSION; |
8 | 1 | 500ns | 500ns | our $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 | |||
11 | 24 | 133µs | 6µs | my ( $to_class, $trait ) = @_; |
12 | ||||
13 | for ( grep { !ref } $to_class, $trait ) { | |||
14 | 28 | 149µs | 5µs | 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 | 112 | 890µs | 8µs | my $meth_name = $meth->name; # spent 155µs making 56 calls to Class::MOP::Method::name, avg 3µs/call |
20 | ||||
21 | 10 | 112µs | 11µs | 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. | |||
34 | 1 | 700ns | 700ns | require Class::MOP; |
35 | ||||
36 | 1 | 4µs | 4µs | 1; |
37 | ||||
38 | __END__ | |||
39 | ||||
40 | =pod | |||
41 | ||||
42 | =head1 NAME | |||
43 | ||||
44 | Class::MOP::MiniTrait - Extremely limited trait application | |||
45 | ||||
46 | =head1 DESCRIPTION | |||
47 | ||||
48 | This package provides a single function, C<apply>, which does a half-assed job | |||
49 | of applying a trait to a class. It exists solely for use inside Class::MOP and | |||
50 | L<Moose> core classes. | |||
51 | ||||
52 | =head1 AUTHORS | |||
53 | ||||
54 | Stevan Little E<lt>stevan@iinteractive.comE<gt> | |||
55 | ||||
56 | =head1 COPYRIGHT AND LICENSE | |||
57 | ||||
58 | Copyright 2006-2010 by Infinity Interactive, Inc. | |||
59 | ||||
60 | L<http://www.iinteractive.com> | |||
61 | ||||
62 | This library is free software; you can redistribute it and/or modify | |||
63 | it under the same terms as Perl itself. | |||
64 | ||||
65 | =cut | |||
66 |