Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Moo/_Utils.pm |
Statements | Executed 1475 statements in 2.88ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
189 | 3 | 3 | 591µs | 1.63ms | _install_coderef | Moo::_Utils::
304 | 7 | 6 | 420µs | 420µs | _getglob | Moo::_Utils::
197 | 2 | 2 | 290µs | 786µs | _name_coderef | Moo::_Utils::
28 | 2 | 1 | 131µs | 64.0ms | _load_module (recurses: max depth 1, inclusive time 13.2ms) | Moo::_Utils::
24 | 2 | 2 | 82µs | 400µs | _set_loaded | Moo::_Utils::
1 | 1 | 1 | 64µs | 77µs | BEGIN@23 | Moo::_Utils::
25 | 3 | 3 | 41µs | 41µs | _getstash | Moo::_Utils::
3 | 1 | 1 | 26µs | 520µs | _install_modifier | Moo::_Utils::
1 | 1 | 1 | 9µs | 1.18ms | _maybe_load_module | Moo::_Utils::
1 | 1 | 1 | 7µs | 20µs | BEGIN@19 | Moo::_Utils::
1 | 1 | 1 | 6µs | 11µs | BEGIN@3 | Moo::_Utils::
1 | 1 | 1 | 6µs | 14µs | BEGIN@89 | Moo::_Utils::
1 | 1 | 1 | 6µs | 16µs | BEGIN@24 | Moo::_Utils::
1 | 1 | 1 | 5µs | 29µs | BEGIN@8 | Moo::_Utils::
1 | 1 | 1 | 5µs | 11µs | BEGIN@120 | Moo::_Utils::
1 | 1 | 1 | 4µs | 23µs | BEGIN@13 | Moo::_Utils::
1 | 1 | 1 | 4µs | 22µs | BEGIN@9 | Moo::_Utils::
1 | 1 | 1 | 4µs | 8µs | BEGIN@96 | Moo::_Utils::
1 | 1 | 1 | 4µs | 10µs | BEGIN@18 | Moo::_Utils::
1 | 1 | 1 | 3µs | 8µs | BEGIN@22 | Moo::_Utils::
1 | 1 | 1 | 2µs | 2µs | BEGIN@21 | Moo::_Utils::
0 | 0 | 0 | 0s | 0s | _get_linear_isa | 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 | 55µs | 2 | 16µs | # spent 11µs (6+5) within Moo::_Utils::BEGIN@3 which was called:
# once (6µs+5µs) by Moo::BEGIN@4 at line 3 # spent 11µs making 1 call to Moo::_Utils::BEGIN@3
# spent 5µs making 1 call to warnings::unimport |
4 | |||||
5 | 304 | 578µs | # spent 420µs within Moo::_Utils::_getglob which was called 304 times, avg 1µs/call:
# 189 times (290µs+0s) by Moo::_Utils::_install_coderef at line 88, avg 2µs/call
# 54 times (53µs+0s) by Method::Generate::Constructor::current_constructor at line 103 of Method/Generate/Constructor.pm, avg 981ns/call
# 17 times (27µs+0s) by Sub::Defer::undefer_sub at line 26 of Sub/Defer.pm, avg 2µs/call
# 17 times (9µs+0s) by Sub::Defer::undefer_sub at line 31 of Sub/Defer.pm, avg 541ns/call
# 12 times (19µs+0s) by Moo::Role::import at line 81 of Moo/Role.pm, avg 2µs/call
# 11 times (18µs+0s) by Moo::_constructor_maker_for at line 180 of Moo.pm, avg 2µs/call
# 4 times (5µs+0s) by Method::Generate::BuildAll::buildall_body_for at line 28 of Method/Generate/BuildAll.pm, avg 1µs/call | ||
6 | 25 | 53µs | # spent 41µs within Moo::_Utils::_getstash which was called 25 times, avg 2µs/call:
# 12 times (21µs+0s) by Moo::Role::import at line 43 of Moo/Role.pm, avg 2µs/call
# 12 times (18µs+0s) by Moo::import at line 71 of Moo.pm, avg 2µs/call
# once (2µs+0s) by Method::Generate::Constructor::new at line 242 of Method/Generate/Constructor.pm | ||
7 | |||||
8 | 2 | 35µs | 2 | 53µs | # spent 29µs (5+24) within Moo::_Utils::BEGIN@8 which was called:
# once (5µs+24µs) by Moo::BEGIN@4 at line 8 # spent 29µs making 1 call to Moo::_Utils::BEGIN@8
# spent 24µs making 1 call to constant::import |
9 | # spent 22µs (4+18) within Moo::_Utils::BEGIN@9 which was called:
# once (4µs+18µs) by Moo::BEGIN@4 at line 12 | ||||
10 | $INC{"Sub/Util.pm"} | ||||
11 | 1 | 4µs | 1 | 18µs | || ( !$INC{"Sub/Name.pm"} && eval { require Sub::Util } ) # spent 18µs making 1 call to constant::import |
12 | 1 | 29µs | 1 | 22µs | ) && defined &Sub::Util::set_subname; # spent 22µs making 1 call to Moo::_Utils::BEGIN@9 |
13 | # spent 23µs (4+19) within Moo::_Utils::BEGIN@13 which was called:
# once (4µs+19µs) by Moo::BEGIN@4 at line 16 | ||||
14 | $INC{"Sub/Name.pm"} | ||||
15 | 1 | 2µs | 1 | 19µs | || ( !$INC{"Sub/Util.pm"} && eval { require Sub::Name } ) # spent 19µs making 1 call to constant::import |
16 | 1 | 14µs | 1 | 23µs | ) && defined &Sub::Name::subname; # spent 23µs making 1 call to Moo::_Utils::BEGIN@13 |
17 | |||||
18 | 2 | 13µs | 2 | 17µs | # spent 10µs (4+7) within Moo::_Utils::BEGIN@18 which was called:
# once (4µs+7µs) by Moo::BEGIN@4 at line 18 # spent 10µs making 1 call to Moo::_Utils::BEGIN@18
# spent 7µs making 1 call to Moo::_strictures::import |
19 | 2 | 13µs | 2 | 34µs | # spent 20µs (7+14) within Moo::_Utils::BEGIN@19 which was called:
# once (7µs+14µs) by Moo::BEGIN@4 at line 19 # spent 20µs making 1 call to Moo::_Utils::BEGIN@19
# spent 14µs making 1 call to Module::Runtime::import |
20 | |||||
21 | 2 | 11µs | 1 | 2µs | # spent 2µs within Moo::_Utils::BEGIN@21 which was called:
# once (2µs+0s) by Moo::BEGIN@4 at line 21 # spent 2µs making 1 call to Moo::_Utils::BEGIN@21 |
22 | 2 | 12µs | 2 | 12µs | # spent 8µs (3+4) within Moo::_Utils::BEGIN@22 which was called:
# once (3µs+4µs) by Moo::BEGIN@4 at line 22 # spent 8µs making 1 call to Moo::_Utils::BEGIN@22
# spent 4µs making 1 call to Exporter::import |
23 | 2 | 50µs | 1 | 77µs | # spent 77µs (64+14) within Moo::_Utils::BEGIN@23 which was called:
# once (64µs+14µs) by Moo::BEGIN@4 at line 23 # spent 77µs making 1 call to Moo::_Utils::BEGIN@23 |
24 | 2 | 241µs | 2 | 27µs | # spent 16µs (6+11) within Moo::_Utils::BEGIN@24 which was called:
# once (6µs+11µs) by Moo::BEGIN@4 at line 24 # spent 16µs making 1 call to Moo::_Utils::BEGIN@24
# spent 11µs making 1 call to Config::import |
25 | |||||
26 | 1 | 1µs | our @EXPORT = qw( | ||
27 | _getglob _install_modifier _load_module _maybe_load_module | ||||
28 | _get_linear_isa _getstash _install_coderef _name_coderef | ||||
29 | _unimport_coderefs _in_global_destruction _set_loaded | ||||
30 | ); | ||||
31 | |||||
32 | sub _in_global_destruction (); | ||||
33 | 1 | 2µs | *_in_global_destruction = \&Devel::GlobalDestruction::in_global_destruction; | ||
34 | |||||
35 | # spent 520µs (26+494) within Moo::_Utils::_install_modifier which was called 3 times, avg 174µs/call:
# 3 times (26µs+494µs) by Moo::Role::_install_single_modifier at line 364 of Moo/Role.pm, avg 174µs/call | ||||
36 | 3 | 2µs | my ($into, $type, $name, $code) = @_; | ||
37 | |||||
38 | 3 | 11µs | 3 | 4µs | if (my $to_modify = $into->can($name)) { # CMM will throw for us if not # spent 4µs making 3 calls to UNIVERSAL::can, avg 1µs/call |
39 | 3 | 1µs | require Sub::Defer; | ||
40 | 3 | 4µs | 3 | 210µs | Sub::Defer::undefer_sub($to_modify); # spent 210µs making 3 calls to Sub::Defer::undefer_sub, avg 70µs/call |
41 | } | ||||
42 | |||||
43 | 3 | 8µs | 3 | 280µs | Class::Method::Modifiers::install_modifier(@_); # spent 280µs making 3 calls to Class::Method::Modifiers::install_modifier, avg 94µs/call |
44 | } | ||||
45 | |||||
46 | our %MAYBE_LOADED; | ||||
47 | |||||
48 | # spent 64.0ms (131µs+63.9) within Moo::_Utils::_load_module which was called 28 times, avg 2.29ms/call:
# 17 times (96µs+63.7ms) by Moo::Role::apply_roles_to_package at line 259 of Moo/Role.pm, avg 3.75ms/call
# 11 times (35µs+209µs) by Moo::Role::apply_single_role_to_package at line 268 of Moo/Role.pm, avg 22µs/call | ||||
49 | 28 | 8µs | my $module = $_[0]; | ||
50 | 28 | 28µs | 28 | 369µs | my $file = module_notional_filename($module); # spent 369µs making 28 calls to Module::Runtime::module_notional_filename, avg 13µs/call |
51 | 28 | 25µs | 28 | 63.7ms | use_package_optimistically($module); # spent 76.7ms making 28 calls to Module::Runtime::use_package_optimistically, avg 2.74ms/call, recursion: max depth 1, sum of overlapping time 13.0ms |
52 | return 1 | ||||
53 | 28 | 54µs | if $INC{$file}; | ||
54 | my $error = $@ || "Can't locate $file"; | ||||
55 | |||||
56 | # can't just ->can('can') because a sub-package Foo::Bar::Baz | ||||
57 | # creates a 'Baz::' key in Foo::Bar's symbol table | ||||
58 | my $stash = _getstash($module)||{}; | ||||
59 | return 1 if grep +(!ref($_) and *$_{CODE}), values %$stash; | ||||
60 | return 1 | ||||
61 | if $INC{"Moose.pm"} && Class::MOP::class_of($module) | ||||
62 | or Mouse::Util->can('find_meta') && Mouse::Util::find_meta($module); | ||||
63 | die $error; | ||||
64 | } | ||||
65 | |||||
66 | # spent 1.18ms (9µs+1.17) within Moo::_Utils::_maybe_load_module which was called:
# once (9µs+1.17ms) by Method::Generate::Accessor::BEGIN@11 at line 17 of Method/Generate/Accessor.pm | ||||
67 | 1 | 500ns | my $module = $_[0]; | ||
68 | return $MAYBE_LOADED{$module} | ||||
69 | 1 | 600ns | if exists $MAYBE_LOADED{$module}; | ||
70 | 2 | 8µs | 2 | 1.17ms | if(! eval { use_package_optimistically($module) }) { # spent 1.15ms making 1 call to Module::Runtime::use_package_optimistically
# spent 14µs making 1 call to Module::Runtime::module_notional_filename |
71 | warn "$module exists but failed to load with error: $@"; | ||||
72 | } | ||||
73 | elsif ( $INC{module_notional_filename($module)} ) { | ||||
74 | return $MAYBE_LOADED{$module} = 1; | ||||
75 | } | ||||
76 | return $MAYBE_LOADED{$module} = 0; | ||||
77 | } | ||||
78 | |||||
79 | # spent 400µs (82+318) within Moo::_Utils::_set_loaded which was called 24 times, avg 17µs/call:
# 12 times (46µs+178µs) by Moo::import at line 23 of Moo.pm, avg 19µs/call
# 12 times (35µs+140µs) by Moo::Role::import at line 35 of Moo/Role.pm, avg 15µs/call | ||||
80 | 24 | 80µs | 24 | 318µs | $INC{Module::Runtime::module_notional_filename($_[0])} ||= $_[1]; # spent 318µs making 24 calls to Module::Runtime::module_notional_filename, avg 13µs/call |
81 | } | ||||
82 | |||||
83 | sub _get_linear_isa { | ||||
84 | return mro::get_linear_isa($_[0]); | ||||
85 | } | ||||
86 | |||||
87 | # spent 1.63ms (591µs+1.04) within Moo::_Utils::_install_coderef which was called 189 times, avg 9µs/call:
# 72 times (220µs+372µs) by Moo::Role::_install_tracked at line 28 of Moo/Role.pm, avg 8µs/call
# 72 times (222µs+370µs) by Moo::_install_tracked at line 17 of Moo.pm, avg 8µs/call
# 45 times (150µs+292µs) by Sub::Defer::defer_sub at line 69 of Sub/Defer.pm, avg 10µs/call | ||||
88 | 189 | 208µs | 378 | 1.04ms | my ($glob, $code) = (_getglob($_[0]), _name_coderef(@_)); # spent 745µs making 189 calls to Moo::_Utils::_name_coderef, avg 4µs/call
# spent 290µs making 189 calls to Moo::_Utils::_getglob, avg 2µs/call |
89 | 2 | 23µs | 2 | 21µs | # spent 14µs (6+7) within Moo::_Utils::BEGIN@89 which was called:
# once (6µs+7µs) by Moo::BEGIN@4 at line 89 # spent 14µs making 1 call to Moo::_Utils::BEGIN@89
# spent 8µs making 1 call to warnings::unimport |
90 | 189 | 220µs | if (*{$glob}{CODE}) { | ||
91 | *{$glob} = $code; | ||||
92 | } | ||||
93 | # perl will sometimes warn about mismatched prototypes coming from the | ||||
94 | # inheritance cache, so disable them if we aren't redefining a sub | ||||
95 | else { | ||||
96 | 2 | 95µs | 2 | 12µs | # spent 8µs (4+4) within Moo::_Utils::BEGIN@96 which was called:
# once (4µs+4µs) by Moo::BEGIN@4 at line 96 # spent 8µs making 1 call to Moo::_Utils::BEGIN@96
# spent 4µs making 1 call to warnings::unimport |
97 | 189 | 55µs | *{$glob} = $code; | ||
98 | } | ||||
99 | } | ||||
100 | |||||
101 | # spent 786µs (290+496) within Moo::_Utils::_name_coderef which was called 197 times, avg 4µs/call:
# 189 times (275µs+470µs) by Moo::_Utils::_install_coderef at line 88, avg 4µs/call
# 8 times (15µs+26µs) by Moo::Role::_install_does at line 372 of Moo/Role.pm, avg 5µs/call | ||||
102 | 197 | 36µs | shift if @_ > 2; # three args is (target, name, sub) | ||
103 | 197 | 839µs | 197 | 496µs | can_haz_subutil ? Sub::Util::set_subname(@_) : # spent 496µs making 197 calls to Sub::Util::set_subname, avg 3µs/call |
104 | can_haz_subname ? Sub::Name::subname(@_) : $_[1]; | ||||
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 | 54µs | 2 | 17µs | # spent 11µs (5+6) within Moo::_Utils::BEGIN@120 which was called:
# once (5µs+6µs) by Moo::BEGIN@4 at line 120 # spent 11µs making 1 call to Moo::_Utils::BEGIN@120
# spent 6µs making 1 call to strict::unimport |
121 | *$full_name = *{$old}{$type}; | ||||
122 | } | ||||
123 | } | ||||
124 | } | ||||
125 | } | ||||
126 | } | ||||
127 | |||||
128 | 1 | 4µs | 1 | 3µs | if ($Config{useithreads}) { # spent 3µs making 1 call to Config::FETCH |
129 | require Moo::HandleMoose::_TypeMap; | ||||
130 | } | ||||
131 | |||||
132 | 1 | 3µs | 1; |