Filename | /opt/perl-5.18.1/lib/site_perl/5.18.1/Moo/_Utils.pm |
Statements | Executed 135 statements in 1.78ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
23 | 2 | 2 | 127µs | 314µs | _install_coderef | Moo::_Utils::
1 | 1 | 1 | 119µs | 119µs | BEGIN@15 | Moo::_Utils::
23 | 1 | 1 | 76µs | 131µs | _name_coderef | Moo::_Utils::
31 | 4 | 3 | 74µs | 74µs | _getglob | Moo::_Utils::
1 | 1 | 1 | 17µs | 27µs | BEGIN@3 | Moo::_Utils::
1 | 1 | 1 | 16µs | 20µs | _maybe_load_module | Moo::_Utils::
1 | 1 | 1 | 14µs | 68µs | BEGIN@11 | Moo::_Utils::
1 | 1 | 1 | 14µs | 26µs | BEGIN@70 | Moo::_Utils::
1 | 1 | 1 | 11µs | 23µs | BEGIN@112 | Moo::_Utils::
1 | 1 | 1 | 10µs | 46µs | BEGIN@8 | Moo::_Utils::
1 | 1 | 1 | 10µs | 97µs | BEGIN@14 | Moo::_Utils::
1 | 1 | 1 | 9µs | 29µs | BEGIN@12 | Moo::_Utils::
1 | 1 | 1 | 9µs | 24µs | BEGIN@92 | Moo::_Utils::
1 | 1 | 1 | 9µs | 40µs | BEGIN@9 | Moo::_Utils::
1 | 1 | 1 | 4µs | 4µs | BEGIN@13 | Moo::_Utils::
1 | 1 | 1 | 4µs | 4µs | CORE:subst (opcode) | Moo::_Utils::
0 | 0 | 0 | 0s | 0s | STANDARD_DESTROY | Moo::_Utils::
0 | 0 | 0 | 0s | 0s | _get_linear_isa | Moo::_Utils::
0 | 0 | 0 | 0s | 0s | _getstash | Moo::_Utils::
0 | 0 | 0 | 0s | 0s | _install_modifier | Moo::_Utils::
0 | 0 | 0 | 0s | 0s | _load_module | Moo::_Utils::
0 | 0 | 0 | 0s | 0s | _unimport_coderefs | Moo::_Utils::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moo::_Utils; | ||||
2 | |||||
3 | 2 | 107µs | 2 | 37µs | # spent 27µs (17+10) within Moo::_Utils::BEGIN@3 which was called:
# once (17µs+10µs) by Moo::BEGIN@4 at line 3 # spent 27µs making 1 call to Moo::_Utils::BEGIN@3
# spent 10µs making 1 call to warnings::unimport |
4 | |||||
5 | 31 | 110µs | # spent 74µs within Moo::_Utils::_getglob which was called 31 times, avg 2µs/call:
# 23 times (56µs+0s) by Moo::_Utils::_install_coderef at line 71, avg 2µs/call
# 3 times (8µs+0s) by Sub::Defer::undefer_sub at line 25 of Sub/Defer.pm, avg 3µs/call
# 3 times (4µs+0s) by Sub::Defer::undefer_sub at line 30 of Sub/Defer.pm, avg 1µs/call
# 2 times (7µs+0s) by Method::Generate::Accessor::generate_method at line 121 of Method/Generate/Accessor.pm, avg 3µs/call | ||
6 | sub _getstash { \%{"$_[0]::"} } | ||||
7 | |||||
8 | 2 | 44µs | 2 | 82µs | # spent 46µs (10+36) within Moo::_Utils::BEGIN@8 which was called:
# once (10µs+36µs) by Moo::BEGIN@4 at line 8 # spent 46µs making 1 call to Moo::_Utils::BEGIN@8
# spent 36µs making 1 call to constant::import |
9 | 3 | 43µs | 2 | 72µs | # spent 40µs (9+31) within Moo::_Utils::BEGIN@9 which was called:
# once (9µs+31µs) by Moo::BEGIN@4 at line 9 # spent 40µs making 1 call to Moo::_Utils::BEGIN@9
# spent 31µs making 1 call to constant::import |
10 | |||||
11 | 3 | 40µs | 3 | 122µs | # spent 68µs (14+54) within Moo::_Utils::BEGIN@11 which was called:
# once (14µs+54µs) by Moo::BEGIN@4 at line 11 # spent 68µs making 1 call to Moo::_Utils::BEGIN@11
# spent 39µs making 1 call to strictures::import
# spent 15µs making 1 call to strictures::VERSION |
12 | 2 | 41µs | 2 | 49µs | # spent 29µs (9+20) within Moo::_Utils::BEGIN@12 which was called:
# once (9µs+20µs) by Moo::BEGIN@4 at line 12 # spent 29µs making 1 call to Moo::_Utils::BEGIN@12
# spent 20µs making 1 call to Module::Runtime::import |
13 | 2 | 30µs | 1 | 4µs | # spent 4µs within Moo::_Utils::BEGIN@13 which was called:
# once (4µs+0s) by Moo::BEGIN@4 at line 13 # spent 4µs making 1 call to Moo::_Utils::BEGIN@13 |
14 | 2 | 44µs | 2 | 184µs | # spent 97µs (10+87) within Moo::_Utils::BEGIN@14 which was called:
# once (10µs+87µs) by Moo::BEGIN@4 at line 14 # spent 97µs making 1 call to Moo::_Utils::BEGIN@14
# spent 87µs making 1 call to base::import |
15 | 2 | 591µs | 1 | 119µs | # spent 119µs within Moo::_Utils::BEGIN@15 which was called:
# once (119µs+0s) by Moo::BEGIN@4 at line 15 # spent 119µs making 1 call to Moo::_Utils::BEGIN@15 |
16 | |||||
17 | 1 | 3µs | our @EXPORT = qw( | ||
18 | _getglob _install_modifier _load_module _maybe_load_module | ||||
19 | _get_linear_isa _getstash _install_coderef _name_coderef | ||||
20 | _unimport_coderefs _in_global_destruction | ||||
21 | ); | ||||
22 | |||||
23 | sub _in_global_destruction (); | ||||
24 | 1 | 3µs | *_in_global_destruction = \&Devel::GlobalDestruction::in_global_destruction; | ||
25 | |||||
26 | sub _install_modifier { | ||||
27 | my ($into, $type, $name, $code) = @_; | ||||
28 | |||||
29 | if (my $to_modify = $into->can($name)) { # CMM will throw for us if not | ||||
30 | require Sub::Defer; | ||||
31 | Sub::Defer::undefer_sub($to_modify); | ||||
32 | } | ||||
33 | |||||
34 | Class::Method::Modifiers::install_modifier(@_); | ||||
35 | } | ||||
36 | |||||
37 | 1 | 100ns | our %MAYBE_LOADED; | ||
38 | |||||
39 | sub _load_module { | ||||
40 | (my $proto = $_[0]) =~ s/::/\//g; | ||||
41 | return 1 if $INC{"${proto}.pm"}; | ||||
42 | # can't just ->can('can') because a sub-package Foo::Bar::Baz | ||||
43 | # creates a 'Baz::' key in Foo::Bar's symbol table | ||||
44 | my $stash = _getstash($_[0])||{}; | ||||
45 | return 1 if grep +(!ref($_) and *$_{CODE}), values %$stash; | ||||
46 | require_module($_[0]); | ||||
47 | return 1; | ||||
48 | } | ||||
49 | |||||
50 | # spent 20µs (16+4) within Moo::_Utils::_maybe_load_module which was called:
# once (16µs+4µs) by Method::Generate::Accessor::BEGIN@11 at line 17 of Method/Generate/Accessor.pm | ||||
51 | 1 | 700ns | return $MAYBE_LOADED{$_[0]} if exists $MAYBE_LOADED{$_[0]}; | ||
52 | 1 | 12µs | 1 | 4µs | (my $proto = $_[0]) =~ s/::/\//g; # spent 4µs making 1 call to Moo::_Utils::CORE:subst |
53 | 1 | 300ns | local $@; | ||
54 | 3 | 4µs | if (eval { require "${proto}.pm"; 1 }) { | ||
55 | $MAYBE_LOADED{$_[0]} = 1; | ||||
56 | } else { | ||||
57 | if (exists $INC{"${proto}.pm"}) { | ||||
58 | warn "$_[0] exists but failed to load with error: $@"; | ||||
59 | } | ||||
60 | $MAYBE_LOADED{$_[0]} = 0; | ||||
61 | } | ||||
62 | 1 | 5µs | return $MAYBE_LOADED{$_[0]}; | ||
63 | } | ||||
64 | |||||
65 | sub _get_linear_isa { | ||||
66 | return mro::get_linear_isa($_[0]); | ||||
67 | } | ||||
68 | |||||
69 | # spent 314µs (127+187) within Moo::_Utils::_install_coderef which was called 23 times, avg 14µs/call:
# 18 times (96µs+148µs) by Moo::_install_tracked at line 18 of Moo.pm, avg 14µs/call
# 5 times (30µs+39µs) by Sub::Defer::defer_sub at line 52 of Sub/Defer.pm, avg 14µs/call | ||||
70 | 2 | 245µs | 2 | 38µs | # spent 26µs (14+12) within Moo::_Utils::BEGIN@70 which was called:
# once (14µs+12µs) by Moo::BEGIN@4 at line 70 # spent 26µs making 1 call to Moo::_Utils::BEGIN@70
# spent 12µs making 1 call to warnings::unimport |
71 | 23 | 90µs | 46 | 187µs | *{_getglob($_[0])} = _name_coderef(@_); # spent 131µs making 23 calls to Moo::_Utils::_name_coderef, avg 6µs/call
# spent 56µs making 23 calls to Moo::_Utils::_getglob, avg 2µs/call |
72 | } | ||||
73 | |||||
74 | # spent 131µs (76+55) within Moo::_Utils::_name_coderef which was called 23 times, avg 6µs/call:
# 23 times (76µs+55µs) by Moo::_Utils::_install_coderef at line 71, avg 6µs/call | ||||
75 | 23 | 6µs | shift if @_ > 2; # three args is (target, name, sub) | ||
76 | 23 | 148µs | 23 | 54µs | can_haz_subname ? Sub::Name::subname(@_) : $_[1]; # spent 54µs making 23 calls to Sub::Name::subname, avg 2µs/call |
77 | } | ||||
78 | |||||
79 | sub _unimport_coderefs { | ||||
80 | my ($target, $info) = @_; | ||||
81 | return unless $info and my $exports = $info->{exports}; | ||||
82 | my %rev = reverse %$exports; | ||||
83 | my $stash = _getstash($target); | ||||
84 | foreach my $name (keys %$exports) { | ||||
85 | if ($stash->{$name} and defined(&{$stash->{$name}})) { | ||||
86 | if ($rev{$target->can($name)}) { | ||||
87 | my $old = delete $stash->{$name}; | ||||
88 | my $full_name = join('::',$target,$name); | ||||
89 | # Copy everything except the code slot back into place (e.g. $has) | ||||
90 | foreach my $type (qw(SCALAR HASH ARRAY IO)) { | ||||
91 | next unless defined(*{$old}{$type}); | ||||
92 | 2 | 139µs | 2 | 38µs | # spent 24µs (9+14) within Moo::_Utils::BEGIN@92 which was called:
# once (9µs+14µs) by Moo::BEGIN@4 at line 92 # spent 24µs making 1 call to Moo::_Utils::BEGIN@92
# spent 14µs making 1 call to strict::unimport |
93 | *$full_name = *{$old}{$type}; | ||||
94 | } | ||||
95 | } | ||||
96 | } | ||||
97 | } | ||||
98 | } | ||||
99 | |||||
100 | sub STANDARD_DESTROY { | ||||
101 | my $self = shift; | ||||
102 | |||||
103 | my $e = do { | ||||
104 | local $?; | ||||
105 | local $@; | ||||
106 | eval { | ||||
107 | $self->DEMOLISHALL(_in_global_destruction); | ||||
108 | }; | ||||
109 | $@; | ||||
110 | }; | ||||
111 | |||||
112 | 2 | 67µs | 2 | 35µs | # spent 23µs (11+12) within Moo::_Utils::BEGIN@112 which was called:
# once (11µs+12µs) by Moo::BEGIN@4 at line 112 # spent 23µs making 1 call to Moo::_Utils::BEGIN@112
# spent 12µs making 1 call to warnings::unimport |
113 | die $e if $e; # rethrow | ||||
114 | } | ||||
115 | |||||
116 | 1 | 6µs | 1; | ||
# spent 4µs within Moo::_Utils::CORE:subst which was called:
# once (4µs+0s) by Moo::_Utils::_maybe_load_module at line 52 |