Profile of Module/Implementation.pm

← Index
NYTProf Performance Profile «line view»
For script/ponapi
Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:09 2016

Filename | /usr/share/perl5/Module/Implementation.pm
Statements | Executed 198 statements in 1.08ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 1.12ms | 1.22ms | Module::Implementation::::BEGIN@12Module::Implementation::BEGIN@12
1 | 1 | 1 | 643µs | 2.45ms | Module::Implementation::::BEGIN@13Module::Implementation::BEGIN@13
3 | 1 | 1 | 93µs | 100µs | Module::Implementation::::_copy_symbolsModule::Implementation::_copy_symbols
3 | 1 | 1 | 58µs | 3.47ms | Module::Implementation::::_load_implementationModule::Implementation::_load_implementation
3 | 1 | 1 | 47µs | 56µs | Module::Implementation::::_build_loaderModule::Implementation::_build_loader
3 | 3 | 3 | 32µs | 3.60ms | Module::Implementation::::__ANON__[:47]Module::Implementation::__ANON__[:47]
20 | 2 | 1 | 16µs | 16µs | Module::Implementation::::CORE:substModule::Implementation::CORE:subst (opcode)
3 | 3 | 3 | 16µs | 72µs | Module::Implementation::::build_loader_subModule::Implementation::build_loader_sub
1 | 1 | 1 | 6µs | 15µs | Module::Implementation::::BEGIN@123Module::Implementation::BEGIN@123
1 | 1 | 1 | 6µs | 17µs | Module::Implementation::::BEGIN@124Module::Implementation::BEGIN@124
1 | 1 | 1 | 6µs | 10µs | Module::Implementation::::BEGIN@10Module::Implementation::BEGIN@10
1 | 1 | 1 | 6µs | 6µs | Module::Implementation::::BEGIN@5Module::Implementation::BEGIN@5
1 | 1 | 1 | 5µs | 15µs | Module::Implementation::::BEGIN@9Module::Implementation::BEGIN@9
1 | 1 | 1 | 2µs | 2µs | Module::Implementation::::implementation_forModule::Implementation::implementation_for
0 | 0 | 0 | 0s | 0s | Module::Implementation::::__ANON__[:73]Module::Implementation::__ANON__[:73]
0 | 0 | 0 | 0s | 0s | Module::Implementation::::__ANON__[:77]Module::Implementation::__ANON__[:77]
0 | 0 | 0 | 0s | 0s | Module::Implementation::::__ANON__[:90]Module::Implementation::__ANON__[:90]
0 | 0 | 0 | 0s | 0s | Module::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
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package Module::Implementation;
2 |  |  |  |  | {
3 | 2 | 800ns |  |  | $Module::Implementation::VERSION = '0.07';
4 |  |  |  |  | }
5 |  |  |  |  | # spent 6µs within Module::Implementation::BEGIN@5 which was called: # once (6µs+0s) by Class::Load::BEGIN@11 at line 7 BEGIN {
6 | 1 | 4µs |  |  | $Module::Implementation::AUTHORITY = 'cpan:DROLSKY';
7 | 1 | 16µs | 1 | 6µs | } # spent 6µs making 1 call to Module::Implementation::BEGIN@5
8 |  |  |  |  |
9 | 2 | 19µs | 2 | 25µs | # spent 15µs (5+10) within Module::Implementation::BEGIN@9 which was called: # once (5µs+10µs) by Class::Load::BEGIN@11 at line 9 use strict; # spent 15µs making 1 call to Module::Implementation::BEGIN@9 # spent 10µs making 1 call to strict::import
10 | 2 | 25µs | 2 | 14µs | # spent 10µs (6+4) within Module::Implementation::BEGIN@10 which was called: # once (6µs+4µs) by Class::Load::BEGIN@11 at line 10 use warnings; # spent 10µs making 1 call to Module::Implementation::BEGIN@10 # spent 4µs making 1 call to warnings::import
11 |  |  |  |  |
12 | 3 | 138µs | 3 | 1.24ms | # spent 1.22ms (1.12+93µs) within Module::Implementation::BEGIN@12 which was called: # once (1.12ms+93µs) by Class::Load::BEGIN@11 at line 12 use Module::Runtime 0.012 qw( require_module ); # spent 1.22ms making 1 call to Module::Implementation::BEGIN@12 # spent 11µs making 1 call to Module::Runtime::import # spent 8µs making 1 call to UNIVERSAL::VERSION
13 | 2 | 495µs | 2 | 2.48ms | # spent 2.45ms (643µs+1.80) within Module::Implementation::BEGIN@13 which was called: # once (643µs+1.80ms) by Class::Load::BEGIN@11 at line 13 use Try::Tiny; # spent 2.45ms making 1 call to Module::Implementation::BEGIN@13 # spent 30µs making 1 call to Exporter::import
14 |  |  |  |  |
15 | 1 | 200ns |  |  | my %Implementation;
16 |  |  |  |  |
17 |  |  |  |  | # spent 72µs (16+56) within Module::Implementation::build_loader_sub which was called 3 times, avg 24µs/call: # once (5µs+20µs) by Package::Stash::BEGIN@17 at line 21 of Package/Stash.pm # once (5µs+19µs) by Getopt::Long::Descriptive::BEGIN@10 at line 51 of Params/Validate.pm # once (5µs+17µs) by App::Cmd::BEGIN@13 at line 21 of Class/Load.pm sub build_loader_sub {
18 | 3 | 2µs |  |  | my $caller = caller();
19 |  |  |  |  |
20 | 3 | 18µs | 3 | 56µs | return _build_loader( $caller, @_ ); # spent 56µs making 3 calls to Module::Implementation::_build_loader, avg 19µs/call
21 |  |  |  |  | }
22 |  |  |  |  |
23 |  |  |  |  | # spent 56µs (47+9) within Module::Implementation::_build_loader which was called 3 times, avg 19µs/call: # 3 times (47µs+9µs) by Module::Implementation::build_loader_sub at line 20, avg 19µs/call sub _build_loader {
24 | 3 | 1µs |  |  | my $package = shift;
25 | 3 | 4µs |  |  | my %args = @_;
26 |  |  |  |  |
27 | 3 | 4µs |  |  | my @implementations = @{ $args{implementations} };
28 | 3 | 4µs |  |  | my @symbols = @{ $args{symbols} || [] };
29 |  |  |  |  |
30 | 3 | 400ns |  |  | my $implementation;
31 | 3 | 3µs |  |  | my $env_var = uc $package;
32 | 3 | 22µs | 3 | 9µs | $env_var =~ s/::/_/g; # spent 9µs making 3 calls to Module::Implementation::CORE:subst, avg 3µs/call
33 | 3 | 2µs |  |  | $env_var .= '_IMPLEMENTATION';
34 |  |  |  |  |
35 |  |  |  |  | # spent 3.60ms (32µs+3.57) within Module::Implementation::__ANON__[/usr/share/perl5/Module/Implementation.pm:47] which was called 3 times, avg 1.20ms/call: # once (12µs+2.61ms) by Getopt::Long::Descriptive::BEGIN@10 at line 66 of Params/Validate.pm # once (11µs+490µs) by Package::Stash::BEGIN@17 at line 21 of Package/Stash.pm # once (10µs+467µs) by App::Cmd::BEGIN@13 at line 26 of Class/Load.pm return sub {
36 | 3 | 12µs | 3 | 3.47ms | my ( $implementation, $loaded ) = _load_implementation( # spent 3.47ms making 3 calls to Module::Implementation::_load_implementation, avg 1.16ms/call
37 |  |  |  |  | $package,
38 |  |  |  |  | $ENV{$env_var},
39 |  |  |  |  | \@implementations,
40 |  |  |  |  | );
41 |  |  |  |  |
42 | 3 | 2µs |  |  | $Implementation{$package} = $implementation;
43 |  |  |  |  |
44 | 3 | 6µs | 3 | 100µs | _copy_symbols( $loaded, $package, \@symbols ); # spent 100µs making 3 calls to Module::Implementation::_copy_symbols, avg 33µs/call
45 |  |  |  |  |
46 | 3 | 8µs |  |  | return $loaded;
47 | 3 | 19µ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 {
51 | 1 | 300ns |  |  | my $package = shift;
52 |  |  |  |  |
53 | 1 | 4µs |  |  | return $Implementation{$package};
54 |  |  |  |  | }
55 |  |  |  |  |
56 |  |  |  |  | # spent 3.47ms (58µs+3.41) within Module::Implementation::_load_implementation which was called 3 times, avg 1.16ms/call: # 3 times (58µs+3.41ms) by Module::Implementation::__ANON__[/usr/share/perl5/Module/Implementation.pm:47] at line 36, avg 1.16ms/call sub _load_implementation {
57 | 3 | 800ns |  |  | my $package = shift;
58 | 3 | 2µs |  |  | my $env_value = shift;
59 | 3 | 500ns |  |  | my $implementations = shift;
60 |  |  |  |  |
61 | 3 | 900ns |  |  | 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 | 3 | 700ns |  |  | my $err;
83 | 3 | 2µs |  |  | for my $possible ( @{$implementations} ) {
84 | 3 | 2µs |  |  | my $try = "${package}::$possible";
85 |  |  |  |  |
86 | 3 | 300ns |  |  | my $ok;
87 |  |  |  |  | try {
88 | 3 | 6µs | 3 | 3.31ms | require_module($try); # spent 3.31ms making 3 calls to Module::Runtime::require_module, avg 1.10ms/call
89 | 3 | 7µs |  |  | $ok = 1;
90 |  |  |  |  | }
91 |  |  |  |  | catch {
92 |  |  |  |  | $err .= $_ if defined $_;
93 | 3 | 32µs | 6 | 3.41ms | }; # spent 3.40ms making 3 calls to Try::Tiny::try, avg 1.13ms/call # spent 14µs making 3 calls to Try::Tiny::catch, avg 5µs/call
94 |  |  |  |  |
95 | 3 | 12µ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 100µs (93+7) within Module::Implementation::_copy_symbols which was called 3 times, avg 33µs/call: # 3 times (93µs+7µs) by Module::Implementation::__ANON__[/usr/share/perl5/Module/Implementation.pm:47] at line 44, avg 33µs/call sub _copy_symbols {
112 | 3 | 1µs |  |  | my $from_package = shift;
113 | 3 | 600ns |  |  | my $to_package = shift;
114 | 3 | 1µs |  |  | my $symbols = shift;
115 |  |  |  |  |
116 | 3 | 11µs |  |  | for my $sym ( @{$symbols} ) {
117 | 17 | 33µs | 17 | 7µs | my $type = $sym =~ s/^([\$\@\%\&\*])// ? $1 : '&'; # spent 7µs making 17 calls to Module::Implementation::CORE:subst, avg 412ns/call
118 |  |  |  |  |
119 | 17 | 7µs |  |  | my $from = "${from_package}::$sym";
120 | 17 | 5µs |  |  | my $to = "${to_package}::$sym";
121 |  |  |  |  |
122 |  |  |  |  | {
123 | 19 | 30µs | 2 | 24µs | # spent 15µs (6+9) within Module::Implementation::BEGIN@123 which was called: # once (6µs+9µs) by Class::Load::BEGIN@11 at line 123 no strict 'refs'; # spent 15µs making 1 call to Module::Implementation::BEGIN@123 # spent 9µs making 1 call to strict::unimport
124 | 2 | 78µs | 2 | 29µs | # spent 17µs (6+11) within Module::Implementation::BEGIN@124 which was called: # once (6µs+11µs) by Class::Load::BEGIN@11 at line 124 no warnings 'once'; # spent 17µ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}
132 | 17 | 36µs |  |  | : $type eq '*' ? *{$from}
133 |  |  |  |  | : die
134 |  |  |  |  | "Can't copy symbol from $from_package to $to_package: $type$sym";
135 |  |  |  |  | }
136 |  |  |  |  | }
137 |  |  |  |  | }
138 |  |  |  |  |
139 | 1 | 3µs |  |  | 1;
140 |  |  |  |  |
141 |  |  |  |  | # ABSTRACT: Loads one of several alternate underlying implementations for a module
142 |  |  |  |  |
143 |  |  |  |  | __END__
|  |  |  |  | # spent 16µs within Module::Implementation::CORE:subst which was called 20 times, avg 795ns/call: # 17 times (7µs+0s) by Module::Implementation::_copy_symbols at line 117, avg 412ns/call # 3 times (9µs+0s) by Module::Implementation::_build_loader at line 32, avg 3µs/call sub Module::Implementation::CORE:subst; # opcode