← Index
NYTProf Performance Profile   « line view »
For /home/ss5/perl5/perlbrew/perls/perl-5.22.0/bin/benchmarkanything-storage
  Run on Mon Jan 29 16:55:34 2018
Reported on Mon Jan 29 16:57:06 2018

Filename/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Module/Implementation.pm
StatementsExecuted 177 statements in 830µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111600µs1.01msModule::Implementation::::BEGIN@9Module::Implementation::BEGIN@9
31161µs64µsModule::Implementation::::_copy_symbolsModule::Implementation::_copy_symbols
31148µs2.01msModule::Implementation::::_load_implementationModule::Implementation::_load_implementation
31139µs44µsModule::Implementation::::_build_loaderModule::Implementation::_build_loader
33327µs2.11msModule::Implementation::::__ANON__[:52]Module::Implementation::__ANON__[:52]
33315µs59µsModule::Implementation::::build_loader_subModule::Implementation::build_loader_sub
31112µs1.86msModule::Implementation::::try {...} Module::Implementation::try {...}
11111µs13µsModule::Implementation::::BEGIN@5Module::Implementation::BEGIN@5
11110µs32µsModule::Implementation::::BEGIN@8Module::Implementation::BEGIN@8
16219µs9µsModule::Implementation::::CORE:substModule::Implementation::CORE:subst (opcode)
1117µs25µsModule::Implementation::::BEGIN@129Module::Implementation::BEGIN@129
1116µs22µsModule::Implementation::::BEGIN@128Module::Implementation::BEGIN@128
1116µs14µ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
31400ns$Module::Implementation::VERSION = '0.09';
4
5251µs216µs
# spent 13µs (11+3) within Module::Implementation::BEGIN@5 which was called: # once (11µs+3µs) by Class::Load::BEGIN@11 at line 5
use strict;
# spent 13µs making 1 call to Module::Implementation::BEGIN@5 # spent 3µs making 1 call to strict::import
6218µs223µs
# spent 14µs (6+8) within Module::Implementation::BEGIN@6 which was called: # once (6µs+8µs) by Class::Load::BEGIN@11 at line 6
use warnings;
# spent 14µs making 1 call to Module::Implementation::BEGIN@6 # spent 8µs making 1 call to warnings::import
7
8328µs355µs
# spent 32µs (10+22) within Module::Implementation::BEGIN@8 which was called: # once (10µs+22µs) by Class::Load::BEGIN@11 at line 8
use Module::Runtime 0.012 qw( require_module );
# spent 32µs making 1 call to Module::Implementation::BEGIN@8 # spent 16µs making 1 call to Module::Runtime::import # spent 6µs making 1 call to UNIVERSAL::VERSION
92426µs21.04ms
# spent 1.01ms (600µs+410µs) within Module::Implementation::BEGIN@9 which was called: # once (600µs+410µs) by Class::Load::BEGIN@11 at line 9
use Try::Tiny;
# spent 1.01ms making 1 call to Module::Implementation::BEGIN@9 # spent 28µ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.
141500nsunless ( exists $Module::Implementation::{VERSION}
15 && ${ $Module::Implementation::{VERSION} } ) {
16
17 $Module::Implementation::{VERSION} = \42;
18}
19
201100nsmy %Implementation;
21
22
# spent 59µs (15+44) within Module::Implementation::build_loader_sub which was called 3 times, avg 20µs/call: # once (6µs+14µs) by Package::Stash::BEGIN@15 at line 19 of Package/Stash.pm # once (4µs+15µs) by B::Hooks::EndOfScope::BEGIN@15 at line 17 of B/Hooks/EndOfScope.pm # once (4µs+15µs) by Moose::BEGIN@12 at line 16 of Class/Load.pm
sub build_loader_sub {
2332µs my $caller = caller();
24
25312µs344µs return _build_loader( $caller, @_ );
# spent 44µs making 3 calls to Module::Implementation::_build_loader, avg 15µs/call
26}
27
28
# spent 44µs (39+5) within Module::Implementation::_build_loader which was called 3 times, avg 15µs/call: # 3 times (39µs+5µs) by Module::Implementation::build_loader_sub at line 25, avg 15µs/call
sub _build_loader {
2931µs my $package = shift;
3035µs my %args = @_;
31
3234µs my @implementations = @{ $args{implementations} };
3332µs my @symbols = @{ $args{symbols} || [] };
34
353500ns my $implementation;
3633µs my $env_var = uc $package;
37316µs35µs $env_var =~ s/::/_/g;
# spent 5µs making 3 calls to Module::Implementation::CORE:subst, avg 2µs/call
3832µs $env_var .= '_IMPLEMENTATION';
39
40
# spent 2.11ms (27µs+2.08) within Module::Implementation::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Module/Implementation.pm:52] which was called 3 times, avg 702µs/call: # once (10µs+1.16ms) by B::Hooks::EndOfScope::BEGIN@15 at line 17 of B/Hooks/EndOfScope.pm # once (10µs+464µs) by Moose::BEGIN@12 at line 21 of Class/Load.pm # once (8µs+452µs) by Package::Stash::BEGIN@15 at line 19 of Package/Stash.pm
return sub {
41 my ( $implementation, $loaded ) = _load_implementation(
42 $package,
43310µs32.01ms $ENV{$env_var},
# spent 2.01ms making 3 calls to Module::Implementation::_load_implementation, avg 671µs/call
44 \@implementations,
45 );
46
4732µs $Implementation{$package} = $implementation;
48
4935µs364µs _copy_symbols( $loaded, $package, \@symbols );
# spent 64µs making 3 calls to Module::Implementation::_copy_symbols, avg 21µs/call
50
5136µs return $loaded;
52314µs };
53}
54
55
# spent 2µs within Module::Implementation::implementation_for which was called: # once (2µs+0s) by Package::Stash::BEGIN@15 at line 35 of Package/Stash.pm
sub implementation_for {
561300ns my $package = shift;
57
5813µs return $Implementation{$package};
59}
60
61
# spent 2.01ms (48µs+1.97) within Module::Implementation::_load_implementation which was called 3 times, avg 671µs/call: # 3 times (48µs+1.97ms) by Module::Implementation::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Module/Implementation.pm:52] at line 43, avg 671µs/call
sub _load_implementation {
6231µs my $package = shift;
6332µs my $env_value = shift;
643700ns my $implementations = shift;
65
663900ns 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 {
873500ns my $err;
8833µs for my $possible ( @{$implementations} ) {
8932µs my $try = "${package}::$possible";
90
913100ns my $ok;
92
# spent 1.86ms (12µs+1.85) within Module::Implementation::try {...} which was called 3 times, avg 620µs/call: # 3 times (12µs+1.85ms) by Try::Tiny::try at line 92 of Try/Tiny.pm, avg 620µs/call
try {
9337µs31.85ms require_module($try);
# spent 1.85ms making 3 calls to Module::Runtime::require_module, avg 616µs/call
9436µs $ok = 1;
95 }
96 catch {
97 $err .= $_ if defined $_;
98328µs61.97ms };
# spent 1.91ms making 3 calls to Try::Tiny::try, avg 638µs/call # spent 51µs making 3 calls to Try::Tiny::catch, avg 17µs/call
99
100310µ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 64µs (61+4) within Module::Implementation::_copy_symbols which was called 3 times, avg 21µs/call: # 3 times (61µs+4µs) by Module::Implementation::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Module/Implementation.pm:52] at line 49, avg 21µs/call
sub _copy_symbols {
11731µs my $from_package = shift;
11831µs my $to_package = shift;
1193500ns my $symbols = shift;
120
12139µs for my $sym ( @{$symbols} ) {
1221319µs134µs my $type = $sym =~ s/^([\$\@\%\&\*])// ? $1 : '&';
# spent 4µs making 13 calls to Module::Implementation::CORE:subst, avg 285ns/call
123
124135µs my $from = "${from_package}::$sym";
125133µs my $to = "${to_package}::$sym";
126
127 {
1281526µs238µs
# spent 22µs (6+16) within Module::Implementation::BEGIN@128 which was called: # once (6µs+16µs) by Class::Load::BEGIN@11 at line 128
no strict 'refs';
# spent 22µs making 1 call to Module::Implementation::BEGIN@128 # spent 16µs making 1 call to strict::unimport
129267µs242µs
# spent 25µs (7+18) within Module::Implementation::BEGIN@129 which was called: # once (7µs+18µs) by Class::Load::BEGIN@11 at line 129
no warnings 'once';
# spent 25µs making 1 call to Module::Implementation::BEGIN@129 # spent 18µ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}
1371322µ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 9µs within Module::Implementation::CORE:subst which was called 16 times, avg 550ns/call: # 13 times (4µs+0s) by Module::Implementation::_copy_symbols at line 122, avg 285ns/call # 3 times (5µs+0s) by Module::Implementation::_build_loader at line 37, avg 2µs/call
sub Module::Implementation::CORE:subst; # opcode