Filename | /usr/local/share/perl/5.18.2/Moo/_Utils.pm |
Statements | Executed 149 statements in 2.45ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 2.21ms | 2.59ms | BEGIN@10 | Moo::_Utils::
1 | 1 | 1 | 1.82ms | 1.97ms | BEGIN@24 | Moo::_Utils::
1 | 1 | 1 | 878µs | 1.97ms | BEGIN@29 | Moo::_Utils::
1 | 1 | 1 | 450µs | 709µs | BEGIN@28 | Moo::_Utils::
1 | 1 | 1 | 346µs | 5.76ms | BEGIN@26 | Moo::_Utils::
14 | 2 | 2 | 117µs | 293µs | _install_coderef | Moo::_Utils::
34 | 5 | 4 | 100µs | 100µs | _getglob | Moo::_Utils::
14 | 1 | 1 | 64µs | 130µs | _name_coderef | Moo::_Utils::
1 | 1 | 1 | 29µs | 265µs | _install_modifier | Moo::_Utils::
1 | 1 | 1 | 21µs | 32µs | BEGIN@3 | Moo::_Utils::
1 | 1 | 1 | 17µs | 35µs | BEGIN@27 | Moo::_Utils::
1 | 1 | 1 | 15µs | 2.30ms | _maybe_load_module | Moo::_Utils::
1 | 1 | 1 | 12µs | 26µs | BEGIN@90 | Moo::_Utils::
2 | 1 | 1 | 12µs | 108µs | _set_loaded | Moo::_Utils::
1 | 1 | 1 | 11µs | 21µs | BEGIN@97 | Moo::_Utils::
3 | 2 | 2 | 11µs | 11µs | _getstash | Moo::_Utils::
1 | 1 | 1 | 9µs | 24µs | BEGIN@120 | Moo::_Utils::
1 | 1 | 1 | 8µs | 41µs | BEGIN@8 | Moo::_Utils::
0 | 0 | 0 | 0s | 0s | __ANON__[:20] | 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 | 91µs | 2 | 43µs | # spent 32µs (21+11) within Moo::_Utils::BEGIN@3 which was called:
# once (21µs+11µs) by Moo::BEGIN@4 at line 3 # spent 32µs making 1 call to Moo::_Utils::BEGIN@3
# spent 11µs making 1 call to warnings::unimport |
4 | |||||
5 | 34 | 160µs | # spent 100µs within Moo::_Utils::_getglob which was called 34 times, avg 3µs/call:
# 14 times (46µs+0s) by Moo::_Utils::_install_coderef at line 89, avg 3µs/call
# 14 times (36µs+0s) by Method::Generate::Constructor::current_constructor at line 110 of Method/Generate/Constructor.pm, avg 3µs/call
# 2 times (8µs+0s) by Moo::_constructor_maker_for at line 181 of Moo.pm, avg 4µs/call
# 2 times (7µs+0s) by Sub::Defer::undefer_sub at line 26 of Sub/Defer.pm, avg 3µs/call
# 2 times (3µs+0s) by Sub::Defer::undefer_sub at line 31 of Sub/Defer.pm, avg 1µs/call | ||
6 | 3 | 20µs | # spent 11µs within Moo::_Utils::_getstash which was called 3 times, avg 4µs/call:
# 2 times (6µs+0s) by Moo::import at line 71 of Moo.pm, avg 3µs/call
# once (5µs+0s) by Method::Generate::Constructor::new at line 241 of Method/Generate/Constructor.pm | ||
7 | |||||
8 | 2 | 222µs | 2 | 73µs | # spent 41µs (8+33) within Moo::_Utils::BEGIN@8 which was called:
# once (8µs+33µs) by Moo::BEGIN@4 at line 8 # spent 41µs making 1 call to Moo::_Utils::BEGIN@8
# spent 32µs making 1 call to Moo::_strictures::import |
9 | |||||
10 | # spent 2.59ms (2.21+384µs) within Moo::_Utils::BEGIN@10 which was called:
# once (2.21ms+384µs) by Moo::BEGIN@4 at line 22 | ||||
11 | 1 | 5µs | *lt_5_8_3 = ( $] < 5.008003 or $ENV{MOO_TEST_PRE_583} ) ? sub(){1} : sub(){0}; | ||
12 | 1 | 300ns | my ($su, $sn); | ||
13 | $su = $INC{'Sub/Util.pm'} && defined &Sub::Util::set_subname | ||||
14 | or $sn = $INC{'Sub/Name.pm'} | ||||
15 | 1 | 80µs | or $su = eval { require Sub::Util; } && defined &Sub::Util::set_subname | ||
16 | 1 | 3µs | or $sn = eval { require Sub::Name; }; | ||
17 | |||||
18 | *_subname = $su ? \&Sub::Util::set_subname | ||||
19 | : $sn ? \&Sub::Name::subname | ||||
20 | 1 | 2µs | : sub { $_[1] }; | ||
21 | 1 | 4µs | *_CAN_SUBNAME = ($su || $sn) ? sub(){1} : sub(){0}; | ||
22 | 1 | 48µs | 1 | 2.59ms | } # spent 2.59ms making 1 call to Moo::_Utils::BEGIN@10 |
23 | |||||
24 | 2 | 183µs | 2 | 2.00ms | # spent 1.97ms (1.82+157µs) within Moo::_Utils::BEGIN@24 which was called:
# once (1.82ms+157µs) by Moo::BEGIN@4 at line 24 # spent 1.97ms making 1 call to Moo::_Utils::BEGIN@24
# spent 28µs making 1 call to Module::Runtime::import |
25 | |||||
26 | 2 | 104µs | 1 | 5.76ms | # spent 5.76ms (346µs+5.42) within Moo::_Utils::BEGIN@26 which was called:
# once (346µs+5.42ms) by Moo::BEGIN@4 at line 26 # spent 5.76ms making 1 call to Moo::_Utils::BEGIN@26 |
27 | 2 | 31µs | 2 | 53µs | # spent 35µs (17+18) within Moo::_Utils::BEGIN@27 which was called:
# once (17µs+18µs) by Moo::BEGIN@4 at line 27 # spent 35µs making 1 call to Moo::_Utils::BEGIN@27
# spent 18µs making 1 call to Exporter::import |
28 | 2 | 110µs | 1 | 709µs | # spent 709µs (450+259) within Moo::_Utils::BEGIN@28 which was called:
# once (450µs+259µs) by Moo::BEGIN@4 at line 28 # spent 709µs making 1 call to Moo::_Utils::BEGIN@28 |
29 | 2 | 574µs | 2 | 1.99ms | # spent 1.97ms (878µs+1.10) within Moo::_Utils::BEGIN@29 which was called:
# once (878µs+1.10ms) by Moo::BEGIN@4 at line 29 # spent 1.97ms making 1 call to Moo::_Utils::BEGIN@29
# spent 16µs making 1 call to Config::import |
30 | |||||
31 | 1 | 3µs | our @EXPORT = qw( | ||
32 | _getglob _install_modifier _load_module _maybe_load_module | ||||
33 | _getstash _install_coderef _name_coderef | ||||
34 | _unimport_coderefs _in_global_destruction _set_loaded | ||||
35 | ); | ||||
36 | |||||
37 | sub _in_global_destruction (); | ||||
38 | 1 | 3µs | *_in_global_destruction = \&Devel::GlobalDestruction::in_global_destruction; | ||
39 | |||||
40 | # spent 265µs (29+236) within Moo::_Utils::_install_modifier which was called:
# once (29µs+236µs) by Moo::around at line 66 of Moo.pm | ||||
41 | 1 | 1µs | my ($into, $type, $name, $code) = @_; | ||
42 | |||||
43 | 1 | 18µs | 1 | 5µs | if (my $to_modify = $into->can($name)) { # CMM will throw for us if not # spent 5µs making 1 call to UNIVERSAL::can |
44 | 1 | 900ns | require Sub::Defer; | ||
45 | 1 | 2µs | 1 | 4µs | Sub::Defer::undefer_sub($to_modify); # spent 4µs making 1 call to Sub::Defer::undefer_sub |
46 | } | ||||
47 | |||||
48 | 1 | 6µs | 1 | 228µs | Class::Method::Modifiers::install_modifier(@_); # spent 228µs making 1 call to Class::Method::Modifiers::install_modifier |
49 | } | ||||
50 | |||||
51 | 1 | 300ns | our %MAYBE_LOADED; | ||
52 | |||||
53 | sub _load_module { | ||||
54 | my $module = $_[0]; | ||||
55 | my $file = module_notional_filename($module); | ||||
56 | use_package_optimistically($module); | ||||
57 | return 1 | ||||
58 | if $INC{$file}; | ||||
59 | my $error = $@ || "Can't locate $file"; | ||||
60 | |||||
61 | # can't just ->can('can') because a sub-package Foo::Bar::Baz | ||||
62 | # creates a 'Baz::' key in Foo::Bar's symbol table | ||||
63 | my $stash = _getstash($module)||{}; | ||||
64 | return 1 if grep +(!ref($_) and *$_{CODE}), values %$stash; | ||||
65 | return 1 | ||||
66 | if $INC{"Moose.pm"} && Class::MOP::class_of($module) | ||||
67 | or Mouse::Util->can('find_meta') && Mouse::Util::find_meta($module); | ||||
68 | die $error; | ||||
69 | } | ||||
70 | |||||
71 | # spent 2.30ms (15µs+2.29) within Moo::_Utils::_maybe_load_module which was called:
# once (15µs+2.29ms) by Method::Generate::Accessor::BEGIN@11 at line 17 of Method/Generate/Accessor.pm | ||||
72 | 1 | 1µs | my $module = $_[0]; | ||
73 | 1 | 800ns | return $MAYBE_LOADED{$module} | ||
74 | if exists $MAYBE_LOADED{$module}; | ||||
75 | 2 | 12µs | 2 | 2.29ms | if(! eval { use_package_optimistically($module) }) { # spent 2.26ms making 1 call to Module::Runtime::use_package_optimistically
# spent 30µs making 1 call to Module::Runtime::module_notional_filename |
76 | warn "$module exists but failed to load with error: $@"; | ||||
77 | } | ||||
78 | elsif ( $INC{module_notional_filename($module)} ) { | ||||
79 | return $MAYBE_LOADED{$module} = 1; | ||||
80 | } | ||||
81 | return $MAYBE_LOADED{$module} = 0; | ||||
82 | } | ||||
83 | |||||
84 | # spent 108µs (12+96) within Moo::_Utils::_set_loaded which was called 2 times, avg 54µs/call:
# 2 times (12µs+96µs) by Moo::import at line 23 of Moo.pm, avg 54µs/call | ||||
85 | 2 | 10µs | 2 | 96µs | $INC{Module::Runtime::module_notional_filename($_[0])} ||= $_[1]; # spent 96µs making 2 calls to Module::Runtime::module_notional_filename, avg 48µs/call |
86 | } | ||||
87 | |||||
88 | # spent 293µs (117+176) within Moo::_Utils::_install_coderef which was called 14 times, avg 21µs/call:
# 12 times (94µs+144µs) by Moo::_install_tracked at line 17 of Moo.pm, avg 20µs/call
# 2 times (22µs+31µs) by Sub::Defer::defer_sub at line 72 of Sub/Defer.pm, avg 27µs/call | ||||
89 | 14 | 44µs | 28 | 176µs | my ($glob, $code) = (_getglob($_[0]), _name_coderef(@_)); # spent 130µs making 14 calls to Moo::_Utils::_name_coderef, avg 9µs/call
# spent 46µs making 14 calls to Moo::_Utils::_getglob, avg 3µs/call |
90 | 2 | 102µs | 2 | 39µs | # spent 26µs (12+14) within Moo::_Utils::BEGIN@90 which was called:
# once (12µs+14µs) by Moo::BEGIN@4 at line 90 # spent 26µs making 1 call to Moo::_Utils::BEGIN@90
# spent 14µs making 1 call to warnings::unimport |
91 | 14 | 40µs | if (*{$glob}{CODE}) { | ||
92 | *{$glob} = $code; | ||||
93 | } | ||||
94 | # perl will sometimes warn about mismatched prototypes coming from the | ||||
95 | # inheritance cache, so disable them if we aren't redefining a sub | ||||
96 | else { | ||||
97 | 2 | 224µs | 2 | 31µs | # spent 21µs (11+10) within Moo::_Utils::BEGIN@97 which was called:
# once (11µs+10µs) by Moo::BEGIN@4 at line 97 # spent 21µs making 1 call to Moo::_Utils::BEGIN@97
# spent 10µs making 1 call to warnings::unimport |
98 | 14 | 11µs | *{$glob} = $code; | ||
99 | } | ||||
100 | } | ||||
101 | |||||
102 | # spent 130µs (64+66) within Moo::_Utils::_name_coderef which was called 14 times, avg 9µs/call:
# 14 times (64µs+66µs) by Moo::_Utils::_install_coderef at line 89, avg 9µs/call | ||||
103 | 14 | 6µs | shift if @_ > 2; # three args is (target, name, sub) | ||
104 | 14 | 132µs | 14 | 66µs | _CAN_SUBNAME ? _subname(@_) : $_[1]; # spent 66µs making 14 calls to Sub::Util::set_subname, avg 5µs/call |
105 | } | ||||
106 | |||||
107 | sub _unimport_coderefs { | ||||
108 | my ($target, $info) = @_; | ||||
109 | return unless $info and my $exports = $info->{exports}; | ||||
110 | my %rev = reverse %$exports; | ||||
111 | my $stash = _getstash($target); | ||||
112 | foreach my $name (keys %$exports) { | ||||
113 | if ($stash->{$name} and defined(&{$stash->{$name}})) { | ||||
114 | if ($rev{$target->can($name)}) { | ||||
115 | my $old = delete $stash->{$name}; | ||||
116 | my $full_name = join('::',$target,$name); | ||||
117 | # Copy everything except the code slot back into place (e.g. $has) | ||||
118 | foreach my $type (qw(SCALAR HASH ARRAY IO)) { | ||||
119 | next unless defined(*{$old}{$type}); | ||||
120 | 2 | 106µs | 2 | 39µs | # spent 24µs (9+15) within Moo::_Utils::BEGIN@120 which was called:
# once (9µs+15µs) by Moo::BEGIN@4 at line 120 # spent 24µs making 1 call to Moo::_Utils::BEGIN@120
# spent 15µs making 1 call to strict::unimport |
121 | *$full_name = *{$old}{$type}; | ||||
122 | } | ||||
123 | } | ||||
124 | } | ||||
125 | } | ||||
126 | } | ||||
127 | |||||
128 | 1 | 89µs | 1 | 4µs | if ($Config{useithreads}) { # spent 4µs making 1 call to Config::FETCH |
129 | require Moo::HandleMoose::_TypeMap; | ||||
130 | } | ||||
131 | |||||
132 | 1 | 5µs | 1; |