| Filename | /Users/ap13/perl5/lib/perl5/darwin-2level/Class/MOP/MiniTrait.pm |
| Statements | Executed 325 statements in 1.39ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 7 | 6 | 6 | 1.10ms | 40.8ms | Class::MOP::MiniTrait::apply |
| 1 | 1 | 1 | 23µs | 43µs | Class::MOP::MiniTrait::BEGIN@4 |
| 1 | 1 | 1 | 14µs | 40µs | Class::MOP::MiniTrait::BEGIN@7 |
| 1 | 1 | 1 | 13µs | 20µs | Class::MOP::MiniTrait::BEGIN@5 |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Class::MOP::MiniTrait; | ||||
| 2 | 1 | 1µs | our $VERSION = '2.1403'; | ||
| 3 | |||||
| 4 | 2 | 37µs | 2 | 64µs | # spent 43µs (23+20) within Class::MOP::MiniTrait::BEGIN@4 which was called:
# once (23µs+20µs) by Class::MOP::Class::BEGIN@11 at line 4 # spent 43µs making 1 call to Class::MOP::MiniTrait::BEGIN@4
# spent 20µs making 1 call to strict::import |
| 5 | 2 | 39µs | 2 | 26µs | # spent 20µs (13+7) within Class::MOP::MiniTrait::BEGIN@5 which was called:
# once (13µs+7µs) by Class::MOP::Class::BEGIN@11 at line 5 # spent 20µs making 1 call to Class::MOP::MiniTrait::BEGIN@5
# spent 7µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 2 | 244µs | 2 | 66µs | # spent 40µs (14+26) within Class::MOP::MiniTrait::BEGIN@7 which was called:
# once (14µs+26µs) by Class::MOP::Class::BEGIN@11 at line 7 # spent 40µs making 1 call to Class::MOP::MiniTrait::BEGIN@7
# spent 26µs making 1 call to Module::Runtime::import |
| 8 | |||||
| 9 | # spent 40.8ms (1.10+39.7) within Class::MOP::MiniTrait::apply which was called 7 times, avg 5.84ms/call:
# 2 times (710µs+29.2ms) by Class::MOP::Class::_immutable_metaclass at line 1371 of Class/MOP/Class.pm, avg 15.0ms/call
# once (101µs+3.27ms) by parent::import at line 11 of Moose/Meta/Method.pm
# once (100µs+2.76ms) by Moose::BEGIN@24 at line 24 of Moose/Meta/Class.pm
# once (71µs+1.73ms) by Moose::Meta::TypeCoercion::BEGIN@8 at line 23 of Moose/Meta/Attribute.pm
# once (60µs+1.40ms) by Moose::BEGIN@32 at line 24 of Moose/Meta/Role.pm
# once (60µs+1.38ms) by Moose::BEGIN@28 at line 11 of Moose/Meta/Instance.pm | ||||
| 10 | 316 | 1.06ms | my ( $to_class, $trait ) = @_; | ||
| 11 | |||||
| 12 | for ( grep { !ref } $to_class, $trait ) { | ||||
| 13 | 12 | 2.63ms | use_package_optimistically($_); # spent 2.63ms making 12 calls to Module::Runtime::use_package_optimistically, avg 219µs/call | ||
| 14 | 12 | 2.76ms | $_ = Class::MOP::Class->initialize($_); # spent 2.76ms making 12 calls to Class::MOP::Class::initialize, avg 230µs/call | ||
| 15 | } | ||||
| 16 | |||||
| 17 | 93 | 5.02ms | for my $meth ( grep { $_->package_name ne 'UNIVERSAL' } $trait->get_all_methods ) { # spent 4.96ms making 7 calls to Class::MOP::Class::get_all_methods, avg 709µs/call
# spent 54µs making 86 calls to Class::MOP::Method::package_name, avg 622ns/call | ||
| 18 | 58 | 45µs | my $meth_name = $meth->name; # spent 45µs making 58 calls to Class::MOP::Method::name, avg 783ns/call | ||
| 19 | next if index($meth_name, '__') == 0; # skip private subs | ||||
| 20 | |||||
| 21 | 142 | 27.7ms | if ( $to_class->find_method_by_name($meth_name) ) { # spent 14.7ms making 43 calls to Class::MOP::Class::add_around_method_modifier, avg 341µs/call
# spent 13.0ms making 56 calls to Class::MOP::Class::find_method_by_name, avg 231µs/call
# spent 35µs making 43 calls to Class::MOP::Method::body, avg 812ns/call | ||
| 22 | $to_class->add_around_method_modifier( $meth_name, $meth->body ); | ||||
| 23 | } | ||||
| 24 | else { | ||||
| 25 | 26 | 1.63ms | $to_class->add_method( $meth_name, $meth->clone ); # spent 1.29ms making 13 calls to Class::MOP::Mixin::HasMethods::add_method, avg 99µs/call
# spent 341µs making 13 calls to Class::MOP::Method::clone, avg 26µ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 | 800ns | require Class::MOP; | ||
| 35 | |||||
| 36 | 1 | 5µs | 1; | ||
| 37 | |||||
| 38 | # ABSTRACT: Extremely limited trait application | ||||
| 39 | |||||
| 40 | __END__ |