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

Filename/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/OCBNET/CSS/Parser/CSS.pm
StatementsExecuted 470694 statements in 23.8s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
271552517.20s7.20sOCBNET::CSS::Parser::CSS::::CORE:substOCBNET::CSS::Parser::CSS::CORE:subst (opcode)
9988217.02s15.5sOCBNET::CSS::Parser::CSS::::__ANON__[:252]OCBNET::CSS::Parser::CSS::__ANON__[:252] (recurses: max depth 3, inclusive time 13.4s)
20284314.02s8.82sOCBNET::CSS::Parser::CSS::::__ANON__[:82]OCBNET::CSS::Parser::CSS::__ANON__[:82]
4752113.27s4.48sOCBNET::CSS::Parser::CSS::::__ANON__[:154]OCBNET::CSS::Parser::CSS::__ANON__[:154]
139257411.57s1.57sOCBNET::CSS::Parser::CSS::::CORE:regcompOCBNET::CSS::Parser::CSS::CORE:regcomp (opcode)
503622516ms15.5sOCBNET::CSS::Parser::CSS::::__ANON__[:175]OCBNET::CSS::Parser::CSS::__ANON__[:175] (recurses: max depth 2, inclusive time 12.3s)
2028411347ms347msOCBNET::CSS::Parser::CSS::::CORE:matchOCBNET::CSS::Parser::CSS::CORE:match (opcode)
502041106ms106msOCBNET::CSS::Parser::CSS::::CORE:qrOCBNET::CSS::Parser::CSS::CORE:qr (opcode)
1113.09ms8.08msOCBNET::CSS::Parser::CSS::::BEGIN@30OCBNET::CSS::Parser::CSS::BEGIN@30
111105µs208µsOCBNET::CSS::Parser::CSS::::BEGIN@10OCBNET::CSS::Parser::CSS::BEGIN@10
11157µs90µsOCBNET::CSS::Parser::CSS::::BEGIN@11OCBNET::CSS::Parser::CSS::BEGIN@11
11152µs52µsOCBNET::CSS::Parser::CSS::::BEGIN@19.7OCBNET::CSS::Parser::CSS::BEGIN@19.7
11152µs584µsOCBNET::CSS::Parser::CSS::::BEGIN@29OCBNET::CSS::Parser::CSS::BEGIN@29
11125µs25µsOCBNET::CSS::Parser::CSS::::BEGIN@22OCBNET::CSS::Parser::CSS::BEGIN@22
11125µs25µsOCBNET::CSS::Parser::CSS::::BEGIN@25OCBNET::CSS::Parser::CSS::BEGIN@25
11123µs23µsOCBNET::CSS::Parser::CSS::::BEGIN@16OCBNET::CSS::Parser::CSS::BEGIN@16
11122µs22µsOCBNET::CSS::Parser::CSS::::BEGIN@19OCBNET::CSS::Parser::CSS::BEGIN@19
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####################################################################################################
5# TODO: improve and test handling with invalid formated files
6####################################################################################################
7package OCBNET::CSS::Parser::CSS;
8####################################################################################################
9
102182µs2311µs
# spent 208µs (105+103) within OCBNET::CSS::Parser::CSS::BEGIN@10 which was called: # once (105µs+103µs) by OCBNET::Spritesets::CSS::Block::BEGIN@23 at line 10
use strict;
# spent 208µs making 1 call to OCBNET::CSS::Parser::CSS::BEGIN@10 # spent 103µs making 1 call to strict::import
112216µs2124µs
# spent 90µs (57+34) within OCBNET::CSS::Parser::CSS::BEGIN@11 which was called: # once (57µs+34µs) by OCBNET::Spritesets::CSS::Block::BEGIN@23 at line 11
use warnings;
# spent 90µs making 1 call to OCBNET::CSS::Parser::CSS::BEGIN@11 # spent 34µs making 1 call to warnings::import
12
13####################################################################################################
14
15# define our version string
161144µs123µs
# spent 23µs within OCBNET::CSS::Parser::CSS::BEGIN@16 which was called: # once (23µs+0s) by OCBNET::Spritesets::CSS::Block::BEGIN@23 at line 16
BEGIN { $OCBNET::CSS::Parser::CSS::VERSION = "0.70"; }
# spent 23µs making 1 call to OCBNET::CSS::Parser::CSS::BEGIN@16
17
18# load exporter and inherit from it
193359µs274µs
# spent 22µs within OCBNET::CSS::Parser::CSS::BEGIN@19 which was called: # once (22µs+0s) by OCBNET::Spritesets::CSS::Block::BEGIN@23 at line 19 # spent 52µs within OCBNET::CSS::Parser::CSS::BEGIN@19.7 which was called: # once (52µs+0s) by OCBNET::Spritesets::CSS::Block::BEGIN@23 at line 19
BEGIN { use Exporter qw(); our @ISA = qw(Exporter); }
# spent 52µs making 1 call to OCBNET::CSS::Parser::CSS::BEGIN@19.7 # spent 22µs making 1 call to OCBNET::CSS::Parser::CSS::BEGIN@19
20
21# define our functions that will be exported
221170µs125µs
# spent 25µs within OCBNET::CSS::Parser::CSS::BEGIN@22 which was called: # once (25µs+0s) by OCBNET::Spritesets::CSS::Block::BEGIN@23 at line 22
BEGIN { our @EXPORT = qw($parse_blocks $parse_declarations); }
# spent 25µs making 1 call to OCBNET::CSS::Parser::CSS::BEGIN@22
23
24# define our functions than can be exported
251143µs125µs
# spent 25µs within OCBNET::CSS::Parser::CSS::BEGIN@25 which was called: # once (25µs+0s) by OCBNET::Spritesets::CSS::Block::BEGIN@23 at line 25
BEGIN { our @EXPORT_OK = qw($parse_bracket $parse_definition); }
# spent 25µs making 1 call to OCBNET::CSS::Parser::CSS::BEGIN@25
26
27####################################################################################################
28
292182µs21.12ms
# spent 584µs (52+533) within OCBNET::CSS::Parser::CSS::BEGIN@29 which was called: # once (52µs+533µs) by OCBNET::Spritesets::CSS::Block::BEGIN@23 at line 29
use OCBNET::CSS::Parser::Base qw($re_apo $re_quot);
# spent 584µs making 1 call to OCBNET::CSS::Parser::CSS::BEGIN@29 # spent 533µs making 1 call to Exporter::import
3024.75ms28.71ms
# spent 8.08ms (3.09+5.00) within OCBNET::CSS::Parser::CSS::BEGIN@30 which was called: # once (3.09ms+5.00ms) by OCBNET::Spritesets::CSS::Block::BEGIN@23 at line 30
use OCBNET::CSS::Parser::Selectors qw($re_options);
# spent 8.08ms making 1 call to OCBNET::CSS::Parser::CSS::BEGIN@30 # spent 628µs making 1 call to Exporter::import
31
32####################################################################################################
33
341700nsour $parse_blocks;
351400nsour $parse_bracket;
361500nsour $parse_definition;
371400nsour $parse_declarations;
38
39####################################################################################################
40
41165µs118µsour $re_option = qr/\w(?:\w|-)*\s*:\s*[^;]+;/;
# spent 18µs making 1 call to OCBNET::CSS::Parser::CSS::CORE:qr
421139µs291µsour $re_options = qr/$re_option(?:\s*$re_option)*/m;
# spent 81µs making 1 call to OCBNET::CSS::Parser::CSS::CORE:regcomp # spent 10µs making 1 call to OCBNET::CSS::Parser::CSS::CORE:qr
43
44####################################################################################################
45
461128µs651µsmy $re_closer =
# spent 51µs making 6 calls to OCBNET::CSS::Parser::CSS::CORE:qr, avg 9µs/call
47{
48 "" => qr/\A\z/,
49 "\(" => qr/\A(\)|\z)/,
50 "\[" => qr/\A(\]|\z)/,
51 "\{" => qr/\A(\}|\z)/,
52 "\"" => qr/\A(\"|\z)/,
53 "\'" => qr/\A(\'|\z)/
54};
55
56####################################################################################################
57
58# rename either one of parse_decl subs
59$parse_definition = sub
60
# spent 8.82s (4.02+4.81) within OCBNET::CSS::Parser::CSS::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/OCBNET/CSS/Parser/CSS.pm:82] which was called 20284 times, avg 435µs/call: # 10036 times (2.38s+3.92s) by OCBNET::Spritesets::CSS::Parser::read at line 182 of webmerge/scripts/modules/OCBNET/Spritesets/CSS/Parser.pm, avg 628µs/call # 5296 times (780ms+427ms) by OCBNET::Spritesets::CSS::Parser::read at line 138 of webmerge/scripts/modules/OCBNET/Spritesets/CSS/Parser.pm, avg 228µs/call # 4952 times (857ms+457ms) by OCBNET::Spritesets::CSS::Parser::read at line 179 of webmerge/scripts/modules/OCBNET/Spritesets/CSS/Parser.pm, avg 265µs/call
{
61
6220284115ms my ($option, $code) = @_;
63
64 # remove whitespace from body
65202841.45s202841.09s $code =~ s/(?:\A\s+|\s+\z)//gm;
# spent 1.09s making 20284 calls to OCBNET::CSS::Parser::CSS::CORE:subst, avg 54µs/call
66
67 # check if this is a valid sprite option block
68202841.44s40568445ms return unless $code =~ m/^\s*$re_options(?:\s|\n)*\z/m;
# spent 347ms making 20284 calls to OCBNET::CSS::Parser::CSS::CORE:match, avg 17µs/call # spent 98.2ms making 20284 calls to OCBNET::CSS::Parser::CSS::CORE:regcomp, avg 5µs/call
69
70 # split all declarations
7134672503ms my @declarations = map {
7214908693ms [ split(/\s*:\s*/, $_, 2) ]
73 } split(/\s*;\s*/, $code);
74
75 # set option via our css system
761490869.0ms foreach my $item (@declarations)
7734672587ms346723.27s { $option->set(lc $item->[0], $item->[1]); }
# spent 3.27s making 34672 calls to OCBNET::Spritesets::CSS::Collection::set, avg 94µs/call
78
79 # return object
8014908495ms return $option;
81
82116µs};
83
84# parse all declaration in given data
85# usefull to parse css selector blocks
86# also used to parse spriteset comments
87# ******************************************************************************
88$parse_declarations = sub
89
# spent 4.48s (3.27+1.20) within OCBNET::CSS::Parser::CSS::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/OCBNET/CSS/Parser/CSS.pm:154] which was called 4752 times, avg 942µs/call: # 4752 times (3.27s+1.20s) by OCBNET::Spritesets::CSS::Block::parse at line 43 of webmerge/scripts/modules/OCBNET/Spritesets/CSS/Block.pm, avg 942µs/call
{
90
91 # get stylesheet
92475217.2ms my ($data) = @_;
93
94 # array of rules
9547526.70ms my @declarations;
96
97 # loop until no more data
98475218.8ms while (${$data} ne '')
99 {
100 # consume data
101282402.30s56480982ms if (${$data} =~
# spent 786ms making 28240 calls to OCBNET::CSS::Parser::CSS::CORE:subst, avg 28µs/call # spent 196ms making 28240 calls to OCBNET::CSS::Parser::CSS::CORE:regcomp, avg 7µs/call
102 s/^
103 (
104 (?:
105 # escaped char
106 (?: \\ .)+ |
107 # comment or only a slash
108 \/+ (?:\*+ .*? \*+ \/+)? |
109 # a string in delimiters
110 \" $re_quot \" | \' $re_apo \' |
111 # not the delimiter
112 [^\:\;\/]+
113 )*
114 )
115 (
116 (?:\:
117 # escaped char
118 (?: \\ .)+ |
119 # comment or only a slash
120 \/+ (?:\*+ .*? \*+ \/+)? |
121 # a string in delimiters
122 \" $re_quot \" | \' $re_apo \' |
123 # not the delimiter
124 [^\;\/]+
125 )*
126 (?:\;|\z)
127 )
128 //xs
129 )
130 {
131
132 # store the name and the config
133 # create a copy for stripped version
13428240470ms my $declaration = [$1, $2, $1, $2];
135
136 # strip comments from declaration copy
13728240816ms28240162ms $declaration->[2] =~ s/\/\*\s*.*?\s*\*\///gs;
# spent 162ms making 28240 calls to OCBNET::CSS::Parser::CSS::CORE:subst, avg 6µs/call
13828240618ms2824057.4ms $declaration->[3] =~ s/\/\*\s*.*?\s*\*\///gs;
# spent 57.4ms making 28240 calls to OCBNET::CSS::Parser::CSS::CORE:subst, avg 2µs/call
139
140 # store in order into array
14128240159ms push @declarations, $declaration;
142
143 }
144 else
145 {
146 # this should not happen, investigate further
147 die "Fatal: CSS parse error: ", substr(${$data}, 0, 110);
148 }
149 }
150
151 # return parsed declarations
1524752205ms return \ @declarations;
153
154111µs};
155# EO sub $parse_declarations
156
157####################################################################################################
158
159# parse the css into blocks
160$parse_blocks = sub
161
# spent 15.5s (516ms+15.0) within OCBNET::CSS::Parser::CSS::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/OCBNET/CSS/Parser/CSS.pm:175] which was called 5036 times, avg 3.08ms/call: # 5012 times (514ms+-514ms) by OCBNET::CSS::Parser::CSS::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/OCBNET/CSS/Parser/CSS.pm:252] at line 221, avg 0s/call # 24 times (1.75ms+15.5s) by OCBNET::Spritesets::CSS::Parser::read at line 95 of webmerge/scripts/modules/OCBNET/Spritesets/CSS/Parser.pm, avg 646ms/call
{
162
163 # get passed input arguments
164503628.2ms my ($data, $parent, $clause) = @_;
165
166 # create new block node with the given parent
1675036131ms5036700ms my $block = OCBNET::Spritesets::CSS::Block->new($parent);
# spent 700ms making 5036 calls to OCBNET::Spritesets::CSS::Block::new, avg 139µs/call
168
169 # parse the new block as normal bracket block
170503665.7ms503615.5s $parse_bracket->($data, $block, '', $clause);
# spent 26.6s making 5036 calls to OCBNET::CSS::Parser::CSS::__ANON__[webmerge/scripts/modules/OCBNET/CSS/Parser/CSS.pm:252], avg 5.28ms/call, recursion: max depth 2, sum of overlapping time 11.1s
171
172 # return object
1735036172ms return $parent;
174
17519µs};
176
177####################################################################################################
178
179# parse a bracket block
180$parse_bracket = sub
181
# spent 15.5s (7.02+8.47) within OCBNET::CSS::Parser::CSS::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/OCBNET/CSS/Parser/CSS.pm:252] which was called 9988 times, avg 1.55ms/call: # 5036 times (6.02s+9.47s) by OCBNET::CSS::Parser::CSS::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/OCBNET/CSS/Parser/CSS.pm:175] at line 170, avg 3.08ms/call # 4952 times (995ms+-995ms) by OCBNET::CSS::Parser::CSS::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/OCBNET/CSS/Parser/CSS.pm:252] at line 230, avg 0s/call
{
182
183 # get passed input arguments
184998869.7ms my ($data, $block, $opener, $clause) = @_;
185
186 # add opener to head if defined
187998840.1ms $block->{'head'} .= $opener if $opener;
188
189 # repeat until all the data is parsed
190 # be sure to include an abort clause
191998814.9ms while(1)
192 {
193
194 # simpler grammars
1955048012.2s2572806.38s if (${$data} =~ s/^(
# spent 5.10s making 166548 calls to OCBNET::CSS::Parser::CSS::CORE:subst, avg 31µs/call # spent 1.28s making 90732 calls to OCBNET::CSS::Parser::CSS::CORE:regcomp, avg 14µs/call
196 # escaped char
197 (?: \\ .)+ |
198 # comment or only a slash
199 \/+ (?:\* .*? \*\/+)? |
200 # a string in delimiters
201 \" $re_quot \" | \' $re_apo \'
202 )//xs)
203 {
204 # just store the match
205 $block->{'head'} .= $1;
206 }
207
208 # check if we found our exit clause
209 elsif (${$data} =~ s/^($clause)//s)
210 {
211 # add closer to head if defined
212998871.8ms $block->{'head'} .= $1 if $opener;
213 # return the block node
2149988366ms return $block;
215 }
216
217 # parse an inner block recursive
218 elsif (${$data} =~ s/^(\{)//s)
219 {
220 # parse this one block body
2215012352ms10024106ms $parse_blocks->($data, $block, qr/^(\})/);
# spent 106ms making 5012 calls to OCBNET::CSS::Parser::CSS::CORE:qr, avg 21µs/call # spent 12.3s making 5012 calls to OCBNET::CSS::Parser::CSS::__ANON__[webmerge/scripts/modules/OCBNET/CSS/Parser/CSS.pm:175], avg 2.45ms/call, recursion: max depth 2, sum of overlapping time 12.3s
222 # create new block node with the given parent
2235012202ms5012773ms $block = OCBNET::Spritesets::CSS::Block->new($block->{'parent'});
# spent 773ms making 5012 calls to OCBNET::Spritesets::CSS::Block::new, avg 154µs/call
224 }
225
226 # parse further for a bracket
227 elsif (${$data} =~ s/^(\(|\[)//s)
228 {
229 # parse a default bracket block
2304952140ms49520s $parse_bracket->($data, $block, $1, $re_closer->{$1});
# spent 2.32s making 4952 calls to OCBNET::CSS::Parser::CSS::__ANON__[webmerge/scripts/modules/OCBNET/CSS/Parser/CSS.pm:252], avg 468µs/call, recursion: max depth 3, sum of overlapping time 2.32s
231 }
232
233 # parse unimportant chars in this context
234 elsif (${$data} =~ s/^([^\{\}\[\]\(\)\"\'\/]+)//s)
235 {
236 $block->{'head'} .= $1;
237 }
238
239 # invalid parsing
240 else
241 {
242 # this should not happen, investigate further
243 die "Fatal: CSS parse error: ", substr(${$data}, 0, 10);
244 }
245
246 }
247 # EO while 1
248
249 # this should not happen, investigate further
250 die "Fatal: Escaped endless parse loop?";
251
252111µs};
253
254####################################################################################################
255####################################################################################################
256136µs1;
 
# spent 347ms within OCBNET::CSS::Parser::CSS::CORE:match which was called 20284 times, avg 17µs/call: # 20284 times (347ms+0s) by OCBNET::CSS::Parser::CSS::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/OCBNET/CSS/Parser/CSS.pm:82] at line 68, avg 17µs/call
sub OCBNET::CSS::Parser::CSS::CORE:match; # opcode
# spent 106ms within OCBNET::CSS::Parser::CSS::CORE:qr which was called 5020 times, avg 21µs/call: # 5012 times (106ms+0s) by OCBNET::CSS::Parser::CSS::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/OCBNET/CSS/Parser/CSS.pm:252] at line 221, avg 21µs/call # 6 times (51µs+0s) by OCBNET::Spritesets::CSS::Block::BEGIN@23 at line 46, avg 9µs/call # once (18µs+0s) by OCBNET::Spritesets::CSS::Block::BEGIN@23 at line 41 # once (10µs+0s) by OCBNET::Spritesets::CSS::Block::BEGIN@23 at line 42
sub OCBNET::CSS::Parser::CSS::CORE:qr; # opcode
# spent 1.57s within OCBNET::CSS::Parser::CSS::CORE:regcomp which was called 139257 times, avg 11µs/call: # 90732 times (1.28s+0s) by OCBNET::CSS::Parser::CSS::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/OCBNET/CSS/Parser/CSS.pm:252] at line 195, avg 14µs/call # 28240 times (196ms+0s) by OCBNET::CSS::Parser::CSS::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/OCBNET/CSS/Parser/CSS.pm:154] at line 101, avg 7µs/call # 20284 times (98.2ms+0s) by OCBNET::CSS::Parser::CSS::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/OCBNET/CSS/Parser/CSS.pm:82] at line 68, avg 5µs/call # once (81µs+0s) by OCBNET::Spritesets::CSS::Block::BEGIN@23 at line 42
sub OCBNET::CSS::Parser::CSS::CORE:regcomp; # opcode
# spent 7.20s within OCBNET::CSS::Parser::CSS::CORE:subst which was called 271552 times, avg 27µs/call: # 166548 times (5.10s+0s) by OCBNET::CSS::Parser::CSS::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/OCBNET/CSS/Parser/CSS.pm:252] at line 195, avg 31µs/call # 28240 times (786ms+0s) by OCBNET::CSS::Parser::CSS::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/OCBNET/CSS/Parser/CSS.pm:154] at line 101, avg 28µs/call # 28240 times (162ms+0s) by OCBNET::CSS::Parser::CSS::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/OCBNET/CSS/Parser/CSS.pm:154] at line 137, avg 6µs/call # 28240 times (57.4ms+0s) by OCBNET::CSS::Parser::CSS::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/OCBNET/CSS/Parser/CSS.pm:154] at line 138, avg 2µs/call # 20284 times (1.09s+0s) by OCBNET::CSS::Parser::CSS::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/OCBNET/CSS/Parser/CSS.pm:82] at line 65, avg 54µs/call
sub OCBNET::CSS::Parser::CSS::CORE:subst; # opcode