| Filename | /usr/local/lib/perl/5.18.2/Moose/Role.pm |
| Statements | Executed 1155 statements in 2.90ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 35 | 1 | 1 | 1.12ms | 46.9ms | Moose::Role::init_meta |
| 30 | 16 | 15 | 375µs | 3.37ms | Moose::Role::has |
| 100 | 2 | 1 | 315µs | 11.9ms | Moose::Role::super |
| 28 | 15 | 15 | 187µs | 244ms | Moose::Role::with (recurses: max depth 2, inclusive time 40.5ms) |
| 40 | 21 | 8 | 158µs | 1.50ms | Moose::Role::requires |
| 14 | 8 | 6 | 58µs | 500µs | Moose::Role::around |
| 9 | 2 | 1 | 33µs | 245µs | Moose::Role::_add_method_modifier |
| 6 | 4 | 2 | 22µs | 221µs | Moose::Role::override |
| 1 | 1 | 1 | 16µs | 33µs | PONAPI::Builder::BEGIN@1 |
| 4 | 3 | 2 | 15µs | 138µs | Moose::Role::before |
| 1 | 1 | 1 | 8µs | 15µs | PONAPI::Builder::BEGIN@2 |
| 1 | 1 | 1 | 8µs | 21µs | Moose::Role::BEGIN@9 |
| 1 | 1 | 1 | 8µs | 124µs | Moose::Role::BEGIN@11 |
| 1 | 1 | 1 | 7µs | 42µs | Moose::Role::BEGIN@8 |
| 1 | 1 | 1 | 7µs | 28µs | Moose::Role::BEGIN@16 |
| 1 | 1 | 1 | 6µs | 1.03ms | Moose::Role::BEGIN@18 |
| 1 | 1 | 1 | 6µs | 134µs | Moose::Role::BEGIN@14 |
| 1 | 1 | 1 | 5µs | 5µs | Moose::Role::BEGIN@17 |
| 1 | 1 | 1 | 4µs | 4µs | Moose::Role::BEGIN@7 |
| 1 | 1 | 1 | 4µs | 4µs | Moose::Role::BEGIN@6 |
| 1 | 1 | 1 | 3µs | 3µs | Moose::Role::BEGIN@13 |
| 0 | 0 | 0 | 0s | 0s | Moose::Role::after |
| 0 | 0 | 0 | 0s | 0s | Moose::Role::augment |
| 0 | 0 | 0 | 0s | 0s | Moose::Role::excludes |
| 0 | 0 | 0 | 0s | 0s | Moose::Role::extends |
| 0 | 0 | 0 | 0s | 0s | Moose::Role::inner |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | 2 | 26µs | 2 | 50µs | # spent 33µs (16+17) within PONAPI::Builder::BEGIN@1 which was called:
# once (16µs+17µs) by PONAPI::Builder::BEGIN@4 at line 1 # spent 33µs making 1 call to PONAPI::Builder::BEGIN@1
# spent 17µs making 1 call to strict::import |
| 2 | 2 | 44µs | 2 | 23µs | # spent 15µs (8+8) within PONAPI::Builder::BEGIN@2 which was called:
# once (8µs+8µs) by PONAPI::Builder::BEGIN@4 at line 2 # spent 15µs making 1 call to PONAPI::Builder::BEGIN@2
# spent 8µs making 1 call to warnings::import |
| 3 | package Moose::Role; | ||||
| 4 | 1 | 500ns | our $VERSION = '2.1604'; | ||
| 5 | |||||
| 6 | 2 | 20µs | 1 | 4µs | # spent 4µs within Moose::Role::BEGIN@6 which was called:
# once (4µs+0s) by PONAPI::Builder::BEGIN@4 at line 6 # spent 4µs making 1 call to Moose::Role::BEGIN@6 |
| 7 | 2 | 21µs | 1 | 4µs | # spent 4µs within Moose::Role::BEGIN@7 which was called:
# once (4µs+0s) by PONAPI::Builder::BEGIN@4 at line 7 # spent 4µs making 1 call to Moose::Role::BEGIN@7 |
| 8 | 2 | 25µs | 2 | 76µs | # spent 42µs (7+34) within Moose::Role::BEGIN@8 which was called:
# once (7µs+34µs) by PONAPI::Builder::BEGIN@4 at line 8 # spent 42µs making 1 call to Moose::Role::BEGIN@8
# spent 34µs making 1 call to Exporter::import |
| 9 | 2 | 25µs | 2 | 34µs | # spent 21µs (8+13) within Moose::Role::BEGIN@9 which was called:
# once (8µs+13µs) by PONAPI::Builder::BEGIN@4 at line 9 # spent 21µs making 1 call to Moose::Role::BEGIN@9
# spent 13µs making 1 call to Module::Runtime::import |
| 10 | |||||
| 11 | 2 | 29µs | 2 | 241µs | # spent 124µs (8+117) within Moose::Role::BEGIN@11 which was called:
# once (8µs+117µs) by PONAPI::Builder::BEGIN@4 at line 11 # spent 124µs making 1 call to Moose::Role::BEGIN@11
# spent 116µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
| 12 | |||||
| 13 | 2 | 19µs | 1 | 3µs | # spent 3µs within Moose::Role::BEGIN@13 which was called:
# once (3µs+0s) by PONAPI::Builder::BEGIN@4 at line 13 # spent 3µs making 1 call to Moose::Role::BEGIN@13 |
| 14 | 2 | 27µs | 2 | 262µs | # spent 134µs (6+128) within Moose::Role::BEGIN@14 which was called:
# once (6µs+128µs) by PONAPI::Builder::BEGIN@4 at line 14 # spent 134µs making 1 call to Moose::Role::BEGIN@14
# spent 128µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
| 15 | |||||
| 16 | 2 | 20µs | 2 | 49µs | # spent 28µs (7+21) within Moose::Role::BEGIN@16 which was called:
# once (7µs+21µs) by PONAPI::Builder::BEGIN@4 at line 16 # spent 28µs making 1 call to Moose::Role::BEGIN@16
# spent 21µs making 1 call to Moose::Exporter::import |
| 17 | 2 | 18µs | 1 | 5µs | # spent 5µs within Moose::Role::BEGIN@17 which was called:
# once (5µs+0s) by PONAPI::Builder::BEGIN@4 at line 17 # spent 5µs making 1 call to Moose::Role::BEGIN@17 |
| 18 | 2 | 641µs | 2 | 2.06ms | # spent 1.03ms (6µs+1.03) within Moose::Role::BEGIN@18 which was called:
# once (6µs+1.03ms) by PONAPI::Builder::BEGIN@4 at line 18 # spent 1.03ms making 1 call to Moose::Role::BEGIN@18
# spent 1.03ms making 1 call to Moose::Util::TypeConstraints::import |
| 19 | |||||
| 20 | sub extends { | ||||
| 21 | throw_exception("RolesDoNotSupportExtends"); | ||||
| 22 | } | ||||
| 23 | |||||
| 24 | # spent 244ms (187µs+244) within Moose::Role::with which was called 28 times, avg 8.72ms/call:
# 14 times (74µs+102ms) by Moose::Role::with at line 419 of Moose/Exporter.pm, avg 7.26ms/call
# once (20µs+25.2ms) by Module::Runtime::require_module at line 10 of Moose/Meta/Method/Accessor/Native/Hash/set.pm
# once (7µs+21.6ms) by Module::Runtime::require_module at line 9 of Moose/Meta/Method/Accessor/Native/Array/push.pm
# once (6µs+18.7ms) by Module::Runtime::require_module at line 11 of Moose/Meta/Method/Accessor/Native/Hash/Writer.pm
# once (7µs+14.5ms) by Module::Runtime::require_module at line 9 of Moose/Meta/Method/Accessor/Native/Hash/count.pm
# once (8µs+11.3ms) by Module::Runtime::require_module at line 5 of Moose/Meta/Attribute/Native/Trait/Hash.pm
# once (7µs+10.8ms) by Module::Runtime::require_module at line 9 of Moose/Meta/Method/Accessor/Native/Array/Writer.pm
# once (8µs+9.88ms) by Module::Runtime::require_module at line 11 of Moose/Meta/Method/Accessor/Native/Array/get.pm
# once (7µs+9.63ms) by Module::Runtime::require_module at line 9 of Moose/Meta/Method/Accessor/Native/Reader.pm
# once (6µs+7.88ms) by Module::Runtime::require_module at line 9 of Moose/Meta/Method/Accessor/Native/Hash/exists.pm
# once (7µs+6.33ms) by Module::Runtime::require_module at line 9 of Moose/Meta/Method/Accessor/Native/Hash/get.pm
# once (6µs+1.90ms) by Module::Runtime::require_module at line 9 of Moose/Meta/Method/Accessor/Native/Array/count.pm
# once (6µs+1.85ms) by Module::Runtime::require_module at line 9 of Moose/Meta/Method/Accessor/Native/Hash/keys.pm
# once (15µs+1.46ms) by Module::Runtime::require_module at line 12 of Moose/Meta/Method/Accessor/Native/Writer.pm
# once (6µs+1.36ms) by Module::Runtime::require_module at line 5 of Moose/Meta/Attribute/Native/Trait/Array.pm | ||||
| 25 | 14 | 69µs | 14 | 34.7ms | Moose::Util::apply_all_roles( shift, @_ ); # spent 142ms making 14 calls to Moose::Util::apply_all_roles, avg 10.2ms/call, recursion: max depth 3, sum of overlapping time 107ms |
| 26 | } | ||||
| 27 | |||||
| 28 | # spent 1.50ms (158µs+1.34) within Moose::Role::requires which was called 40 times, avg 38µs/call:
# 20 times (60µs+581µs) by Moose::Role::requires at line 419 of Moose/Exporter.pm, avg 32µs/call
# once (7µs+109µs) by Module::Runtime::require_module at line 6 of lib/PONAPI/Builder.pm
# once (13µs+69µs) by Module::Runtime::require_module at line 8 of lib/PONAPI/Builder/Role/HasLinksBuilder.pm
# once (7µs+67µs) by Module::Runtime::require_module at line 9 of Moose/Meta/Method/Accessor/Native/Collection.pm
# once (10µs+55µs) by Module::Runtime::require_module at line 10 of Moose/Meta/Attribute/Native/Trait.pm
# once (6µs+54µs) by Module::Runtime::require_module at line 6 of lib/PONAPI/Repository.pm
# once (6µs+49µs) by Module::Runtime::require_module at line 11 of Moose/Meta/Method/Accessor/Native/Reader.pm
# once (5µs+47µs) by Module::Runtime::require_module at line 14 of Moose/Meta/Method/Accessor/Native/Writer.pm
# once (4µs+26µs) by Module::Runtime::require_module at line 7 of lib/PONAPI/Repository.pm
# once (4µs+26µs) by Module::Runtime::require_module at line 8 of lib/PONAPI/Repository.pm
# once (3µs+25µs) by Module::Runtime::require_module at line 9 of lib/PONAPI/Repository.pm
# once (3µs+25µs) by Module::Runtime::require_module at line 14 of lib/PONAPI/Repository.pm
# once (3µs+24µs) by Module::Runtime::require_module at line 11 of lib/PONAPI/Repository.pm
# once (3µs+24µs) by Module::Runtime::require_module at line 20 of lib/PONAPI/Repository.pm
# once (4µs+24µs) by Module::Runtime::require_module at line 16 of lib/PONAPI/Repository.pm
# once (3µs+24µs) by Module::Runtime::require_module at line 13 of lib/PONAPI/Repository.pm
# once (3µs+23µs) by Module::Runtime::require_module at line 12 of lib/PONAPI/Repository.pm
# once (3µs+24µs) by Module::Runtime::require_module at line 19 of lib/PONAPI/Repository.pm
# once (3µs+24µs) by Module::Runtime::require_module at line 17 of lib/PONAPI/Repository.pm
# once (3µs+23µs) by Module::Runtime::require_module at line 15 of lib/PONAPI/Repository.pm
# once (3µs+23µs) by Module::Runtime::require_module at line 18 of lib/PONAPI/Repository.pm | ||||
| 29 | 20 | 4µs | my $meta = shift; | ||
| 30 | 20 | 5µs | throw_exception( MustSpecifyAtleastOneMethod => role_name => $meta->name ) unless @_; | ||
| 31 | 20 | 45µs | 20 | 581µs | $meta->add_required_methods(@_); # spent 581µs making 20 calls to Moose::Meta::Role::add_required_methods, avg 29µs/call |
| 32 | } | ||||
| 33 | |||||
| 34 | sub excludes { | ||||
| 35 | my $meta = shift; | ||||
| 36 | throw_exception( MustSpecifyAtleastOneRole => role_name => $meta->name ) unless @_; | ||||
| 37 | $meta->add_excluded_roles(@_); | ||||
| 38 | } | ||||
| 39 | |||||
| 40 | # spent 3.37ms (375µs+2.99) within Moose::Role::has which was called 30 times, avg 112µs/call:
# 15 times (276µs+1.29ms) by Moose::Role::has at line 419 of Moose/Exporter.pm, avg 105µs/call
# once (7µs+148µs) by Module::Runtime::require_module at line 8 of lib/PONAPI/Builder.pm
# once (6µs+136µs) by Module::Runtime::require_module at line 6 of lib/PONAPI/DAO/Request/Role/HasID.pm
# once (8µs+133µs) by Module::Runtime::require_module at line 9 of lib/PONAPI/DAO/Request/Role/UpdateLike.pm
# once (13µs+127µs) by Module::Runtime::require_module at line 11 of lib/PONAPI/DAO/Request/Role/HasFields.pm
# once (6µs+130µs) by Module::Runtime::require_module at line 6 of lib/PONAPI/DAO/Request/Role/HasRelationshipType.pm
# once (11µs+122µs) by Module::Runtime::require_module at line 11 of lib/PONAPI/DAO/Request/Role/HasFilter.pm
# once (6µs+123µs) by Module::Runtime::require_module at line 11 of lib/PONAPI/DAO/Request/Role/HasSort.pm
# once (5µs+116µs) by Module::Runtime::require_module at line 10 of lib/PONAPI/Builder/Role/HasLinksBuilder.pm
# once (10µs+107µs) by Module::Runtime::require_module at line 11 of lib/PONAPI/DAO/Request/Role/HasInclude.pm
# once (4µs+109µs) by Module::Runtime::require_module at line 154 of Moose/Meta/Attribute/Native/Trait.pm
# once (5µs+106µs) by Module::Runtime::require_module at line 11 of lib/PONAPI/DAO/Request/Role/HasData.pm
# once (5µs+96µs) by Module::Runtime::require_module at line 12 of lib/PONAPI/Builder/Role/HasMeta.pm
# once (5µs+92µs) by Module::Runtime::require_module at line 6 of lib/PONAPI/DAO/Request/Role/HasDataBulk.pm
# once (5µs+88µs) by Module::Runtime::require_module at line 6 of lib/PONAPI/DAO/Request/Role/HasPage.pm
# once (4µs+67µs) by Module::Runtime::require_module at line 22 of lib/PONAPI/DAO/Request/Role/UpdateLike.pm | ||||
| 41 | 15 | 5µs | my $meta = shift; | ||
| 42 | 15 | 6µs | my $name = shift; | ||
| 43 | 15 | 14µs | throw_exception( InvalidHasProvidedInARole => role_name => $meta->name, | ||
| 44 | attribute_name => $name, | ||||
| 45 | ) | ||||
| 46 | if @_ == 1; | ||||
| 47 | 15 | 42µs | 15 | 125µs | my %context = Moose::Util::_caller_info; # spent 125µs making 15 calls to Moose::Util::_caller_info, avg 8µs/call |
| 48 | 15 | 12µs | $context{context} = 'has declaration'; | ||
| 49 | 15 | 16µs | $context{type} = 'role'; | ||
| 50 | 15 | 56µs | my %options = ( definition_context => \%context, @_ ); | ||
| 51 | 15 | 25µs | my $attrs = ( ref($name) eq 'ARRAY' ) ? $name : [ ($name) ]; | ||
| 52 | 15 | 107µs | 15 | 1.17ms | $meta->add_attribute( $_, %options ) for @$attrs; # spent 1.17ms making 15 calls to Moose::Meta::Role::add_attribute, avg 78µs/call |
| 53 | } | ||||
| 54 | |||||
| 55 | sub _add_method_modifier { | ||||
| 56 | 9 | 3µs | my $type = shift; | ||
| 57 | 9 | 2µs | my $meta = shift; | ||
| 58 | |||||
| 59 | 9 | 3µs | if ( ref($_[0]) eq 'Regexp' ) { | ||
| 60 | throw_exception( RolesDoNotSupportRegexReferencesForMethodModifiers => modifier_type => $type, | ||||
| 61 | role_name => $meta->name, | ||||
| 62 | ); | ||||
| 63 | } | ||||
| 64 | |||||
| 65 | 9 | 26µs | 9 | 212µs | Moose::Util::add_method_modifier($meta, $type, \@_); # spent 212µs making 9 calls to Moose::Util::add_method_modifier, avg 24µs/call |
| 66 | } | ||||
| 67 | |||||
| 68 | 2 | 5µs | 2 | 54µs | # spent 138µs (15+124) within Moose::Role::before which was called 4 times, avg 35µs/call:
# 2 times (6µs+54µs) by Moose::Role::before at line 419 of Moose/Exporter.pm, avg 30µs/call
# once (6µs+45µs) by Module::Runtime::require_module at line 16 of Moose/Meta/Attribute/Native/Trait.pm
# once (3µs+24µs) by Module::Runtime::require_module at line 52 of Moose/Meta/Attribute/Native/Trait.pm # spent 54µs making 2 calls to Moose::Role::_add_method_modifier, avg 27µs/call |
| 69 | |||||
| 70 | sub after { _add_method_modifier('after', @_) } | ||||
| 71 | |||||
| 72 | 7 | 20µs | 7 | 191µs | # spent 500µs (58+442) within Moose::Role::around which was called 14 times, avg 36µs/call:
# 7 times (18µs+191µs) by Moose::Role::around at line 419 of Moose/Exporter.pm, avg 30µs/call
# once (11µs+60µs) by Module::Runtime::require_module at line 42 of Moose/Meta/Method/Accessor/Native.pm
# once (6µs+42µs) by Module::Runtime::require_module at line 163 of Moose/Meta/Method/Accessor/Native/Collection.pm
# once (6µs+35µs) by Module::Runtime::require_module at line 29 of Moose/Meta/Method/Accessor/Native/Hash/set.pm
# once (4µs+35µs) by Module::Runtime::require_module at line 128 of Moose/Meta/Method/Accessor/Native/Writer.pm
# once (6µs+32µs) by Module::Runtime::require_module at line 86 of Moose/Meta/Attribute/Native/Trait.pm
# once (3µs+24µs) by Module::Runtime::require_module at line 138 of Moose/Meta/Method/Accessor/Native/Writer.pm
# once (3µs+23µs) by Module::Runtime::require_module at line 121 of Moose/Meta/Attribute/Native/Trait.pm # spent 191µs making 7 calls to Moose::Role::_add_method_modifier, avg 27µs/call |
| 73 | |||||
| 74 | # see Moose.pm for discussion | ||||
| 75 | # spent 11.9ms (315µs+11.6) within Moose::Role::super which was called 100 times, avg 119µs/call:
# 50 times (150µs+10.4ms) by Moose::Meta::Method::Accessor::Native::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Meta/Method/Accessor/Native.pm:147] at line 130 of Moose/Meta/Method/Accessor/Native.pm, avg 211µs/call
# 50 times (165µs+1.25ms) by Moose::Meta::Method::Accessor::Native::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Meta/Method/Accessor/Native.pm:116] at line 113 of Moose/Meta/Method/Accessor/Native.pm, avg 28µs/call | ||||
| 76 | 100 | 22µs | return unless $Moose::SUPER_BODY; | ||
| 77 | 100 | 282µs | 100 | 11.6ms | $Moose::SUPER_BODY->(@Moose::SUPER_ARGS); # spent 10.4ms making 50 calls to Moose::Meta::Method::Accessor::_eval_environment, avg 208µs/call
# spent 1.25ms making 50 calls to Moose::Meta::Method::Accessor::_get_value, avg 25µs/call |
| 78 | } | ||||
| 79 | |||||
| 80 | # spent 221µs (22+198) within Moose::Role::override which was called 6 times, avg 37µs/call:
# 3 times (10µs+87µs) by Moose::Role::override at line 419 of Moose/Exporter.pm, avg 32µs/call
# once (6µs+58µs) by Module::Runtime::require_module at line 116 of Moose/Meta/Method/Accessor/Native.pm
# once (4µs+27µs) by Module::Runtime::require_module at line 125 of Moose/Meta/Method/Accessor/Native.pm
# once (3µs+26µs) by Module::Runtime::require_module at line 147 of Moose/Meta/Method/Accessor/Native.pm | ||||
| 81 | 3 | 500ns | my $meta = shift; | ||
| 82 | 3 | 1µs | my ( $name, $code ) = @_; | ||
| 83 | 3 | 8µs | 3 | 87µs | $meta->add_override_method_modifier( $name, $code ); # spent 87µs making 3 calls to Moose::Meta::Role::add_override_method_modifier, avg 29µs/call |
| 84 | } | ||||
| 85 | |||||
| 86 | sub inner { | ||||
| 87 | throw_exception("RolesDoNotSupportInner"); | ||||
| 88 | } | ||||
| 89 | |||||
| 90 | sub augment { | ||||
| 91 | throw_exception("RolesDoNotSupportAugment"); | ||||
| 92 | } | ||||
| 93 | |||||
| 94 | 1 | 5µs | 1 | 771µs | Moose::Exporter->setup_import_methods( # spent 771µs making 1 call to Moose::Exporter::setup_import_methods |
| 95 | with_meta => [ | ||||
| 96 | qw( with requires excludes has before after around override ) | ||||
| 97 | ], | ||||
| 98 | as_is => [ | ||||
| 99 | qw( extends super inner augment ), | ||||
| 100 | 'Carp::confess', | ||||
| 101 | 'Scalar::Util::blessed', | ||||
| 102 | ], | ||||
| 103 | ); | ||||
| 104 | |||||
| 105 | # spent 46.9ms (1.12+45.8) within Moose::Role::init_meta which was called 35 times, avg 1.34ms/call:
# 35 times (1.12ms+45.8ms) by Moose::Role::import at line 484 of Moose/Exporter.pm, avg 1.34ms/call | ||||
| 106 | 35 | 9µs | shift; | ||
| 107 | 35 | 80µs | my %args = @_; | ||
| 108 | |||||
| 109 | 35 | 18µs | my $role = $args{for_class}; | ||
| 110 | |||||
| 111 | 35 | 9µs | unless ($role) { | ||
| 112 | require Moose; | ||||
| 113 | throw_exception( InitMetaRequiresClass => params => \%args ); | ||||
| 114 | } | ||||
| 115 | |||||
| 116 | 35 | 22µs | my $metaclass = $args{metaclass} || "Moose::Meta::Role"; | ||
| 117 | 35 | 27µs | my $meta_name = exists $args{meta_name} ? $args{meta_name} : 'meta'; | ||
| 118 | |||||
| 119 | 35 | 192µs | 35 | 112µs | throw_exception( MetaclassNotLoaded => class_name => $metaclass ) # spent 112µs making 35 calls to Class::Load::XS::is_class_loaded, avg 3µs/call |
| 120 | unless is_class_loaded($metaclass); | ||||
| 121 | |||||
| 122 | 35 | 124µs | 35 | 38µs | throw_exception( MetaclassMustBeASubclassOfMooseMetaRole => role_name => $metaclass ) # spent 38µs making 35 calls to UNIVERSAL::isa, avg 1µs/call |
| 123 | unless $metaclass->isa('Moose::Meta::Role'); | ||||
| 124 | |||||
| 125 | # make a subtype for each Moose role | ||||
| 126 | 35 | 122µs | 70 | 23.2ms | role_type $role unless find_type_constraint($role); # spent 22.6ms making 34 calls to Moose::Util::TypeConstraints::role_type, avg 665µs/call
# spent 596µs making 35 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 17µs/call
# spent 2µs making 1 call to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10] |
| 127 | |||||
| 128 | 35 | 9µs | my $meta; | ||
| 129 | 35 | 64µs | 35 | 56µs | if ( $meta = Class::MOP::get_metaclass_by_name($role) ) { # spent 56µs making 35 calls to Class::MOP::get_metaclass_by_name, avg 2µs/call |
| 130 | unless ( $meta->isa("Moose::Meta::Role") ) { | ||||
| 131 | if ( $meta->isa('Moose::Meta::Class') ) { | ||||
| 132 | throw_exception( MetaclassIsAClassNotASubclassOfGivenMetaclass => class_name => $role, | ||||
| 133 | metaclass => $metaclass, | ||||
| 134 | ); | ||||
| 135 | } else { | ||||
| 136 | throw_exception( MetaclassIsNotASubclassOfGivenMetaclass => class_name => $role, | ||||
| 137 | metaclass => $metaclass, | ||||
| 138 | ); | ||||
| 139 | } | ||||
| 140 | } | ||||
| 141 | } | ||||
| 142 | else { | ||||
| 143 | 35 | 77µs | 35 | 3.94ms | $meta = $metaclass->initialize($role); # spent 3.94ms making 35 calls to Moose::Meta::Role::initialize, avg 113µs/call |
| 144 | 35 | 163µs | 70 | 762µs | my $filename = module_notional_filename($meta->name); # spent 724µs making 35 calls to Module::Runtime::module_notional_filename, avg 21µs/call
# spent 38µs making 35 calls to Class::MOP::Package::name, avg 1µs/call |
| 145 | 35 | 29µs | $INC{$filename} = '(set by Moose)' | ||
| 146 | unless exists $INC{$filename}; | ||||
| 147 | } | ||||
| 148 | |||||
| 149 | 35 | 27µs | if (defined $meta_name) { | ||
| 150 | # also check for inherited non moose 'meta' method? | ||||
| 151 | 35 | 68µs | 35 | 1.55ms | my $existing = $meta->get_method($meta_name); # spent 1.55ms making 35 calls to Class::MOP::Mixin::HasMethods::get_method, avg 44µs/call |
| 152 | 35 | 6µs | if ($existing && !$existing->isa('Class::MOP::Method::Meta')) { | ||
| 153 | Carp::cluck "Moose::Role is overwriting an existing method named " | ||||
| 154 | . "$meta_name in role $role with a method " | ||||
| 155 | . "which returns the class's metaclass. If this is " | ||||
| 156 | . "actually what you want, you should remove the " | ||||
| 157 | . "existing method, otherwise, you should rename or " | ||||
| 158 | . "disable this generated method using the " | ||||
| 159 | . "'-meta_name' option to 'use Moose::Role'."; | ||||
| 160 | } | ||||
| 161 | 35 | 64µs | 35 | 16.1ms | $meta->_add_meta_method($meta_name); # spent 16.1ms making 35 calls to Class::MOP::Mixin::HasMethods::_add_meta_method, avg 460µs/call |
| 162 | } | ||||
| 163 | |||||
| 164 | 35 | 89µs | return $meta; | ||
| 165 | } | ||||
| 166 | |||||
| 167 | 1 | 5µs | 1; | ||
| 168 | |||||
| 169 | # ABSTRACT: The Moose Role | ||||
| 170 | |||||
| 171 | __END__ |