← Index
NYTProf Performance Profile   « line view »
For index.cgi
  Run on Sat May 9 17:18:47 2020
Reported on Sat May 9 17:19:07 2020

Filename/usr/local/share/perl/5.18.2/Moo/_Utils.pm
StatementsExecuted 149 statements in 2.45ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1112.21ms2.59msMoo::_Utils::::BEGIN@10Moo::_Utils::BEGIN@10
1111.82ms1.97msMoo::_Utils::::BEGIN@24Moo::_Utils::BEGIN@24
111878µs1.97msMoo::_Utils::::BEGIN@29Moo::_Utils::BEGIN@29
111450µs709µsMoo::_Utils::::BEGIN@28Moo::_Utils::BEGIN@28
111346µs5.76msMoo::_Utils::::BEGIN@26Moo::_Utils::BEGIN@26
1422117µs293µsMoo::_Utils::::_install_coderefMoo::_Utils::_install_coderef
3454100µs100µsMoo::_Utils::::_getglobMoo::_Utils::_getglob
141164µs130µsMoo::_Utils::::_name_coderefMoo::_Utils::_name_coderef
11129µs265µsMoo::_Utils::::_install_modifierMoo::_Utils::_install_modifier
11121µs32µsMoo::_Utils::::BEGIN@3Moo::_Utils::BEGIN@3
11117µs35µsMoo::_Utils::::BEGIN@27Moo::_Utils::BEGIN@27
11115µs2.30msMoo::_Utils::::_maybe_load_moduleMoo::_Utils::_maybe_load_module
11112µs26µsMoo::_Utils::::BEGIN@90Moo::_Utils::BEGIN@90
21112µs108µsMoo::_Utils::::_set_loadedMoo::_Utils::_set_loaded
11111µs21µsMoo::_Utils::::BEGIN@97Moo::_Utils::BEGIN@97
32211µs11µsMoo::_Utils::::_getstashMoo::_Utils::_getstash
1119µs24µsMoo::_Utils::::BEGIN@120Moo::_Utils::BEGIN@120
1118µs41µsMoo::_Utils::::BEGIN@8Moo::_Utils::BEGIN@8
0000s0sMoo::_Utils::::__ANON__[:20]Moo::_Utils::__ANON__[:20]
0000s0sMoo::_Utils::::_load_moduleMoo::_Utils::_load_module
0000s0sMoo::_Utils::::_unimport_coderefsMoo::_Utils::_unimport_coderefs
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Moo::_Utils;
2
3291µs243µ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
no warnings 'once'; # guard against -w
# spent 32µs making 1 call to Moo::_Utils::BEGIN@3 # spent 11µs making 1 call to warnings::unimport
4
534160µ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
sub _getglob { \*{$_[0]} }
6320µ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
sub _getstash { \%{"$_[0]::"} }
7
82222µs273µ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
use Moo::_strictures;
# 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
BEGIN {
1115µs *lt_5_8_3 = ( $] < 5.008003 or $ENV{MOO_TEST_PRE_583} ) ? sub(){1} : sub(){0};
121300ns my ($su, $sn);
13 $su = $INC{'Sub/Util.pm'} && defined &Sub::Util::set_subname
14 or $sn = $INC{'Sub/Name.pm'}
15180µs or $su = eval { require Sub::Util; } && defined &Sub::Util::set_subname
1613µs or $sn = eval { require Sub::Name; };
17
18 *_subname = $su ? \&Sub::Util::set_subname
19 : $sn ? \&Sub::Name::subname
2012µs : sub { $_[1] };
2114µs *_CAN_SUBNAME = ($su || $sn) ? sub(){1} : sub(){0};
22148µs12.59ms}
# spent 2.59ms making 1 call to Moo::_Utils::BEGIN@10
23
242183µs22.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
use Module::Runtime qw(use_package_optimistically module_notional_filename);
# spent 1.97ms making 1 call to Moo::_Utils::BEGIN@24 # spent 28µs making 1 call to Module::Runtime::import
25
262104µs15.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
use Devel::GlobalDestruction ();
# spent 5.76ms making 1 call to Moo::_Utils::BEGIN@26
27231µs253µ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
use Exporter qw(import);
# spent 35µs making 1 call to Moo::_Utils::BEGIN@27 # spent 18µs making 1 call to Exporter::import
282110µs1709µ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
use Moo::_mro;
# spent 709µs making 1 call to Moo::_Utils::BEGIN@28
292574µs21.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
use Config;
# spent 1.97ms making 1 call to Moo::_Utils::BEGIN@29 # spent 16µs making 1 call to Config::import
30
3113µsour @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
37sub _in_global_destruction ();
3813µ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
sub _install_modifier {
4111µs my ($into, $type, $name, $code) = @_;
42
43118µs15µs if (my $to_modify = $into->can($name)) { # CMM will throw for us if not
# spent 5µs making 1 call to UNIVERSAL::can
441900ns require Sub::Defer;
4512µs14µs Sub::Defer::undefer_sub($to_modify);
# spent 4µs making 1 call to Sub::Defer::undefer_sub
46 }
47
4816µs1228µs Class::Method::Modifiers::install_modifier(@_);
# spent 228µs making 1 call to Class::Method::Modifiers::install_modifier
49}
50
511300nsour %MAYBE_LOADED;
52
53sub _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
sub _maybe_load_module {
7211µs my $module = $_[0];
731800ns return $MAYBE_LOADED{$module}
74 if exists $MAYBE_LOADED{$module};
75212µs22.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
sub _set_loaded {
85210µs296µ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
sub _install_coderef {
891444µs28176µ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
902102µs239µ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
no warnings 'redefine';
# spent 26µs making 1 call to Moo::_Utils::BEGIN@90 # spent 14µs making 1 call to warnings::unimport
911440µ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 {
972224µs231µ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
no warnings 'prototype';
# spent 21µs making 1 call to Moo::_Utils::BEGIN@97 # spent 10µs making 1 call to warnings::unimport
981411µ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
sub _name_coderef {
103146µs shift if @_ > 2; # three args is (target, name, sub)
10414132µs1466µs _CAN_SUBNAME ? _subname(@_) : $_[1];
# spent 66µs making 14 calls to Sub::Util::set_subname, avg 5µs/call
105}
106
107sub _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});
1202106µs239µ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
no strict 'refs';
# 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
128189µs14µsif ($Config{useithreads}) {
# spent 4µs making 1 call to Config::FETCH
129 require Moo::HandleMoose::_TypeMap;
130}
131
13215µs1;