| Filename | /usr/share/perl5/Moo/_Utils.pm |
| Statements | Executed 0 statements in 0s |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 547 | 2 | 2 | 2.89ms | 8.43ms | Moo::_Utils::_install_coderef |
| 588 | 7 | 3 | 1.91ms | 1.91ms | Moo::_Utils::_getglob |
| 547 | 1 | 1 | 1.45ms | 3.73ms | Moo::_Utils::_name_coderef |
| 1 | 1 | 1 | 328µs | 478µs | Moo::_Utils::BEGIN@14 |
| 1 | 1 | 1 | 162µs | 216µs | Moo::_Utils::BEGIN@16 |
| 2 | 1 | 1 | 50µs | 90µs | Moo::_Utils::_set_loaded |
| 1 | 1 | 1 | 18µs | 61µs | Moo::_Utils::_maybe_load_module |
| 1 | 1 | 1 | 14µs | 28µs | Moo::_Utils::BEGIN@82 |
| 1 | 1 | 1 | 12µs | 20µs | Moo::_Utils::BEGIN@3 |
| 1 | 1 | 1 | 11µs | 39µs | Moo::_Utils::BEGIN@12 |
| 1 | 1 | 1 | 10µs | 46µs | Moo::_Utils::BEGIN@8 |
| 1 | 1 | 1 | 10µs | 55µs | Moo::_Utils::BEGIN@11 |
| 1 | 1 | 1 | 10µs | 22µs | Moo::_Utils::BEGIN@17 |
| 1 | 1 | 1 | 9µs | 18µs | Moo::_Utils::BEGIN@112 |
| 1 | 1 | 1 | 8µs | 15µs | Moo::_Utils::BEGIN@15 |
| 1 | 1 | 1 | 8µs | 24µs | Moo::_Utils::BEGIN@9 |
| 1 | 1 | 1 | 8µs | 14µs | Moo::_Utils::BEGIN@89 |
| 2 | 1 | 1 | 5µs | 5µs | Moo::_Utils::_getstash |
| 0 | 0 | 0 | 0s | 0s | Moo::_Utils::_get_linear_isa |
| 0 | 0 | 0 | 0s | 0s | Moo::_Utils::_install_modifier |
| 0 | 0 | 0 | 0s | 0s | Moo::_Utils::_load_module |
| 0 | 0 | 0 | 0s | 0s | Moo::_Utils::_unimport_coderefs |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moo::_Utils; | ||||
| 2 | |||||
| 3 | 2 | 28µs | # spent 20µs (12+8) within Moo::_Utils::BEGIN@3 which was called:
# once (12µs+8µs) by Sub::Defer::BEGIN@5 at line 3 # spent 20µs making 1 call to Moo::_Utils::BEGIN@3
# spent 8µs making 1 call to warnings::unimport | ||
| 4 | |||||
| 5 | # spent 1.91ms within Moo::_Utils::_getglob which was called 588 times, avg 3µs/call:
# 547 times (1.81ms+0s) by Moo::_Utils::_install_coderef at line 81, avg 3µs/call
# 16 times (42µs+0s) by Sub::Defer::undefer_sub at line 25 of Sub/Defer.pm, avg 3µs/call
# 16 times (17µs+0s) by Sub::Defer::undefer_sub at line 30 of Sub/Defer.pm, avg 1µs/call
# 6 times (28µs+0s) by Method::Generate::Accessor::generate_method at line 109 of Method/Generate/Accessor.pm, avg 5µs/call
# once (4µs+0s) by Method::Generate::Accessor::generate_method at line 126 of Method/Generate/Accessor.pm
# once (3µs+0s) by Method::Generate::Accessor::generate_method at line 182 of Method/Generate/Accessor.pm
# once (3µs+0s) by Method::Generate::Accessor::generate_method at line 146 of Method/Generate/Accessor.pm | ||||
| 6 | # spent 5µs within Moo::_Utils::_getstash which was called 2 times, avg 2µs/call:
# 2 times (5µs+0s) by Moo::import at line 68 of Moo.pm, avg 2µs/call | ||||
| 7 | |||||
| 8 | 2 | 82µs | # spent 46µs (10+36) within Moo::_Utils::BEGIN@8 which was called:
# once (10µs+36µs) by Sub::Defer::BEGIN@5 at line 8 # spent 46µs making 1 call to Moo::_Utils::BEGIN@8
# spent 36µs making 1 call to constant::import | ||
| 9 | 2 | 40µs | # spent 24µs (8+16) within Moo::_Utils::BEGIN@9 which was called:
# once (8µs+16µs) by Sub::Defer::BEGIN@5 at line 9 # spent 24µs making 1 call to Moo::_Utils::BEGIN@9
# spent 16µs making 1 call to constant::import | ||
| 10 | |||||
| 11 | 3 | 100µs | # spent 55µs (10+45) within Moo::_Utils::BEGIN@11 which was called:
# once (10µs+45µs) by Sub::Defer::BEGIN@5 at line 11 # spent 55µs making 1 call to Moo::_Utils::BEGIN@11
# spent 32µs making 1 call to strictures::import
# spent 13µs making 1 call to strictures::VERSION | ||
| 12 | 2 | 66µs | # spent 39µs (11+28) within Moo::_Utils::BEGIN@12 which was called:
# once (11µs+28µs) by Sub::Defer::BEGIN@5 at line 12 # spent 39µs making 1 call to Moo::_Utils::BEGIN@12
# spent 28µs making 1 call to Module::Runtime::import | ||
| 13 | |||||
| 14 | 1 | 478µs | # spent 478µs (328+151) within Moo::_Utils::BEGIN@14 which was called:
# once (328µs+151µs) by Sub::Defer::BEGIN@5 at line 14 # spent 478µs making 1 call to Moo::_Utils::BEGIN@14 | ||
| 15 | 2 | 22µs | # spent 15µs (8+7) within Moo::_Utils::BEGIN@15 which was called:
# once (8µs+7µs) by Sub::Defer::BEGIN@5 at line 15 # spent 15µs making 1 call to Moo::_Utils::BEGIN@15
# spent 7µs making 1 call to Exporter::import | ||
| 16 | 1 | 216µs | # spent 216µs (162+54) within Moo::_Utils::BEGIN@16 which was called:
# once (162µs+54µs) by Sub::Defer::BEGIN@5 at line 16 # spent 216µs making 1 call to Moo::_Utils::BEGIN@16 | ||
| 17 | 2 | 35µs | # spent 22µs (10+13) within Moo::_Utils::BEGIN@17 which was called:
# once (10µs+13µs) by Sub::Defer::BEGIN@5 at line 17 # spent 22µs making 1 call to Moo::_Utils::BEGIN@17
# spent 13µs making 1 call to Config::import | ||
| 18 | |||||
| 19 | our @EXPORT = qw( | ||||
| 20 | _getglob _install_modifier _load_module _maybe_load_module | ||||
| 21 | _get_linear_isa _getstash _install_coderef _name_coderef | ||||
| 22 | _unimport_coderefs _in_global_destruction _set_loaded | ||||
| 23 | ); | ||||
| 24 | |||||
| 25 | sub _in_global_destruction (); | ||||
| 26 | *_in_global_destruction = \&Devel::GlobalDestruction::in_global_destruction; | ||||
| 27 | |||||
| 28 | sub _install_modifier { | ||||
| 29 | my ($into, $type, $name, $code) = @_; | ||||
| 30 | |||||
| 31 | if (my $to_modify = $into->can($name)) { # CMM will throw for us if not | ||||
| 32 | require Sub::Defer; | ||||
| 33 | Sub::Defer::undefer_sub($to_modify); | ||||
| 34 | } | ||||
| 35 | |||||
| 36 | Class::Method::Modifiers::install_modifier(@_); | ||||
| 37 | } | ||||
| 38 | |||||
| 39 | our %MAYBE_LOADED; | ||||
| 40 | |||||
| 41 | sub _load_module { | ||||
| 42 | my $module = $_[0]; | ||||
| 43 | my $file = module_notional_filename($module); | ||||
| 44 | use_package_optimistically($module); | ||||
| 45 | return 1 | ||||
| 46 | if $INC{$file}; | ||||
| 47 | my $error = $@ || "Can't locate $file"; | ||||
| 48 | |||||
| 49 | # can't just ->can('can') because a sub-package Foo::Bar::Baz | ||||
| 50 | # creates a 'Baz::' key in Foo::Bar's symbol table | ||||
| 51 | my $stash = _getstash($module)||{}; | ||||
| 52 | return 1 if grep +(!ref($_) and *$_{CODE}), values %$stash; | ||||
| 53 | return 1 | ||||
| 54 | if $INC{"Moose.pm"} && Class::MOP::class_of($module) | ||||
| 55 | or Mouse::Util->can('find_meta') && Mouse::Util::find_meta($module); | ||||
| 56 | die $error; | ||||
| 57 | } | ||||
| 58 | |||||
| 59 | # spent 61µs (18+43) within Moo::_Utils::_maybe_load_module which was called:
# once (18µs+43µs) by Method::Generate::Accessor::BEGIN@11 at line 17 of Method/Generate/Accessor.pm | ||||
| 60 | my $module = $_[0]; | ||||
| 61 | return $MAYBE_LOADED{$module} | ||||
| 62 | if exists $MAYBE_LOADED{$module}; | ||||
| 63 | 2 | 43µs | if(! eval { use_package_optimistically($module) }) { # spent 37µs making 1 call to Module::Runtime::use_package_optimistically
# spent 6µs making 1 call to Module::Runtime::module_notional_filename | ||
| 64 | warn "$module exists but failed to load with error: $@"; | ||||
| 65 | } | ||||
| 66 | elsif ( $INC{module_notional_filename($module)} ) { | ||||
| 67 | return $MAYBE_LOADED{$module} = 1; | ||||
| 68 | } | ||||
| 69 | return $MAYBE_LOADED{$module} = 0; | ||||
| 70 | } | ||||
| 71 | |||||
| 72 | # spent 90µs (50+39) within Moo::_Utils::_set_loaded which was called 2 times, avg 45µs/call:
# 2 times (50µs+39µs) by Moo::import at line 23 of Moo.pm, avg 45µs/call | ||||
| 73 | 2 | 39µs | $INC{Module::Runtime::module_notional_filename($_[0])} ||= $_[1]; # spent 39µs making 2 calls to Module::Runtime::module_notional_filename, avg 20µs/call | ||
| 74 | } | ||||
| 75 | |||||
| 76 | sub _get_linear_isa { | ||||
| 77 | return mro::get_linear_isa($_[0]); | ||||
| 78 | } | ||||
| 79 | |||||
| 80 | # spent 8.43ms (2.89+5.54) within Moo::_Utils::_install_coderef which was called 547 times, avg 15µs/call:
# 535 times (2.82ms+5.45ms) by Sub::Defer::defer_sub at line 61 of Sub/Defer.pm, avg 15µs/call
# 12 times (73µs+89µs) by Moo::_install_tracked at line 17 of Moo.pm, avg 13µs/call | ||||
| 81 | 1094 | 5.54ms | my ($glob, $code) = (_getglob($_[0]), _name_coderef(@_)); # spent 3.73ms making 547 calls to Moo::_Utils::_name_coderef, avg 7µs/call
# spent 1.81ms making 547 calls to Moo::_Utils::_getglob, avg 3µs/call | ||
| 82 | 2 | 42µs | # spent 28µs (14+14) within Moo::_Utils::BEGIN@82 which was called:
# once (14µs+14µs) by Sub::Defer::BEGIN@5 at line 82 # spent 28µs making 1 call to Moo::_Utils::BEGIN@82
# spent 14µs making 1 call to warnings::unimport | ||
| 83 | if (*{$glob}{CODE}) { | ||||
| 84 | *{$glob} = $code; | ||||
| 85 | } | ||||
| 86 | # perl will sometimes warn about mismatched prototypes coming from the | ||||
| 87 | # inheritance cache, so disable them if we aren't redefining a sub | ||||
| 88 | else { | ||||
| 89 | 2 | 20µs | # spent 14µs (8+6) within Moo::_Utils::BEGIN@89 which was called:
# once (8µs+6µs) by Sub::Defer::BEGIN@5 at line 89 # spent 14µs making 1 call to Moo::_Utils::BEGIN@89
# spent 6µs making 1 call to warnings::unimport | ||
| 90 | *{$glob} = $code; | ||||
| 91 | } | ||||
| 92 | } | ||||
| 93 | |||||
| 94 | # spent 3.73ms (1.45+2.28) within Moo::_Utils::_name_coderef which was called 547 times, avg 7µs/call:
# 547 times (1.45ms+2.28ms) by Moo::_Utils::_install_coderef at line 81, avg 7µs/call | ||||
| 95 | shift if @_ > 2; # three args is (target, name, sub) | ||||
| 96 | 547 | 2.28ms | can_haz_subname ? Sub::Name::subname(@_) : $_[1]; # spent 2.28ms making 547 calls to Sub::Name::subname, avg 4µs/call | ||
| 97 | } | ||||
| 98 | |||||
| 99 | sub _unimport_coderefs { | ||||
| 100 | my ($target, $info) = @_; | ||||
| 101 | return unless $info and my $exports = $info->{exports}; | ||||
| 102 | my %rev = reverse %$exports; | ||||
| 103 | my $stash = _getstash($target); | ||||
| 104 | foreach my $name (keys %$exports) { | ||||
| 105 | if ($stash->{$name} and defined(&{$stash->{$name}})) { | ||||
| 106 | if ($rev{$target->can($name)}) { | ||||
| 107 | my $old = delete $stash->{$name}; | ||||
| 108 | my $full_name = join('::',$target,$name); | ||||
| 109 | # Copy everything except the code slot back into place (e.g. $has) | ||||
| 110 | foreach my $type (qw(SCALAR HASH ARRAY IO)) { | ||||
| 111 | next unless defined(*{$old}{$type}); | ||||
| 112 | 2 | 26µs | # spent 18µs (9+8) within Moo::_Utils::BEGIN@112 which was called:
# once (9µs+8µs) by Sub::Defer::BEGIN@5 at line 112 # spent 18µs making 1 call to Moo::_Utils::BEGIN@112
# spent 8µs making 1 call to strict::unimport | ||
| 113 | *$full_name = *{$old}{$type}; | ||||
| 114 | } | ||||
| 115 | } | ||||
| 116 | } | ||||
| 117 | } | ||||
| 118 | } | ||||
| 119 | |||||
| 120 | 1 | 4µs | if ($Config{useithreads}) { # spent 4µs making 1 call to Config::FETCH | ||
| 121 | require Moo::HandleMoose::_TypeMap; | ||||
| 122 | } | ||||
| 123 | |||||
| 124 | 1; |