← Index
NYTProf Performance Profile   « line view »
For script/ponapi
  Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:09 2016

Filename/usr/share/perl5/Module/Implementation.pm
StatementsExecuted 198 statements in 1.08ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.12ms1.22msModule::Implementation::::BEGIN@12Module::Implementation::BEGIN@12
111643µs2.45msModule::Implementation::::BEGIN@13Module::Implementation::BEGIN@13
31193µs100µsModule::Implementation::::_copy_symbolsModule::Implementation::_copy_symbols
31158µs3.47msModule::Implementation::::_load_implementationModule::Implementation::_load_implementation
31147µs56µsModule::Implementation::::_build_loaderModule::Implementation::_build_loader
33332µs3.60msModule::Implementation::::__ANON__[:47]Module::Implementation::__ANON__[:47]
202116µs16µsModule::Implementation::::CORE:substModule::Implementation::CORE:subst (opcode)
33316µs72µsModule::Implementation::::build_loader_subModule::Implementation::build_loader_sub
1116µs15µsModule::Implementation::::BEGIN@123Module::Implementation::BEGIN@123
1116µs17µsModule::Implementation::::BEGIN@124Module::Implementation::BEGIN@124
1116µs10µsModule::Implementation::::BEGIN@10Module::Implementation::BEGIN@10
1116µs6µsModule::Implementation::::BEGIN@5Module::Implementation::BEGIN@5
1115µs15µsModule::Implementation::::BEGIN@9Module::Implementation::BEGIN@9
1112µs2µsModule::Implementation::::implementation_forModule::Implementation::implementation_for
0000s0sModule::Implementation::::__ANON__[:73]Module::Implementation::__ANON__[:73]
0000s0sModule::Implementation::::__ANON__[:77]Module::Implementation::__ANON__[:77]
0000s0sModule::Implementation::::__ANON__[:90]Module::Implementation::__ANON__[:90]
0000s0sModule::Implementation::::__ANON__[:93]Module::Implementation::__ANON__[:93]
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{
32800ns $Module::Implementation::VERSION = '0.07';
4}
5
# spent 6µs within Module::Implementation::BEGIN@5 which was called: # once (6µs+0s) by Class::Load::BEGIN@11 at line 7
BEGIN {
614µs $Module::Implementation::AUTHORITY = 'cpan:DROLSKY';
7116µs16µs}
# spent 6µs making 1 call to Module::Implementation::BEGIN@5
8
9219µs225µs
# spent 15µs (5+10) within Module::Implementation::BEGIN@9 which was called: # once (5µs+10µs) by Class::Load::BEGIN@11 at line 9
use strict;
# spent 15µs making 1 call to Module::Implementation::BEGIN@9 # spent 10µs making 1 call to strict::import
10225µs214µs
# spent 10µs (6+4) within Module::Implementation::BEGIN@10 which was called: # once (6µs+4µs) by Class::Load::BEGIN@11 at line 10
use warnings;
# spent 10µs making 1 call to Module::Implementation::BEGIN@10 # spent 4µs making 1 call to warnings::import
11
123138µs31.24ms
# spent 1.22ms (1.12+93µs) within Module::Implementation::BEGIN@12 which was called: # once (1.12ms+93µs) by Class::Load::BEGIN@11 at line 12
use Module::Runtime 0.012 qw( require_module );
# spent 1.22ms making 1 call to Module::Implementation::BEGIN@12 # spent 11µs making 1 call to Module::Runtime::import # spent 8µs making 1 call to UNIVERSAL::VERSION
132495µs22.48ms
# spent 2.45ms (643µs+1.80) within Module::Implementation::BEGIN@13 which was called: # once (643µs+1.80ms) by Class::Load::BEGIN@11 at line 13
use Try::Tiny;
# spent 2.45ms making 1 call to Module::Implementation::BEGIN@13 # spent 30µs making 1 call to Exporter::import
14
151200nsmy %Implementation;
16
17
# spent 72µs (16+56) within Module::Implementation::build_loader_sub which was called 3 times, avg 24µs/call: # once (5µs+20µs) by Package::Stash::BEGIN@17 at line 21 of Package/Stash.pm # once (5µs+19µs) by Getopt::Long::Descriptive::BEGIN@10 at line 51 of Params/Validate.pm # once (5µs+17µs) by App::Cmd::BEGIN@13 at line 21 of Class/Load.pm
sub build_loader_sub {
1832µs my $caller = caller();
19
20318µs356µs return _build_loader( $caller, @_ );
# spent 56µs making 3 calls to Module::Implementation::_build_loader, avg 19µs/call
21}
22
23
# spent 56µs (47+9) within Module::Implementation::_build_loader which was called 3 times, avg 19µs/call: # 3 times (47µs+9µs) by Module::Implementation::build_loader_sub at line 20, avg 19µs/call
sub _build_loader {
2431µs my $package = shift;
2534µs my %args = @_;
26
2734µs my @implementations = @{ $args{implementations} };
2834µs my @symbols = @{ $args{symbols} || [] };
29
303400ns my $implementation;
3133µs my $env_var = uc $package;
32322µs39µs $env_var =~ s/::/_/g;
# spent 9µs making 3 calls to Module::Implementation::CORE:subst, avg 3µs/call
3332µs $env_var .= '_IMPLEMENTATION';
34
35
# spent 3.60ms (32µs+3.57) within Module::Implementation::__ANON__[/usr/share/perl5/Module/Implementation.pm:47] which was called 3 times, avg 1.20ms/call: # once (12µs+2.61ms) by Getopt::Long::Descriptive::BEGIN@10 at line 66 of Params/Validate.pm # once (11µs+490µs) by Package::Stash::BEGIN@17 at line 21 of Package/Stash.pm # once (10µs+467µs) by App::Cmd::BEGIN@13 at line 26 of Class/Load.pm
return sub {
36312µs33.47ms my ( $implementation, $loaded ) = _load_implementation(
# spent 3.47ms making 3 calls to Module::Implementation::_load_implementation, avg 1.16ms/call
37 $package,
38 $ENV{$env_var},
39 \@implementations,
40 );
41
4232µs $Implementation{$package} = $implementation;
43
4436µs3100µs _copy_symbols( $loaded, $package, \@symbols );
# spent 100µs making 3 calls to Module::Implementation::_copy_symbols, avg 33µs/call
45
4638µs return $loaded;
47319µs };
48}
49
50
# spent 2µs within Module::Implementation::implementation_for which was called: # once (2µs+0s) by Package::Stash::BEGIN@17 at line 37 of Package/Stash.pm
sub implementation_for {
511300ns my $package = shift;
52
5314µs return $Implementation{$package};
54}
55
56
# spent 3.47ms (58µs+3.41) within Module::Implementation::_load_implementation which was called 3 times, avg 1.16ms/call: # 3 times (58µs+3.41ms) by Module::Implementation::__ANON__[/usr/share/perl5/Module/Implementation.pm:47] at line 36, avg 1.16ms/call
sub _load_implementation {
573800ns my $package = shift;
5832µs my $env_value = shift;
593500ns my $implementations = shift;
60
613900ns if ($env_value) {
62 die "$env_value is not a valid implementation for $package"
63 unless grep { $_ eq $env_value } @{$implementations};
64
65 my $requested = "${package}::$env_value";
66
67 # Values from the %ENV hash are tainted. We know it's safe to untaint
68 # this value because the value was one of our known implementations.
69 ($requested) = $requested =~ /^(.+)$/;
70
71 try {
72 require_module($requested);
73 }
74 catch {
75 require Carp;
76 Carp::croak("Could not load $requested: $_");
77 };
78
79 return ( $env_value, $requested );
80 }
81 else {
823700ns my $err;
8332µs for my $possible ( @{$implementations} ) {
8432µs my $try = "${package}::$possible";
85
863300ns my $ok;
87 try {
8836µs33.31ms require_module($try);
# spent 3.31ms making 3 calls to Module::Runtime::require_module, avg 1.10ms/call
8937µs $ok = 1;
90 }
91 catch {
92 $err .= $_ if defined $_;
93332µs63.41ms };
# spent 3.40ms making 3 calls to Try::Tiny::try, avg 1.13ms/call # spent 14µs making 3 calls to Try::Tiny::catch, avg 5µs/call
94
95312µs return ( $possible, $try ) if $ok;
96 }
97
98 require Carp;
99 if ( defined $err && length $err ) {
100 Carp::croak(
101 "Could not find a suitable $package implementation: $err");
102 }
103 else {
104 Carp::croak(
105 'Module::Runtime failed to load a module but did not throw a real error. This should never happen. Something is very broken'
106 );
107 }
108 }
109}
110
111
# spent 100µs (93+7) within Module::Implementation::_copy_symbols which was called 3 times, avg 33µs/call: # 3 times (93µs+7µs) by Module::Implementation::__ANON__[/usr/share/perl5/Module/Implementation.pm:47] at line 44, avg 33µs/call
sub _copy_symbols {
11231µs my $from_package = shift;
1133600ns my $to_package = shift;
11431µs my $symbols = shift;
115
116311µs for my $sym ( @{$symbols} ) {
1171733µs177µs my $type = $sym =~ s/^([\$\@\%\&\*])// ? $1 : '&';
# spent 7µs making 17 calls to Module::Implementation::CORE:subst, avg 412ns/call
118
119177µs my $from = "${from_package}::$sym";
120175µs my $to = "${to_package}::$sym";
121
122 {
1231930µs224µs
# spent 15µs (6+9) within Module::Implementation::BEGIN@123 which was called: # once (6µs+9µs) by Class::Load::BEGIN@11 at line 123
no strict 'refs';
# spent 15µs making 1 call to Module::Implementation::BEGIN@123 # spent 9µs making 1 call to strict::unimport
124278µs229µs
# spent 17µs (6+11) within Module::Implementation::BEGIN@124 which was called: # once (6µs+11µs) by Class::Load::BEGIN@11 at line 124
no warnings 'once';
# spent 17µs making 1 call to Module::Implementation::BEGIN@124 # spent 11µs making 1 call to warnings::unimport
125
126 # Copied from Exporter
127 *{$to}
128 = $type eq '&' ? \&{$from}
129 : $type eq '$' ? \${$from}
130 : $type eq '@' ? \@{$from}
131 : $type eq '%' ? \%{$from}
1321736µs : $type eq '*' ? *{$from}
133 : die
134 "Can't copy symbol from $from_package to $to_package: $type$sym";
135 }
136 }
137}
138
13913µs1;
140
141# ABSTRACT: Loads one of several alternate underlying implementations for a module
142
143__END__
 
# spent 16µs within Module::Implementation::CORE:subst which was called 20 times, avg 795ns/call: # 17 times (7µs+0s) by Module::Implementation::_copy_symbols at line 117, avg 412ns/call # 3 times (9µs+0s) by Module::Implementation::_build_loader at line 32, avg 3µs/call
sub Module::Implementation::CORE:subst; # opcode