← 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:40 2014

Filename/opt/perl-5.18.1/lib/site_perl/5.18.1/Module/Implementation.pm
StatementsExecuted 148 statements in 1.60ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.88ms2.04msModule::Implementation::::BEGIN@12Module::Implementation::BEGIN@12
1111.07ms3.82msModule::Implementation::::BEGIN@13Module::Implementation::BEGIN@13
21188µs96µsModule::Implementation::::_copy_symbolsModule::Implementation::_copy_symbols
21176µs2.44msModule::Implementation::::_load_implementationModule::Implementation::_load_implementation (recurses: max depth 1, inclusive time 770µs)
21140µs48µsModule::Implementation::::_build_loaderModule::Implementation::_build_loader
22226µs3.33msModule::Implementation::::__ANON__[:47]Module::Implementation::__ANON__[:47]
11116µs31µsModule::Implementation::::BEGIN@124Module::Implementation::BEGIN@124
142115µs15µsModule::Implementation::::CORE:substModule::Implementation::CORE:subst (opcode)
22212µs60µsModule::Implementation::::build_loader_subModule::Implementation::build_loader_sub
11111µs11µsModule::Implementation::::BEGIN@5Module::Implementation::BEGIN@5
11110µs24µsModule::Implementation::::BEGIN@123Module::Implementation::BEGIN@123
1119µs13µsModule::Implementation::::BEGIN@10Module::Implementation::BEGIN@10
1119µs24µ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{
321µs $Module::Implementation::VERSION = '0.07';
4}
5
# spent 11µs within Module::Implementation::BEGIN@5 which was called: # once (11µs+0s) by Class::Load::BEGIN@9 at line 7
BEGIN {
616µs $Module::Implementation::AUTHORITY = 'cpan:DROLSKY';
7127µs111µs}
# spent 11µs making 1 call to Module::Implementation::BEGIN@5
8
9230µs239µs
# spent 24µs (9+15) within Module::Implementation::BEGIN@9 which was called: # once (9µs+15µs) by Class::Load::BEGIN@9 at line 9
use strict;
# spent 24µs making 1 call to Module::Implementation::BEGIN@9 # spent 15µs making 1 call to strict::import
10237µs218µs
# spent 13µs (9+5) within Module::Implementation::BEGIN@10 which was called: # once (9µs+5µs) by Class::Load::BEGIN@9 at line 10
use warnings;
# spent 13µs making 1 call to Module::Implementation::BEGIN@10 # spent 4µs making 1 call to warnings::import
11
123237µs32.06ms
# spent 2.04ms (1.88+160µs) within Module::Implementation::BEGIN@12 which was called: # once (1.88ms+160µs) by Class::Load::BEGIN@9 at line 12
use Module::Runtime 0.012 qw( require_module );
# spent 2.04ms making 1 call to Module::Implementation::BEGIN@12 # spent 17µs making 1 call to Module::Runtime::import # spent 11µs making 1 call to UNIVERSAL::VERSION
132815µs23.86ms
# spent 3.82ms (1.07+2.75) within Module::Implementation::BEGIN@13 which was called: # once (1.07ms+2.75ms) by Class::Load::BEGIN@9 at line 13
use Try::Tiny;
# spent 3.82ms making 1 call to Module::Implementation::BEGIN@13 # spent 40µs making 1 call to Exporter::import
14
151100nsmy %Implementation;
16
17
# spent 60µs (12+48) within Module::Implementation::build_loader_sub which was called 2 times, avg 30µs/call: # once (7µs+28µs) by Moose::BEGIN@15 at line 19 of Class/Load.pm # once (5µs+20µs) by Package::Stash::BEGIN@17 at line 21 of Package/Stash.pm
sub build_loader_sub {
1822µs my $caller = caller();
19
20210µs248µs return _build_loader( $caller, @_ );
# spent 48µs making 2 calls to Module::Implementation::_build_loader, avg 24µs/call
21}
22
23
# spent 48µs (40+7) within Module::Implementation::_build_loader which was called 2 times, avg 24µs/call: # 2 times (40µs+7µs) by Module::Implementation::build_loader_sub at line 20, avg 24µs/call
sub _build_loader {
242600ns my $package = shift;
2523µs my %args = @_;
26
2723µs my @implementations = @{ $args{implementations} };
2823µs my @symbols = @{ $args{symbols} || [] };
29
302200ns my $implementation;
3125µs my $env_var = uc $package;
32219µs27µs $env_var =~ s/::/_/g;
# spent 7µs making 2 calls to Module::Implementation::CORE:subst, avg 4µs/call
3322µs $env_var .= '_IMPLEMENTATION';
34
35
# spent 3.33ms (26µs+3.30) within Module::Implementation::__ANON__[/opt/perl-5.18.1/lib/site_perl/5.18.1/Module/Implementation.pm:47] which was called 2 times, avg 1.66ms/call: # once (11µs+2.45ms) by Moose::BEGIN@15 at line 24 of Class/Load.pm # once (15µs+853µs) by Package::Stash::BEGIN@17 at line 21 of Package/Stash.pm
return sub {
36210µs22.44ms my ( $implementation, $loaded ) = _load_implementation(
# spent 3.21ms making 2 calls to Module::Implementation::_load_implementation, avg 1.60ms/call, recursion: max depth 1, sum of overlapping time 770µs
37 $package,
38 $ENV{$env_var},
39 \@implementations,
40 );
41
4222µs $Implementation{$package} = $implementation;
43
4424µs296µs _copy_symbols( $loaded, $package, \@symbols );
# spent 96µs making 2 calls to Module::Implementation::_copy_symbols, avg 48µs/call
45
4628µs return $loaded;
47215µ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 2.44ms (76µs+2.36) within Module::Implementation::_load_implementation which was called 2 times, avg 1.22ms/call: # 2 times (76µs+2.36ms) by Module::Implementation::__ANON__[/opt/perl-5.18.1/lib/site_perl/5.18.1/Module/Implementation.pm:47] at line 36, avg 1.22ms/call
sub _load_implementation {
572700ns my $package = shift;
5822µs my $env_value = shift;
592200ns my $implementations = shift;
60
612500ns 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 {
822100ns my $err;
8321µs for my $possible ( @{$implementations} ) {
8432µs my $try = "${package}::$possible";
85
863100ns my $ok;
87 try {
8836µs32.28ms require_module($try);
# spent 2.99ms making 3 calls to Module::Runtime::require_module, avg 995µs/call, recursion: max depth 1, sum of overlapping time 704µs
8924µs $ok = 1;
90 }
91 catch {
92111µs $err .= $_ if defined $_;
93345µs62.39ms };
# spent 3.12ms making 3 calls to Try::Tiny::try, avg 1.04ms/call, recursion: max depth 1, sum of overlapping time 745µs # spent 12µs making 3 calls to Try::Tiny::catch, avg 4µs/call
94
95311µ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 96µs (88+8) within Module::Implementation::_copy_symbols which was called 2 times, avg 48µs/call: # 2 times (88µs+8µs) by Module::Implementation::__ANON__[/opt/perl-5.18.1/lib/site_perl/5.18.1/Module/Implementation.pm:47] at line 44, avg 48µs/call
sub _copy_symbols {
1122700ns my $from_package = shift;
1132400ns my $to_package = shift;
1142300ns my $symbols = shift;
115
11628µs for my $sym ( @{$symbols} ) {
1171231µs128µs my $type = $sym =~ s/^([\$\@\%\&\*])// ? $1 : '&';
# spent 8µs making 12 calls to Module::Implementation::CORE:subst, avg 633ns/call
118
119125µs my $from = "${from_package}::$sym";
120123µs my $to = "${to_package}::$sym";
121
122 {
1231443µs239µs
# spent 24µs (10+14) within Module::Implementation::BEGIN@123 which was called: # once (10µs+14µs) by Class::Load::BEGIN@9 at line 123
no strict 'refs';
# spent 24µs making 1 call to Module::Implementation::BEGIN@123 # spent 14µs making 1 call to strict::unimport
1242137µs246µs
# spent 31µs (16+15) within Module::Implementation::BEGIN@124 which was called: # once (16µs+15µs) by Class::Load::BEGIN@9 at line 124
no warnings 'once';
# spent 31µs making 1 call to Module::Implementation::BEGIN@124 # spent 15µ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}
1321235µs : $type eq '*' ? *{$from}
133 : die
134 "Can't copy symbol from $from_package to $to_package: $type$sym";
135 }
136 }
137}
138
13914µs1;
140
141# ABSTRACT: Loads one of several alternate underlying implementations for a module
142
143__END__
 
# spent 15µs within Module::Implementation::CORE:subst which was called 14 times, avg 1µs/call: # 12 times (8µs+0s) by Module::Implementation::_copy_symbols at line 117, avg 633ns/call # 2 times (7µs+0s) by Module::Implementation::_build_loader at line 32, avg 4µs/call
sub Module::Implementation::CORE:subst; # opcode