← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mentat.storage.mongo.pl
  Run on Tue Jun 24 09:58:41 2014
Reported on Tue Jun 24 09:59:28 2014

Filename/usr/local/share/perl/5.14.2/Module/Implementation.pm
StatementsExecuted 244 statements in 2.78ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1112.98ms3.22msModule::Implementation::::BEGIN@12Module::Implementation::BEGIN@12
1111.77ms5.73msModule::Implementation::::BEGIN@13Module::Implementation::BEGIN@13
311174µs192µsModule::Implementation::::_copy_symbolsModule::Implementation::_copy_symbols
311101µs2.91msModule::Implementation::::_load_implementationModule::Implementation::_load_implementation
31188µs108µsModule::Implementation::::_build_loaderModule::Implementation::_build_loader
33359µs3.16msModule::Implementation::::__ANON__[:47]Module::Implementation::__ANON__[:47]
202138µs38µsModule::Implementation::::CORE:substModule::Implementation::CORE:subst (opcode)
33327µs135µsModule::Implementation::::build_loader_subModule::Implementation::build_loader_sub
11118µs44µsModule::Implementation::::BEGIN@123Module::Implementation::BEGIN@123
11118µs18µsModule::Implementation::::BEGIN@5Module::Implementation::BEGIN@5
11117µs40µsModule::Implementation::::BEGIN@124Module::Implementation::BEGIN@124
11115µs22µsModule::Implementation::::BEGIN@9Module::Implementation::BEGIN@9
11115µs25µsModule::Implementation::::BEGIN@10Module::Implementation::BEGIN@10
1113µs3µ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{
322µs $Module::Implementation::VERSION = '0.07';
4}
5
# spent 18µs within Module::Implementation::BEGIN@5 which was called: # once (18µs+0s) by Params::Validate::BEGIN@12 at line 7
BEGIN {
6110µs $Module::Implementation::AUTHORITY = 'cpan:DROLSKY';
7152µs118µs}
# spent 18µs making 1 call to Module::Implementation::BEGIN@5
8
9254µs229µs
# spent 22µs (15+7) within Module::Implementation::BEGIN@9 which was called: # once (15µs+7µs) by Params::Validate::BEGIN@12 at line 9
use strict;
# spent 22µs making 1 call to Module::Implementation::BEGIN@9 # spent 7µs making 1 call to strict::import
10259µs235µs
# spent 25µs (15+10) within Module::Implementation::BEGIN@10 which was called: # once (15µs+10µs) by Params::Validate::BEGIN@12 at line 10
use warnings;
# spent 25µs making 1 call to Module::Implementation::BEGIN@10 # spent 10µs making 1 call to warnings::import
11
123416µs33.29ms
# spent 3.22ms (2.98+246µs) within Module::Implementation::BEGIN@12 which was called: # once (2.98ms+246µs) by Params::Validate::BEGIN@12 at line 12
use Module::Runtime 0.012 qw( require_module );
# spent 3.22ms making 1 call to Module::Implementation::BEGIN@12 # spent 36µs making 1 call to UNIVERSAL::VERSION # spent 34µs making 1 call to Module::Runtime::import
1321.36ms25.81ms
# spent 5.73ms (1.77+3.96) within Module::Implementation::BEGIN@13 which was called: # once (1.77ms+3.96ms) by Params::Validate::BEGIN@12 at line 13
use Try::Tiny;
# spent 5.73ms making 1 call to Module::Implementation::BEGIN@13 # spent 77µs making 1 call to Exporter::import
14
151400nsmy %Implementation;
16
17
# spent 135µs (27+108) within Module::Implementation::build_loader_sub which was called 3 times, avg 45µs/call: # once (12µs+44µs) by DateTime::Duration::BEGIN@12 at line 51 of Params/Validate.pm # once (10µs+41µs) by DateTime::TimeZone::Local::BEGIN@12 at line 19 of Class/Load.pm # once (5µs+23µs) by Package::Stash::BEGIN@17 at line 21 of Package/Stash.pm
sub build_loader_sub {
1834µs my $caller = caller();
19
20325µs3108µs return _build_loader( $caller, @_ );
# spent 108µs making 3 calls to Module::Implementation::_build_loader, avg 36µs/call
21}
22
23
# spent 108µs (88+20) within Module::Implementation::_build_loader which was called 3 times, avg 36µs/call: # 3 times (88µs+20µs) by Module::Implementation::build_loader_sub at line 20, avg 36µs/call
sub _build_loader {
2433µs my $package = shift;
2539µs my %args = @_;
26
27610µs my @implementations = @{ $args{implementations} };
2869µs my @symbols = @{ $args{symbols} || [] };
29
303800ns my $implementation;
3133µs my $env_var = uc $package;
32342µs320µs $env_var =~ s/::/_/g;
# spent 20µs making 3 calls to Module::Implementation::CORE:subst, avg 7µs/call
3334µs $env_var .= '_IMPLEMENTATION';
34
35
# spent 3.16ms (59µs+3.10) within Module::Implementation::__ANON__[/usr/local/share/perl/5.14.2/Module/Implementation.pm:47] which was called 3 times, avg 1.05ms/call: # once (25µs+1.42ms) by DateTime::Duration::BEGIN@12 at line 66 of Params/Validate.pm # once (21µs+1.12ms) by DateTime::TimeZone::Local::BEGIN@12 at line 24 of Class/Load.pm # once (13µs+568µs) by Package::Stash::BEGIN@17 at line 21 of Package/Stash.pm
return sub {
36320µs32.91ms my ( $implementation, $loaded ) = _load_implementation(
# spent 2.91ms making 3 calls to Module::Implementation::_load_implementation, avg 971µs/call
37 $package,
38 $ENV{$env_var},
39 \@implementations,
40 );
41
4235µs $Implementation{$package} = $implementation;
43
44312µs3192µs _copy_symbols( $loaded, $package, \@symbols );
# spent 192µs making 3 calls to Module::Implementation::_copy_symbols, avg 64µs/call
45
46322µs return $loaded;
47335µs };
48}
49
50
# spent 3µs within Module::Implementation::implementation_for which was called: # once (3µs+0s) by Package::Stash::BEGIN@17 at line 37 of Package/Stash.pm
sub implementation_for {
511600ns my $package = shift;
52
5314µs return $Implementation{$package};
54}
55
56
# spent 2.91ms (101µs+2.81) within Module::Implementation::_load_implementation which was called 3 times, avg 971µs/call: # 3 times (101µs+2.81ms) by Module::Implementation::__ANON__[/usr/local/share/perl/5.14.2/Module/Implementation.pm:47] at line 36, avg 971µs/call
sub _load_implementation {
5732µs my $package = shift;
5835µs my $env_value = shift;
5931µs my $implementations = shift;
60
6132µs 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 {
823800ns my $err;
8366µs for my $possible ( @{$implementations} ) {
8434µs my $try = "${package}::$possible";
85
863600ns my $ok;
87 try {
8839µs32.60ms require_module($try);
# spent 2.60ms making 3 calls to Module::Runtime::require_module, avg 866µs/call
89312µs $ok = 1;
90 }
91 catch {
92 $err .= $_ if defined $_;
93352µs62.81ms };
# spent 2.76ms making 3 calls to Try::Tiny::try, avg 919µs/call # spent 54µs making 3 calls to Try::Tiny::catch, avg 18µs/call
94
95320µ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 192µs (174+18) within Module::Implementation::_copy_symbols which was called 3 times, avg 64µs/call: # 3 times (174µs+18µs) by Module::Implementation::__ANON__[/usr/local/share/perl/5.14.2/Module/Implementation.pm:47] at line 44, avg 64µs/call
sub _copy_symbols {
11233µs my $from_package = shift;
11331µs my $to_package = shift;
1143900ns my $symbols = shift;
115
116619µs for my $sym ( @{$symbols} ) {
1171759µs1718µs my $type = $sym =~ s/^([\$\@\%\&\*])// ? $1 : '&';
# spent 18µs making 17 calls to Module::Implementation::CORE:subst, avg 1µs/call
118
1191712µs my $from = "${from_package}::$sym";
120177µs my $to = "${to_package}::$sym";
121
122 {
1231985µs269µs
# spent 44µs (18+25) within Module::Implementation::BEGIN@123 which was called: # once (18µs+25µs) by Params::Validate::BEGIN@12 at line 123
no strict 'refs';
# spent 44µs making 1 call to Module::Implementation::BEGIN@123 # spent 25µs making 1 call to strict::unimport
1242228µs264µs
# spent 40µs (17+23) within Module::Implementation::BEGIN@124 which was called: # once (17µs+23µs) by Params::Validate::BEGIN@12 at line 124
no warnings 'once';
# spent 40µs making 1 call to Module::Implementation::BEGIN@124 # spent 23µs making 1 call to warnings::unimport
125
126 # Copied from Exporter
1273413µs *{$to}
128 = $type eq '&' ? \&{$from}
129 : $type eq '$' ? \${$from}
130 : $type eq '@' ? \@{$from}
131 : $type eq '%' ? \%{$from}
1321762µs : $type eq '*' ? *{$from}
133 : die
134 "Can't copy symbol from $from_package to $to_package: $type$sym";
135 }
136 }
137}
138
13916µs1;
140
141# ABSTRACT: Loads one of several alternate underlying implementations for a module
142
143__END__
 
# spent 38µs within Module::Implementation::CORE:subst which was called 20 times, avg 2µs/call: # 17 times (18µs+0s) by Module::Implementation::_copy_symbols at line 117, avg 1µs/call # 3 times (20µs+0s) by Module::Implementation::_build_loader at line 32, avg 7µs/call
sub Module::Implementation::CORE:subst; # opcode