← Index
NYTProf Performance Profile   « line view »
For -e
  Run on Thu Jun 30 16:34:56 2016
Reported on Thu Jun 30 16:35:09 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.45ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.59ms1.72msModule::Implementation::::BEGIN@8Module::Implementation::BEGIN@8
1111.17ms1.89msModule::Implementation::::BEGIN@9Module::Implementation::BEGIN@9
11132µs35µsModule::Implementation::::_copy_symbolsModule::Implementation::_copy_symbols
11120µs866µsModule::Implementation::::_load_implementationModule::Implementation::_load_implementation
11117µs20µsModule::Implementation::::BEGIN@5Module::Implementation::BEGIN@5
11115µs915µsModule::Implementation::::__ANON__[:52]Module::Implementation::__ANON__[:52]
11114µs17µsModule::Implementation::::_build_loaderModule::Implementation::_build_loader
1119µs20µsModule::Implementation::::BEGIN@129Module::Implementation::BEGIN@129
1118µs20µsModule::Implementation::::BEGIN@128Module::Implementation::BEGIN@128
1118µs12µsModule::Implementation::::BEGIN@6Module::Implementation::BEGIN@6
1116µs22µsModule::Implementation::::build_loader_subModule::Implementation::build_loader_sub
6215µs5µsModule::Implementation::::CORE:substModule::Implementation::CORE:subst (opcode)
1115µs799µsModule::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
31400ns$Module::Implementation::VERSION = '0.09';
4
5227µs222µs
# spent 20µs (17+2) within Module::Implementation::BEGIN@5 which was called: # once (17µs+2µs) by Params::Validate::BEGIN@11 at line 5
use strict;
# spent 20µs making 1 call to Module::Implementation::BEGIN@5 # spent 2µs making 1 call to strict::import
6229µs217µs
# spent 12µs (8+5) within Module::Implementation::BEGIN@6 which was called: # once (8µs+5µs) by Params::Validate::BEGIN@11 at line 6
use warnings;
# spent 12µs making 1 call to Module::Implementation::BEGIN@6 # spent 5µs making 1 call to warnings::import
7
83320µs31.75ms
# spent 1.72ms (1.59+133µs) within Module::Implementation::BEGIN@8 which was called: # once (1.59ms+133µs) by Params::Validate::BEGIN@11 at line 8
use Module::Runtime 0.012 qw( require_module );
# spent 1.72ms making 1 call to Module::Implementation::BEGIN@8 # spent 15µs making 1 call to Module::Runtime::import # spent 10µs making 1 call to UNIVERSAL::VERSION
92849µs21.93ms
# spent 1.89ms (1.17+720µs) within Module::Implementation::BEGIN@9 which was called: # once (1.17ms+720µs) by Params::Validate::BEGIN@11 at line 9
use Try::Tiny;
# spent 1.89ms making 1 call to Module::Implementation::BEGIN@9 # spent 45µ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.
141900nsunless ( exists $Module::Implementation::{VERSION}
15 && ${ $Module::Implementation::{VERSION} } ) {
16
17 $Module::Implementation::{VERSION} = \42;
18}
19
201200nsmy %Implementation;
21
22
# spent 22µs (6+17) within Module::Implementation::build_loader_sub which was called: # once (6µs+17µs) by DateTime::Duration::BEGIN@11 at line 46 of Params/Validate.pm
sub build_loader_sub {
231600ns my $caller = caller();
24
2514µs117µs return _build_loader( $caller, @_ );
# spent 17µs making 1 call to Module::Implementation::_build_loader
26}
27
28
# spent 17µs (14+2) within Module::Implementation::_build_loader which was called: # once (14µs+2µs) by Module::Implementation::build_loader_sub at line 25
sub _build_loader {
291200ns my $package = shift;
3011µs my %args = @_;
31
321700ns my @implementations = @{ $args{implementations} };
331900ns my @symbols = @{ $args{symbols} || [] };
34
351100ns my $implementation;
361800ns my $env_var = uc $package;
3718µs12µs $env_var =~ s/::/_/g;
# spent 2µs making 1 call to Module::Implementation::CORE:subst
381500ns $env_var .= '_IMPLEMENTATION';
39
40
# spent 915µs (15+900) 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 (15µs+900µs) by DateTime::Duration::BEGIN@11 at line 61 of Params/Validate.pm
return sub {
41 my ( $implementation, $loaded ) = _load_implementation(
42 $package,
4313µs1866µs $ENV{$env_var},
# spent 866µs making 1 call to Module::Implementation::_load_implementation
44 \@implementations,
45 );
46
471700ns $Implementation{$package} = $implementation;
48
4912µs135µs _copy_symbols( $loaded, $package, \@symbols );
# spent 35µs making 1 call to Module::Implementation::_copy_symbols
50
5113µs return $loaded;
5216µs };
53}
54
55sub implementation_for {
56 my $package = shift;
57
58 return $Implementation{$package};
59}
60
61
# spent 866µs (20+845) within Module::Implementation::_load_implementation which was called: # once (20µs+845µ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 43
sub _load_implementation {
621300ns my $package = shift;
6311µs my $env_value = shift;
641100ns my $implementations = shift;
65
661300ns 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;
881600ns for my $possible ( @{$implementations} ) {
891900ns my $try = "${package}::$possible";
90
911100ns my $ok;
92
# spent 799µs (5+794) within Module::Implementation::try {...} which was called: # once (5µs+794µs) by Try::Tiny::try at line 92 of Try/Tiny.pm
try {
9311µs1794µs require_module($try);
# spent 794µs making 1 call to Module::Runtime::require_module
9413µs $ok = 1;
95 }
96 catch {
97 $err .= $_ if defined $_;
98111µs2845µs };
# spent 818µs making 1 call to Try::Tiny::try # spent 27µs making 1 call to Try::Tiny::catch
99
10015µ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 35µs (32+3) within Module::Implementation::_copy_symbols which was called: # once (32µs+3µ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 {
1171300ns my $from_package = shift;
1181300ns my $to_package = shift;
1191100ns my $symbols = shift;
120
12114µs for my $sym ( @{$symbols} ) {
122512µs53µs my $type = $sym =~ s/^([\$\@\%\&\*])// ? $1 : '&';
# spent 3µs making 5 calls to Module::Implementation::CORE:subst, avg 600ns/call
123
12452µs my $from = "${from_package}::$sym";
12552µs my $to = "${to_package}::$sym";
126
127 {
128729µs232µs
# spent 20µs (8+12) within Module::Implementation::BEGIN@128 which was called: # once (8µs+12µs) by Params::Validate::BEGIN@11 at line 128
no strict 'refs';
# spent 20µs making 1 call to Module::Implementation::BEGIN@128 # spent 12µs making 1 call to strict::unimport
1292102µs232µs
# spent 20µs (9+12) within Module::Implementation::BEGIN@129 which was called: # once (9µs+12µs) by Params::Validate::BEGIN@11 at line 129
no warnings 'once';
# spent 20µs making 1 call to Module::Implementation::BEGIN@129 # spent 12µ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}
137512µs : $type eq '*' ? *{$from}
138 : die
139 "Can't copy symbol from $from_package to $to_package: $type$sym";
140 }
141 }
142}
143
14414µs1;
145
146# ABSTRACT: Loads one of several alternate underlying implementations for a module
147
148__END__
 
# spent 5µs within Module::Implementation::CORE:subst which was called 6 times, avg 883ns/call: # 5 times (3µs+0s) by Module::Implementation::_copy_symbols at line 122, avg 600ns/call # once (2µs+0s) by Module::Implementation::_build_loader at line 37
sub Module::Implementation::CORE:subst; # opcode