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

Filename/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/Optimize/TXT.pm
StatementsExecuted 29 statements in 4.06ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11192µs361µsRTP::Webmerge::Optimize::TXT::::BEGIN@8RTP::Webmerge::Optimize::TXT::BEGIN@8
11162µs745µsRTP::Webmerge::Optimize::TXT::::BEGIN@72RTP::Webmerge::Optimize::TXT::BEGIN@72
11161µs94µsRTP::Webmerge::Optimize::TXT::::BEGIN@10RTP::Webmerge::Optimize::TXT::BEGIN@10
11160µs220µsRTP::Webmerge::Optimize::TXT::::BEGIN@75RTP::Webmerge::Optimize::TXT::BEGIN@75
11155µs55µsRTP::Webmerge::Optimize::TXT::::BEGIN@18.32RTP::Webmerge::Optimize::TXT::BEGIN@18.32
11152µs139µsRTP::Webmerge::Optimize::TXT::::BEGIN@9RTP::Webmerge::Optimize::TXT::BEGIN@9
11142µs42µsRTP::Webmerge::Optimize::TXT::::__ANON__[:132]RTP::Webmerge::Optimize::TXT::__ANON__[:132]
11137µs37µsRTP::Webmerge::Optimize::TXT::::__ANON__[:108]RTP::Webmerge::Optimize::TXT::__ANON__[:108]
11131µs31µsRTP::Webmerge::Optimize::TXT::::BEGIN@21RTP::Webmerge::Optimize::TXT::BEGIN@21
11124µs24µsRTP::Webmerge::Optimize::TXT::::BEGIN@18RTP::Webmerge::Optimize::TXT::BEGIN@18
11123µs23µsRTP::Webmerge::Optimize::TXT::::BEGIN@15RTP::Webmerge::Optimize::TXT::BEGIN@15
0000s0sRTP::Webmerge::Optimize::TXT::::__ANON__[:130]RTP::Webmerge::Optimize::TXT::__ANON__[:130]
0000s0sRTP::Webmerge::Optimize::TXT::::cleantxtRTP::Webmerge::Optimize::TXT::cleantxt
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::Optimize::TXT;
6###################################################################################################
7
82164µs2630µs
# spent 361µs (92+269) within RTP::Webmerge::Optimize::TXT::BEGIN@8 which was called: # once (92µs+269µs) by main::BEGIN@46 at line 8
use Carp;
# spent 361µs making 1 call to RTP::Webmerge::Optimize::TXT::BEGIN@8 # spent 269µs making 1 call to Exporter::import
92151µs2225µs
# spent 139µs (52+86) within RTP::Webmerge::Optimize::TXT::BEGIN@9 which was called: # once (52µs+86µs) by main::BEGIN@46 at line 9
use strict;
# spent 139µs making 1 call to RTP::Webmerge::Optimize::TXT::BEGIN@9 # spent 86µs making 1 call to strict::import
102200µs2127µs
# spent 94µs (61+33) within RTP::Webmerge::Optimize::TXT::BEGIN@10 which was called: # once (61µs+33µs) by main::BEGIN@46 at line 10
use warnings;
# spent 94µs making 1 call to RTP::Webmerge::Optimize::TXT::BEGIN@10 # spent 33µs making 1 call to warnings::import
11
12###################################################################################################
13
14# define our version string
151159µs123µs
# spent 23µs within RTP::Webmerge::Optimize::TXT::BEGIN@15 which was called: # once (23µs+0s) by main::BEGIN@46 at line 15
BEGIN { $RTP::Webmerge::Optimize::TXT::VERSION = "0.70" }
# spent 23µs making 1 call to RTP::Webmerge::Optimize::TXT::BEGIN@15
16
17# load exporter and inherit from it
183447µs279µs
# spent 24µs within RTP::Webmerge::Optimize::TXT::BEGIN@18 which was called: # once (24µs+0s) by main::BEGIN@46 at line 18 # spent 55µs within RTP::Webmerge::Optimize::TXT::BEGIN@18.32 which was called: # once (55µs+0s) by main::BEGIN@46 at line 18
BEGIN { use Exporter qw(); our @ISA = qw(Exporter) }
# spent 55µs making 1 call to RTP::Webmerge::Optimize::TXT::BEGIN@18.32 # spent 24µs making 1 call to RTP::Webmerge::Optimize::TXT::BEGIN@18
19
20# define our functions to be exported
2111.26ms131µs
# spent 31µs within RTP::Webmerge::Optimize::TXT::BEGIN@21 which was called: # once (31µs+0s) by main::BEGIN@46 at line 21
BEGIN { our @EXPORT = qw(cleantxt); }
# spent 31µs making 1 call to RTP::Webmerge::Optimize::TXT::BEGIN@21
22
23###################################################################################################
24
25# safe text cleaning
26# for html, css and js
27# changes source files
28sub cleantxt ($$;$)
29{
30
31 # get input variables
32 my ($data, $config, $options) = @_;
33
34 # options are really optional
35 $options = {} unless $options;
36
37 # defined end of line characters
38 # only auto switch between win and linux
39 my $eol = $^O eq "MSWin32" ? "\r\n" : "\n";
40
41 # get the end of line type
42 my $type = $options->{'type'}
43 || $config->{'txt-type'}
44 || 'auto';
45
46 # check for other forced types
47 $eol = "\r\n" if $type =~ m/w/i; # win
48 $eol = "\r" if $type =~ m/c/i; # mac
49 $eol = "\n" if $type =~ m/x/i; # nix
50
51 # remove unwanted utf8 boms
52 if ($config->{'txt-remove-bom'})
53 { ${$data} =~ s/^\xEF\xBB\xBF//; }
54
55 # trim trailing whitespace
56 if ($config->{'txt-trim-trailing'})
57 { ${$data} =~ s/[ \f\t]+(?=[\n\r])//gm; }
58
59 # convert newlines to desired type
60 if ($config->{'txt-normalize-eol'})
61 { ${$data} =~ s/(?:\r\n|\n\r|\n|\r)/$eol/gm; }
62
63 # return success
64 return 1;
65
66}
67# EO sub cleantxt
68
69###################################################################################################
70
71# load webmberge module variables to hook
722217µs21.43ms
# spent 745µs (62+683) within RTP::Webmerge::Optimize::TXT::BEGIN@72 which was called: # once (62µs+683µs) by main::BEGIN@46 at line 72
use RTP::Webmerge qw(@initers @checkers %executables range);
# spent 745µs making 1 call to RTP::Webmerge::Optimize::TXT::BEGIN@72 # spent 683µs making 1 call to Exporter::import
73
74# load functions from webmerge io library
7521.28ms2380µs
# spent 220µs (60+160) within RTP::Webmerge::Optimize::TXT::BEGIN@75 which was called: # once (60µs+160µs) by main::BEGIN@46 at line 75
use RTP::Webmerge::IO qw(processfile);
# spent 220µs making 1 call to RTP::Webmerge::Optimize::TXT::BEGIN@75 # spent 160µs making 1 call to Exporter::import
76
77###################################################################################################
78
79# push to initers
80# return for getOpts
81push @initers, sub
82
# spent 37µs within RTP::Webmerge::Optimize::TXT::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/Optimize/TXT.pm:108] which was called: # once (37µs+0s) by RTP::Webmerge::initConfig at line 263 of webmerge/scripts/modules/RTP/Webmerge.pm
{
83
84 # get config
8514µs my ($config) = @_;
86
87 # create config variable to be available
8814µs $config->{'cmd_optimize-txt'} = 1;
89
90 # text file type [nix|mac|win]
9112µs $config->{'cmd_txt-type'} = 1;
92 # remove superfluous utf boms
9312µs $config->{'cmd_txt-remove-bom'} = 1;
94 # normalize line endings to given type
9512µs $config->{'cmd_txt-normalize-eol'} = 1;
96 # trim trailing whitespace in text files
9713µs $config->{'cmd_txt-trim-trailing'} = 1;
98
99 # connect each tmpl variable with the getOpt option
100 return (
101136µs 'optimize-txt|txt!', \ $config->{'cmd_optimize-txt'},
102 'txt-type=s', \ $config->{'cmd_txt-type'},
103 'txt-remove-bom!', \ $config->{'cmd_txt-remove-bom'},
104 'txt-normalize-eol!', \ $config->{'cmd_txt-normalize-eol'},
105 'txt-trim-trailing!', \ $config->{'cmd_txt-trim-trailing'},
106 );
107
108116µs};
109# EO push initer
110
111###################################################################################################
112
113# push to checkers
114push @checkers, sub
115
# spent 42µs within RTP::Webmerge::Optimize::TXT::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/Optimize/TXT.pm:132] which was called: # once (42µs+0s) by RTP::Webmerge::checkConfig at line 290 of webmerge/scripts/modules/RTP/Webmerge.pm
{
116
117 # get config
11813µs my ($config) = @_;
119
120 # disable if not optimizing
12115µs unless ($config->{'optimize'})
122 { $config->{'optimize-txt'} = 0; }
123
124 # define executables to optimize txts
125 $executables{'txtopt'} = ['txtopt', sub {
126
127 # process that file via cleantxt (pass options)
128 return processfile($_[0], \&cleantxt, $_[1], $_[2]);
129
130148µs }, 1];
131
132116µs};
133# EO push checker
134
135###################################################################################################
136
137# now create a new file optimizer subroutine and hook it our optimizers
138121µs137µs$RTP::Webmerge::Optimize::optimizer{'txt'} = RTP::Webmerge::Optimize::optimize('txt');
# spent 37µs making 1 call to RTP::Webmerge::Optimize::optimize
139
140###################################################################################################
141###################################################################################################
142124µs1;