Filename | /home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/Process/CSS/Inlinedata.pm |
Statements | Executed 104729 statements in 4.41s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
4560 | 1 | 1 | 2.02s | 19.4s | inline_url | RTP::Webmerge::Process::CSS::Inlinedata::
8469 | 1 | 1 | 1.14s | 1.14s | CORE:substcont (opcode) | RTP::Webmerge::Process::CSS::Inlinedata::
8 | 1 | 1 | 493ms | 21.0s | inlinedata | RTP::Webmerge::Process::CSS::Inlinedata::
4560 | 1 | 1 | 278ms | 370ms | getbytes | RTP::Webmerge::Process::CSS::Inlinedata::
16240 | 4 | 1 | 226ms | 226ms | CORE:match (opcode) | RTP::Webmerge::Process::CSS::Inlinedata::
2556 | 1 | 1 | 79.6ms | 79.6ms | CORE:ftsize (opcode) | RTP::Webmerge::Process::CSS::Inlinedata::
4560 | 1 | 1 | 76.3ms | 76.3ms | CORE:qr (opcode) | RTP::Webmerge::Process::CSS::Inlinedata::
9128 | 3 | 1 | 53.9ms | 53.9ms | CORE:regcomp (opcode) | RTP::Webmerge::Process::CSS::Inlinedata::
1 | 1 | 1 | 22.2ms | 33.6ms | BEGIN@32 | RTP::Webmerge::Process::CSS::Inlinedata::
1 | 1 | 1 | 13.9ms | 18.7ms | BEGIN@26 | RTP::Webmerge::Process::CSS::Inlinedata::
8 | 1 | 1 | 6.39ms | 6.39ms | CORE:subst (opcode) | RTP::Webmerge::Process::CSS::Inlinedata::
1 | 1 | 1 | 1.26ms | 93.4ms | BEGIN@29 | RTP::Webmerge::Process::CSS::Inlinedata::
1 | 1 | 1 | 95µs | 368µs | BEGIN@8 | RTP::Webmerge::Process::CSS::Inlinedata::
1 | 1 | 1 | 71µs | 71µs | __ANON__[:338] | RTP::Webmerge::Process::CSS::Inlinedata::
1 | 1 | 1 | 70µs | 628µs | BEGIN@314 | RTP::Webmerge::Process::CSS::Inlinedata::
1 | 1 | 1 | 63µs | 222µs | BEGIN@44 | RTP::Webmerge::Process::CSS::Inlinedata::
1 | 1 | 1 | 60µs | 214µs | BEGIN@40 | RTP::Webmerge::Process::CSS::Inlinedata::
1 | 1 | 1 | 59µs | 586µs | BEGIN@42 | RTP::Webmerge::Process::CSS::Inlinedata::
1 | 1 | 1 | 58µs | 91µs | BEGIN@10 | RTP::Webmerge::Process::CSS::Inlinedata::
1 | 1 | 1 | 56µs | 56µs | BEGIN@18.31 | RTP::Webmerge::Process::CSS::Inlinedata::
1 | 1 | 1 | 52µs | 141µs | BEGIN@9 | RTP::Webmerge::Process::CSS::Inlinedata::
1 | 1 | 1 | 29µs | 29µs | BEGIN@21 | RTP::Webmerge::Process::CSS::Inlinedata::
1 | 1 | 1 | 28µs | 28µs | BEGIN@35 | RTP::Webmerge::Process::CSS::Inlinedata::
1 | 1 | 1 | 27µs | 27µs | BEGIN@15 | RTP::Webmerge::Process::CSS::Inlinedata::
1 | 1 | 1 | 23µs | 23µs | BEGIN@18 | RTP::Webmerge::Process::CSS::Inlinedata::
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::Process::CSS::Inlinedata; | ||||
6 | ################################################################################################### | ||||
7 | |||||
8 | 2 | 168µs | 2 | 640µs | # spent 368µs (95+272) within RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@8 which was called:
# once (95µs+272µs) by RTP::Webmerge::Process::CSS::BEGIN@22 at line 8 # spent 368µs making 1 call to RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@8
# spent 272µs making 1 call to Exporter::import |
9 | 2 | 143µs | 2 | 229µs | # spent 141µs (52+88) within RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@9 which was called:
# once (52µs+88µs) by RTP::Webmerge::Process::CSS::BEGIN@22 at line 9 # spent 141µs making 1 call to RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@9
# spent 88µs making 1 call to strict::import |
10 | 2 | 256µs | 2 | 124µs | # spent 91µs (58+33) within RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@10 which was called:
# once (58µs+33µs) by RTP::Webmerge::Process::CSS::BEGIN@22 at line 10 # spent 91µs making 1 call to RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@10
# spent 33µs making 1 call to warnings::import |
11 | |||||
12 | ################################################################################################### | ||||
13 | |||||
14 | # define our version string | ||||
15 | 1 | 150µs | 1 | 27µs | # spent 27µs within RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@15 which was called:
# once (27µs+0s) by RTP::Webmerge::Process::CSS::BEGIN@22 at line 15 # spent 27µs making 1 call to RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@15 |
16 | |||||
17 | # load exporter and inherit from it | ||||
18 | 3 | 405µs | 2 | 79µs | # spent 23µs within RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@18 which was called:
# once (23µs+0s) by RTP::Webmerge::Process::CSS::BEGIN@22 at line 18
# spent 56µs within RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@18.31 which was called:
# once (56µs+0s) by RTP::Webmerge::Process::CSS::BEGIN@22 at line 18 # spent 56µs making 1 call to RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@18.31
# spent 23µs making 1 call to RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@18 |
19 | |||||
20 | # define our functions to be exported | ||||
21 | 1 | 148µs | 1 | 29µs | # spent 29µs within RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@21 which was called:
# once (29µs+0s) by RTP::Webmerge::Process::CSS::BEGIN@22 at line 21 # spent 29µs making 1 call to RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@21 |
22 | |||||
23 | ################################################################################################### | ||||
24 | |||||
25 | # wrap as IO Object | ||||
26 | 2 | 872µs | 2 | 18.8ms | # spent 18.7ms (13.9+4.80) within RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@26 which was called:
# once (13.9ms+4.80ms) by RTP::Webmerge::Process::CSS::BEGIN@22 at line 26 # spent 18.7ms making 1 call to RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@26
# spent 120µs making 1 call to Exporter::import |
27 | |||||
28 | # use perl default base64 converter | ||||
29 | 2 | 736µs | 2 | 93.7ms | # spent 93.4ms (1.26+92.2) within RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@29 which was called:
# once (1.26ms+92.2ms) by RTP::Webmerge::Process::CSS::BEGIN@22 at line 29 # spent 93.4ms making 1 call to RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@29
# spent 252µs making 1 call to Exporter::import |
30 | |||||
31 | # use mimeinfo to detect mimetypes | ||||
32 | 2 | 747µs | 2 | 33.9ms | # spent 33.6ms (22.2+11.4) within RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@32 which was called:
# once (22.2ms+11.4ms) by RTP::Webmerge::Process::CSS::BEGIN@22 at line 32 # spent 33.6ms making 1 call to RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@32
# spent 322µs making 1 call to Exporter::import |
33 | |||||
34 | # load spriteset preprocessor (experimental) | ||||
35 | 2 | 193µs | 1 | 28µs | # spent 28µs within RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@35 which was called:
# once (28µs+0s) by RTP::Webmerge::Process::CSS::BEGIN@22 at line 35 # spent 28µs making 1 call to RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@35 |
36 | |||||
37 | ################################################################################################### | ||||
38 | |||||
39 | # import functions from IO module | ||||
40 | 2 | 172µs | 2 | 368µs | # spent 214µs (60+154) within RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@40 which was called:
# once (60µs+154µs) by RTP::Webmerge::Process::CSS::BEGIN@22 at line 40 # spent 214µs making 1 call to RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@40
# spent 154µs making 1 call to Exporter::import |
41 | |||||
42 | 2 | 192µs | 2 | 1.11ms | # spent 586µs (59+528) within RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@42 which was called:
# once (59µs+528µs) by RTP::Webmerge::Process::CSS::BEGIN@22 at line 42 # spent 586µs making 1 call to RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@42
# spent 528µs making 1 call to Exporter::import |
43 | |||||
44 | 2 | 5.34ms | 2 | 381µs | # spent 222µs (63+159) within RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@44 which was called:
# once (63µs+159µs) by RTP::Webmerge::Process::CSS::BEGIN@22 at line 44 # spent 222µs making 1 call to RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@44
# spent 159µs making 1 call to Exporter::import |
45 | |||||
46 | ################################################################################################### | ||||
47 | |||||
48 | # parse urls out of the css file | ||||
49 | # do a lousy match for better performance | ||||
50 | # my $re_url = qr/url\s*\([\"\']?([^\)]+?)[\"\']?\)/x; | ||||
51 | |||||
52 | # some handy regular expressions | ||||
53 | # my $re_apo = qr/(?:[^\'\\]+|\\.)*/s; | ||||
54 | # my $re_quot = qr/(?:[^\"\\]+|\\.)*/s; | ||||
55 | |||||
56 | ################################################################################################### | ||||
57 | |||||
58 | # cache all downloaded urls | ||||
59 | 1 | 5µs | my $downloaded = {}; | ||
60 | |||||
61 | ################################################################################################### | ||||
62 | |||||
63 | # init to byte factors | ||||
64 | 1 | 16µs | my %bytefactors = ( | ||
65 | 'B' => 1024 ** 0, | ||||
66 | 'KB' => 1024 ** 1, | ||||
67 | 'MB' => 1024 ** 2, | ||||
68 | 'GB' => 1024 ** 3 | ||||
69 | ); | ||||
70 | |||||
71 | # helper function | ||||
72 | sub getbytes | ||||
73 | # spent 370ms (278+92.9) within RTP::Webmerge::Process::CSS::Inlinedata::getbytes which was called 4560 times, avg 81µs/call:
# 4560 times (278ms+92.9ms) by RTP::Webmerge::Process::CSS::Inlinedata::inline_url at line 258, avg 81µs/call | ||||
74 | |||||
75 | # get the byte string | ||||
76 | 4560 | 20.1ms | my ($string) = @_; | ||
77 | |||||
78 | # match a floating point number and the measure unit | ||||
79 | 4560 | 472ms | 4560 | 92.9ms | if ($string =~ m/([-+]?(?:[0-9]*\.[0-9]+|[0-9]+))\s*(B|KB|MB|GB)?/i) # spent 92.9ms making 4560 calls to RTP::Webmerge::Process::CSS::Inlinedata::CORE:match, avg 20µs/call |
80 | { | ||||
81 | # multiply number by factor | ||||
82 | return $1 * $bytefactors{uc$2}; | ||||
83 | } | ||||
84 | |||||
85 | # return original | ||||
86 | return $string; | ||||
87 | |||||
88 | } | ||||
89 | # EO getbytes | ||||
90 | |||||
91 | ################################################################################################### | ||||
92 | |||||
93 | # replace jquery calls with simple dollar signs | ||||
94 | # this way we can have best code compatibility | ||||
95 | # and still use the dollar sign when possible | ||||
96 | sub inlinedata | ||||
97 | # spent 21.0s (493ms+20.5) within RTP::Webmerge::Process::CSS::Inlinedata::inlinedata which was called 8 times, avg 2.63s/call:
# 8 times (493ms+20.5s) by RTP::Webmerge::callProcessor at line 555 of webmerge/scripts/modules/RTP/Webmerge.pm, avg 2.63s/call | ||||
98 | |||||
99 | # get input variables | ||||
100 | 8 | 33µs | my ($data, $config) = @_; | ||
101 | |||||
102 | # declare lexical variables | ||||
103 | 8 | 56µs | my $info = {}; | ||
104 | |||||
105 | # start search and replace | ||||
106 | 8469 | 1.52s | 13045 | 20.5s | ${$data} =~ s/(?:(\/\*.*?\*\/)|$re_url)/$1 || &inline_url($config, $info, $2)/gmes; # spent 19.4s making 4560 calls to RTP::Webmerge::Process::CSS::Inlinedata::inline_url, avg 4.25ms/call
# spent 1.14s making 8469 calls to RTP::Webmerge::Process::CSS::Inlinedata::CORE:substcont, avg 134µs/call
# spent 6.39ms making 8 calls to RTP::Webmerge::Process::CSS::Inlinedata::CORE:subst, avg 799µs/call
# spent 225µs making 8 calls to RTP::Webmerge::Process::CSS::Inlinedata::CORE:regcomp, avg 28µs/call |
107 | |||||
108 | # create lexical variables | ||||
109 | 8 | 114µs | my @duplicates, my $replaced = 0; | ||
110 | |||||
111 | # do some statistics about the replacement | ||||
112 | 8 | 4.41ms | foreach my $url (keys %{$info->{'seen'}}) | ||
113 | { | ||||
114 | 2144 | 10.0ms | if ($info->{'seen'}->{$url} > 1) | ||
115 | { push(@duplicates, $url); } | ||||
116 | 2144 | 3.10ms | $replaced ++; | ||
117 | } | ||||
118 | |||||
119 | # print warnings if we have duplicates | ||||
120 | # this can only be optimized manually | ||||
121 | 8 | 96µs | if (scalar(@duplicates)) | ||
122 | { | ||||
123 | 4 | 503µs | warn "\nINFO: Replaced $replaced images\n"; | ||
124 | 4 | 171µs | warn "\nWARNING: Some urls have been included multiple times\n"; | ||
125 | 4 | 138µs | warn "Please try to reference each urls only once in the style sheet!\n"; | ||
126 | 4 | 130µs | warn "It could be possible to merge the selectors of all identical urls!\n"; | ||
127 | 4 | 1.95ms | warn "\n ", join("\n ", map { substr($_, - 65) . " (" . $info->{'seen'}->{$_} . ")" } @duplicates) , "\n\n"; | ||
128 | } | ||||
129 | |||||
130 | # return success | ||||
131 | 8 | 2.88ms | return 1; | ||
132 | |||||
133 | } | ||||
134 | # EO sub dejquery | ||||
135 | |||||
136 | ################################################################################################### | ||||
137 | |||||
138 | # process a local url | ||||
139 | # return inline data | ||||
140 | sub inline_url | ||||
141 | # spent 19.4s (2.02+17.4) within RTP::Webmerge::Process::CSS::Inlinedata::inline_url which was called 4560 times, avg 4.25ms/call:
# 4560 times (2.02s+17.4s) by RTP::Webmerge::Process::CSS::Inlinedata::inlinedata at line 106, avg 4.25ms/call | ||||
142 | |||||
143 | # get input variables | ||||
144 | 4560 | 41.9ms | my ($config, $info, $url) = @_; | ||
145 | |||||
146 | # store original url | ||||
147 | 4560 | 7.77ms | my $original = $url; | ||
148 | |||||
149 | # declare lexical variables | ||||
150 | 4560 | 6.84ms | my ($dataref, $mimetype); | ||
151 | |||||
152 | # file is an absolute link | ||||
153 | 4560 | 126ms | 4560 | 34.1ms | if ($url =~ m/^[a-z]+:\/\//) # spent 34.1ms making 4560 calls to RTP::Webmerge::Process::CSS::Inlinedata::CORE:match, avg 7µs/call |
154 | { | ||||
155 | |||||
156 | # loop all external configurations | ||||
157 | foreach my $ext (@{$config->{'external'} || []}) | ||||
158 | { | ||||
159 | |||||
160 | # get configure href | ||||
161 | my $href = $ext->{'href'}; | ||||
162 | |||||
163 | # try http protocol if there is no expicit | ||||
164 | # protocol given in the link. Maybe this should | ||||
165 | # be configurable, but IMO this should suffice. | ||||
166 | $url = 'http:' . $url if $url =~ m/^\/\//; | ||||
167 | |||||
168 | # test if given url matches this href | ||||
169 | if ($url =~ m/^([a-z]+:)?\Q$href\E/) | ||||
170 | { | ||||
171 | |||||
172 | # do nothing if downloads of externals has been disabled | ||||
173 | return 'url(' . $original . ')' unless $ext->{'enabled'}; | ||||
174 | |||||
175 | # check if download is already cached | ||||
176 | unless (exists $downloaded->{$original}) | ||||
177 | { | ||||
178 | |||||
179 | # try to load the lwp module conditional | ||||
180 | unless (eval { require LWP::UserAgent; 1 }) | ||||
181 | { die "module LWP::UserAgent not found"; } | ||||
182 | |||||
183 | # create a new user agent | ||||
184 | my $ua = new LWP::UserAgent; | ||||
185 | |||||
186 | # fake an internet explorer 7 agent string | ||||
187 | $ua->agent('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)'); | ||||
188 | |||||
189 | # create the request | ||||
190 | my $request = new HTTP::Request 'GET', $original; | ||||
191 | |||||
192 | # get referer from local or global options | ||||
193 | my $referer = $ext->{'referer'} || $config->{'referer'}; | ||||
194 | |||||
195 | # set referer for this request | ||||
196 | $request->referer($referer) if $referer; | ||||
197 | |||||
198 | # do request synchronous and get response | ||||
199 | my $response = $ua->request($request); | ||||
200 | |||||
201 | # check the return status | ||||
202 | die 'download of external data failed' if $response->code ne 200; | ||||
203 | |||||
204 | # store to cached urls (only fetch each url once per webmerge run) | ||||
205 | $downloaded->{$original} = [\ $response->content, $response->header('content-type')]; | ||||
206 | |||||
207 | } | ||||
208 | |||||
209 | # get variables from the cache | ||||
210 | $dataref = $downloaded->{$original}->[0]; | ||||
211 | $mimetype = $downloaded->{$original}->[1]; | ||||
212 | |||||
213 | # exit foreach ext loop | ||||
214 | last; | ||||
215 | |||||
216 | } | ||||
217 | # EO if url matches href | ||||
218 | |||||
219 | } | ||||
220 | # EO each external config | ||||
221 | |||||
222 | } | ||||
223 | # EO if remote url | ||||
224 | |||||
225 | # file is local | ||||
226 | # relative to webroot | ||||
227 | else | ||||
228 | { | ||||
229 | |||||
230 | # remove any query string | ||||
231 | # $url =~ s/\?.*?$//; | ||||
232 | |||||
233 | # create pattern to decide which files to embed | ||||
234 | 4560 | 270ms | my @exts = map { quotemeta } split(/\s*,\s*/, $config->{'inlinedataexts'}); | ||
235 | 4560 | 54.5ms | my $embed_pattern = '\.(?:' . join('|', @exts) . ')$'; | ||
236 | 4560 | 334ms | 9120 | 89.8ms | my $re_embed_pattern = qr/$embed_pattern/; # spent 76.3ms making 4560 calls to RTP::Webmerge::Process::CSS::Inlinedata::CORE:qr, avg 17µs/call
# spent 13.5ms making 4560 calls to RTP::Webmerge::Process::CSS::Inlinedata::CORE:regcomp, avg 3µs/call |
237 | |||||
238 | # only process usefull file extensions | ||||
239 | 4560 | 436ms | 9120 | 118ms | unless ($url =~ m/$re_embed_pattern/) # spent 77.4ms making 4560 calls to RTP::Webmerge::Process::CSS::Inlinedata::CORE:match, avg 17µs/call
# spent 40.2ms making 4560 calls to RTP::Webmerge::Process::CSS::Inlinedata::CORE:regcomp, avg 9µs/call |
240 | { return 'url(' . $original . ')'; } | ||||
241 | |||||
242 | # get the filesize | ||||
243 | 4560 | 12.0ms | my $size = 0; | ||
244 | |||||
245 | # check if the file has already been written | ||||
246 | 4560 | 193ms | 2556 | 79.6ms | unless (exists $config->{'atomic'}->{$url}) { $size = -s $url; } # spent 79.6ms making 2556 calls to RTP::Webmerge::Process::CSS::Inlinedata::CORE:ftsize, avg 31µs/call |
247 | 2004 | 21.1ms | else { $size = length(${$config->{'atomic'}->{$url}->[0]}); } | ||
248 | |||||
249 | # if size is not given | ||||
250 | 4560 | 7.53ms | unless (defined $size) | ||
251 | { | ||||
252 | # the url probably would return error 404 | ||||
253 | # we may could try to download it via url | ||||
254 | die "url $url is not accessible"; | ||||
255 | } | ||||
256 | |||||
257 | # only replace files inline if greater than 4KB | ||||
258 | 4560 | 185ms | 4560 | 370ms | if ($size > getbytes($config->{'inlinedatamax'})) # spent 370ms making 4560 calls to RTP::Webmerge::Process::CSS::Inlinedata::getbytes, avg 81µs/call |
259 | { return 'url(' . $original . ')'; } | ||||
260 | |||||
261 | # get into lexical variable | ||||
262 | 2560 | 14.8ms | my $seen = $info->{'seen'} || {}; | ||
263 | |||||
264 | # count url occurences | ||||
265 | 2560 | 37.2ms | unless (exists $seen->{$url}) | ||
266 | { $seen->{$url} = 1; } | ||||
267 | 416 | 2.39ms | else { $seen->{$url} ++; } | ||
268 | |||||
269 | # be sure to store it | ||||
270 | 2560 | 7.38ms | $info->{'seen'} = $seen; | ||
271 | |||||
272 | # read the linked url locally | ||||
273 | 2560 | 45.0ms | 2560 | 4.33s | $dataref = readfile($url, $config->{'atomic'}); # spent 4.33s making 2560 calls to RTP::Webmerge::IO::readfile, avg 1.69ms/call |
274 | |||||
275 | # fix for windows and mime magic | ||||
276 | # most people will not have the db | ||||
277 | 2560 | 173ms | 2560 | 21.2ms | if($^O =~ m!MSWin32!i) # spent 21.2ms making 2560 calls to RTP::Webmerge::Process::CSS::Inlinedata::CORE:match, avg 8µs/call |
278 | { | ||||
279 | push @File::MimeInfo::DIRS, | ||||
280 | res_path('{CONF}/mime'), | ||||
281 | res_path('{EXT}/conf/mime'); | ||||
282 | } | ||||
283 | |||||
284 | # check if file was written atomic | ||||
285 | 2560 | 28.2ms | if ($config->{'atomic'}->{$url}) | ||
286 | { | ||||
287 | # get the current atomic object | ||||
288 | 4 | 26µs | my $fh = $config->{'atomic'}->{$url}->[1]; | ||
289 | # retrieve the temporary filename | ||||
290 | 4 | 31µs | $url = ${*$fh}{'io_atomicfile_temp'}; | ||
291 | } | ||||
292 | |||||
293 | # get mimetype from file | ||||
294 | 2560 | 41.6ms | 2560 | 12.3s | $mimetype = mimetype($url); # spent 12.3s making 2560 calls to File::MimeInfo::Magic::mimetype, avg 4.79ms/call |
295 | |||||
296 | # fail if we have no mimetype | ||||
297 | 2560 | 28.4ms | die "unknown file-type" unless $mimetype; | ||
298 | |||||
299 | } | ||||
300 | # EO if local url | ||||
301 | |||||
302 | # check if we have an inline data representation | ||||
303 | 2560 | 6.01ms | return wrapURL($original) unless (defined $dataref && defined $mimetype); | ||
304 | |||||
305 | # return the inline data replacement | ||||
306 | 2560 | 280ms | 2560 | 72.1ms | return sprintf('url(data:%s;base64,%s)', $mimetype, encode_base64(${$dataref}, '')); # spent 72.1ms making 2560 calls to MIME::Base64::encode_base64, avg 28µs/call |
307 | |||||
308 | } | ||||
309 | # EO sub inline_url | ||||
310 | |||||
311 | ################################################################################################### | ||||
312 | |||||
313 | # import registered processors | ||||
314 | 2 | 614µs | 2 | 1.18ms | # spent 628µs (70+557) within RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@314 which was called:
# once (70µs+557µs) by RTP::Webmerge::Process::CSS::BEGIN@22 at line 314 # spent 628µs making 1 call to RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@314
# spent 557µs making 1 call to Exporter::import |
315 | |||||
316 | # register the processor function | ||||
317 | 1 | 6µs | $processors{'inlinedata'} = \& inlinedata; | ||
318 | |||||
319 | # register initializer | ||||
320 | push @initers, sub | ||||
321 | # spent 71µs within RTP::Webmerge::Process::CSS::Inlinedata::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/Process/CSS/Inlinedata.pm:338] which was called:
# once (71µs+0s) by RTP::Webmerge::initConfig at line 263 of webmerge/scripts/modules/RTP/Webmerge.pm | ||||
322 | |||||
323 | # get input variables | ||||
324 | 1 | 4µs | my ($config) = @_; | ||
325 | |||||
326 | # assign default value to variable | ||||
327 | 1 | 5µs | $config->{'inlinedatamax'} = 4096; | ||
328 | |||||
329 | # extensions to be embeded in css | ||||
330 | 1 | 3µs | $config->{'inlinedataexts'} = 'gif,jpg,jpeg,png'; | ||
331 | |||||
332 | # return additional get options attribute | ||||
333 | return ( | ||||
334 | 1 | 75µs | 'inlinedatamax=i' => \ $config->{'cmd_inlinedatamax'}, | ||
335 | 'inlinedataexts=s' => \ $config->{'cmd_inlinedataexts'} | ||||
336 | ); | ||||
337 | |||||
338 | 1 | 14µs | }; | ||
339 | # EO plugin initer | ||||
340 | |||||
341 | ################################################################################################### | ||||
342 | ################################################################################################### | ||||
343 | 1 | 26µs | 1; | ||
# spent 79.6ms within RTP::Webmerge::Process::CSS::Inlinedata::CORE:ftsize which was called 2556 times, avg 31µs/call:
# 2556 times (79.6ms+0s) by RTP::Webmerge::Process::CSS::Inlinedata::inline_url at line 246, avg 31µs/call | |||||
# spent 226ms within RTP::Webmerge::Process::CSS::Inlinedata::CORE:match which was called 16240 times, avg 14µs/call:
# 4560 times (92.9ms+0s) by RTP::Webmerge::Process::CSS::Inlinedata::getbytes at line 79, avg 20µs/call
# 4560 times (77.4ms+0s) by RTP::Webmerge::Process::CSS::Inlinedata::inline_url at line 239, avg 17µs/call
# 4560 times (34.1ms+0s) by RTP::Webmerge::Process::CSS::Inlinedata::inline_url at line 153, avg 7µs/call
# 2560 times (21.2ms+0s) by RTP::Webmerge::Process::CSS::Inlinedata::inline_url at line 277, avg 8µs/call | |||||
# spent 76.3ms within RTP::Webmerge::Process::CSS::Inlinedata::CORE:qr which was called 4560 times, avg 17µs/call:
# 4560 times (76.3ms+0s) by RTP::Webmerge::Process::CSS::Inlinedata::inline_url at line 236, avg 17µs/call | |||||
# spent 53.9ms within RTP::Webmerge::Process::CSS::Inlinedata::CORE:regcomp which was called 9128 times, avg 6µs/call:
# 4560 times (40.2ms+0s) by RTP::Webmerge::Process::CSS::Inlinedata::inline_url at line 239, avg 9µs/call
# 4560 times (13.5ms+0s) by RTP::Webmerge::Process::CSS::Inlinedata::inline_url at line 236, avg 3µs/call
# 8 times (225µs+0s) by RTP::Webmerge::Process::CSS::Inlinedata::inlinedata at line 106, avg 28µs/call | |||||
# spent 6.39ms within RTP::Webmerge::Process::CSS::Inlinedata::CORE:subst which was called 8 times, avg 799µs/call:
# 8 times (6.39ms+0s) by RTP::Webmerge::Process::CSS::Inlinedata::inlinedata at line 106, avg 799µs/call | |||||
# spent 1.14s within RTP::Webmerge::Process::CSS::Inlinedata::CORE:substcont which was called 8469 times, avg 134µs/call:
# 8469 times (1.14s+0s) by RTP::Webmerge::Process::CSS::Inlinedata::inlinedata at line 106, avg 134µs/call |