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

Filename/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/IO/CSS.pm
StatementsExecuted 162866 statements in 9.65s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
32566415.64s5.64sRTP::Webmerge::IO::CSS::::CORE:substcontRTP::Webmerge::IO::CSS::CORE:substcont (opcode)
32509411.70s1.81sRTP::Webmerge::IO::CSS::::wrapURLRTP::Webmerge::IO::CSS::wrapURL
20111.16s26.8sRTP::Webmerge::IO::CSS::::incCSSRTP::Webmerge::IO::CSS::incCSS
2022758ms59.8sRTP::Webmerge::IO::CSS::::readCSSRTP::Webmerge::IO::CSS::readCSS
1811605ms26.1sRTP::Webmerge::IO::CSS::::exportCSSRTP::Webmerge::IO::CSS::exportCSS
3258961193ms193msRTP::Webmerge::IO::CSS::::CORE:substRTP::Webmerge::IO::CSS::CORE:subst (opcode)
21176.6ms1.98sRTP::Webmerge::IO::CSS::::importCSSRTP::Webmerge::IO::CSS::importCSS
80516.87ms6.87msRTP::Webmerge::IO::CSS::::CORE:regcompRTP::Webmerge::IO::CSS::CORE:regcomp (opcode)
1811765µs5.63sRTP::Webmerge::IO::CSS::::writeCSSRTP::Webmerge::IO::CSS::writeCSS
11190µs342µsRTP::Webmerge::IO::CSS::::BEGIN@10RTP::Webmerge::IO::CSS::BEGIN@10
11172µs658µsRTP::Webmerge::IO::CSS::::BEGIN@179RTP::Webmerge::IO::CSS::BEGIN@179
11162µs62µsRTP::Webmerge::IO::CSS::::BEGIN@26.16RTP::Webmerge::IO::CSS::BEGIN@26.16
11158µs280µsRTP::Webmerge::IO::CSS::::BEGIN@37RTP::Webmerge::IO::CSS::BEGIN@37
11157µs294µsRTP::Webmerge::IO::CSS::::BEGIN@40RTP::Webmerge::IO::CSS::BEGIN@40
11156µs86µsRTP::Webmerge::IO::CSS::::BEGIN@12RTP::Webmerge::IO::CSS::BEGIN@12
11155µs143µsRTP::Webmerge::IO::CSS::::BEGIN@11RTP::Webmerge::IO::CSS::BEGIN@11
11129µs29µsRTP::Webmerge::IO::CSS::::BEGIN@29RTP::Webmerge::IO::CSS::BEGIN@29
11128µs28µsRTP::Webmerge::IO::CSS::::__ANON__[:202]RTP::Webmerge::IO::CSS::__ANON__[:202]
11126µs26µsRTP::Webmerge::IO::CSS::::BEGIN@32RTP::Webmerge::IO::CSS::BEGIN@32
11125µs25µsRTP::Webmerge::IO::CSS::::BEGIN@23RTP::Webmerge::IO::CSS::BEGIN@23
11125µs25µsRTP::Webmerge::IO::CSS::::BEGIN@26RTP::Webmerge::IO::CSS::BEGIN@26
11120µs20µsRTP::Webmerge::IO::CSS::::CORE:qrRTP::Webmerge::IO::CSS::CORE:qr (opcode)
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::IO::CSS;
6###################################################################################################
7# http://www.w3.org/TR/CSS21/syndata.html#uri
8###################################################################################################
9
102166µs2595µ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
use Carp;
# spent 342µs making 1 call to RTP::Webmerge::IO::CSS::BEGIN@10 # spent 253µs making 1 call to Exporter::import
112144µs2231µ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
use strict;
# spent 143µs making 1 call to RTP::Webmerge::IO::CSS::BEGIN@11 # spent 88µs making 1 call to strict::import
122340µs2116µ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
use warnings;
# 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
18158µs120µsour $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
231197µs125µ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
BEGIN { $RTP::Webmerge::IO::CSS::VERSION = "0.8.2" }
# spent 25µs making 1 call to RTP::Webmerge::IO::CSS::BEGIN@23
24
25# load exporter and inherit from it
263483µs287µs
# spent 62µs within RTP::Webmerge::IO::CSS::BEGIN@26.16 which was called: # once (62µs+0s) by RTP::Webmerge::Merge::BEGIN@67 at line 26 # spent 25µs within RTP::Webmerge::IO::CSS::BEGIN@26 which was called: # once (25µs+0s) by RTP::Webmerge::Merge::BEGIN@67 at line 26
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
291179µs129µ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
BEGIN { our @EXPORT = qw(incCSS readCSS importCSS exportCSS writeCSS); }
# spent 29µs making 1 call to RTP::Webmerge::IO::CSS::BEGIN@29
30
31# define our functions to be exported
321172µs126µ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
BEGIN { our @EXPORT_OK = qw($re_url wrapURL); }
# spent 26µs making 1 call to RTP::Webmerge::IO::CSS::BEGIN@32
33
34###################################################################################################
35
36# import webmerge io file reader and writer
372176µs2502µ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
use RTP::Webmerge::IO qw(readfile writefile);
# 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
4022.42ms2531µ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
use RTP::Webmerge::Path qw(dirname exportURI importURI);
# 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
46sub 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
5032509123ms my ($uri) = @_;
51
52 # escape apostrophes
5332509852ms32509112ms $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
5732509153ms $uri =~ s/\\/\//g if $^O eq "MSWin32";
58
59 # wrap and return escaped uri
60325091.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
73sub 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
772067µs my ($cssfile, $config) = @_;
78
79 # read complete css file
8020256µs2073.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
832022µ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)
87123701.07s4946025.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)
90207.20ms406.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
9320601µ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
102sub 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
10620101µs my ($cssfile, $config) = @_;
107
108 # read and normalize the stylesheet
10920232µs2026.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)
113123701.46s3711032.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
11620755µs return $data;
117
118}
119# EO sub readCSS
120
121###################################################################################################
122
123# import the final stylesheet
124# normalize uris to absolute local paths
125sub 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
129214µ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)
1331237110ms37111.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
136278µs return $data;
137
138}
139# EO importCSS
140
141###################################################################################################
142
143# export a CSS stylesheets
144# normalize urls to web uris
145sub 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
14918109µ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)
15365924.78s2634725.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
15618696µs return 1;
157
158}
159# EO sub exportCSS
160
161###################################################################################################
162
163# write a css file to the disk
164sub 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
16818121µs my ($path, $data, $config) = @_;
169
170 # call io function to write the file atomically
17118618µs185.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
1792546µs21.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
use RTP::Webmerge qw(@initers);
# 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
182push @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
18613µs my ($config) = @_;
187
188 # include imported css files
18914µ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
19412µs $config->{'absoluteurls'} = 0;
195
196 # return additional get options attribute
197 return (
198130µs 'import-css!' => \ $config->{'cmd_import-css'},
199 'absoluteurls!' => \ $config->{'cmd_absoluteurls'}
200 );
201
202114µs};
203# EO plugin initer
204
205###################################################################################################
206###################################################################################################
207117µs1;
 
# 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
sub RTP::Webmerge::IO::CSS::CORE:qr; # opcode
# 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
sub RTP::Webmerge::IO::CSS::CORE:regcomp; # opcode
# 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
sub RTP::Webmerge::IO::CSS::CORE:subst; # opcode
# 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
sub RTP::Webmerge::IO::CSS::CORE:substcont; # opcode