← Index
NYTProf Performance Profile   « line view »
For -e
  Run on Thu Jun 30 16:16:00 2016
Reported on Thu Jun 30 16:16:08 2016

Filename/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/Module/Implementation.pm
StatementsExecuted 73 statements in 1.87ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1112.20ms2.38msModule::Implementation::::BEGIN@8Module::Implementation::BEGIN@8
1111.48ms4.92msModule::Implementation::::BEGIN@9Module::Implementation::BEGIN@9
11150µs55µsModule::Implementation::::_copy_symbolsModule::Implementation::_copy_symbols
11131µs1.39msModule::Implementation::::_load_implementationModule::Implementation::_load_implementation
11126µs30µsModule::Implementation::::_build_loaderModule::Implementation::_build_loader
11124µs27µsModule::Implementation::::BEGIN@5Module::Implementation::BEGIN@5
11121µs1.46msModule::Implementation::::__ANON__[:52]Module::Implementation::__ANON__[:52]
11115µs21µsModule::Implementation::::BEGIN@6Module::Implementation::BEGIN@6
11112µs28µsModule::Implementation::::BEGIN@129Module::Implementation::BEGIN@129
11111µs28µsModule::Implementation::::BEGIN@128Module::Implementation::BEGIN@128
6219µs9µsModule::Implementation::::CORE:substModule::Implementation::CORE:subst (opcode)
1119µs38µsModule::Implementation::::build_loader_subModule::Implementation::build_loader_sub
1118µs1.29msModule::Implementation::::try {...} Module::Implementation::try {...}
0000s0sModule::Implementation::::__ANON__[:78]Module::Implementation::__ANON__[:78]
0000s0sModule::Implementation::::__ANON__[:82]Module::Implementation::__ANON__[:82]
0000s0sModule::Implementation::::__ANON__[:95]Module::Implementation::__ANON__[:95]
0000s0sModule::Implementation::::__ANON__[:98]Module::Implementation::__ANON__[:98]
0000s0sModule::Implementation::::catch {...} Module::Implementation::catch {...}
0000s0sModule::Implementation::::implementation_forModule::Implementation::implementation_for
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Module::Implementation;
2# git description: v0.08-2-gd599347
31600ns$Module::Implementation::VERSION = '0.09';
4
5235µs231µs
# spent 27µs (24+3) within Module::Implementation::BEGIN@5 which was called: # once (24µs+3µs) by Params::Validate::BEGIN@11 at line 5
use strict;
# spent 27µs making 1 call to Module::Implementation::BEGIN@5 # spent 3µs making 1 call to strict::import
6244µs228µs
# spent 21µs (15+6) within Module::Implementation::BEGIN@6 which was called: # once (15µs+6µs) by Params::Validate::BEGIN@11 at line 6
use warnings;
# spent 21µs making 1 call to Module::Implementation::BEGIN@6 # spent 6µs making 1 call to warnings::import
7
83409µs32.42ms
# spent 2.38ms (2.20+187µs) within Module::Implementation::BEGIN@8 which was called: # once (2.20ms+187µs) by Params::Validate::BEGIN@11 at line 8
use Module::Runtime 0.012 qw( require_module );
# spent 2.38ms making 1 call to Module::Implementation::BEGIN@8 # spent 20µs making 1 call to Module::Runtime::import # spent 14µs making 1 call to UNIVERSAL::VERSION
921.04ms24.97ms
# spent 4.92ms (1.48+3.44) within Module::Implementation::BEGIN@9 which was called: # once (1.48ms+3.44ms) by Params::Validate::BEGIN@11 at line 9
use Try::Tiny;
# spent 4.92ms making 1 call to Module::Implementation::BEGIN@9 # spent 50µs making 1 call to Exporter::import
10
11# This is needed for the benefit of Test::CleanNamespaces, which in turn loads
12# Package::Stash, which in turn loads this module and expects a minimum
13# version.
1411µsunless ( exists $Module::Implementation::{VERSION}
15 && ${ $Module::Implementation::{VERSION} } ) {
16
17 $Module::Implementation::{VERSION} = \42;
18}
19
201200nsmy %Implementation;
21
22
# spent 38µs (9+30) within Module::Implementation::build_loader_sub which was called: # once (9µs+30µs) by DateTime::Duration::BEGIN@11 at line 46 of Params/Validate.pm
sub build_loader_sub {
231900ns my $caller = caller();
24
2516µs130µs return _build_loader( $caller, @_ );
# spent 30µs making 1 call to Module::Implementation::_build_loader
26}
27
28
# spent 30µs (26+3) within Module::Implementation::_build_loader which was called: # once (26µs+3µs) by Module::Implementation::build_loader_sub at line 25
sub _build_loader {
291400ns my $package = shift;
3012µs my %args = @_;
31
3211µs my @implementations = @{ $args{implementations} };
3311µs my @symbols = @{ $args{symbols} || [] };
34
351200ns my $implementation;
3611µs my $env_var = uc $package;
37117µs14µs $env_var =~ s/::/_/g;
# spent 4µs making 1 call to Module::Implementation::CORE:subst
381900ns $env_var .= '_IMPLEMENTATION';
39
40
# spent 1.46ms (21µs+1.44) within Module::Implementation::__ANON__[/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/Module/Implementation.pm:52] which was called: # once (21µs+1.44ms) by DateTime::Duration::BEGIN@11 at line 61 of Params/Validate.pm
return sub {
41 my ( $implementation, $loaded ) = _load_implementation(
42 $package,
4315µs11.39ms $ENV{$env_var},
# spent 1.39ms making 1 call to Module::Implementation::_load_implementation
44 \@implementations,
45 );
46
4711µs $Implementation{$package} = $implementation;
48
4914µs155µs _copy_symbols( $loaded, $package, \@symbols );
# spent 55µs making 1 call to Module::Implementation::_copy_symbols
50
5115µs return $loaded;
52110µs };
53}
54
55sub implementation_for {
56 my $package = shift;
57
58 return $Implementation{$package};
59}
60
61
# spent 1.39ms (31µs+1.36) within Module::Implementation::_load_implementation which was called: # once (31µs+1.36ms) by Module::Implementation::__ANON__[/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/Module/Implementation.pm:52] at line 43
sub _load_implementation {
621400ns my $package = shift;
6311µs my $env_value = shift;
641200ns my $implementations = shift;
65
661500ns if ($env_value) {
67 die "$env_value is not a valid implementation for $package"
68 unless grep { $_ eq $env_value } @{$implementations};
69
70 my $requested = "${package}::$env_value";
71
72 # Values from the %ENV hash are tainted. We know it's safe to untaint
73 # this value because the value was one of our known implementations.
74 ($requested) = $requested =~ /^(.+)$/;
75
76 try {
77 require_module($requested);
78 }
79 catch {
80 require Carp;
81 Carp::croak("Could not load $requested: $_");
82 };
83
84 return ( $env_value, $requested );
85 }
86 else {
871100ns my $err;
8811µs for my $possible ( @{$implementations} ) {
8911µs my $try = "${package}::$possible";
90
911100ns my $ok;
92
# spent 1.29ms (8µs+1.28) within Module::Implementation::try {...} which was called: # once (8µs+1.28ms) by Try::Tiny::try at line 92 of Try/Tiny.pm
try {
9312µs11.28ms require_module($try);
# spent 1.28ms making 1 call to Module::Runtime::require_module
9414µs $ok = 1;
95 }
96 catch {
97 $err .= $_ if defined $_;
98117µs21.36ms };
# spent 1.32ms making 1 call to Try::Tiny::try # spent 34µs making 1 call to Try::Tiny::catch
99
10017µs return ( $possible, $try ) if $ok;
101 }
102
103 require Carp;
104 if ( defined $err && length $err ) {
105 Carp::croak(
106 "Could not find a suitable $package implementation: $err");
107 }
108 else {
109 Carp::croak(
110 'Module::Runtime failed to load a module but did not throw a real error. This should never happen. Something is very broken'
111 );
112 }
113 }
114}
115
116
# spent 55µs (50+5) within Module::Implementation::_copy_symbols which was called: # once (50µs+5µs) by Module::Implementation::__ANON__[/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/Module/Implementation.pm:52] at line 49
sub _copy_symbols {
1171500ns my $from_package = shift;
1181300ns my $to_package = shift;
1191300ns my $symbols = shift;
120
12116µs for my $sym ( @{$symbols} ) {
122520µs55µs my $type = $sym =~ s/^([\$\@\%\&\*])// ? $1 : '&';
# spent 5µs making 5 calls to Module::Implementation::CORE:subst, avg 1µs/call
123
12455µs my $from = "${from_package}::$sym";
12553µs my $to = "${to_package}::$sym";
126
127 {
128744µs244µs
# spent 28µs (11+16) within Module::Implementation::BEGIN@128 which was called: # once (11µs+16µs) by Params::Validate::BEGIN@11 at line 128
no strict 'refs';
# spent 28µs making 1 call to Module::Implementation::BEGIN@128 # spent 16µs making 1 call to strict::unimport
1292142µs245µs
# spent 28µs (12+17) within Module::Implementation::BEGIN@129 which was called: # once (12µs+17µs) by Params::Validate::BEGIN@11 at line 129
no warnings 'once';
# spent 28µs making 1 call to Module::Implementation::BEGIN@129 # spent 17µs making 1 call to warnings::unimport
130
131 # Copied from Exporter
132 *{$to}
133 = $type eq '&' ? \&{$from}
134 : $type eq '$' ? \${$from}
135 : $type eq '@' ? \@{$from}
136 : $type eq '%' ? \%{$from}
137518µs : $type eq '*' ? *{$from}
138 : die
139 "Can't copy symbol from $from_package to $to_package: $type$sym";
140 }
141 }
142}
143
14416µs1;
145
146# ABSTRACT: Loads one of several alternate underlying implementations for a module
147
148__END__
 
# spent 9µs within Module::Implementation::CORE:subst which was called 6 times, avg 1µs/call: # 5 times (5µs+0s) by Module::Implementation::_copy_symbols at line 122, avg 1µs/call # once (4µs+0s) by Module::Implementation::_build_loader at line 37
sub Module::Implementation::CORE:subst; # opcode