| Filename | /home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/IO/CSS.pm |
| Statements | Executed 162866 statements in 9.65s |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 32566 | 4 | 1 | 5.64s | 5.64s | RTP::Webmerge::IO::CSS::CORE:substcont (opcode) |
| 32509 | 4 | 1 | 1.70s | 1.81s | RTP::Webmerge::IO::CSS::wrapURL |
| 20 | 1 | 1 | 1.16s | 26.8s | RTP::Webmerge::IO::CSS::incCSS |
| 20 | 2 | 2 | 758ms | 59.8s | RTP::Webmerge::IO::CSS::readCSS |
| 18 | 1 | 1 | 605ms | 26.1s | RTP::Webmerge::IO::CSS::exportCSS |
| 32589 | 6 | 1 | 193ms | 193ms | RTP::Webmerge::IO::CSS::CORE:subst (opcode) |
| 2 | 1 | 1 | 76.6ms | 1.98s | RTP::Webmerge::IO::CSS::importCSS |
| 80 | 5 | 1 | 6.87ms | 6.87ms | RTP::Webmerge::IO::CSS::CORE:regcomp (opcode) |
| 18 | 1 | 1 | 765µs | 5.63s | RTP::Webmerge::IO::CSS::writeCSS |
| 1 | 1 | 1 | 90µs | 342µs | RTP::Webmerge::IO::CSS::BEGIN@10 |
| 1 | 1 | 1 | 72µs | 658µs | RTP::Webmerge::IO::CSS::BEGIN@179 |
| 1 | 1 | 1 | 62µs | 62µs | RTP::Webmerge::IO::CSS::BEGIN@26.16 |
| 1 | 1 | 1 | 58µs | 280µs | RTP::Webmerge::IO::CSS::BEGIN@37 |
| 1 | 1 | 1 | 57µs | 294µs | RTP::Webmerge::IO::CSS::BEGIN@40 |
| 1 | 1 | 1 | 56µs | 86µs | RTP::Webmerge::IO::CSS::BEGIN@12 |
| 1 | 1 | 1 | 55µs | 143µs | RTP::Webmerge::IO::CSS::BEGIN@11 |
| 1 | 1 | 1 | 29µs | 29µs | RTP::Webmerge::IO::CSS::BEGIN@29 |
| 1 | 1 | 1 | 28µs | 28µs | RTP::Webmerge::IO::CSS::__ANON__[:202] |
| 1 | 1 | 1 | 26µs | 26µs | RTP::Webmerge::IO::CSS::BEGIN@32 |
| 1 | 1 | 1 | 25µs | 25µs | RTP::Webmerge::IO::CSS::BEGIN@23 |
| 1 | 1 | 1 | 25µs | 25µs | RTP::Webmerge::IO::CSS::BEGIN@26 |
| 1 | 1 | 1 | 20µs | 20µs | RTP::Webmerge::IO::CSS::CORE:qr (opcode) |
| 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::IO::CSS; | ||||
| 6 | ################################################################################################### | ||||
| 7 | # http://www.w3.org/TR/CSS21/syndata.html#uri | ||||
| 8 | ################################################################################################### | ||||
| 9 | |||||
| 10 | 2 | 166µs | 2 | 595µs | # spent 342µs (90+253) within RTP::Webmerge::IO::CSS::BEGIN@10 which was called:
# once (90µs+253µs) by RTP::Webmerge::Merge::BEGIN@67 at line 10 # spent 342µs making 1 call to RTP::Webmerge::IO::CSS::BEGIN@10
# spent 253µs making 1 call to Exporter::import |
| 11 | 2 | 144µs | 2 | 231µs | # spent 143µs (55+88) within RTP::Webmerge::IO::CSS::BEGIN@11 which was called:
# once (55µs+88µs) by RTP::Webmerge::Merge::BEGIN@67 at line 11 # spent 143µs making 1 call to RTP::Webmerge::IO::CSS::BEGIN@11
# spent 88µs making 1 call to strict::import |
| 12 | 2 | 340µs | 2 | 116µs | # spent 86µs (56+30) within RTP::Webmerge::IO::CSS::BEGIN@12 which was called:
# once (56µs+30µs) by RTP::Webmerge::Merge::BEGIN@67 at line 12 # spent 86µs making 1 call to RTP::Webmerge::IO::CSS::BEGIN@12
# spent 30µs making 1 call to warnings::import |
| 13 | |||||
| 14 | ################################################################################################### | ||||
| 15 | |||||
| 16 | # parse urls out of the css file | ||||
| 17 | # do a lousy match for better performance | ||||
| 18 | 1 | 58µs | 1 | 20µs | our $re_url = qr/url\(\s*[\"\']?((?!data:)[^\)]+?)[\"\']?\s*\)/x; # spent 20µs making 1 call to RTP::Webmerge::IO::CSS::CORE:qr |
| 19 | |||||
| 20 | ################################################################################################### | ||||
| 21 | |||||
| 22 | # define our version string | ||||
| 23 | 1 | 197µs | 1 | 25µs | # spent 25µs within RTP::Webmerge::IO::CSS::BEGIN@23 which was called:
# once (25µs+0s) by RTP::Webmerge::Merge::BEGIN@67 at line 23 # spent 25µs making 1 call to RTP::Webmerge::IO::CSS::BEGIN@23 |
| 24 | |||||
| 25 | # load exporter and inherit from it | ||||
| 26 | 3 | 483µs | 2 | 87µs | BEGIN { use Exporter qw(); our @ISA = qw(Exporter) } # spent 62µs making 1 call to RTP::Webmerge::IO::CSS::BEGIN@26.16
# spent 25µs making 1 call to RTP::Webmerge::IO::CSS::BEGIN@26 |
| 27 | |||||
| 28 | # define our variables to be exported | ||||
| 29 | 1 | 179µs | 1 | 29µs | # spent 29µs within RTP::Webmerge::IO::CSS::BEGIN@29 which was called:
# once (29µs+0s) by RTP::Webmerge::Merge::BEGIN@67 at line 29 # spent 29µs making 1 call to RTP::Webmerge::IO::CSS::BEGIN@29 |
| 30 | |||||
| 31 | # define our functions to be exported | ||||
| 32 | 1 | 172µs | 1 | 26µs | # spent 26µs within RTP::Webmerge::IO::CSS::BEGIN@32 which was called:
# once (26µs+0s) by RTP::Webmerge::Merge::BEGIN@67 at line 32 # spent 26µs making 1 call to RTP::Webmerge::IO::CSS::BEGIN@32 |
| 33 | |||||
| 34 | ################################################################################################### | ||||
| 35 | |||||
| 36 | # import webmerge io file reader and writer | ||||
| 37 | 2 | 176µs | 2 | 502µs | # spent 280µs (58+222) within RTP::Webmerge::IO::CSS::BEGIN@37 which was called:
# once (58µs+222µs) by RTP::Webmerge::Merge::BEGIN@67 at line 37 # spent 280µs making 1 call to RTP::Webmerge::IO::CSS::BEGIN@37
# spent 222µs making 1 call to Exporter::import |
| 38 | |||||
| 39 | # import local webroot path | ||||
| 40 | 2 | 2.42ms | 2 | 531µs | # spent 294µs (57+237) within RTP::Webmerge::IO::CSS::BEGIN@40 which was called:
# once (57µs+237µs) by RTP::Webmerge::Merge::BEGIN@67 at line 40 # spent 294µs making 1 call to RTP::Webmerge::IO::CSS::BEGIN@40
# spent 237µs making 1 call to Exporter::import |
| 41 | |||||
| 42 | ################################################################################################### | ||||
| 43 | |||||
| 44 | # wrap url for css | ||||
| 45 | # also makes it canonical | ||||
| 46 | sub wrapURL | ||||
| 47 | # spent 1.81s (1.70+112ms) within RTP::Webmerge::IO::CSS::wrapURL which was called 32509 times, avg 56µs/call:
# 12350 times (673ms+37.4ms) by RTP::Webmerge::IO::CSS::readCSS at line 113, avg 58µs/call
# 12350 times (636ms+44.4ms) by RTP::Webmerge::IO::CSS::incCSS at line 87, avg 55µs/call
# 6574 times (343ms+26.4ms) by RTP::Webmerge::IO::CSS::exportCSS at line 153, avg 56µs/call
# 1235 times (46.9ms+4.05ms) by RTP::Webmerge::IO::CSS::importCSS at line 133, avg 41µs/call | ||||
| 48 | |||||
| 49 | # get uri | ||||
| 50 | 32509 | 123ms | my ($uri) = @_; | ||
| 51 | |||||
| 52 | # escape apostrophes | ||||
| 53 | 32509 | 852ms | 32509 | 112ms | $uri =~ s/\'/\\\'/g; # spent 112ms making 32509 calls to RTP::Webmerge::IO::CSS::CORE:subst, avg 3µs/call |
| 54 | |||||
| 55 | # replace windows backslashes | ||||
| 56 | # with correct forward slashes | ||||
| 57 | 32509 | 153ms | $uri =~ s/\\/\//g if $^O eq "MSWin32"; | ||
| 58 | |||||
| 59 | # wrap and return escaped uri | ||||
| 60 | 32509 | 1.08s | return sprintf('url(\'%s\')', $uri); | ||
| 61 | |||||
| 62 | } | ||||
| 63 | # EO wrapURL | ||||
| 64 | |||||
| 65 | ################################################################################################### | ||||
| 66 | |||||
| 67 | |||||
| 68 | ################################################################################################### | ||||
| 69 | |||||
| 70 | # include a css file | ||||
| 71 | # resolve import statements | ||||
| 72 | # normalize uris to webroot | ||||
| 73 | sub incCSS | ||||
| 74 | # spent 26.8s (1.16+25.6) within RTP::Webmerge::IO::CSS::incCSS which was called 20 times, avg 1.34s/call:
# 20 times (1.16s+25.6s) by RTP::Webmerge::IO::CSS::readCSS at line 109, avg 1.34s/call | ||||
| 75 | |||||
| 76 | # get input variables | ||||
| 77 | 20 | 67µs | my ($cssfile, $config) = @_; | ||
| 78 | |||||
| 79 | # read complete css file | ||||
| 80 | 20 | 256µs | 20 | 73.2ms | my $data = readfile($cssfile); # spent 73.2ms making 20 calls to RTP::Webmerge::IO::readfile, avg 3.66ms/call |
| 81 | |||||
| 82 | # die with an error message that css file is not found | ||||
| 83 | 20 | 22µs | die "css import <$cssfile> could not be read: $!\n" unless $data; | ||
| 84 | |||||
| 85 | # change all web uris in the stylesheet to absolute local paths | ||||
| 86 | # also changes urls in comments (needed for the spriteset feature) | ||||
| 87 | 12370 | 1.07s | 49460 | 25.6s | ${$data} =~ s/$re_url/wrapURL(importURI($1, dirname($cssfile), $config))/egm; # spent 20.0s making 12350 calls to RTP::Webmerge::Path::importURI, avg 1.62ms/call
# spent 4.46s making 12350 calls to File::Basename::dirname, avg 361µs/call
# spent 681ms making 12350 calls to RTP::Webmerge::IO::CSS::wrapURL, avg 55µs/call
# spent 461ms making 12370 calls to RTP::Webmerge::IO::CSS::CORE:substcont, avg 37µs/call
# spent 3.21ms making 20 calls to RTP::Webmerge::IO::CSS::CORE:subst, avg 161µs/call
# spent 527µs making 20 calls to RTP::Webmerge::IO::CSS::CORE:regcomp, avg 26µs/call |
| 88 | |||||
| 89 | # resolve all css imports and include the stylesheets (recursive resolve url paths) | ||||
| 90 | 20 | 7.20ms | 40 | 6.12ms | ${$data} =~ s/\@import\s+$re_url/${incCSS($1, $config)}/gme if $config->{'import-css'}; # spent 5.76ms making 20 calls to RTP::Webmerge::IO::CSS::CORE:subst, avg 288µs/call
# spent 362µs making 20 calls to RTP::Webmerge::IO::CSS::CORE:regcomp, avg 18µs/call |
| 91 | |||||
| 92 | # return scalar | ||||
| 93 | 20 | 601µs | return $data; | ||
| 94 | |||||
| 95 | } | ||||
| 96 | # EO sub incCSS | ||||
| 97 | |||||
| 98 | ################################################################################################### | ||||
| 99 | |||||
| 100 | # read a css file from the disk | ||||
| 101 | # normalize uris to absolute web uris | ||||
| 102 | sub readCSS | ||||
| 103 | # spent 59.8s (758ms+59.1) within RTP::Webmerge::IO::CSS::readCSS which was called 20 times, avg 2.99s/call:
# 18 times (699ms+53.1s) by RTP::Webmerge::Checksum::crcCheckEntry at line 107 of webmerge/scripts/modules/RTP/Webmerge/Checksum.pm, avg 2.99s/call
# 2 times (58.6ms+6.00s) by RTP::Webmerge::Merge::collect at line 236 of webmerge/scripts/modules/RTP/Webmerge/Merge.pm, avg 3.03s/call | ||||
| 104 | |||||
| 105 | # get input variables | ||||
| 106 | 20 | 101µs | my ($cssfile, $config) = @_; | ||
| 107 | |||||
| 108 | # read and normalize the stylesheet | ||||
| 109 | 20 | 232µs | 20 | 26.8s | my $data = incCSS($cssfile, $config); # spent 26.8s making 20 calls to RTP::Webmerge::IO::CSS::incCSS, avg 1.34s/call |
| 110 | |||||
| 111 | # resolve all local paths in the stylesheet to web uris | ||||
| 112 | # also changes urls in comments (needed for the spriteset feature) | ||||
| 113 | 12370 | 1.46s | 37110 | 32.3s | ${$data} =~ s/$re_url/wrapURL(exportURI($1, undef))/egm; # spent 30.6s making 12350 calls to RTP::Webmerge::Path::exportURI, avg 2.48ms/call
# spent 909ms making 12370 calls to RTP::Webmerge::IO::CSS::CORE:substcont, avg 74µs/call
# spent 711ms making 12350 calls to RTP::Webmerge::IO::CSS::wrapURL, avg 58µs/call
# spent 5.69ms making 20 calls to RTP::Webmerge::IO::CSS::CORE:subst, avg 285µs/call
# spent 4.52ms making 20 calls to RTP::Webmerge::IO::CSS::CORE:regcomp, avg 226µs/call |
| 114 | |||||
| 115 | # return scalar | ||||
| 116 | 20 | 755µs | return $data; | ||
| 117 | |||||
| 118 | } | ||||
| 119 | # EO sub readCSS | ||||
| 120 | |||||
| 121 | ################################################################################################### | ||||
| 122 | |||||
| 123 | # import the final stylesheet | ||||
| 124 | # normalize uris to absolute local paths | ||||
| 125 | sub importCSS | ||||
| 126 | # spent 1.98s (76.6ms+1.91) within RTP::Webmerge::IO::CSS::importCSS which was called 2 times, avg 992ms/call:
# 2 times (76.6ms+1.91s) by RTP::Webmerge::Merge::collect at line 242 of webmerge/scripts/modules/RTP/Webmerge/Merge.pm, avg 992ms/call | ||||
| 127 | |||||
| 128 | # get input variables | ||||
| 129 | 2 | 14µs | my ($data, $cssfile, $config) = @_; | ||
| 130 | |||||
| 131 | # change all web uris in the stylesheet to absolute local paths | ||||
| 132 | # also changes urls in comments (needed for the spriteset feature) | ||||
| 133 | 1237 | 110ms | 3711 | 1.91s | ${$data} =~ s/$re_url/wrapURL(importURI($1, undef, $config))/egm; # spent 1.81s making 1235 calls to RTP::Webmerge::Path::importURI, avg 1.47ms/call
# spent 51.0ms making 1235 calls to RTP::Webmerge::IO::CSS::wrapURL, avg 41µs/call
# spent 44.5ms making 1237 calls to RTP::Webmerge::IO::CSS::CORE:substcont, avg 36µs/call
# spent 787µs making 2 calls to RTP::Webmerge::IO::CSS::CORE:subst, avg 394µs/call
# spent 22µs making 2 calls to RTP::Webmerge::IO::CSS::CORE:regcomp, avg 11µs/call |
| 134 | |||||
| 135 | # return as string | ||||
| 136 | 2 | 78µs | return $data; | ||
| 137 | |||||
| 138 | } | ||||
| 139 | # EO importCSS | ||||
| 140 | |||||
| 141 | ################################################################################################### | ||||
| 142 | |||||
| 143 | # export a CSS stylesheets | ||||
| 144 | # normalize urls to web uris | ||||
| 145 | sub exportCSS | ||||
| 146 | # spent 26.1s (605ms+25.5) within RTP::Webmerge::IO::CSS::exportCSS which was called 18 times, avg 1.45s/call:
# 18 times (605ms+25.5s) by RTP::Webmerge::Merge::writer at line 125 of webmerge/scripts/modules/RTP/Webmerge/Merge.pm, avg 1.45s/call | ||||
| 147 | |||||
| 148 | # get input variables | ||||
| 149 | 18 | 109µs | my ($file, $data, $config) = @_; | ||
| 150 | |||||
| 151 | # change all absolute local paths to web uris | ||||
| 152 | # also changes urls in comments (needed for the spriteset feature) | ||||
| 153 | 6592 | 4.78s | 26347 | 25.5s | ${$data} =~ s/$re_url/wrapURL(exportURI($1, dirname($file)))/egm; # spent 18.2s making 6574 calls to RTP::Webmerge::Path::exportURI, avg 2.76ms/call
# spent 4.22s making 6589 calls to RTP::Webmerge::IO::CSS::CORE:substcont, avg 641µs/call
# spent 2.64s making 6574 calls to File::Basename::dirname, avg 402µs/call
# spent 370ms making 6574 calls to RTP::Webmerge::IO::CSS::wrapURL, avg 56µs/call
# spent 65.3ms making 18 calls to RTP::Webmerge::IO::CSS::CORE:subst, avg 3.63ms/call
# spent 1.44ms making 18 calls to RTP::Webmerge::IO::CSS::CORE:regcomp, avg 80µs/call |
| 154 | |||||
| 155 | # return success | ||||
| 156 | 18 | 696µs | return 1; | ||
| 157 | |||||
| 158 | } | ||||
| 159 | # EO sub exportCSS | ||||
| 160 | |||||
| 161 | ################################################################################################### | ||||
| 162 | |||||
| 163 | # write a css file to the disk | ||||
| 164 | sub writeCSS | ||||
| 165 | # spent 5.63s (765µs+5.63) within RTP::Webmerge::IO::CSS::writeCSS which was called 18 times, avg 313ms/call:
# 18 times (765µs+5.63s) by RTP::Webmerge::Merge::writer at line 144 of webmerge/scripts/modules/RTP/Webmerge/Merge.pm, avg 313ms/call | ||||
| 166 | |||||
| 167 | # get input variables | ||||
| 168 | 18 | 121µs | my ($path, $data, $config) = @_; | ||
| 169 | |||||
| 170 | # call io function to write the file atomically | ||||
| 171 | 18 | 618µs | 18 | 5.63s | return writefile($path, $data, $config->{'atomic'}, 1) # spent 5.63s making 18 calls to RTP::Webmerge::IO::writefile, avg 313ms/call |
| 172 | |||||
| 173 | } | ||||
| 174 | # EO sub writeCSS | ||||
| 175 | |||||
| 176 | ################################################################################################### | ||||
| 177 | |||||
| 178 | # extend the configurator | ||||
| 179 | 2 | 546µs | 2 | 1.24ms | # spent 658µs (72+586) within RTP::Webmerge::IO::CSS::BEGIN@179 which was called:
# once (72µs+586µs) by RTP::Webmerge::Merge::BEGIN@67 at line 179 # spent 658µs making 1 call to RTP::Webmerge::IO::CSS::BEGIN@179
# spent 586µs making 1 call to Exporter::import |
| 180 | |||||
| 181 | # register initializer | ||||
| 182 | push @initers, sub | ||||
| 183 | # spent 28µs within RTP::Webmerge::IO::CSS::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/IO/CSS.pm:202] which was called:
# once (28µs+0s) by RTP::Webmerge::initConfig at line 263 of webmerge/scripts/modules/RTP/Webmerge.pm | ||||
| 184 | |||||
| 185 | # get input variables | ||||
| 186 | 1 | 3µs | my ($config) = @_; | ||
| 187 | |||||
| 188 | # include imported css files | ||||
| 189 | 1 | 4µs | $config->{'import-css'} = 1; | ||
| 190 | |||||
| 191 | # should we use absolute urls | ||||
| 192 | # otherwise includes will be relative | ||||
| 193 | # for this option we need to webroot path | ||||
| 194 | 1 | 2µs | $config->{'absoluteurls'} = 0; | ||
| 195 | |||||
| 196 | # return additional get options attribute | ||||
| 197 | return ( | ||||
| 198 | 1 | 30µs | 'import-css!' => \ $config->{'cmd_import-css'}, | ||
| 199 | 'absoluteurls!' => \ $config->{'cmd_absoluteurls'} | ||||
| 200 | ); | ||||
| 201 | |||||
| 202 | 1 | 14µs | }; | ||
| 203 | # EO plugin initer | ||||
| 204 | |||||
| 205 | ################################################################################################### | ||||
| 206 | ################################################################################################### | ||||
| 207 | 1 | 17µs | 1; | ||
# spent 20µs within RTP::Webmerge::IO::CSS::CORE:qr which was called:
# once (20µs+0s) by RTP::Webmerge::Merge::BEGIN@67 at line 18 | |||||
# spent 6.87ms within RTP::Webmerge::IO::CSS::CORE:regcomp which was called 80 times, avg 86µs/call:
# 20 times (4.52ms+0s) by RTP::Webmerge::IO::CSS::readCSS at line 113, avg 226µs/call
# 20 times (527µs+0s) by RTP::Webmerge::IO::CSS::incCSS at line 87, avg 26µs/call
# 20 times (362µs+0s) by RTP::Webmerge::IO::CSS::incCSS at line 90, avg 18µs/call
# 18 times (1.44ms+0s) by RTP::Webmerge::IO::CSS::exportCSS at line 153, avg 80µs/call
# 2 times (22µs+0s) by RTP::Webmerge::IO::CSS::importCSS at line 133, avg 11µs/call | |||||
# spent 193ms within RTP::Webmerge::IO::CSS::CORE:subst which was called 32589 times, avg 6µs/call:
# 32509 times (112ms+0s) by RTP::Webmerge::IO::CSS::wrapURL at line 53, avg 3µs/call
# 20 times (5.76ms+0s) by RTP::Webmerge::IO::CSS::incCSS at line 90, avg 288µs/call
# 20 times (5.69ms+0s) by RTP::Webmerge::IO::CSS::readCSS at line 113, avg 285µs/call
# 20 times (3.21ms+0s) by RTP::Webmerge::IO::CSS::incCSS at line 87, avg 161µs/call
# 18 times (65.3ms+0s) by RTP::Webmerge::IO::CSS::exportCSS at line 153, avg 3.63ms/call
# 2 times (787µs+0s) by RTP::Webmerge::IO::CSS::importCSS at line 133, avg 394µs/call | |||||
# spent 5.64s within RTP::Webmerge::IO::CSS::CORE:substcont which was called 32566 times, avg 173µs/call:
# 12370 times (909ms+0s) by RTP::Webmerge::IO::CSS::readCSS at line 113, avg 74µs/call
# 12370 times (461ms+0s) by RTP::Webmerge::IO::CSS::incCSS at line 87, avg 37µs/call
# 6589 times (4.22s+0s) by RTP::Webmerge::IO::CSS::exportCSS at line 153, avg 641µs/call
# 1237 times (44.5ms+0s) by RTP::Webmerge::IO::CSS::importCSS at line 133, avg 36µs/call |