← Index
NYTProf Performance Profile   « line view »
For webmerge/scripts/webmerge.pl
  Run on Mon Oct 7 02:42:42 2013
Reported on Mon Oct 7 03:03:21 2013

Filename/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/Path.pm
StatementsExecuted 261084 statements in 5.42s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
13585212.65s21.8sRTP::Webmerge::Path::::importURIRTP::Webmerge::Path::importURI
19016831.30s49.1sRTP::Webmerge::Path::::exportURIRTP::Webmerge::Path::exportURI
2719135254ms2.89sRTP::Webmerge::Path::::check_pathRTP::Webmerge::Path::check_path
273722225ms290msRTP::Webmerge::Path::::res_pathRTP::Webmerge::Path::res_path
1358921176ms176msRTP::Webmerge::Path::::CORE:ftdirRTP::Webmerge::Path::CORE:ftdir (opcode)
217864199.6ms99.6msRTP::Webmerge::Path::::CORE:substRTP::Webmerge::Path::CORE:subst (opcode)
163263171.4ms71.4msRTP::Webmerge::Path::::CORE:matchRTP::Webmerge::Path::CORE:match (opcode)
1112.53ms4.17msRTP::Webmerge::Path::::BEGIN@43RTP::Webmerge::Path::BEGIN@43
964515µs909µsRTP::Webmerge::Path::::chdirRTP::Webmerge::Path::chdir
11194µs441µsRTP::Webmerge::Path::::BEGIN@37RTP::Webmerge::Path::BEGIN@37
11188µs363µsRTP::Webmerge::Path::::BEGIN@8RTP::Webmerge::Path::BEGIN@8
42273µs73µsRTP::Webmerge::Path::::DESTROYRTP::Webmerge::Path::DESTROY
11165µs365µsRTP::Webmerge::Path::::BEGIN@40RTP::Webmerge::Path::BEGIN@40
11156µs56µsRTP::Webmerge::Path::::BEGIN@26.11RTP::Webmerge::Path::BEGIN@26.11
11155µs88µsRTP::Webmerge::Path::::BEGIN@10RTP::Webmerge::Path::BEGIN@10
11154µs141µsRTP::Webmerge::Path::::BEGIN@9RTP::Webmerge::Path::BEGIN@9
11130µs30µsRTP::Webmerge::Path::::BEGIN@32RTP::Webmerge::Path::BEGIN@32
11128µs28µsRTP::Webmerge::Path::::BEGIN@29RTP::Webmerge::Path::BEGIN@29
11123µs23µsRTP::Webmerge::Path::::BEGIN@23RTP::Webmerge::Path::BEGIN@23
11122µs22µsRTP::Webmerge::Path::::BEGIN@26RTP::Webmerge::Path::BEGIN@26
0000s0sRTP::Webmerge::Path::::EODRTP::Webmerge::Path::EOD
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1###################################################################################################
2# Copyright 2013 by Marcel Greter
3# This file is part of Webmerge (GPL3)
4###################################################################################################
5package RTP::Webmerge::Path;
6###################################################################################################
7
82169µs2638µs
# spent 363µs (88+275) within RTP::Webmerge::Path::BEGIN@8 which was called: # once (88µs+275µs) by RTP::Webmerge::BEGIN@58 at line 8
use Carp;
# spent 363µs making 1 call to RTP::Webmerge::Path::BEGIN@8 # spent 275µs making 1 call to Exporter::import
92146µs2228µs
# spent 141µs (54+87) within RTP::Webmerge::Path::BEGIN@9 which was called: # once (54µs+87µs) by RTP::Webmerge::BEGIN@58 at line 9
use strict;
# spent 141µs making 1 call to RTP::Webmerge::Path::BEGIN@9 # spent 87µs making 1 call to strict::import
102322µs2121µs
# spent 88µs (55+33) within RTP::Webmerge::Path::BEGIN@10 which was called: # once (55µs+33µs) by RTP::Webmerge::BEGIN@58 at line 10
use warnings;
# spent 88µs making 1 call to RTP::Webmerge::Path::BEGIN@10 # spent 33µs making 1 call to warnings::import
11
12###################################################################################################
13
14# global variables for various paths
15# $webroot: absolute path to htdocs root
16# $confroot: directory of the config file
17# $directory: our current working directory
1812µsour ($webroot, $confroot, $extroot, $directory);
19
20###################################################################################################
21
22# define our version string
231149µs123µs
# spent 23µs within RTP::Webmerge::Path::BEGIN@23 which was called: # once (23µs+0s) by RTP::Webmerge::BEGIN@58 at line 23
BEGIN { $RTP::Webmerge::Path::VERSION = "0.8.3" }
# spent 23µs making 1 call to RTP::Webmerge::Path::BEGIN@23
24
25# load exporter and inherit from it
263375µs279µs
# spent 22µs within RTP::Webmerge::Path::BEGIN@26 which was called: # once (22µs+0s) by RTP::Webmerge::BEGIN@58 at line 26 # spent 56µs within RTP::Webmerge::Path::BEGIN@26.11 which was called: # once (56µs+0s) by RTP::Webmerge::BEGIN@58 at line 26
BEGIN { use Exporter qw(); our @ISA = qw(Exporter) }
# spent 56µs making 1 call to RTP::Webmerge::Path::BEGIN@26.11 # spent 22µs making 1 call to RTP::Webmerge::Path::BEGIN@26
27
28# define our variables to be exported
291185µs128µs
# spent 28µs within RTP::Webmerge::Path::BEGIN@29 which was called: # once (28µs+0s) by RTP::Webmerge::BEGIN@58 at line 29
BEGIN { our @EXPORT = qw(dirname res_path check_path exportURI importURI); }
# spent 28µs making 1 call to RTP::Webmerge::Path::BEGIN@29
30
31# define our functions to be exported
321173µs130µs
# spent 30µs within RTP::Webmerge::Path::BEGIN@32 which was called: # once (30µs+0s) by RTP::Webmerge::BEGIN@58 at line 32
BEGIN { our @EXPORT_OK = qw(EOD basename $webroot $confroot $extroot $directory); }
# spent 30µs making 1 call to RTP::Webmerge::Path::BEGIN@32
33
34###################################################################################################
35
36# use cwd to normalize paths
372286µs2788µs
# spent 441µs (94+347) within RTP::Webmerge::Path::BEGIN@37 which was called: # once (94µs+347µs) by RTP::Webmerge::BEGIN@58 at line 37
use Cwd qw(realpath abs_path);
# spent 441µs making 1 call to RTP::Webmerge::Path::BEGIN@37 # spent 347µs making 1 call to Exporter::import
38
39# use to parse path and filename
402178µs2665µs
# spent 365µs (65+300) within RTP::Webmerge::Path::BEGIN@40 which was called: # once (65µs+300µs) by RTP::Webmerge::BEGIN@58 at line 40
use File::Basename qw(dirname basename);
# spent 365µs making 1 call to RTP::Webmerge::Path::BEGIN@40 # spent 300µs making 1 call to Exporter::import
41
42# import system path conversion functions
4324.03ms24.66ms
# spent 4.17ms (2.53+1.64) within RTP::Webmerge::Path::BEGIN@43 which was called: # once (2.53ms+1.64ms) by RTP::Webmerge::BEGIN@58 at line 43
use File::Spec::Functions qw(rel2abs abs2rel);
# spent 4.17ms making 1 call to RTP::Webmerge::Path::BEGIN@43 # spent 491µs making 1 call to Exporter::import
44
45###################################################################################################
46
47# directory delimiter for supported OS
48sub EOD { $^O eq "MSWin32" ? '\\' : '/'; }
49
50###################################################################################################
51
52# resolve URI to an absolute path on filesystem
53# directory has to exist, but not the actual file
54sub importURI
55
# spent 21.8s (2.65+19.1) within RTP::Webmerge::Path::importURI which was called 13585 times, avg 1.60ms/call: # 12350 times (2.40s+17.6s) by RTP::Webmerge::IO::CSS::incCSS at line 87 of webmerge/scripts/modules/RTP/Webmerge/IO/CSS.pm, avg 1.62ms/call # 1235 times (249ms+1.56s) by RTP::Webmerge::IO::CSS::importCSS at line 133 of webmerge/scripts/modules/RTP/Webmerge/IO/CSS.pm, avg 1.47ms/call
{
56
57 # get URI and local path
5813585115ms my ($uri, $relpath) = @_;
59
60 # set relpath to webroot if nothin else given
611358520.2ms $relpath = $webroot unless defined $relpath;
62
63 # remove hash tag and query string for URI
6413585363ms1358557.8ms my $suffix = $uri =~ s/([\;\?\#].*?)$// ? $1 : '';
# spent 57.8ms making 13585 calls to RTP::Webmerge::Path::CORE:subst, avg 4µs/call
65
66 # get path and filename
6713585172ms135853.82s my $path = dirname $uri;
# spent 3.82s making 13585 calls to File::Basename::dirname, avg 281µs/call
6813585165ms135853.56s my $file = basename $uri;
# spent 3.56s making 13585 calls to File::Basename::basename, avg 262µs/call
69
70 # check if URI is absolute
7113585402ms1358548.0ms if ($uri =~ m/^\//)
# spent 48.0ms making 13585 calls to RTP::Webmerge::Path::CORE:match, avg 4µs/call
72 {
73 # absolute uris should be loaded from webroot
74 # if you need another webroot, localize it before
75 $path = realpath(join('/', $webroot, $path));
76 }
77 else
78 {
79 # relative uris load from parent cssfile
80135851.52s2717011.5s $path = realpath(rel2abs($path, $relpath));
# spent 10.4s making 13585 calls to File::Spec::Functions::__ANON__[File/Spec/Functions.pm:43], avg 764µs/call # spent 1.08s making 13585 calls to Cwd::abs_path, avg 79µs/call
81 }
82
83 # assert that at least the path of the URI exists on the actual filesystem
8413585403ms13585176ms die "URI($uri) could not be imported (CWD: $relpath)\n" unless $path && -d $path;
# spent 176ms making 13585 calls to RTP::Webmerge::Path::CORE:ftdir, avg 13µs/call
85
86 # return the final absolute local path
87 # the suffix is lost as we convert the
88 # URI to a real absolute local filepath
8913585498ms return join('/', $path, $file);
90
91}
92# EO sub importURI
93
94###################################################################################################
95
96# export an absolute path on filesystem to an URI
97# maybe absolute or relative from the given path
98# if no path is given, we use the global webroot
99sub exportURI ($;$$)
100
# spent 49.1s (1.30+47.8) within RTP::Webmerge::Path::exportURI which was called 19016 times, avg 2.58ms/call: # 12350 times (842ms+29.8s) by RTP::Webmerge::IO::CSS::readCSS at line 113 of webmerge/scripts/modules/RTP/Webmerge/IO/CSS.pm, avg 2.48ms/call # 6574 times (430ms+17.7s) by RTP::Webmerge::IO::CSS::exportCSS at line 153 of webmerge/scripts/modules/RTP/Webmerge/IO/CSS.pm, avg 2.76ms/call # 18 times (27.1ms+88.0ms) by RTP::Webmerge::Merge::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/Merge.pm:480] at line 363 of webmerge/scripts/modules/RTP/Webmerge/Merge.pm, avg 6.39ms/call # 18 times (1.02ms+38.4ms) by RTP::Webmerge::Merge::writer at line 116 of webmerge/scripts/modules/RTP/Webmerge/Merge.pm, avg 2.19ms/call # 18 times (924µs+37.8ms) by RTP::Webmerge::Checksum::crcCheckEntry at line 134 of webmerge/scripts/modules/RTP/Webmerge/Checksum.pm, avg 2.15ms/call # 18 times (960µs+37.5ms) by RTP::Webmerge::Checksum::crcCheckEntry at line 90 of webmerge/scripts/modules/RTP/Webmerge/Checksum.pm, avg 2.13ms/call # 18 times (889µs+36.1ms) by RTP::Webmerge::Checksum::crcCheckEntry at line 121 of webmerge/scripts/modules/RTP/Webmerge/Checksum.pm, avg 2.06ms/call # 2 times (102µs+4.00ms) by RTP::Webmerge::Merge::collect at line 233 of webmerge/scripts/modules/RTP/Webmerge/Merge.pm, avg 2.05ms/call
{
101
102 # get input variables
10319016190ms my ($path, $relpath, $abs) = @_;
104
105 # set relpath to webroot if nothin else given
1061901645.2ms $relpath = $webroot unless defined $relpath;
107
108 # relative URI from relpath
10919016257ms1901647.8s my $uri = abs2rel($path, $relpath);
# spent 47.8s making 19016 calls to File::Spec::Functions::__ANON__[File/Spec/Functions.pm:43], avg 2.51ms/call
110
111 # normalize directory delimiters on win
1121901691.6ms $uri =~ s/\\+/\//g if $^O eq "MSWin32";
113
114 # create absolute URI if set
1151901625.3ms $uri = '/' . $uri if $abs;
116
117 # return URI
11819016423ms return $uri;
119
120}
121# EO sub exportURI
122
123###################################################################################################
124
125# resolve path with special markers for directories
126# will replace {EXT}, {WWW} and {CONF} is given paths
127# also make relative paths relative to current directory
128sub res_path ($)
129
# spent 290ms (225+65.1) within RTP::Webmerge::Path::res_path which was called 2737 times, avg 106µs/call: # 2719 times (224ms+64.9ms) by RTP::Webmerge::Path::check_path at line 160, avg 106µs/call # 18 times (1.10ms+265µs) by RTP::Webmerge::collectOutputs at line 129 of webmerge/scripts/modules/RTP/Webmerge.pm, avg 76µs/call
{
130
131 # get path string
132273710.4ms my ($path) = @_;
133
134 # make some assertions and give die message from parent
13527374.34ms Carp::croak "check_path with undefined path called" if not defined $path;
13627377.59ms Carp::croak "check_path with empty path called" if $path eq '';
137
138 # replace variables within path
139 # make dollar sign mandatory in future
140273762.0ms273619.5ms $path =~ s/\$?\{EXT\}/$extroot/gm if $extroot;
# spent 19.5ms making 2736 calls to RTP::Webmerge::Path::CORE:subst, avg 7µs/call
141273744.1ms273011.0ms $path =~ s/\$?\{WWW\}/$webroot/gm if $webroot;
# spent 11.0ms making 2730 calls to RTP::Webmerge::Path::CORE:subst, avg 4µs/call
142273766.1ms273511.3ms $path =~ s/\$?\{CONF\}/$confroot/gm if $confroot;
# spent 11.3ms making 2735 calls to RTP::Webmerge::Path::CORE:subst, avg 4µs/call
143
144 # return if path is already absolute
1452737110ms273723.4ms return $path if $path =~m /^(?:\/|[a-zA-Z]:)/;
# spent 23.4ms making 2737 calls to RTP::Webmerge::Path::CORE:match, avg 9µs/call
146
147 # prepended current directory and return
148431.07ms return join('/', $directory || '.', $path);
149
150}
151
152###################################################################################################
153
154# same as resolve path but check for existence of the parent directory
155# will resolve path to current filesystem and returns an absolute path
156sub check_path ($)
157
# spent 2.89s (254ms+2.64) within RTP::Webmerge::Path::check_path which was called 2719 times, avg 1.06ms/call: # 2614 times (245ms+2.54s) by RTP::Webmerge::IO::readfile at line 112 of webmerge/scripts/modules/RTP/Webmerge/IO.pm, avg 1.07ms/call # 39 times (3.51ms+36.1ms) by RTP::Webmerge::IO::writefile at line 184 of webmerge/scripts/modules/RTP/Webmerge/IO.pm, avg 1.01ms/call # 18 times (1.69ms+17.5ms) by RTP::Webmerge::Merge::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/Merge.pm:480] at line 353 of webmerge/scripts/modules/RTP/Webmerge/Merge.pm, avg 1.07ms/call # 18 times (1.53ms+16.2ms) by RTP::Webmerge::Checksum::crcCheckEntry at line 134 of webmerge/scripts/modules/RTP/Webmerge/Checksum.pm, avg 982µs/call # 18 times (1.47ms+14.9ms) by RTP::Webmerge::Checksum::crcCheckEntry at line 104 of webmerge/scripts/modules/RTP/Webmerge/Checksum.pm, avg 910µs/call # 4 times (315µs+2.87ms) by RTP::Webmerge::Prepare::prepare at line 61 of webmerge/scripts/modules/RTP/Webmerge/Prepare.pm, avg 796µs/call # 2 times (160µs+1.65ms) by RTP::Webmerge::Merge::collect at line 229 of webmerge/scripts/modules/RTP/Webmerge/Merge.pm, avg 903µs/call # once (82µs+804µs) by main::RUNTIME at line 399 of webmerge/scripts/webmerge.pl # once (105µs+777µs) by main::RUNTIME at line 241 of webmerge/scripts/webmerge.pl # once (69µs+715µs) by main::get_xml at line 280 of webmerge/scripts/webmerge.pl # once (71µs+699µs) by main::RUNTIME at line 400 of webmerge/scripts/webmerge.pl # once (64µs+668µs) by main::read_xml at line 307 of webmerge/scripts/webmerge.pl # once (68µs+558µs) by main::RUNTIME at line 247 of webmerge/scripts/webmerge.pl
{
158
159 # resolve the path string
160271933.1ms2719289ms my $path = &res_path;
# spent 289ms making 2719 calls to RTP::Webmerge::Path::res_path, avg 106µs/call
161
162 # create absolute path for the directory and re-add filename
163 # abs_path will error out if the given path does not exist
1642719382ms81572.35s return join('/', abs_path(dirname($path)), basename($path));
# spent 1.12s making 2719 calls to File::Basename::dirname, avg 411µs/call # spent 1.02s making 2719 calls to File::Basename::basename, avg 374µs/call # spent 213ms making 2719 calls to Cwd::abs_path, avg 78µs/call
165
166}
167
168###################################################################################################
169
170# change current directory
171# returns an object you have to hold on
172# as soon as the object is destroyed we
173# restore the previous current directory
174sub chdir
175
# spent 909µs (515+394) within RTP::Webmerge::Path::chdir which was called 9 times, avg 101µs/call: # 2 times (238µs+210µs) by RTP::Webmerge::collectOutputs at line 100 of webmerge/scripts/modules/RTP/Webmerge.pm, avg 224µs/call # 2 times (184µs+184µs) by RTP::Webmerge::Merge::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/Merge.pm:480] at line 336 of webmerge/scripts/modules/RTP/Webmerge/Merge.pm, avg 184µs/call # 2 times (34µs+0s) by RTP::Webmerge::Prepare::prepare at line 51 of webmerge/scripts/modules/RTP/Webmerge/Prepare.pm, avg 17µs/call # once (21µs+0s) by RTP::Webmerge::collectOutputs at line 89 of webmerge/scripts/modules/RTP/Webmerge.pm # once (21µs+0s) by RTP::Webmerge::Checksum::crcCheck at line 161 of webmerge/scripts/modules/RTP/Webmerge/Checksum.pm # once (16µs+0s) by RTP::Webmerge::Merge::merger at line 497 of webmerge/scripts/modules/RTP/Webmerge/Merge.pm
{
176
177 # chdir arguments
178951µs my ($self, $chdirs) = @_;
179
180 # assert that current has some value
18199µs $directory = abs_path '.' unless $directory;
182
183 # assertion that we have some valid arguments
1849134µs return unless $chdirs && scalar(@{$chdirs}) > 0;
185
186 # create a new variable
187412µs my $dir = $directory;
188
189 # accept array as chdirs argument
190423µs foreach my $chdir (@{$chdirs || []})
191 {
192 # now change our current directory variable
1934144µs452µs if ($chdir =~ m/^(?:\/|[a-z]:)/i) { $directory = $chdir; }
# spent 52µs making 4 calls to RTP::Webmerge::Path::CORE:match, avg 13µs/call
194432µs else { $directory = join('/', $directory, $chdir); }
195 }
196
197 # give a message to the console for debug
198 # print "changed directory => $directory\n";
199
200 # assertion that the directory does actually exist
2014162µs488µs die "chdir failed, directory <$directory> does not exist!\n" unless -d $directory;
# spent 88µs making 4 calls to RTP::Webmerge::Path::CORE:ftdir, avg 22µs/call
202
203 # resolve to an absolute path
2044322µs4254µs $directory = abs_path($directory);
# spent 254µs making 4 calls to Cwd::abs_path, avg 64µs/call
205
206 # bless scalar reference
2074131µs return bless \ $dir, $self;
208
209}
210
211###################################################################################################
212
213# restore the saved directory
214sub DESTROY
215
# spent 73µs within RTP::Webmerge::Path::DESTROY which was called 4 times, avg 18µs/call: # 2 times (46µs+0s) by RTP::Webmerge::Merge::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/Merge.pm:480] at line 512 of webmerge/scripts/modules/RTP/Webmerge/Merge.pm, avg 23µs/call # 2 times (27µs+0s) by RTP::Webmerge::collectOutputs at line 115 of webmerge/scripts/modules/RTP/Webmerge.pm, avg 14µs/call
{
216
217 # destroy arguments
218416µs my ($self) = @_;
219
220 # restore old directory
2214110µs $directory = ${$self};
222
223 # give a message to the console for debug
224 # print "restored directory => $directory\n";
225
226}
227
228###################################################################################################
229###################################################################################################
230117µs1;
 
# spent 176ms within RTP::Webmerge::Path::CORE:ftdir which was called 13589 times, avg 13µs/call: # 13585 times (176ms+0s) by RTP::Webmerge::Path::importURI at line 84, avg 13µs/call # 4 times (88µs+0s) by RTP::Webmerge::Path::chdir at line 201, avg 22µs/call
sub RTP::Webmerge::Path::CORE:ftdir; # opcode
# spent 71.4ms within RTP::Webmerge::Path::CORE:match which was called 16326 times, avg 4µs/call: # 13585 times (48.0ms+0s) by RTP::Webmerge::Path::importURI at line 71, avg 4µs/call # 2737 times (23.4ms+0s) by RTP::Webmerge::Path::res_path at line 145, avg 9µs/call # 4 times (52µs+0s) by RTP::Webmerge::Path::chdir at line 193, avg 13µs/call
sub RTP::Webmerge::Path::CORE:match; # opcode
# spent 99.6ms within RTP::Webmerge::Path::CORE:subst which was called 21786 times, avg 5µs/call: # 13585 times (57.8ms+0s) by RTP::Webmerge::Path::importURI at line 64, avg 4µs/call # 2736 times (19.5ms+0s) by RTP::Webmerge::Path::res_path at line 140, avg 7µs/call # 2735 times (11.3ms+0s) by RTP::Webmerge::Path::res_path at line 142, avg 4µs/call # 2730 times (11.0ms+0s) by RTP::Webmerge::Path::res_path at line 141, avg 4µs/call
sub RTP::Webmerge::Path::CORE:subst; # opcode