← Index
NYTProf Performance Profile   « line view »
For svc/members/upsert
  Run on Tue Jan 13 11:50:22 2015
Reported on Tue Jan 13 12:09:47 2015

Filename/usr/share/perl5/Module/Implementation.pm
StatementsExecuted 233 statements in 2.86ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1112.14ms2.25msModule::Implementation::::BEGIN@8Module::Implementation::BEGIN@8
1111.70ms3.15msModule::Implementation::::BEGIN@9Module::Implementation::BEGIN@9
41195µs106µsModule::Implementation::::_copy_symbolsModule::Implementation::_copy_symbols
41165µs9.40msModule::Implementation::::_load_implementationModule::Implementation::_load_implementation
41148µs57µsModule::Implementation::::_build_loaderModule::Implementation::_build_loader
44434µs9.54msModule::Implementation::::__ANON__[:52]Module::Implementation::__ANON__[:52]
222120µs20µsModule::Implementation::::CORE:substModule::Implementation::CORE:subst (opcode)
11120µs33µsModule::Implementation::::BEGIN@5Module::Implementation::BEGIN@5
41117µs9.23msModule::Implementation::::try {...} Module::Implementation::try {...}
44416µs73µsModule::Implementation::::build_loader_subModule::Implementation::build_loader_sub
1118µs19µsModule::Implementation::::BEGIN@128Module::Implementation::BEGIN@128
1117µs12µsModule::Implementation::::BEGIN@6Module::Implementation::BEGIN@6
1117µs23µsModule::Implementation::::BEGIN@129Module::Implementation::BEGIN@129
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
5234µs247µs
# spent 33µs (20+14) within Module::Implementation::BEGIN@5 which was called: # once (20µs+14µs) by Params::Validate::BEGIN@9 at line 5
use strict;
# spent 33µs making 1 call to Module::Implementation::BEGIN@5 # spent 14µs making 1 call to strict::import
6228µs216µs
# spent 12µs (7+4) within Module::Implementation::BEGIN@6 which was called: # once (7µs+4µs) by Params::Validate::BEGIN@9 at line 6
use warnings;
# spent 12µs making 1 call to Module::Implementation::BEGIN@6 # spent 4µs making 1 call to warnings::import
7
83834µs32.28ms
# spent 2.25ms (2.14+113µs) within Module::Implementation::BEGIN@8 which was called: # once (2.14ms+113µs) by Params::Validate::BEGIN@9 at line 8
use Module::Runtime 0.012 qw( require_module );
# spent 2.25ms making 1 call to Module::Implementation::BEGIN@8 # spent 13µs making 1 call to Module::Runtime::import # spent 12µs making 1 call to UNIVERSAL::VERSION
921.53ms23.18ms
# spent 3.15ms (1.70+1.45) within Module::Implementation::BEGIN@9 which was called: # once (1.70ms+1.45ms) by Params::Validate::BEGIN@9 at line 9
use Try::Tiny;
# spent 3.15ms making 1 call to Module::Implementation::BEGIN@9 # spent 30µ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.
141900nsunless ( exists $Module::Implementation::{VERSION}
15 && ${ $Module::Implementation::{VERSION} } ) {
16
17 $Module::Implementation::{VERSION} = \42;
18}
19
201100nsmy %Implementation;
21
22
# spent 73µs (16+57) within Module::Implementation::build_loader_sub which was called 4 times, avg 18µs/call: # once (4µs+17µs) by Package::Stash::BEGIN@15 at line 19 of Package/Stash.pm # once (6µs+15µs) by DateTime::TimeZone::OffsetOnly::BEGIN@9 at line 48 of Params/Validate.pm # once (4µs+13µs) by B::Hooks::EndOfScope::BEGIN@20 at line 22 of B/Hooks/EndOfScope.pm # once (4µs+12µs) by DateTime::TimeZone::Local::BEGIN@6 at line 22 of Class/Load.pm
sub build_loader_sub {
2342µs my $caller = caller();
24
25414µs457µs return _build_loader( $caller, @_ );
# spent 57µs making 4 calls to Module::Implementation::_build_loader, avg 14µs/call
26}
27
28
# spent 57µs (48+9) within Module::Implementation::_build_loader which was called 4 times, avg 14µs/call: # 4 times (48µs+9µs) by Module::Implementation::build_loader_sub at line 25, avg 14µs/call
sub _build_loader {
2941µs my $package = shift;
3044µs my %args = @_;
31
3243µs my @implementations = @{ $args{implementations} };
3343µs my @symbols = @{ $args{symbols} || [] };
34
354200ns my $implementation;
3643µs my $env_var = uc $package;
37421µs49µs $env_var =~ s/::/_/g;
# spent 9µs making 4 calls to Module::Implementation::CORE:subst, avg 2µs/call
3842µs $env_var .= '_IMPLEMENTATION';
39
40
# spent 9.54ms (34µs+9.50) within Module::Implementation::__ANON__[/usr/share/perl5/Module/Implementation.pm:52] which was called 4 times, avg 2.38ms/call: # once (8µs+4.92ms) by B::Hooks::EndOfScope::BEGIN@20 at line 22 of B/Hooks/EndOfScope.pm # once (10µs+2.22ms) by DateTime::TimeZone::OffsetOnly::BEGIN@9 at line 63 of Params/Validate.pm # once (8µs+1.28ms) by Package::Stash::BEGIN@15 at line 19 of Package/Stash.pm # once (7µs+1.08ms) by DateTime::TimeZone::Local::BEGIN@6 at line 27 of Class/Load.pm
return sub {
41410µs49.40ms my ( $implementation, $loaded ) = _load_implementation(
# spent 9.40ms making 4 calls to Module::Implementation::_load_implementation, avg 2.35ms/call
42 $package,
43 $ENV{$env_var},
44 \@implementations,
45 );
46
4742µs $Implementation{$package} = $implementation;
48
4947µs4106µs _copy_symbols( $loaded, $package, \@symbols );
# spent 106µs making 4 calls to Module::Implementation::_copy_symbols, avg 26µs/call
50
51411µs return $loaded;
52425µ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 {
561400ns my $package = shift;
57
5813µs return $Implementation{$package};
59}
60
61
# spent 9.40ms (65µs+9.33) within Module::Implementation::_load_implementation which was called 4 times, avg 2.35ms/call: # 4 times (65µs+9.33ms) by Module::Implementation::__ANON__[/usr/share/perl5/Module/Implementation.pm:52] at line 41, avg 2.35ms/call
sub _load_implementation {
624900ns my $package = shift;
6345µs my $env_value = shift;
644500ns my $implementations = shift;
65
6641µs 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 {
874500ns my $err;
8842µs for my $possible ( @{$implementations} ) {
8943µs my $try = "${package}::$possible";
90
914400ns my $ok;
92
# spent 9.23ms (17µs+9.21) within Module::Implementation::try {...} which was called 4 times, avg 2.31ms/call: # 4 times (17µs+9.21ms) by Try::Tiny::try at line 81 of Try/Tiny.pm, avg 2.31ms/call
try {
9347µs49.21ms require_module($try);
# spent 9.21ms making 4 calls to Module::Runtime::require_module, avg 2.30ms/call
9447µs $ok = 1;
95 }
96 catch {
97 $err .= $_ if defined $_;
98437µs89.33ms };
# spent 9.32ms making 4 calls to Try::Tiny::try, avg 2.33ms/call # spent 14µs making 4 calls to Try::Tiny::catch, avg 3µs/call
99
100412µ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 106µs (95+11) within Module::Implementation::_copy_symbols which was called 4 times, avg 26µs/call: # 4 times (95µs+11µs) by Module::Implementation::__ANON__[/usr/share/perl5/Module/Implementation.pm:52] at line 49, avg 26µs/call
sub _copy_symbols {
11741µs my $from_package = shift;
1184700ns my $to_package = shift;
1194700ns my $symbols = shift;
120
121411µs for my $sym ( @{$symbols} ) {
1221837µs1811µs my $type = $sym =~ s/^([\$\@\%\&\*])// ? $1 : '&';
# spent 11µs making 18 calls to Module::Implementation::CORE:subst, avg 617ns/call
123
124188µs my $from = "${from_package}::$sym";
125184µs my $to = "${to_package}::$sym";
126
127 {
1282038µs230µs
# spent 19µs (8+11) within Module::Implementation::BEGIN@128 which was called: # once (8µs+11µs) by Params::Validate::BEGIN@9 at line 128
no strict 'refs';
# spent 19µs making 1 call to Module::Implementation::BEGIN@128 # spent 11µs making 1 call to strict::unimport
1292107µs239µs
# spent 23µs (7+16) within Module::Implementation::BEGIN@129 which was called: # once (7µs+16µs) by Params::Validate::BEGIN@9 at line 129
no warnings 'once';
# spent 23µs making 1 call to Module::Implementation::BEGIN@129 # spent 16µ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}
1371835µ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 20µs within Module::Implementation::CORE:subst which was called 22 times, avg 909ns/call: # 18 times (11µs+0s) by Module::Implementation::_copy_symbols at line 122, avg 617ns/call # 4 times (9µs+0s) by Module::Implementation::_build_loader at line 37, avg 2µs/call
sub Module::Implementation::CORE:subst; # opcode