Filename | /home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/Checksum.pm |
Statements | Executed 449 statements in 28.0ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
2 | 1 | 1 | 17.2ms | 54.1s | crcCheckEntry | RTP::Webmerge::Checksum::
54 | 3 | 1 | 5.74ms | 5.74ms | CORE:prtf (opcode) | RTP::Webmerge::Checksum::
18 | 1 | 1 | 575µs | 575µs | CORE:ftis (opcode) | RTP::Webmerge::Checksum::
1 | 1 | 1 | 222µs | 54.1s | crcCheck | RTP::Webmerge::Checksum::
1 | 1 | 1 | 110µs | 388µs | BEGIN@8 | RTP::Webmerge::Checksum::
1 | 1 | 1 | 62µs | 203µs | BEGIN@29 | RTP::Webmerge::Checksum::
1 | 1 | 1 | 59µs | 403µs | BEGIN@28 | RTP::Webmerge::Checksum::
1 | 1 | 1 | 58µs | 269µs | BEGIN@26 | RTP::Webmerge::Checksum::
1 | 1 | 1 | 58µs | 334µs | BEGIN@27 | RTP::Webmerge::Checksum::
1 | 1 | 1 | 55µs | 55µs | BEGIN@18.25 | RTP::Webmerge::Checksum::
1 | 1 | 1 | 55µs | 86µs | BEGIN@10 | RTP::Webmerge::Checksum::
1 | 1 | 1 | 53µs | 138µs | BEGIN@9 | RTP::Webmerge::Checksum::
1 | 1 | 1 | 27µs | 27µs | BEGIN@21 | RTP::Webmerge::Checksum::
1 | 1 | 1 | 24µs | 24µs | BEGIN@18 | RTP::Webmerge::Checksum::
1 | 1 | 1 | 23µs | 23µs | BEGIN@15 | RTP::Webmerge::Checksum::
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 | ################################################################################################### | ||||
5 | package RTP::Webmerge::Checksum; | ||||
6 | ################################################################################################### | ||||
7 | |||||
8 | 2 | 174µs | 2 | 666µ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 # spent 388µs making 1 call to RTP::Webmerge::Checksum::BEGIN@8
# spent 278µs making 1 call to Exporter::import |
9 | 2 | 143µs | 2 | 222µ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 # spent 138µs making 1 call to RTP::Webmerge::Checksum::BEGIN@9
# spent 85µs making 1 call to strict::import |
10 | 2 | 194µs | 2 | 117µ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 # 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 | ||||
15 | 1 | 174µs | 1 | 23µs | # spent 23µs within RTP::Webmerge::Checksum::BEGIN@15 which was called:
# once (23µs+0s) by main::BEGIN@36 at line 15 # spent 23µs making 1 call to RTP::Webmerge::Checksum::BEGIN@15 |
16 | |||||
17 | # load exporter and inherit from it | ||||
18 | 3 | 393µs | 2 | 80µs | 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 | ||||
21 | 1 | 141µs | 1 | 27µs | # spent 27µs within RTP::Webmerge::Checksum::BEGIN@21 which was called:
# once (27µs+0s) by main::BEGIN@36 at line 21 # spent 27µs making 1 call to RTP::Webmerge::Checksum::BEGIN@21 |
22 | |||||
23 | ################################################################################################### | ||||
24 | |||||
25 | # load our local modules | ||||
26 | 2 | 152µs | 2 | 479µ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 # spent 269µs making 1 call to RTP::Webmerge::Checksum::BEGIN@26
# spent 210µs making 1 call to Exporter::import |
27 | 2 | 177µs | 2 | 611µ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 # spent 334µs making 1 call to RTP::Webmerge::Checksum::BEGIN@27
# spent 276µs making 1 call to Exporter::import |
28 | 2 | 184µs | 2 | 748µ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 # spent 403µs making 1 call to RTP::Webmerge::Checksum::BEGIN@28
# spent 344µs making 1 call to Exporter::import |
29 | 2 | 3.52ms | 2 | 344µ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 # spent 203µs making 1 call to RTP::Webmerge::Checksum::BEGIN@29
# spent 142µs making 1 call to Exporter::import |
30 | |||||
31 | ################################################################################################### | ||||
32 | |||||
33 | sub 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 | ||||
37 | 2 | 13µs | my ($config, $merge, $type) = @_; | ||
38 | |||||
39 | # test if the merge has been disabled | ||||
40 | 2 | 21µs | return if exists $merge->{'disabled'} && | ||
41 | lc $merge->{'disabled'} eq 'true'; | ||||
42 | |||||
43 | # process all files to be written for this merge | ||||
44 | 2 | 75µs | foreach my $output (@{$merge->{'output'} || []}) | ||
45 | { | ||||
46 | |||||
47 | # test if the merge has been disabled | ||||
48 | 18 | 107µs | return if exists $output->{'disabled'} && | ||
49 | lc $output->{'disabled'} eq 'true'; | ||||
50 | |||||
51 | # create the result hash for various checks | ||||
52 | 18 | 306µs | my $result = { 'dst' => 0, 'src' => 0, 'srcs' => [] }; | ||
53 | |||||
54 | # create path to store this generated output | ||||
55 | 18 | 112µs | my $result_path = $output->{'outputpath'}; | ||
56 | |||||
57 | # create path to store checksum of this output | ||||
58 | 18 | 106µs | my $checksum_path = join('.', $result_path, 'md5'); | ||
59 | |||||
60 | 18 | 1.44ms | 18 | 575µ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 | ||||
70 | 18 | 342µs | 18 | 27.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 | ||||
73 | 18 | 3.24ms | my @crcs = split(/\s*(?:\r?\n)+\s*/, ${$crc}); | ||
74 | |||||
75 | # remove leading checksums | ||||
76 | 18 | 132µs | my $checksum_result = shift(@crcs); | ||
77 | 18 | 47µs | my $checksum_joined = shift(@crcs); | ||
78 | |||||
79 | # read the previously created file | ||||
80 | 18 | 282µs | 18 | 97.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 | ||||
83 | 18 | 721µs | 36 | 33.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 | { | ||||
90 | 18 | 2.69ms | 36 | 40.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 | ||||
94 | 18 | 70µs | my $crcs_joined = ''; | ||
95 | |||||
96 | # process all source files | ||||
97 | 18 | 185µs | foreach my $source (@crcs) | ||
98 | { | ||||
99 | |||||
100 | # split the line into path and checksum | ||||
101 | 18 | 521µs | my ($source_path, $source_crc) = split(/:\s*/, $source, 2); | ||
102 | |||||
103 | # source_path is always relative from the readed checksum file | ||||
104 | 18 | 646µs | 36 | 23.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 | ||||
107 | 18 | 361µs | 18 | 53.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 | |||||
111 | 18 | 497µs | 36 | 16.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 | ||||
114 | 18 | 4.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 | { | ||||
121 | 18 | 2.54ms | 36 | 38.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 | |||||
126 | 18 | 471µs | 36 | 3.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 | |||||
128 | 18 | 543µ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 | { | ||||
134 | 18 | 2.95ms | 54 | 58.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 | ||||
148 | sub 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 | ||||
152 | 1 | 4µs | my ($config) = @_; | ||
153 | |||||
154 | # get the xml config root | ||||
155 | 1 | 4µs | my $xml = $config->{'xml'}; | ||
156 | |||||
157 | 1 | 63µs | foreach my $merges (@{$xml->{'merge'} || []}) | ||
158 | { | ||||
159 | |||||
160 | # change directory (restore previous state after this block) | ||||
161 | 1 | 42µs | 1 | 21µ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 | ||||
164 | 1 | 23µs | unless ($merges->{'disabled'} && lc $merges->{'disabled'} eq 'true') | ||
165 | { | ||||
166 | |||||
167 | 1 | 8µs | foreach my $merge (@{$merges->{'css'} || []}) | ||
168 | 2 | 37µs | 2 | 54.1s | { crcCheckEntry($config, $merge, 'css'); } # spent 54.1s making 2 calls to RTP::Webmerge::Checksum::crcCheckEntry, avg 27.1s/call |
169 | |||||
170 | 1 | 18µ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 | ################################################################################################### | ||||
183 | 1 | 13µs | 1; | ||
# 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 | |||||
# 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 |