← Index
NYTProf Performance Profile   « line view »
For fastest.pl
  Run on Fri Jan 31 20:48:16 2014
Reported on Fri Jan 31 20:49:41 2014

Filename/opt/perl-5.18.1/lib/site_perl/5.18.1/Moo/_Utils.pm
StatementsExecuted 135 statements in 1.78ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
2322127µs314µsMoo::_Utils::::_install_coderefMoo::_Utils::_install_coderef
111119µs119µsMoo::_Utils::::BEGIN@15Moo::_Utils::BEGIN@15
231176µs131µsMoo::_Utils::::_name_coderefMoo::_Utils::_name_coderef
314374µs74µsMoo::_Utils::::_getglobMoo::_Utils::_getglob
11117µs27µsMoo::_Utils::::BEGIN@3Moo::_Utils::BEGIN@3
11116µs20µsMoo::_Utils::::_maybe_load_moduleMoo::_Utils::_maybe_load_module
11114µs68µsMoo::_Utils::::BEGIN@11Moo::_Utils::BEGIN@11
11114µs26µsMoo::_Utils::::BEGIN@70Moo::_Utils::BEGIN@70
11111µs23µsMoo::_Utils::::BEGIN@112Moo::_Utils::BEGIN@112
11110µs46µsMoo::_Utils::::BEGIN@8Moo::_Utils::BEGIN@8
11110µs97µsMoo::_Utils::::BEGIN@14Moo::_Utils::BEGIN@14
1119µs29µsMoo::_Utils::::BEGIN@12Moo::_Utils::BEGIN@12
1119µs24µsMoo::_Utils::::BEGIN@92Moo::_Utils::BEGIN@92
1119µs40µsMoo::_Utils::::BEGIN@9Moo::_Utils::BEGIN@9
1114µs4µsMoo::_Utils::::BEGIN@13Moo::_Utils::BEGIN@13
1114µs4µsMoo::_Utils::::CORE:substMoo::_Utils::CORE:subst (opcode)
0000s0sMoo::_Utils::::STANDARD_DESTROYMoo::_Utils::STANDARD_DESTROY
0000s0sMoo::_Utils::::_get_linear_isaMoo::_Utils::_get_linear_isa
0000s0sMoo::_Utils::::_getstashMoo::_Utils::_getstash
0000s0sMoo::_Utils::::_install_modifierMoo::_Utils::_install_modifier
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
32107µs237µ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
no warnings 'once'; # guard against -w
# spent 27µs making 1 call to Moo::_Utils::BEGIN@3 # spent 10µs making 1 call to warnings::unimport
4
531110µ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
sub _getglob { \*{$_[0]} }
6sub _getstash { \%{"$_[0]::"} }
7
8244µs282µ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
use constant lt_5_8_3 => ( $] < 5.008003 or $ENV{MOO_TEST_PRE_583} ) ? 1 : 0;
# spent 46µs making 1 call to Moo::_Utils::BEGIN@8 # spent 36µs making 1 call to constant::import
9343µs272µ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
use constant can_haz_subname => eval { require Sub::Name };
# spent 40µs making 1 call to Moo::_Utils::BEGIN@9 # spent 31µs making 1 call to constant::import
10
11340µs3122µ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
use strictures 1;
# 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
12241µs249µ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
use Module::Runtime qw(require_module);
# spent 29µs making 1 call to Moo::_Utils::BEGIN@12 # spent 20µs making 1 call to Module::Runtime::import
13230µs14µs
# spent 4µs within Moo::_Utils::BEGIN@13 which was called: # once (4µs+0s) by Moo::BEGIN@4 at line 13
use Devel::GlobalDestruction ();
# spent 4µs making 1 call to Moo::_Utils::BEGIN@13
14244µs2184µ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
use base qw(Exporter);
# spent 97µs making 1 call to Moo::_Utils::BEGIN@14 # spent 87µs making 1 call to base::import
152591µs1119µs
# spent 119µs within Moo::_Utils::BEGIN@15 which was called: # once (119µs+0s) by Moo::BEGIN@4 at line 15
use Moo::_mro;
# spent 119µs making 1 call to Moo::_Utils::BEGIN@15
16
1713µsour @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
23sub _in_global_destruction ();
2413µs*_in_global_destruction = \&Devel::GlobalDestruction::in_global_destruction;
25
26sub _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
371100nsour %MAYBE_LOADED;
38
39sub _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
sub _maybe_load_module {
511700ns return $MAYBE_LOADED{$_[0]} if exists $MAYBE_LOADED{$_[0]};
52112µs14µs (my $proto = $_[0]) =~ s/::/\//g;
# spent 4µs making 1 call to Moo::_Utils::CORE:subst
531300ns local $@;
5434µ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 }
6215µs return $MAYBE_LOADED{$_[0]};
63}
64
65sub _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
sub _install_coderef {
702245µs238µ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
no warnings 'redefine';
# spent 26µs making 1 call to Moo::_Utils::BEGIN@70 # spent 12µs making 1 call to warnings::unimport
712390µs46187µ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
sub _name_coderef {
75236µs shift if @_ > 2; # three args is (target, name, sub)
7623148µs2354µs can_haz_subname ? Sub::Name::subname(@_) : $_[1];
# spent 54µs making 23 calls to Sub::Name::subname, avg 2µs/call
77}
78
79sub _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});
922139µs238µ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
no strict 'refs';
# 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
100sub 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
112267µs235µ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
no warnings 'misc';
# 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
11616µs1;
 
# spent 4µs within Moo::_Utils::CORE:subst which was called: # once (4µs+0s) by Moo::_Utils::_maybe_load_module at line 52
sub Moo::_Utils::CORE:subst; # opcode