← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mentat.storage.mongo.pl
  Run on Tue Jun 24 10:04:38 2014
Reported on Tue Jun 24 10:05:10 2014

Filename/usr/local/share/perl/5.14.2/Module/Implementation.pm
StatementsExecuted 244 statements in 1.33ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.41ms1.53msModule::Implementation::::BEGIN@12Module::Implementation::BEGIN@12
111769µs2.61msModule::Implementation::::BEGIN@13Module::Implementation::BEGIN@13
311115µs127µsModule::Implementation::::_copy_symbolsModule::Implementation::_copy_symbols
31166µs1.69msModule::Implementation::::_load_implementationModule::Implementation::_load_implementation
31156µs67µsModule::Implementation::::_build_loaderModule::Implementation::_build_loader
33333µs1.85msModule::Implementation::::__ANON__[:47]Module::Implementation::__ANON__[:47]
202122µs22µsModule::Implementation::::CORE:substModule::Implementation::CORE:subst (opcode)
33317µs84µsModule::Implementation::::build_loader_subModule::Implementation::build_loader_sub
1118µs8µsModule::Implementation::::BEGIN@5Module::Implementation::BEGIN@5
1118µs18µsModule::Implementation::::BEGIN@123Module::Implementation::BEGIN@123
1117µs17µsModule::Implementation::::BEGIN@124Module::Implementation::BEGIN@124
1116µs9µsModule::Implementation::::BEGIN@9Module::Implementation::BEGIN@9
1116µs11µ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{
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 Params::Validate::BEGIN@12 at line 7
BEGIN {
614µs $Module::Implementation::AUTHORITY = 'cpan:DROLSKY';
7123µs18µs}
# spent 8µs making 1 call to Module::Implementation::BEGIN@5
8
9223µs212µs
# spent 9µs (6+3) within Module::Implementation::BEGIN@9 which was called: # once (6µs+3µs) by Params::Validate::BEGIN@12 at line 9
use strict;
# spent 9µs making 1 call to Module::Implementation::BEGIN@9 # spent 3µs making 1 call to strict::import
10226µs215µs
# spent 11µs (6+5) within Module::Implementation::BEGIN@10 which was called: # once (6µs+5µs) by Params::Validate::BEGIN@12 at line 10
use warnings;
# spent 11µs making 1 call to Module::Implementation::BEGIN@10 # spent 4µs making 1 call to warnings::import
11
123190µs31.56ms
# spent 1.53ms (1.41+121µs) within Module::Implementation::BEGIN@12 which was called: # once (1.41ms+121µs) by Params::Validate::BEGIN@12 at line 12
use Module::Runtime 0.012 qw( require_module );
# spent 1.53ms making 1 call to Module::Implementation::BEGIN@12 # spent 17µs making 1 call to UNIVERSAL::VERSION # spent 14µs making 1 call to Module::Runtime::import
132594µs22.65ms
# spent 2.61ms (769µs+1.85) within Module::Implementation::BEGIN@13 which was called: # once (769µs+1.85ms) by Params::Validate::BEGIN@12 at line 13
use Try::Tiny;
# spent 2.61ms making 1 call to Module::Implementation::BEGIN@13 # spent 34µs making 1 call to Exporter::import
14
151200nsmy %Implementation;
16
17
# spent 84µs (17+67) within Module::Implementation::build_loader_sub which was called 3 times, avg 28µs/call: # once (7µs+28µs) by Package::Stash::BEGIN@17 at line 21 of Package/Stash.pm # once (5µs+20µs) by DateTime::Duration::BEGIN@12 at line 51 of Params/Validate.pm # once (5µs+18µs) by DateTime::TimeZone::Local::BEGIN@12 at line 19 of Class/Load.pm
sub build_loader_sub {
18618µs my $caller = caller();
19
20367µs return _build_loader( $caller, @_ );
# spent 67µs making 3 calls to Module::Implementation::_build_loader, avg 22µs/call
21}
22
23
# spent 67µs (56+11) within Module::Implementation::_build_loader which was called 3 times, avg 22µs/call: # 3 times (56µs+11µs) by Module::Implementation::build_loader_sub at line 20, avg 22µs/call
sub _build_loader {
242766µs my $package = shift;
25 my %args = @_;
26
2732µs my @implementations = @{ $args{implementations} };
2832µs my @symbols = @{ $args{symbols} || [] };
29
30 my $implementation;
31 my $env_var = uc $package;
32311µs $env_var =~ s/::/_/g;
# spent 11µs making 3 calls to Module::Implementation::CORE:subst, avg 4µs/call
33 $env_var .= '_IMPLEMENTATION';
34
35
# spent 1.85ms (33µs+1.82) within Module::Implementation::__ANON__[/usr/local/share/perl/5.14.2/Module/Implementation.pm:47] which was called 3 times, avg 617µs/call: # once (11µs+676µs) by DateTime::Duration::BEGIN@12 at line 66 of Params/Validate.pm # once (13µs+641µs) by Package::Stash::BEGIN@17 at line 21 of Package/Stash.pm # once (9µs+502µs) by DateTime::TimeZone::Local::BEGIN@12 at line 24 of Class/Load.pm
return sub {
361233µs31.69ms my ( $implementation, $loaded ) = _load_implementation(
# spent 1.69ms making 3 calls to Module::Implementation::_load_implementation, avg 564µs/call
37 $package,
38 $ENV{$env_var},
39 \@implementations,
40 );
41
42 $Implementation{$package} = $implementation;
43
443127µs _copy_symbols( $loaded, $package, \@symbols );
# spent 127µs making 3 calls to Module::Implementation::_copy_symbols, avg 42µs/call
45
46 return $loaded;
47 };
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 {
5125µs my $package = shift;
52
53 return $Implementation{$package};
54}
55
56
# spent 1.69ms (66µs+1.63) within Module::Implementation::_load_implementation which was called 3 times, avg 564µs/call: # 3 times (66µs+1.63ms) by Module::Implementation::__ANON__[/usr/local/share/perl/5.14.2/Module/Implementation.pm:47] at line 36, avg 564µs/call
sub _load_implementation {
57127µs my $package = shift;
58 my $env_value = shift;
59 my $implementations = shift;
60
6164µ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 {
82 my $err;
8331µs for my $possible ( @{$implementations} ) {
841250µs my $try = "${package}::$possible";
85
86 my $ok;
87 try {
88614µs31.50ms require_module($try);
# spent 1.50ms making 3 calls to Module::Runtime::require_module, avg 501µs/call
89 $ok = 1;
90 }
91 catch {
92 $err .= $_ if defined $_;
9361.63ms };
# spent 1.60ms making 3 calls to Try::Tiny::try, avg 534µs/call # spent 24µs making 3 calls to Try::Tiny::catch, avg 8µs/call
94
95 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 127µs (115+11) within Module::Implementation::_copy_symbols which was called 3 times, avg 42µs/call: # 3 times (115µs+11µs) by Module::Implementation::__ANON__[/usr/local/share/perl/5.14.2/Module/Implementation.pm:47] at line 44, avg 42µs/call
sub _copy_symbols {
1121214µs my $from_package = shift;
113 my $to_package = shift;
114 my $symbols = shift;
115
11631µs for my $sym ( @{$symbols} ) {
1176864µs1711µs my $type = $sym =~ s/^([\$\@\%\&\*])// ? $1 : '&';
# spent 11µs making 17 calls to Module::Implementation::CORE:subst, avg 665ns/call
118
119 my $from = "${from_package}::$sym";
120 my $to = "${to_package}::$sym";
121
122 {
123230µs229µs
# spent 18µs (8+10) within Module::Implementation::BEGIN@123 which was called: # once (8µs+10µs) by Params::Validate::BEGIN@12 at line 123
no strict 'refs';
# spent 18µs making 1 call to Module::Implementation::BEGIN@123 # spent 10µs making 1 call to strict::unimport
1242100µs227µs
# spent 17µs (7+10) within Module::Implementation::BEGIN@124 which was called: # once (7µs+10µs) by Params::Validate::BEGIN@12 at line 124
no warnings 'once';
# spent 17µs making 1 call to Module::Implementation::BEGIN@124 # spent 10µ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}
1325150µ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 22µs within Module::Implementation::CORE:subst which was called 20 times, avg 1µs/call: # 17 times (11µs+0s) by Module::Implementation::_copy_symbols at line 117, avg 665ns/call # 3 times (11µs+0s) by Module::Implementation::_build_loader at line 32, avg 4µs/call
sub Module::Implementation::CORE:subst; # opcode