← Index
NYTProf Performance Profile   « line view »
For index.cgi
  Run on Sat May 9 17:18:47 2020
Reported on Sat May 9 17:19:07 2020

Filename/usr/local/share/perl/5.18.2/Module/Implementation.pm
StatementsExecuted 141 statements in 1.55ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.07ms3.65msModule::Implementation::::BEGIN@9Module::Implementation::BEGIN@9
21197µs106µsModule::Implementation::::_copy_symbolsModule::Implementation::_copy_symbols
21154µs4.26msModule::Implementation::::_load_implementationModule::Implementation::_load_implementation
21142µs51µsModule::Implementation::::_build_loaderModule::Implementation::_build_loader
22229µs4.39msModule::Implementation::::__ANON__[:52]Module::Implementation::__ANON__[:52]
142118µs18µsModule::Implementation::::CORE:substModule::Implementation::CORE:subst (opcode)
11118µs34µsModule::Implementation::::BEGIN@5Module::Implementation::BEGIN@5
11117µs48µsModule::Implementation::::BEGIN@8Module::Implementation::BEGIN@8
22212µs63µsModule::Implementation::::build_loader_subModule::Implementation::build_loader_sub
21112µs4.10msModule::Implementation::::try {...} Module::Implementation::try {...}
11111µs25µsModule::Implementation::::BEGIN@129Module::Implementation::BEGIN@129
11110µs27µsModule::Implementation::::BEGIN@128Module::Implementation::BEGIN@128
1119µs14µsModule::Implementation::::BEGIN@6Module::Implementation::BEGIN@6
1113µs3µsModule::Implementation::::implementation_forModule::Implementation::implementation_for
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 {...}
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
31700ns$Module::Implementation::VERSION = '0.09';
4
5231µs251µs
# spent 34µs (18+17) within Module::Implementation::BEGIN@5 which was called: # once (18µs+17µs) by B::Hooks::EndOfScope::BEGIN@16 at line 5
use strict;
# spent 34µs making 1 call to Module::Implementation::BEGIN@5 # spent 17µs making 1 call to strict::import
6234µs219µs
# spent 14µs (9+5) within Module::Implementation::BEGIN@6 which was called: # once (9µs+5µs) by B::Hooks::EndOfScope::BEGIN@16 at line 6
use warnings;
# spent 14µs making 1 call to Module::Implementation::BEGIN@6 # spent 5µs making 1 call to warnings::import
7
8355µs378µs
# spent 48µs (17+30) within Module::Implementation::BEGIN@8 which was called: # once (17µs+30µs) by B::Hooks::EndOfScope::BEGIN@16 at line 8
use Module::Runtime 0.012 qw( require_module );
# spent 48µs making 1 call to Module::Implementation::BEGIN@8 # spent 16µs making 1 call to Module::Runtime::import # spent 14µs making 1 call to UNIVERSAL::VERSION
92990µs23.70ms
# spent 3.65ms (1.07+2.58) within Module::Implementation::BEGIN@9 which was called: # once (1.07ms+2.58ms) by B::Hooks::EndOfScope::BEGIN@16 at line 9
use Try::Tiny;
# spent 3.65ms 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.
1412µsunless ( exists $Module::Implementation::{VERSION}
15 && ${ $Module::Implementation::{VERSION} } ) {
16
17 $Module::Implementation::{VERSION} = \42;
18}
19
201300nsmy %Implementation;
21
22
# spent 63µs (12+51) within Module::Implementation::build_loader_sub which was called 2 times, avg 32µs/call: # once (7µs+30µs) by B::Hooks::EndOfScope::BEGIN@15 at line 17 of B/Hooks/EndOfScope.pm # once (5µs+22µs) by Package::Stash::BEGIN@15 at line 19 of Package/Stash.pm
sub build_loader_sub {
2322µs my $caller = caller();
24
25211µs251µs return _build_loader( $caller, @_ );
# spent 51µs making 2 calls to Module::Implementation::_build_loader, avg 26µs/call
26}
27
28
# spent 51µs (42+9) within Module::Implementation::_build_loader which was called 2 times, avg 26µs/call: # 2 times (42µs+9µs) by Module::Implementation::build_loader_sub at line 25, avg 26µs/call
sub _build_loader {
2921µs my $package = shift;
3024µs my %args = @_;
31
3223µs my @implementations = @{ $args{implementations} };
3323µs my @symbols = @{ $args{symbols} || [] };
34
352400ns my $implementation;
3626µs my $env_var = uc $package;
37220µs29µs $env_var =~ s/::/_/g;
# spent 9µs making 2 calls to Module::Implementation::CORE:subst, avg 5µs/call
3821µs $env_var .= '_IMPLEMENTATION';
39
40
# spent 4.39ms (29µs+4.36) within Module::Implementation::__ANON__[/usr/local/share/perl/5.18.2/Module/Implementation.pm:52] which was called 2 times, avg 2.20ms/call: # once (17µs+3.55ms) by B::Hooks::EndOfScope::BEGIN@15 at line 17 of B/Hooks/EndOfScope.pm # once (12µs+809µs) by Package::Stash::BEGIN@15 at line 19 of Package/Stash.pm
return sub {
41210µs24.26ms my ( $implementation, $loaded ) = _load_implementation(
# spent 4.26ms making 2 calls to Module::Implementation::_load_implementation, avg 2.13ms/call
42 $package,
43 $ENV{$env_var},
44 \@implementations,
45 );
46
4722µs $Implementation{$package} = $implementation;
48
4925µs2106µs _copy_symbols( $loaded, $package, \@symbols );
# spent 106µs making 2 calls to Module::Implementation::_copy_symbols, avg 53µs/call
50
5127µs return $loaded;
52216µs };
53}
54
55
# spent 3µs within Module::Implementation::implementation_for which was called: # once (3µs+0s) by Package::Stash::BEGIN@15 at line 35 of Package/Stash.pm
sub implementation_for {
561400ns my $package = shift;
57
5814µs return $Implementation{$package};
59}
60
61
# spent 4.26ms (54µs+4.20) within Module::Implementation::_load_implementation which was called 2 times, avg 2.13ms/call: # 2 times (54µs+4.20ms) by Module::Implementation::__ANON__[/usr/local/share/perl/5.18.2/Module/Implementation.pm:52] at line 41, avg 2.13ms/call
sub _load_implementation {
622900ns my $package = shift;
6322µs my $env_value = shift;
642400ns my $implementations = shift;
65
662900ns 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 {
872500ns my $err;
8822µs for my $possible ( @{$implementations} ) {
8922µs my $try = "${package}::$possible";
90
912300ns my $ok;
92
# spent 4.10ms (12µs+4.09) within Module::Implementation::try {...} which was called 2 times, avg 2.05ms/call: # 2 times (12µs+4.09ms) by Try::Tiny::try at line 81 of Try/Tiny.pm, avg 2.05ms/call
try {
9325µs24.09ms require_module($try);
# spent 4.09ms making 2 calls to Module::Runtime::require_module, avg 2.04ms/call
9426µs $ok = 1;
95 }
96 catch {
97 $err .= $_ if defined $_;
98231µs44.20ms };
# spent 4.19ms making 2 calls to Try::Tiny::try, avg 2.10ms/call # spent 12µs making 2 calls to Try::Tiny::catch, avg 6µs/call
99
100211µ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 106µs (97+9) within Module::Implementation::_copy_symbols which was called 2 times, avg 53µs/call: # 2 times (97µs+9µs) by Module::Implementation::__ANON__[/usr/local/share/perl/5.18.2/Module/Implementation.pm:52] at line 49, avg 53µs/call
sub _copy_symbols {
11721µs my $from_package = shift;
1182500ns my $to_package = shift;
1192500ns my $symbols = shift;
120
12129µs for my $sym ( @{$symbols} ) {
1221238µs129µs my $type = $sym =~ s/^([\$\@\%\&\*])// ? $1 : '&';
# spent 9µs making 12 calls to Module::Implementation::CORE:subst, avg 758ns/call
123
124126µs my $from = "${from_package}::$sym";
125125µs my $to = "${to_package}::$sym";
126
127 {
1281447µs244µs
# spent 27µs (10+17) within Module::Implementation::BEGIN@128 which was called: # once (10µs+17µs) by B::Hooks::EndOfScope::BEGIN@16 at line 128
no strict 'refs';
# spent 27µs making 1 call to Module::Implementation::BEGIN@128 # spent 17µs making 1 call to strict::unimport
1292132µs239µs
# spent 25µs (11+14) within Module::Implementation::BEGIN@129 which was called: # once (11µs+14µs) by B::Hooks::EndOfScope::BEGIN@16 at line 129
no warnings 'once';
# spent 25µs making 1 call to Module::Implementation::BEGIN@129 # spent 14µ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}
1371238µs : $type eq '*' ? *{$from}
138 : die
139 "Can't copy symbol from $from_package to $to_package: $type$sym";
140 }
141 }
142}
143
14415µs1;
145
146# ABSTRACT: Loads one of several alternate underlying implementations for a module
147
148__END__
 
# spent 18µs within Module::Implementation::CORE:subst which was called 14 times, avg 1µs/call: # 12 times (9µs+0s) by Module::Implementation::_copy_symbols at line 122, avg 758ns/call # 2 times (9µs+0s) by Module::Implementation::_build_loader at line 37, avg 5µs/call
sub Module::Implementation::CORE:subst; # opcode