← Index
NYTProf Performance Profile   « line view »
For examples/Atom-timer.pl
  Run on Mon Aug 12 14:45:28 2013
Reported on Mon Aug 12 14:46:14 2013

Filename/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/Module/Implementation.pm
StatementsExecuted 127 statements in 1.08ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.22ms1.32msModule::Implementation::::BEGIN@12Module::Implementation::BEGIN@12
111736µs2.54msModule::Implementation::::BEGIN@13Module::Implementation::BEGIN@13
31153µs2.84msModule::Implementation::::_load_implementationModule::Implementation::_load_implementation
31145µs53µsModule::Implementation::::_build_loaderModule::Implementation::_build_loader
33336µs2.90msModule::Implementation::::__ANON__[:47]Module::Implementation::__ANON__[:47]
31126µs28µsModule::Implementation::::_copy_symbolsModule::Implementation::_copy_symbols
33313µs66µsModule::Implementation::::build_loader_subModule::Implementation::build_loader_sub
52110µs10µsModule::Implementation::::CORE:substModule::Implementation::CORE:subst (opcode)
1118µs12µsModule::Implementation::::BEGIN@10Module::Implementation::BEGIN@10
1118µs8µsModule::Implementation::::BEGIN@5Module::Implementation::BEGIN@5
1117µs16µsModule::Implementation::::BEGIN@123Module::Implementation::BEGIN@123
1116µs15µsModule::Implementation::::BEGIN@124Module::Implementation::BEGIN@124
3326µs6µsModule::Implementation::::implementation_forModule::Implementation::implementation_for
1116µs16µsModule::Implementation::::BEGIN@9Module::Implementation::BEGIN@9
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{
32800ns $Module::Implementation::VERSION = '0.07';
4}
5
# spent 8µs within Module::Implementation::BEGIN@5 which was called: # once (8µs+0s) by Class::Load::BEGIN@9 at line 7
BEGIN {
614µs $Module::Implementation::AUTHORITY = 'cpan:DROLSKY';
7122µs18µs}
# spent 8µs making 1 call to Module::Implementation::BEGIN@5
8
9220µs227µs
# spent 16µs (6+11) within Module::Implementation::BEGIN@9 which was called: # once (6µs+11µs) by Class::Load::BEGIN@9 at line 9
use strict;
# spent 16µs making 1 call to Module::Implementation::BEGIN@9 # spent 11µs making 1 call to strict::import
10225µs215µs
# spent 12µs (8+3) within Module::Implementation::BEGIN@10 which was called: # once (8µs+3µs) by Class::Load::BEGIN@9 at line 10
use warnings;
# spent 12µs making 1 call to Module::Implementation::BEGIN@10 # spent 3µs making 1 call to warnings::import
11
123156µs31.34ms
# spent 1.32ms (1.22+102µs) within Module::Implementation::BEGIN@12 which was called: # once (1.22ms+102µs) by Class::Load::BEGIN@9 at line 12
use Module::Runtime 0.012 qw( require_module );
# spent 1.32ms making 1 call to Module::Implementation::BEGIN@12 # spent 12µs making 1 call to Module::Runtime::import # spent 8µs making 1 call to UNIVERSAL::VERSION
132536µs22.56ms
# spent 2.54ms (736µs+1.80) within Module::Implementation::BEGIN@13 which was called: # once (736µs+1.80ms) by Class::Load::BEGIN@9 at line 13
use Try::Tiny;
# spent 2.54ms making 1 call to Module::Implementation::BEGIN@13 # spent 27µs making 1 call to Exporter::import
14
151100nsmy %Implementation;
16
17
# spent 66µs (13+53) within Module::Implementation::build_loader_sub which was called 3 times, avg 22µs/call: # once (5µs+19µs) by Moose::BEGIN@15 at line 19 of Class/Load.pm # once (4µs+17µs) by B::Hooks::EndOfScope::BEGIN@18 at line 21 of B/Hooks/EndOfScope.pm # once (4µs+16µs) by Package::Stash::BEGIN@17 at line 21 of Package/Stash.pm
sub build_loader_sub {
1832µs my $caller = caller();
19
20312µs353µs return _build_loader( $caller, @_ );
# spent 53µs making 3 calls to Module::Implementation::_build_loader, avg 18µs/call
21}
22
23
# spent 53µs (45+8) within Module::Implementation::_build_loader which was called 3 times, avg 18µs/call: # 3 times (45µs+8µs) by Module::Implementation::build_loader_sub at line 20, avg 18µs/call
sub _build_loader {
243900ns my $package = shift;
2534µs my %args = @_;
26
2734µs my @implementations = @{ $args{implementations} };
2832µs my @symbols = @{ $args{symbols} || [] };
29
303200ns my $implementation;
3135µs my $env_var = uc $package;
32319µs38µs $env_var =~ s/::/_/g;
# spent 8µs making 3 calls to Module::Implementation::CORE:subst, avg 3µs/call
3332µs $env_var .= '_IMPLEMENTATION';
34
35
# spent 2.90ms (36µs+2.87) within Module::Implementation::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/Module/Implementation.pm:47] which was called 3 times, avg 967µs/call: # once (9µs+1.79ms) by B::Hooks::EndOfScope::BEGIN@18 at line 21 of B/Hooks/EndOfScope.pm # once (11µs+550µs) by Package::Stash::BEGIN@17 at line 21 of Package/Stash.pm # once (16µs+526µs) by Moose::BEGIN@15 at line 24 of Class/Load.pm
return sub {
36311µs32.84ms my ( $implementation, $loaded ) = _load_implementation(
# spent 2.84ms making 3 calls to Module::Implementation::_load_implementation, avg 946µs/call
37 $package,
38 $ENV{$env_var},
39 \@implementations,
40 );
41
4232µs $Implementation{$package} = $implementation;
43
4435µs328µs _copy_symbols( $loaded, $package, \@symbols );
# spent 28µs making 3 calls to Module::Implementation::_copy_symbols, avg 9µs/call
45
46311µs return $loaded;
47316µs };
48}
49
50
# spent 6µs within Module::Implementation::implementation_for which was called 3 times, avg 2µs/call: # once (2µs+0s) by B::Hooks::EndOfScope::BEGIN@18 at line 20 of B/Hooks/EndOfScope.pm # once (2µs+0s) by Package::Stash::BEGIN@17 at line 24 of Package/Stash.pm # once (2µs+0s) by B::Hooks::EndOfScope::BEGIN@18 at line 25 of B/Hooks/EndOfScope.pm
sub implementation_for {
5131µs my $package = shift;
52
53310µs return $Implementation{$package};
54}
55
56
# spent 2.84ms (53µs+2.78) within Module::Implementation::_load_implementation which was called 3 times, avg 946µs/call: # 3 times (53µs+2.78ms) by Module::Implementation::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/Module/Implementation.pm:47] at line 36, avg 946µs/call
sub _load_implementation {
573800ns my $package = shift;
5832µs my $env_value = shift;
593600ns my $implementations = shift;
60
613600ns 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 {
823300ns my $err;
8332µs for my $possible ( @{$implementations} ) {
8432µs my $try = "${package}::$possible";
85
863400ns my $ok;
87 try {
8836µs32.69ms require_module($try);
# spent 2.69ms making 3 calls to Module::Runtime::require_module, avg 897µs/call
8936µs $ok = 1;
90 }
91 catch {
92 $err .= $_ if defined $_;
93328µs62.78ms };
# spent 2.77ms making 3 calls to Try::Tiny::try, avg 925µs/call # spent 10µs making 3 calls to Try::Tiny::catch, avg 3µs/call
94
95316µ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 28µs (26+2) within Module::Implementation::_copy_symbols which was called 3 times, avg 9µs/call: # 3 times (26µs+2µs) by Module::Implementation::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/Module/Implementation.pm:47] at line 44, avg 9µs/call
sub _copy_symbols {
11231µs my $from_package = shift;
1133500ns my $to_package = shift;
1143500ns my $symbols = shift;
115
11639µs for my $sym ( @{$symbols} ) {
11727µs22µs my $type = $sym =~ s/^([\$\@\%\&\*])// ? $1 : '&';
# spent 2µs making 2 calls to Module::Implementation::CORE:subst, avg 1µs/call
118
11922µs my $from = "${from_package}::$sym";
12022µs my $to = "${to_package}::$sym";
121
122 {
123424µs225µs
# spent 16µs (7+9) within Module::Implementation::BEGIN@123 which was called: # once (7µs+9µs) by Class::Load::BEGIN@9 at line 123
no strict 'refs';
# spent 16µs making 1 call to Module::Implementation::BEGIN@123 # spent 9µs making 1 call to strict::unimport
124290µs224µs
# spent 15µs (6+9) within Module::Implementation::BEGIN@124 which was called: # once (6µs+9µs) by Class::Load::BEGIN@9 at line 124
no warnings 'once';
# spent 15µs making 1 call to Module::Implementation::BEGIN@124 # spent 9µ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}
13225µ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 10µs within Module::Implementation::CORE:subst which was called 5 times, avg 2µs/call: # 3 times (8µs+0s) by Module::Implementation::_build_loader at line 32, avg 3µs/call # 2 times (2µs+0s) by Module::Implementation::_copy_symbols at line 117, avg 1µs/call
sub Module::Implementation::CORE:subst; # opcode