← Index
NYTProf Performance Profile   « line view »
For flows_to_es.pl
  Run on Mon May 9 23:27:59 2016
Reported on Mon May 9 23:28:09 2016

Filename/usr/share/perl5/Module/Implementation.pm
StatementsExecuted 142 statements in 1.17ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
21180µs88µsModule::Implementation::::_copy_symbolsModule::Implementation::_copy_symbols
21141µs2.59msModule::Implementation::::_load_implementationModule::Implementation::_load_implementation
21132µs38µsModule::Implementation::::_build_loaderModule::Implementation::_build_loader
22222µs2.70msModule::Implementation::::__ANON__[:47]Module::Implementation::__ANON__[:47]
11119µs43µsModule::Implementation::::BEGIN@12Module::Implementation::BEGIN@12
142115µs15µsModule::Implementation::::CORE:substModule::Implementation::CORE:subst (opcode)
22210µs49µsModule::Implementation::::build_loader_subModule::Implementation::build_loader_sub
11110µs45µsModule::Implementation::::BEGIN@13Module::Implementation::BEGIN@13
1119µs20µsModule::Implementation::::BEGIN@124Module::Implementation::BEGIN@124
1119µs23µsModule::Implementation::::BEGIN@123Module::Implementation::BEGIN@123
1118µs13µsModule::Implementation::::BEGIN@10Module::Implementation::BEGIN@10
1118µs8µsModule::Implementation::::BEGIN@5Module::Implementation::BEGIN@5
1117µs20µ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 8µs within Module::Implementation::BEGIN@5 which was called: # once (8µs+0s) by B::Hooks::EndOfScope::BEGIN@16 at line 7
BEGIN {
616µs $Module::Implementation::AUTHORITY = 'cpan:DROLSKY';
7123µs18µs}
# spent 8µs making 1 call to Module::Implementation::BEGIN@5
8
9227µs233µs
# spent 20µs (7+13) within Module::Implementation::BEGIN@9 which was called: # once (7µs+13µs) by B::Hooks::EndOfScope::BEGIN@16 at line 9
use strict;
# spent 20µs making 1 call to Module::Implementation::BEGIN@9 # spent 13µs making 1 call to strict::import
10236µs218µs
# spent 13µs (8+5) within Module::Implementation::BEGIN@10 which was called: # once (8µs+5µs) by B::Hooks::EndOfScope::BEGIN@16 at line 10
use warnings;
# spent 13µs making 1 call to Module::Implementation::BEGIN@10 # spent 5µs making 1 call to warnings::import
11
12352µs367µs
# spent 43µs (19+24) within Module::Implementation::BEGIN@12 which was called: # once (19µs+24µs) by B::Hooks::EndOfScope::BEGIN@16 at line 12
use Module::Runtime 0.012 qw( require_module );
# spent 43µs making 1 call to Module::Implementation::BEGIN@12 # spent 14µs making 1 call to Module::Runtime::import # spent 10µs making 1 call to UNIVERSAL::VERSION
132662µs280µs
# spent 45µs (10+35) within Module::Implementation::BEGIN@13 which was called: # once (10µs+35µs) by B::Hooks::EndOfScope::BEGIN@16 at line 13
use Try::Tiny;
# spent 45µs making 1 call to Module::Implementation::BEGIN@13 # spent 35µs making 1 call to Exporter::import
14
151200nsmy %Implementation;
16
17
# spent 49µs (10+38) within Module::Implementation::build_loader_sub which was called 2 times, avg 24µs/call: # once (6µs+20µs) by B::Hooks::EndOfScope::BEGIN@15 at line 17 of /opt/flows/lib/lib/perl5/B/Hooks/EndOfScope.pm # once (5µs+19µs) by Package::Stash::BEGIN@17 at line 21 of Package/Stash.pm
sub build_loader_sub {
1822µs my $caller = caller();
19
2029µs238µs return _build_loader( $caller, @_ );
# spent 38µs making 2 calls to Module::Implementation::_build_loader, avg 19µs/call
21}
22
23
# spent 38µs (32+7) within Module::Implementation::_build_loader which was called 2 times, avg 19µs/call: # 2 times (32µs+7µs) by Module::Implementation::build_loader_sub at line 20, avg 19µs/call
sub _build_loader {
242700ns my $package = shift;
2523µs my %args = @_;
26
2723µs my @implementations = @{ $args{implementations} };
2823µs my @symbols = @{ $args{symbols} || [] };
29
302200ns my $implementation;
3121µs my $env_var = uc $package;
32217µs27µs $env_var =~ s/::/_/g;
# spent 7µs making 2 calls to Module::Implementation::CORE:subst, avg 3µs/call
3321µs $env_var .= '_IMPLEMENTATION';
34
35
# spent 2.70ms (22µs+2.68) within Module::Implementation::__ANON__[/usr/share/perl5/Module/Implementation.pm:47] which was called 2 times, avg 1.35ms/call: # once (12µs+2.04ms) by B::Hooks::EndOfScope::BEGIN@15 at line 17 of /opt/flows/lib/lib/perl5/B/Hooks/EndOfScope.pm # once (10µs+643µs) by Package::Stash::BEGIN@17 at line 21 of Package/Stash.pm
return sub {
3627µs22.59ms my ( $implementation, $loaded ) = _load_implementation(
# spent 2.59ms making 2 calls to Module::Implementation::_load_implementation, avg 1.29ms/call
37 $package,
38 $ENV{$env_var},
39 \@implementations,
40 );
41
4222µs $Implementation{$package} = $implementation;
43
4424µs288µs _copy_symbols( $loaded, $package, \@symbols );
# spent 88µs making 2 calls to Module::Implementation::_copy_symbols, avg 44µs/call
45
4626µs return $loaded;
47213µ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.59ms (41µs+2.55) within Module::Implementation::_load_implementation which was called 2 times, avg 1.29ms/call: # 2 times (41µs+2.55ms) by Module::Implementation::__ANON__[/usr/share/perl5/Module/Implementation.pm:47] at line 36, avg 1.29ms/call
sub _load_implementation {
572700ns my $package = shift;
5822µs my $env_value = shift;
592300ns my $implementations = shift;
60
612700ns 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 {
822200ns my $err;
8322µs for my $possible ( @{$implementations} ) {
8422µs my $try = "${package}::$possible";
85
862100ns my $ok;
87 try {
8824µs22.48ms require_module($try);
# spent 2.48ms making 2 calls to Module::Runtime::require_module, avg 1.24ms/call
8925µs $ok = 1;
90 }
91 catch {
92 $err .= $_ if defined $_;
93222µs42.55ms };
# spent 2.54ms making 2 calls to Try::Tiny::try, avg 1.27ms/call # spent 10µs making 2 calls to Try::Tiny::catch, avg 5µs/call
94
9529µ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 88µs (80+8) within Module::Implementation::_copy_symbols which was called 2 times, avg 44µs/call: # 2 times (80µs+8µs) by Module::Implementation::__ANON__[/usr/share/perl5/Module/Implementation.pm:47] at line 44, avg 44µs/call
sub _copy_symbols {
1122600ns my $from_package = shift;
1132400ns my $to_package = shift;
1142300ns my $symbols = shift;
115
11628µs for my $sym ( @{$symbols} ) {
1171232µs128µs my $type = $sym =~ s/^([\$\@\%\&\*])// ? $1 : '&';
# spent 8µs making 12 calls to Module::Implementation::CORE:subst, avg 667ns/call
118
119125µs my $from = "${from_package}::$sym";
120123µs my $to = "${to_package}::$sym";
121
122 {
1231440µs236µs
# spent 23µs (9+14) within Module::Implementation::BEGIN@123 which was called: # once (9µs+14µs) by B::Hooks::EndOfScope::BEGIN@16 at line 123
no strict 'refs';
# spent 23µs making 1 call to Module::Implementation::BEGIN@123 # spent 14µs making 1 call to strict::unimport
1242113µs231µs
# spent 20µs (9+11) within Module::Implementation::BEGIN@124 which was called: # once (9µs+11µs) by B::Hooks::EndOfScope::BEGIN@16 at line 124
no warnings 'once';
# spent 20µ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}
1321233µ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 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 667ns/call # 2 times (7µs+0s) by Module::Implementation::_build_loader at line 32, avg 3µs/call
sub Module::Implementation::CORE:subst; # opcode