← 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:23 2013

Filename/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/Checksum.pm
StatementsExecuted 449 statements in 28.0ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
21117.2ms54.1sRTP::Webmerge::Checksum::::crcCheckEntryRTP::Webmerge::Checksum::crcCheckEntry
54315.74ms5.74msRTP::Webmerge::Checksum::::CORE:prtfRTP::Webmerge::Checksum::CORE:prtf (opcode)
1811575µs575µsRTP::Webmerge::Checksum::::CORE:ftisRTP::Webmerge::Checksum::CORE:ftis (opcode)
111222µs54.1sRTP::Webmerge::Checksum::::crcCheckRTP::Webmerge::Checksum::crcCheck
111110µs388µsRTP::Webmerge::Checksum::::BEGIN@8RTP::Webmerge::Checksum::BEGIN@8
11162µs203µsRTP::Webmerge::Checksum::::BEGIN@29RTP::Webmerge::Checksum::BEGIN@29
11159µs403µsRTP::Webmerge::Checksum::::BEGIN@28RTP::Webmerge::Checksum::BEGIN@28
11158µs269µsRTP::Webmerge::Checksum::::BEGIN@26RTP::Webmerge::Checksum::BEGIN@26
11158µs334µsRTP::Webmerge::Checksum::::BEGIN@27RTP::Webmerge::Checksum::BEGIN@27
11155µs55µsRTP::Webmerge::Checksum::::BEGIN@18.25RTP::Webmerge::Checksum::BEGIN@18.25
11155µs86µsRTP::Webmerge::Checksum::::BEGIN@10RTP::Webmerge::Checksum::BEGIN@10
11153µs138µsRTP::Webmerge::Checksum::::BEGIN@9RTP::Webmerge::Checksum::BEGIN@9
11127µs27µsRTP::Webmerge::Checksum::::BEGIN@21RTP::Webmerge::Checksum::BEGIN@21
11124µs24µsRTP::Webmerge::Checksum::::BEGIN@18RTP::Webmerge::Checksum::BEGIN@18
11123µs23µsRTP::Webmerge::Checksum::::BEGIN@15RTP::Webmerge::Checksum::BEGIN@15
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::Checksum;
6###################################################################################################
7
82174µs2666µs
# spent 388µs (110+278) within RTP::Webmerge::Checksum::BEGIN@8 which was called: # once (110µs+278µs) by main::BEGIN@36 at line 8
use Carp;
# spent 388µs making 1 call to RTP::Webmerge::Checksum::BEGIN@8 # spent 278µs making 1 call to Exporter::import
92143µs2222µs
# spent 138µs (53+85) within RTP::Webmerge::Checksum::BEGIN@9 which was called: # once (53µs+85µs) by main::BEGIN@36 at line 9
use strict;
# spent 138µs making 1 call to RTP::Webmerge::Checksum::BEGIN@9 # spent 85µs making 1 call to strict::import
102194µs2117µs
# spent 86µs (55+31) within RTP::Webmerge::Checksum::BEGIN@10 which was called: # once (55µs+31µs) by main::BEGIN@36 at line 10
use warnings;
# spent 86µs making 1 call to RTP::Webmerge::Checksum::BEGIN@10 # spent 31µs making 1 call to warnings::import
11
12###################################################################################################
13
14# define our version string
151174µs123µs
# spent 23µs within RTP::Webmerge::Checksum::BEGIN@15 which was called: # once (23µs+0s) by main::BEGIN@36 at line 15
BEGIN { $RTP::Webmerge::Checksum::VERSION = "0.70" }
# spent 23µs making 1 call to RTP::Webmerge::Checksum::BEGIN@15
16
17# load exporter and inherit from it
183393µs280µs
# spent 55µs within RTP::Webmerge::Checksum::BEGIN@18.25 which was called: # once (55µs+0s) by main::BEGIN@36 at line 18 # spent 24µs within RTP::Webmerge::Checksum::BEGIN@18 which was called: # once (24µs+0s) by main::BEGIN@36 at line 18
BEGIN { use Exporter qw(); our @ISA = qw(Exporter) }
# spent 55µs making 1 call to RTP::Webmerge::Checksum::BEGIN@18.25 # spent 24µs making 1 call to RTP::Webmerge::Checksum::BEGIN@18
19
20# define our functions to be exported
211141µs127µs
# spent 27µs within RTP::Webmerge::Checksum::BEGIN@21 which was called: # once (27µs+0s) by main::BEGIN@36 at line 21
BEGIN { our @EXPORT = qw(crcCheck); }
# spent 27µs making 1 call to RTP::Webmerge::Checksum::BEGIN@21
22
23###################################################################################################
24
25# load our local modules
262152µs2479µs
# spent 269µs (58+210) within RTP::Webmerge::Checksum::BEGIN@26 which was called: # once (58µs+210µs) by main::BEGIN@36 at line 26
use RTP::Webmerge::IO;
# spent 269µs making 1 call to RTP::Webmerge::Checksum::BEGIN@26 # spent 210µs making 1 call to Exporter::import
272177µs2611µs
# spent 334µs (58+276) within RTP::Webmerge::Checksum::BEGIN@27 which was called: # once (58µs+276µs) by main::BEGIN@36 at line 27
use RTP::Webmerge::Path;
# spent 334µs making 1 call to RTP::Webmerge::Checksum::BEGIN@27 # spent 276µs making 1 call to Exporter::import
282184µs2748µs
# spent 403µs (59+344) within RTP::Webmerge::Checksum::BEGIN@28 which was called: # once (59µs+344µs) by main::BEGIN@36 at line 28
use RTP::Webmerge::IO::CSS qw(readCSS);
# spent 403µs making 1 call to RTP::Webmerge::Checksum::BEGIN@28 # spent 344µs making 1 call to Exporter::import
2923.52ms2344µs
# spent 203µs (62+142) within RTP::Webmerge::Checksum::BEGIN@29 which was called: # once (62µs+142µs) by main::BEGIN@36 at line 29
use RTP::Webmerge::Fingerprint qw(md5sum);
# spent 203µs making 1 call to RTP::Webmerge::Checksum::BEGIN@29 # spent 142µs making 1 call to Exporter::import
30
31###################################################################################################
32
33sub crcCheckEntry
34
# spent 54.1s (17.2ms+54.1) within RTP::Webmerge::Checksum::crcCheckEntry which was called 2 times, avg 27.1s/call: # 2 times (17.2ms+54.1s) by RTP::Webmerge::Checksum::crcCheck at line 168, avg 27.1s/call
{
35
36 # get input variables
37213µs my ($config, $merge, $type) = @_;
38
39 # test if the merge has been disabled
40221µs return if exists $merge->{'disabled'} &&
41 lc $merge->{'disabled'} eq 'true';
42
43 # process all files to be written for this merge
44275µs foreach my $output (@{$merge->{'output'} || []})
45 {
46
47 # test if the merge has been disabled
4818107µs return if exists $output->{'disabled'} &&
49 lc $output->{'disabled'} eq 'true';
50
51 # create the result hash for various checks
5218306µs my $result = { 'dst' => 0, 'src' => 0, 'srcs' => [] };
53
54 # create path to store this generated output
5518112µs my $result_path = $output->{'outputpath'};
56
57 # create path to store checksum of this output
5818106µs my $checksum_path = join('.', $result_path, 'md5');
59
60181.44ms18575µs unless (-e $checksum_path)
# spent 575µs making 18 calls to RTP::Webmerge::Checksum::CORE:ftis, avg 32µs/call
61 {
62
63 print $checksum_path . " not found\n";
64
65 }
66 else
67 {
68
69 # read the whole checksum file
7018342µs1827.8ms my $crc = readfile($checksum_path);
# spent 27.8ms making 18 calls to RTP::Webmerge::IO::readfile, avg 1.54ms/call
71
72 # split checksum file content into lines
73183.24ms my @crcs = split(/\s*(?:\r?\n)+\s*/, ${$crc});
74
75 # remove leading checksums
7618132µs my $checksum_result = shift(@crcs);
771847µs my $checksum_joined = shift(@crcs);
78
79 # read the previously created file
8018282µs1897.7ms my $content = readfile($result_path);
# spent 97.7ms making 18 calls to RTP::Webmerge::IO::readfile, avg 5.43ms/call
81
82 # check if the generated content changed
8318721µs3633.5ms if (md5sum($content) ne $checksum_result)
# spent 33.3ms making 18 calls to RTP::Webmerge::Fingerprint::md5sum, avg 1.85ms/call # spent 230µs making 18 calls to Digest::MD5::DESTROY, avg 13µs/call
84 {
85 printf "FAIL - dst: %s\n", substr(exportURI($result_path), - 45);
86 printf "=> %s vs %s\n", md5sum($content), $checksum_result;
87 }
88 else
89 {
90182.69ms3640.3ms printf "PASS - dst: %s\n", substr(exportURI($result_path), - 45);
# spent 38.4ms making 18 calls to RTP::Webmerge::Path::exportURI, avg 2.13ms/call # spent 1.92ms making 18 calls to RTP::Webmerge::Checksum::CORE:prtf, avg 107µs/call
91 }
92
93 # declare local variable
941870µs my $crcs_joined = '';
95
96 # process all source files
9718185µs foreach my $source (@crcs)
98 {
99
100 # split the line into path and checksum
10118521µs my ($source_path, $source_crc) = split(/:\s*/, $source, 2);
102
103 # source_path is always relative from the readed checksum file
10418646µs3623.4ms $source_path = check_path(join('/', dirname($checksum_path), $source_path));
# spent 16.4ms making 18 calls to RTP::Webmerge::Path::check_path, avg 910µs/call # spent 7.00ms making 18 calls to File::Basename::dirname, avg 389µs/call
105
106 # read the previously created file
10718361µs1853.8s my $subcontent = $type ne 'css' ?
# spent 53.8s making 18 calls to RTP::Webmerge::IO::CSS::readCSS, avg 2.99s/call
108 readfile($source_path) :
109 readCSS($source_path, $config);
110
11118497µs3616.3ms $crcs_joined .= my $source_md5 = md5sum($subcontent) || 'na';
# spent 16.1ms making 18 calls to RTP::Webmerge::Fingerprint::md5sum, avg 893µs/call # spent 217µs making 18 calls to Digest::MD5::DESTROY, avg 12µs/call
112
113 # check against stored value
114184.17ms if ($source_md5 ne $source_crc)
115 {
116 printf " FAIL - src: %s\n", substr(exportURI($source_path), - 45);
117 printf " => %s vs %s\n", $source_md5, $source_crc;
118 }
119 else
120 {
121182.54ms3638.8ms printf " PASS - src: %s\n", substr(exportURI($source_path), - 45);
# spent 37.0ms making 18 calls to RTP::Webmerge::Path::exportURI, avg 2.06ms/call # spent 1.82ms making 18 calls to RTP::Webmerge::Checksum::CORE:prtf, avg 101µs/call
122 }
123
124 }
125
12618471µs363.79ms my $crc_joined = md5sum(\$crcs_joined);
# spent 3.57ms making 18 calls to RTP::Webmerge::Fingerprint::md5sum, avg 198µs/call # spent 218µs making 18 calls to Digest::MD5::DESTROY, avg 12µs/call
127
12818543µs if ($crc_joined ne $checksum_joined)
129 {
130 printf "FAIL - tst: %s\n", substr(exportURI(check_path($result_path)), - 45);
131 }
132 else
133 {
134182.95ms5458.4ms printf "PASS - tst: %s\n", substr(exportURI(check_path($result_path)), - 45);
# spent 38.7ms making 18 calls to RTP::Webmerge::Path::exportURI, avg 2.15ms/call # spent 17.7ms making 18 calls to RTP::Webmerge::Path::check_path, avg 982µs/call # spent 2.00ms making 18 calls to RTP::Webmerge::Checksum::CORE:prtf, avg 111µs/call
135 }
136
137
138 }
139
- -
142 }
143
144}
145
146# checksum various stuff
147# only mkdir is implemented
148sub crcCheck
149
# spent 54.1s (222µs+54.1) within RTP::Webmerge::Checksum::crcCheck which was called: # once (222µs+54.1s) by main::RUNTIME at line 698 of webmerge/scripts/webmerge.pl
{
150
151 # get input variables
15214µs my ($config) = @_;
153
154 # get the xml config root
15514µs my $xml = $config->{'xml'};
156
157163µs foreach my $merges (@{$xml->{'merge'} || []})
158 {
159
160 # change directory (restore previous state after this block)
161142µs121µs my $dir = RTP::Webmerge::Path->chdir($merges->{'chdir'});
# spent 21µs making 1 call to RTP::Webmerge::Path::chdir
162
163 # do not process if disabled attribute is given and set to true
164123µs unless ($merges->{'disabled'} && lc $merges->{'disabled'} eq 'true')
165 {
166
16718µs foreach my $merge (@{$merges->{'css'} || []})
168237µs254.1s { crcCheckEntry($config, $merge, 'css'); }
# spent 54.1s making 2 calls to RTP::Webmerge::Checksum::crcCheckEntry, avg 27.1s/call
169
170118µs foreach my $merge (@{$merges->{'js'} || []})
171 { crcCheckEntry($config, $merge, 'js'); }
172
173 }
174
175 }
176
177
178}
179# EO sub prepare
180
181###################################################################################################
182###################################################################################################
183113µs1;
 
# spent 575µs within RTP::Webmerge::Checksum::CORE:ftis which was called 18 times, avg 32µs/call: # 18 times (575µs+0s) by RTP::Webmerge::Checksum::crcCheckEntry at line 60, avg 32µs/call
sub RTP::Webmerge::Checksum::CORE:ftis; # opcode
# spent 5.74ms within RTP::Webmerge::Checksum::CORE:prtf which was called 54 times, avg 106µs/call: # 18 times (2.00ms+0s) by RTP::Webmerge::Checksum::crcCheckEntry at line 134, avg 111µs/call # 18 times (1.92ms+0s) by RTP::Webmerge::Checksum::crcCheckEntry at line 90, avg 107µs/call # 18 times (1.82ms+0s) by RTP::Webmerge::Checksum::crcCheckEntry at line 121, avg 101µs/call
sub RTP::Webmerge::Checksum::CORE:prtf; # opcode