← Index
NYTProf Performance Profile   « line view »
For Makefile.PL
  Run on Sun Mar 1 16:04:44 2015
Reported on Sun Mar 1 16:09:02 2015

FilenameC:/tmp64ng/perl/vendor/lib/Portable.pm
StatementsExecuted 90 statements in 0s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1110s0sPortable::::BEGIN@51Portable::BEGIN@51
1110s0sPortable::::BEGIN@52Portable::BEGIN@52
1110s0sPortable::::BEGIN@53Portable::BEGIN@53
1110s0sPortable::::BEGIN@54Portable::BEGIN@54
1110s0sPortable::::BEGIN@55Portable::BEGIN@55
4110s0sPortable::::CORE:ftfilePortable::CORE:ftfile (opcode)
0000s0sPortable::::_ARRAYPortable::_ARRAY
6650s0sPortable::::_HASHPortable::_HASH
2210s0sPortable::::_STRINGPortable::_STRING
0000s0sPortable::::appliedPortable::applied
1110s78.0msPortable::::applyPortable::apply
0000s0sPortable::::confPortable::conf
2220s0sPortable::::configPortable::config
0000s0sPortable::::cpanPortable::cpan
1110s15.6msPortable::::defaultPortable::default
1110s0sPortable::::dist_dirsPortable::dist_dirs
5550s0sPortable::::dist_rootPortable::dist_root
1110s0sPortable::::dist_volumePortable::dist_volume
0000s0sPortable::::envPortable::env
0000s0sPortable::::homedirPortable::homedir
1110s78.0msPortable::::importPortable::import
0000s0sPortable::::minicpanPortable::minicpan
1110s0sPortable::::newPortable::new
0000s0sPortable::::perlpathPortable::perlpath
2210s0sPortable::::portable_configPortable::portable_config
3320s0sPortable::::portable_cpanPortable::portable_cpan
0000s0sPortable::::portable_envPortable::portable_env
3320s0sPortable::::portable_homedirPortable::portable_homedir
3320s0sPortable::::portable_minicpanPortable::portable_minicpan
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Portable;
2
3=pod
4
5=head1 NAME
6
7Portable - Perl on a Stick
8
9=head1 SYNOPSIS
10
11Launch a script portably
12
13 F:\anywhere\perl.exe -MPortable script.pl
14
15Have a script specifically request to run portably
16
17 #!/usr/bin/perl
18 use Portable;
19
20=head1 DESCRIPTION
21
22"Portable" is a term used for applications that are installed onto a
23portable storage device (most commonly a USB memory stick) rather than
24onto a single host.
25
26This technique has become very popular for Windows applications, as it
27allows a user to make use of their own software on typical publically
28accessible computers at libraries, hotels and internet cafes.
29
30Converting a Windows application into portable form has a specific set
31of challenges, as the application has no access to the Windows registry,
32no access to "My Documents" type directories, and does not exist at a
33reliable filesystem path (because the portable storage medium can be
34mounted at an arbitrary volume or filesystem location).
35
36B<Portable> provides a methodology and implementation to support
37the creating of "Portable Perl" applications and distributions.
38
39While this will initially be focused on a Windows implementation,
40wherever possible the module will be built to be platform-agnostic
41in the hope that future versions can support other operating systems,
42or work across multiple operating systems.
43
44This module is not ready for public use. For now, see the code for
45more details on how it works...
46
47=head1 METHODS
48
49=cut
50
5120s10s
# spent 0s within Portable::BEGIN@51 which was called: # once (0s+0s) by ExtUtils::MakeMaker::Config::BEGIN@7 at line 51
use 5.008;
# spent 0s making 1 call to Portable::BEGIN@51
5220s20s
# spent 0s within Portable::BEGIN@52 which was called: # once (0s+0s) by ExtUtils::MakeMaker::Config::BEGIN@7 at line 52
use strict;
# spent 0s making 1 call to Portable::BEGIN@52 # spent 0s making 1 call to strict::import
5320s20s
# spent 0s within Portable::BEGIN@53 which was called: # once (0s+0s) by ExtUtils::MakeMaker::Config::BEGIN@7 at line 53
use warnings;
# spent 0s making 1 call to Portable::BEGIN@53 # spent 0s making 1 call to warnings::import
5420s10s
# spent 0s within Portable::BEGIN@54 which was called: # once (0s+0s) by ExtUtils::MakeMaker::Config::BEGIN@7 at line 54
use Portable::LoadYaml;
# spent 0s making 1 call to Portable::BEGIN@54
5520s10s
# spent 0s within Portable::BEGIN@55 which was called: # once (0s+0s) by ExtUtils::MakeMaker::Config::BEGIN@7 at line 55
use Portable::FileSpec;
# spent 0s making 1 call to Portable::BEGIN@55
56
5710sour $VERSION = '1.22';
58
59# This variable is provided exclusively for the
60# use of test scripts.
6110sour $FAKE_PERL;
62
63# Globally-accessible flag to see if Portable is enabled.
64# Defaults to undef, because if Portable.pm is not loaded
65# AT ALL, $Portable::ENABLED returns undef anyways.
6610sour $ENABLED = undef;
67
68# Param-checking
69
# spent 0s within Portable::_STRING which was called 2 times, avg 0s/call: # once (0s+0s) by Portable::new at line 141 # once (0s+0s) by Portable::new at line 144
sub _STRING ($) {
7020s (defined $_[0] and ! ref $_[0] and length($_[0])) ? $_[0] : undef;
71}
72
# spent 0s within Portable::_HASH which was called 6 times, avg 0s/call: # once (0s+0s) by Portable::default at line 207 # once (0s+0s) by Portable::new at line 147 # once (0s+0s) by Portable::CPAN::new at line 32 of Portable/CPAN.pm # once (0s+0s) by Portable::Config::new at line 16 of Portable/Config.pm # once (0s+0s) by Portable::minicpan::new at line 16 of Portable/minicpan.pm # once (0s+0s) by Portable::HomeDir::new at line 18 of Portable/HomeDir.pm
sub _HASH ($) {
7360s (ref $_[0] eq 'HASH' and scalar %{$_[0]}) ? $_[0] : undef;
74}
75sub _ARRAY ($) {
76 (ref $_[0] eq 'ARRAY' and @{$_[0]}) ? $_[0] : undef;
77}
78
79# Package variables
8010smy %applied;
81my $cache;
82
- -
87#####################################################################
88# Pragma/Import Interface
89
90
# spent 78.0ms (0s+78.0) within Portable::import which was called: # once (0s+78.0ms) by ExtUtils::MakeMaker::Config::BEGIN@7 at line 114 of Config.pm
sub import {
9110s my $class = shift;
9210s178.0ms $class->apply( @_ ? @_ : qw{ Config CPAN } );
# spent 78.0ms making 1 call to Portable::apply
93}
94
95
# spent 78.0ms (0s+78.0) within Portable::apply which was called: # once (0s+78.0ms) by Portable::import at line 92
sub apply {
96 # default %applied;
9710s my $class = shift;
9810s115.6ms my $self = $class->default;
# spent 15.6ms making 1 call to Portable::default
9910s my %apply = map { $_ => 1 } @_;
10010s if ( $apply{Config} and ! $applied{Config} ) {
10110s262.4ms $self->config->apply($self);
# spent 62.4ms making 1 call to Portable::Config::apply # spent 0s making 1 call to Portable::config
10210s $applied{Config} = 1;
10310s $ENABLED = 1;
104 }
10510s if ( $apply{CPAN} and ! $applied{CPAN} and $self->cpan ) {
106 $self->cpan->apply($self);
107 $applied{CPAN} = 1;
108 $ENABLED = 1;
109 }
11010s if ( $apply{HomeDir} and ! $applied{HomeDir} and $self->homedir ) {
111 $self->homedir->apply($self);
112 $applied{HomeDir} = 1;
113 $ENABLED = 1;
114 }
115
116 # We don't need to do anything for CPAN::Mini.
117 # It will load us instead (I think)
118
11910s return 1;
120}
121
122sub applied {
123 $applied{$_[1]};
124}
125
- -
130#####################################################################
131# Constructors
132
133
# spent 0s within Portable::new which was called: # once (0s+0s) by Portable::default at line 213
sub new {
13410s my $class = shift;
13510s my $self = bless { @_ }, $class;
136
137 # Param checking
13810s unless ( exists $self->{dist_volume} ) {
139 die('Missing or invalid dist_volume param');
140 }
14110s20s unless ( _STRING($self->dist_dirs) ) {
# spent 0s making 1 call to Portable::_STRING # spent 0s making 1 call to Portable::dist_dirs
142 die('Missing or invalid dist_dirs param');
143 }
14410s20s unless ( _STRING($self->dist_root) ) {
# spent 0s making 1 call to Portable::_STRING # spent 0s making 1 call to Portable::dist_root
145 die('Missing or invalid dist_root param');
146 }
14710s10s unless ( _HASH($self->{portable}) ) {
# spent 0s making 1 call to Portable::_HASH
148 die('Missing or invalid portable param');
149 }
150
151 # Compulsory support for Config.pm
15210s require Portable::Config;
15310s10s $self->{Config} = Portable::Config->new( $self );
# spent 0s making 1 call to Portable::Config::new
154
155 # Optional support for CPAN::Config
15610s10s if ( $self->portable_cpan ) {
# spent 0s making 1 call to Portable::portable_cpan
15710s require Portable::CPAN;
15810s10s $self->{CPAN} = Portable::CPAN->new( $self );
# spent 0s making 1 call to Portable::CPAN::new
159 }
160
161 # Optional support for File::HomeDir
16210s10s if ( $self->portable_homedir ) {
# spent 0s making 1 call to Portable::portable_homedir
16310s require Portable::HomeDir;
16410s10s $self->{HomeDir} = Portable::HomeDir->new( $self );
# spent 0s making 1 call to Portable::HomeDir::new
165 }
166
167 # Optional support for CPAN::Mini
16810s10s if ( $self->portable_minicpan ) {
# spent 0s making 1 call to Portable::portable_minicpan
16910s require Portable::minicpan;
17010s10s $self->{minicpan} = Portable::minicpan->new( $self );
# spent 0s making 1 call to Portable::minicpan::new
171 }
172
17310s return $self;
174}
175
176
# spent 15.6ms (0s+15.6) within Portable::default which was called: # once (0s+15.6ms) by Portable::apply at line 98
sub default {
177 # state $cache;
17810s return $cache if $cache;
179
180 # Get the perl executable location
18110s my $perlpath = ($ENV{HARNESS_ACTIVE} and $FAKE_PERL) ? $FAKE_PERL : $^X;
182
183 # The path to Perl has a localized path.
184 # G:\\strawberry\\perl\\bin\\perl.exe
185 # Split it up, and search upwards to try and locate the
186 # portable.perl file in the distribution root.
18710s10s my ($dist_volume, $d, $f) = Portable::FileSpec::splitpath($perlpath);
# spent 0s making 1 call to Portable::FileSpec::splitpath
18810s10s my @d = Portable::FileSpec::splitdir($d);
# spent 0s making 1 call to Portable::FileSpec::splitdir
18910s pop @d if @d > 0 && $d[-1] eq '';
19040s80s my @tmp = grep {
# spent 0s making 4 calls to Portable::CORE:ftfile, avg 0s/call # spent 0s making 4 calls to Portable::FileSpec::catpath, avg 0s/call
191 -f Portable::FileSpec::catpath( $dist_volume, $_, 'portable.perl' )
192 }
193 map {
19410s40s Portable::FileSpec::catdir(@d[0 .. $_])
# spent 0s making 4 calls to Portable::FileSpec::catdir, avg 0s/call
195 } reverse ( 0 .. $#d );
19610s my $dist_dirs = $tmp[0];
19710s unless ( defined $dist_dirs ) {
198 die("Failed to find the portable.perl file");
199 }
200
201 # Derive the main paths from the plain dirs
20210s10s my $dist_root = Portable::FileSpec::catpath($dist_volume, $dist_dirs, '' );
# spent 0s making 1 call to Portable::FileSpec::catpath
20310s10s my $conf = Portable::FileSpec::catpath($dist_volume, $dist_dirs, 'portable.perl' );
# spent 0s making 1 call to Portable::FileSpec::catpath
204
205 # Load the YAML file
20610s115.6ms my $portable = Portable::LoadYaml::load_file( $conf );
# spent 15.6ms making 1 call to Portable::LoadYaml::load_file
20710s10s unless ( _HASH($portable) ) {
# spent 0s making 1 call to Portable::_HASH
208 die("Missing or invalid portable.perl file");
209 }
210
211 # Hand off to the main constructor,
212 # cache the result and return it
21310s10s $cache = __PACKAGE__->new(
# spent 0s making 1 call to Portable::new
214 dist_volume => $dist_volume,
215 dist_dirs => $dist_dirs,
216 dist_root => $dist_root,
217 conf => $conf,
218 perlpath => $perlpath,
219 portable => $portable,
220 );
221}
222
- -
227#####################################################################
228# Configuration Accessors
229
230
# spent 0s within Portable::dist_volume which was called: # once (0s+0s) by Portable::Config::apply at line 83 of Portable/Config.pm
sub dist_volume {
23110s $_[0]->{dist_volume};
232}
233
234
# spent 0s within Portable::dist_dirs which was called: # once (0s+0s) by Portable::new at line 141
sub dist_dirs {
23510s $_[0]->{dist_dirs};
236}
237
238
# spent 0s within Portable::dist_root which was called 5 times, avg 0s/call: # once (0s+0s) by Portable::minicpan::new at line 25 of Portable/minicpan.pm # once (0s+0s) by Portable::HomeDir::new at line 27 of Portable/HomeDir.pm # once (0s+0s) by Portable::Config::new at line 23 of Portable/Config.pm # once (0s+0s) by Portable::CPAN::new at line 41 of Portable/CPAN.pm # once (0s+0s) by Portable::new at line 144
sub dist_root {
23950s $_[0]->{dist_root};
240}
241
242sub conf {
243 $_[0]->{conf};
244}
245
246sub perlpath {
247 $_[0]->{perlpath};
248}
249
250
# spent 0s within Portable::portable_cpan which was called 3 times, avg 0s/call: # once (0s+0s) by Portable::CPAN::new at line 32 of Portable/CPAN.pm # once (0s+0s) by Portable::CPAN::new at line 40 of Portable/CPAN.pm # once (0s+0s) by Portable::new at line 156
sub portable_cpan {
25130s $_[0]->{portable}->{CPAN};
252}
253
254
# spent 0s within Portable::portable_config which was called 2 times, avg 0s/call: # once (0s+0s) by Portable::Config::new at line 16 of Portable/Config.pm # once (0s+0s) by Portable::Config::new at line 22 of Portable/Config.pm
sub portable_config {
25520s $_[0]->{portable}->{Config};
256}
257
258
# spent 0s within Portable::portable_homedir which was called 3 times, avg 0s/call: # once (0s+0s) by Portable::HomeDir::new at line 26 of Portable/HomeDir.pm # once (0s+0s) by Portable::HomeDir::new at line 18 of Portable/HomeDir.pm # once (0s+0s) by Portable::new at line 162
sub portable_homedir {
25930s $_[0]->{portable}->{HomeDir};
260}
261
262
# spent 0s within Portable::portable_minicpan which was called 3 times, avg 0s/call: # once (0s+0s) by Portable::minicpan::new at line 16 of Portable/minicpan.pm # once (0s+0s) by Portable::minicpan::new at line 24 of Portable/minicpan.pm # once (0s+0s) by Portable::new at line 168
sub portable_minicpan {
26330s $_[0]->{portable}->{minicpan};
264}
265
266sub portable_env {
267 $_[0]->{portable}->{Env};
268}
269
270
# spent 0s within Portable::config which was called 2 times, avg 0s/call: # once (0s+0s) by Portable::CPAN::new at line 60 of Portable/CPAN.pm # once (0s+0s) by Portable::apply at line 101
sub config {
27120s $_[0]->{Config};
272}
273
274sub cpan {
275 $_[0]->{CPAN};
276}
277
278sub homedir {
279 $_[0]->{HomeDir};
280}
281
282sub minicpan {
283 $_[0]->{minicpan};
284}
285
286sub env {
287 $_[0]->{Env};
288}
289
29010s1;
291
292=pod
293
294=head1 SUPPORT
295
296Bugs should be reported via the CPAN bug tracker.
297
298L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Portable>
299
300For other issues, or commercial support, contact the author.
301
302=head1 AUTHOR
303
304Adam Kennedy E<lt>adamk@cpan.orgE<gt>
305
306=head1 SEE ALSO
307
308L<http://win32.perl.org/>
309
310=head1 COPYRIGHT
311
312Copyright 2008 - 2011 Adam Kennedy.
313
314This program is free software; you can redistribute
315it and/or modify it under the same terms as Perl itself.
316
317The full text of the license can be found in the
318LICENSE file included with this module.
319
320=cut
 
# spent 0s within Portable::CORE:ftfile which was called 4 times, avg 0s/call: # 4 times (0s+0s) by Portable::default at line 190, avg 0s/call
sub Portable::CORE:ftfile; # opcode