← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Thu Dec 15 15:23:56 2022
Reported on Thu Dec 15 15:27:03 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Module/Implementation.pm
StatementsExecuted 141 statements in 1.75ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.42ms1.60msModule::Implementation::::BEGIN@9Module::Implementation::BEGIN@9
21142µs50µsModule::Implementation::::_copy_symbolsModule::Implementation::_copy_symbols
21137µs12.5msModule::Implementation::::_load_implementationModule::Implementation::_load_implementation
21123µs29µsModule::Implementation::::_build_loaderModule::Implementation::_build_loader
11119µs21µsModule::Implementation::::BEGIN@5Module::Implementation::BEGIN@5
22219µs12.6msModule::Implementation::::__ANON__[:52]Module::Implementation::__ANON__[:52]
21115µs12.4msModule::Implementation::::try {...} Module::Implementation::try {...}
142114µs14µsModule::Implementation::::CORE:substModule::Implementation::CORE:subst (opcode)
11113µs31µsModule::Implementation::::BEGIN@8Module::Implementation::BEGIN@8
2228µs37µsModule::Implementation::::build_loader_subModule::Implementation::build_loader_sub
1118µs14µsModule::Implementation::::BEGIN@128Module::Implementation::BEGIN@128
1117µs26µsModule::Implementation::::BEGIN@129Module::Implementation::BEGIN@129
1113µs54µsModule::Implementation::::BEGIN@6Module::Implementation::BEGIN@6
1112µs2µ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
311µs$Module::Implementation::VERSION = '0.09';
4
5225µs223µs
# spent 21µs (19+2) within Module::Implementation::BEGIN@5 which was called: # once (19µs+2µs) by B::Hooks::EndOfScope::BEGIN@13 at line 5
use strict;
# spent 21µs making 1 call to Module::Implementation::BEGIN@5 # spent 2µs making 1 call to strict::import
6216µs2105µs
# spent 54µs (3+51) within Module::Implementation::BEGIN@6 which was called: # once (3µs+51µs) by B::Hooks::EndOfScope::BEGIN@13 at line 6
use warnings;
# spent 54µs making 1 call to Module::Implementation::BEGIN@6 # spent 51µs making 1 call to warnings::import
7
8330µs349µs
# spent 31µs (13+18) within Module::Implementation::BEGIN@8 which was called: # once (13µs+18µs) by B::Hooks::EndOfScope::BEGIN@13 at line 8
use Module::Runtime 0.012 qw( require_module );
# spent 31µs making 1 call to Module::Implementation::BEGIN@8 # spent 10µs making 1 call to Module::Runtime::import # spent 8µs making 1 call to UNIVERSAL::VERSION
921.34ms21.62ms
# spent 1.60ms (1.42+177µs) within Module::Implementation::BEGIN@9 which was called: # once (1.42ms+177µs) by B::Hooks::EndOfScope::BEGIN@13 at line 9
use Try::Tiny;
# spent 1.60ms making 1 call to Module::Implementation::BEGIN@9 # spent 23µ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
2011µsmy %Implementation;
21
22
# spent 37µs (8+29) within Module::Implementation::build_loader_sub which was called 2 times, avg 19µs/call: # once (5µs+14µs) by B::Hooks::EndOfScope::BEGIN@12 at line 14 of B/Hooks/EndOfScope.pm # once (3µs+15µs) by Package::Stash::BEGIN@12 at line 16 of Package/Stash.pm
sub build_loader_sub {
2322µs my $caller = caller();
24
2527µs229µs return _build_loader( $caller, @_ );
# spent 29µs making 2 calls to Module::Implementation::_build_loader, avg 14µs/call
26}
27
28
# spent 29µs (23+6) within Module::Implementation::_build_loader which was called 2 times, avg 14µs/call: # 2 times (23µs+6µs) by Module::Implementation::build_loader_sub at line 25, avg 14µs/call
sub _build_loader {
2921µs my $package = shift;
3022µs my %args = @_;
31
3222µs my @implementations = @{ $args{implementations} };
3323µs my @symbols = @{ $args{symbols} || [] };
34
3520s my $implementation;
3622µs my $env_var = uc $package;
37210µs26µs $env_var =~ s/::/_/g;
# spent 6µs making 2 calls to Module::Implementation::CORE:subst, avg 3µs/call
3822µs $env_var .= '_IMPLEMENTATION';
39
40
# spent 12.6ms (19µs+12.6) within Module::Implementation::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Module/Implementation.pm:52] which was called 2 times, avg 6.30ms/call: # once (10µs+8.21ms) by B::Hooks::EndOfScope::BEGIN@12 at line 14 of B/Hooks/EndOfScope.pm # once (9µs+4.36ms) by Package::Stash::BEGIN@12 at line 16 of Package/Stash.pm
return sub {
41 my ( $implementation, $loaded ) = _load_implementation(
42 $package,
4327µs212.5ms $ENV{$env_var},
# spent 12.5ms making 2 calls to Module::Implementation::_load_implementation, avg 6.26ms/call
44 \@implementations,
45 );
46
4723µs $Implementation{$package} = $implementation;
48
4923µs250µs _copy_symbols( $loaded, $package, \@symbols );
# spent 50µs making 2 calls to Module::Implementation::_copy_symbols, avg 25µs/call
50
5125µs return $loaded;
5228µs };
53}
54
55
# spent 2µs within Module::Implementation::implementation_for which was called: # once (2µs+0s) by Package::Stash::BEGIN@12 at line 32 of Package/Stash.pm
sub implementation_for {
5611µs my $package = shift;
57
5812µs return $Implementation{$package};
59}
60
61
# spent 12.5ms (37µs+12.5) within Module::Implementation::_load_implementation which was called 2 times, avg 6.26ms/call: # 2 times (37µs+12.5ms) by Module::Implementation::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Module/Implementation.pm:52] at line 43, avg 6.26ms/call
sub _load_implementation {
6221µs my $package = shift;
6322µs my $env_value = shift;
6420s my $implementations = shift;
65
6620s 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 {
8720s my $err;
8821µs for my $possible ( @{$implementations} ) {
8922µs my $try = "${package}::$possible";
90
9120s my $ok;
92
# spent 12.4ms (15µs+12.4) within Module::Implementation::try {...} which was called 2 times, avg 6.21ms/call: # 2 times (15µs+12.4ms) by Try::Tiny::try at line 102 of Try/Tiny.pm, avg 6.21ms/call
try {
9325µs212.4ms require_module($try);
# spent 12.4ms making 2 calls to Module::Runtime::require_module, avg 6.20ms/call
9425µs $ok = 1;
95 }
96 catch {
97 $err .= $_ if defined $_;
98221µs412.5ms };
# spent 12.5ms making 2 calls to Try::Tiny::try, avg 6.23ms/call # spent 23µs making 2 calls to Try::Tiny::catch, avg 12µs/call
99
10028µ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 50µs (42+8) within Module::Implementation::_copy_symbols which was called 2 times, avg 25µs/call: # 2 times (42µs+8µs) by Module::Implementation::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Module/Implementation.pm:52] at line 49, avg 25µs/call
sub _copy_symbols {
11722µs my $from_package = shift;
11820s my $to_package = shift;
11921µs my $symbols = shift;
120
12126µs for my $sym ( @{$symbols} ) {
1221217µs128µs my $type = $sym =~ s/^([\$\@\%\&\*])// ? $1 : '&';
# spent 8µs making 12 calls to Module::Implementation::CORE:subst, avg 667ns/call
123
124121µs my $from = "${from_package}::$sym";
125122µs my $to = "${to_package}::$sym";
126
127 {
1281433µs220µs
# spent 14µs (8+6) within Module::Implementation::BEGIN@128 which was called: # once (8µs+6µs) by B::Hooks::EndOfScope::BEGIN@13 at line 128
no strict 'refs';
# spent 14µs making 1 call to Module::Implementation::BEGIN@128 # spent 6µs making 1 call to strict::unimport
1292145µs245µs
# spent 26µs (7+19) within Module::Implementation::BEGIN@129 which was called: # once (7µs+19µs) by B::Hooks::EndOfScope::BEGIN@13 at line 129
no warnings 'once';
# spent 26µs making 1 call to Module::Implementation::BEGIN@129 # spent 19µ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}
1371220µs : $type eq '*' ? *{$from}
138 : die
139 "Can't copy symbol from $from_package to $to_package: $type$sym";
140 }
141 }
142}
143
14417µs1;
145
146# ABSTRACT: Loads one of several alternate underlying implementations for a module
147
148__END__
 
# spent 14µ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 122, avg 667ns/call # 2 times (6µs+0s) by Module::Implementation::_build_loader at line 37, avg 3µs/call
sub Module::Implementation::CORE:subst; # opcode