Filename | /home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/Merge/JS.pm |
Statements | Executed 32 statements in 5.11ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 2.45ms | 4.60ms | BEGIN@70 | RTP::Webmerge::Merge::JS::
1 | 1 | 1 | 92µs | 377µs | BEGIN@8 | RTP::Webmerge::Merge::JS::
1 | 1 | 1 | 85µs | 859µs | BEGIN@41 | RTP::Webmerge::Merge::JS::
1 | 1 | 1 | 77µs | 77µs | BEGIN@18.17 | RTP::Webmerge::Merge::JS::
1 | 1 | 1 | 65µs | 313µs | BEGIN@62 | RTP::Webmerge::Merge::JS::
1 | 1 | 1 | 55µs | 89µs | BEGIN@10 | RTP::Webmerge::Merge::JS::
1 | 1 | 1 | 55µs | 639µs | BEGIN@42 | RTP::Webmerge::Merge::JS::
1 | 1 | 1 | 54µs | 654µs | BEGIN@43 | RTP::Webmerge::Merge::JS::
1 | 1 | 1 | 52µs | 139µs | BEGIN@9 | RTP::Webmerge::Merge::JS::
1 | 1 | 1 | 34µs | 34µs | BEGIN@24 | RTP::Webmerge::Merge::JS::
1 | 1 | 1 | 24µs | 24µs | BEGIN@21 | RTP::Webmerge::Merge::JS::
1 | 1 | 1 | 23µs | 23µs | BEGIN@15 | RTP::Webmerge::Merge::JS::
1 | 1 | 1 | 22µs | 22µs | BEGIN@18 | RTP::Webmerge::Merge::JS::
0 | 0 | 0 | 0s | 0s | __ANON__[:112] | RTP::Webmerge::Merge::JS::
0 | 0 | 0 | 0s | 0s | __ANON__[:74] | RTP::Webmerge::Merge::JS::
0 | 0 | 0 | 0s | 0s | __ANON__[:75] | RTP::Webmerge::Merge::JS::
0 | 0 | 0 | 0s | 0s | __ANON__[:76] | RTP::Webmerge::Merge::JS::
0 | 0 | 0 | 0s | 0s | __ANON__[:77] | RTP::Webmerge::Merge::JS::
0 | 0 | 0 | 0s | 0s | __ANON__[:78] | RTP::Webmerge::Merge::JS::
0 | 0 | 0 | 0s | 0s | __ANON__[:87] | RTP::Webmerge::Merge::JS::
0 | 0 | 0 | 0s | 0s | __ANON__[:92] | RTP::Webmerge::Merge::JS::
0 | 0 | 0 | 0s | 0s | getLicense | RTP::Webmerge::Merge::JS::
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::Merge::JS; | ||||
6 | ################################################################################################### | ||||
7 | |||||
8 | 2 | 166µs | 2 | 662µs | # spent 377µs (92+285) within RTP::Webmerge::Merge::JS::BEGIN@8 which was called:
# once (92µs+285µs) by RTP::Webmerge::Merge::BEGIN@68 at line 8 # spent 377µs making 1 call to RTP::Webmerge::Merge::JS::BEGIN@8
# spent 284µs making 1 call to Exporter::import |
9 | 2 | 162µs | 2 | 226µs | # spent 139µs (52+87) within RTP::Webmerge::Merge::JS::BEGIN@9 which was called:
# once (52µs+87µs) by RTP::Webmerge::Merge::BEGIN@68 at line 9 # spent 139µs making 1 call to RTP::Webmerge::Merge::JS::BEGIN@9
# spent 87µs making 1 call to strict::import |
10 | 2 | 194µs | 2 | 122µs | # spent 89µs (55+33) within RTP::Webmerge::Merge::JS::BEGIN@10 which was called:
# once (55µs+33µs) by RTP::Webmerge::Merge::BEGIN@68 at line 10 # spent 89µs making 1 call to RTP::Webmerge::Merge::JS::BEGIN@10
# spent 33µs making 1 call to warnings::import |
11 | |||||
12 | ################################################################################################### | ||||
13 | |||||
14 | # define our version string | ||||
15 | 1 | 145µs | 1 | 23µs | # spent 23µs within RTP::Webmerge::Merge::JS::BEGIN@15 which was called:
# once (23µs+0s) by RTP::Webmerge::Merge::BEGIN@68 at line 15 # spent 23µs making 1 call to RTP::Webmerge::Merge::JS::BEGIN@15 |
16 | |||||
17 | # load exporter and inherit from it | ||||
18 | 3 | 412µs | 2 | 99µs | BEGIN { use Exporter qw(); our @ISA = qw(Exporter) } # spent 77µs making 1 call to RTP::Webmerge::Merge::JS::BEGIN@18.17
# spent 22µs making 1 call to RTP::Webmerge::Merge::JS::BEGIN@18 |
19 | |||||
20 | # define our functions to be exported | ||||
21 | 1 | 217µs | 1 | 24µs | # spent 24µs within RTP::Webmerge::Merge::JS::BEGIN@21 which was called:
# once (24µs+0s) by RTP::Webmerge::Merge::BEGIN@68 at line 21 # spent 24µs making 1 call to RTP::Webmerge::Merge::JS::BEGIN@21 |
22 | |||||
23 | # define our functions to be exported | ||||
24 | 1 | 553µs | 1 | 34µs | # spent 34µs within RTP::Webmerge::Merge::JS::BEGIN@24 which was called:
# once (34µs+0s) by RTP::Webmerge::Merge::BEGIN@68 at line 24 # spent 34µs making 1 call to RTP::Webmerge::Merge::JS::BEGIN@24 |
25 | |||||
26 | ################################################################################################### | ||||
27 | |||||
28 | # parse license from code | ||||
29 | sub getLicense | ||||
30 | { | ||||
31 | # map out the licenses from inputs | ||||
32 | return | ||||
33 | # remove everything but the very first comment (first line!) | ||||
34 | ${$_->{'data'}} =~m /\A\s*(\/\*(?:\n|\r|.)+?\*\/)\s*(?:\n|\r|.)*\z/m | ||||
35 | # return header with given input path and license or nothing | ||||
36 | ? ( '/* license for ' . $_->{'web_path'} . ' */', $1, '' ) : (); | ||||
37 | } | ||||
38 | |||||
39 | ################################################################################################### | ||||
40 | |||||
41 | 2 | 209µs | 2 | 1.63ms | # spent 859µs (85+775) within RTP::Webmerge::Merge::JS::BEGIN@41 which was called:
# once (85µs+775µs) by RTP::Webmerge::Merge::BEGIN@68 at line 41 # spent 859µs making 1 call to RTP::Webmerge::Merge::JS::BEGIN@41
# spent 775µs making 1 call to Exporter::import |
42 | 2 | 178µs | 2 | 1.22ms | # spent 639µs (55+584) within RTP::Webmerge::Merge::JS::BEGIN@42 which was called:
# once (55µs+584µs) by RTP::Webmerge::Merge::BEGIN@68 at line 42 # spent 639µs making 1 call to RTP::Webmerge::Merge::JS::BEGIN@42
# spent 584µs making 1 call to Exporter::import |
43 | 2 | 313µs | 2 | 1.26ms | # spent 654µs (54+601) within RTP::Webmerge::Merge::JS::BEGIN@43 which was called:
# once (54µs+601µs) by RTP::Webmerge::Merge::BEGIN@68 at line 43 # spent 654µs making 1 call to RTP::Webmerge::Merge::JS::BEGIN@43
# spent 601µs making 1 call to Exporter::import |
44 | |||||
45 | ################################################################################################### | ||||
46 | |||||
47 | # headJS bit to overwrite | ||||
48 | # default JavaScript loader | ||||
49 | 1 | 5µs | my $headJS = " | ||
50 | |||||
51 | // change loadJS to head.js | ||||
52 | webmerge.loadJS = head.hs; | ||||
53 | |||||
54 | "; | ||||
55 | |||||
56 | ################################################################################################### | ||||
57 | |||||
58 | # define joiner string | ||||
59 | 1 | 6µs | $joiner{'js'} = ";\n"; | ||
60 | |||||
61 | # load IO functions | ||||
62 | 2 | 453µs | 2 | 561µs | # spent 313µs (65+248) within RTP::Webmerge::Merge::JS::BEGIN@62 which was called:
# once (65µs+248µs) by RTP::Webmerge::Merge::BEGIN@68 at line 62 # spent 313µs making 1 call to RTP::Webmerge::Merge::JS::BEGIN@62
# spent 248µs making 1 call to Exporter::import |
63 | |||||
64 | # assign IO functions | ||||
65 | 1 | 7µs | $reader{'js'} = \&readJS; | ||
66 | 1 | 4µs | $importer{'js'} = \&importJS; | ||
67 | 1 | 4µs | $exporter{'js'} = \&exportJS; | ||
68 | 1 | 4µs | $writer{'js'} = \&writeJS; | ||
69 | |||||
70 | 2 | 1.97ms | 2 | 5.13ms | # spent 4.60ms (2.45+2.15) within RTP::Webmerge::Merge::JS::BEGIN@70 which was called:
# once (2.45ms+2.15ms) by RTP::Webmerge::Merge::BEGIN@68 at line 70 # spent 4.60ms making 1 call to RTP::Webmerge::Merge::JS::BEGIN@70
# spent 534µs making 1 call to Exporter::import |
71 | |||||
72 | $includer{'js'} = | ||||
73 | { | ||||
74 | 'dev' => sub { includeJS($_) }, | ||||
75 | 'join' => sub { ${$_->{'data'}} }, | ||||
76 | 'minify' => sub { ${$_->{'data'}} }, | ||||
77 | 'compile' => sub { ${$_->{'data'}} }, | ||||
78 | 'license' => sub { getLicense($_) } | ||||
79 | 1 | 36µs | }; | ||
80 | |||||
81 | $processor{'js'} = | ||||
82 | { | ||||
83 | 'minify' => sub | ||||
84 | { | ||||
85 | require JavaScript::Minifier; | ||||
86 | &JavaScript::Minifier::minify('input' => $_[0]); | ||||
87 | }, | ||||
88 | 'compile' => sub | ||||
89 | { | ||||
90 | require RTP::Webmerge::Compile::JS; | ||||
91 | &RTP::Webmerge::Compile::JS::compileJS; | ||||
92 | } | ||||
93 | 1 | 16µs | }; | ||
94 | |||||
95 | $prefixer{'js'} = | ||||
96 | { | ||||
97 | 'dev' => sub | ||||
98 | { | ||||
99 | # get passed input variables | ||||
100 | my ($data, $merge, $config) = @_; | ||||
101 | # check if the merged file has been set to load deferred | ||||
102 | # my $deferred = $merge->{'defer'} && lc $merge->{'defer'} eq 'true'; | ||||
103 | # assertion that we have at least one defered include, otherwise | ||||
104 | # it may never fire the ready event (happens with head.js) | ||||
105 | # $deferred = 0 if scalar $collect->('input') == 0; | ||||
106 | # insert the javascript header | ||||
107 | my $prefix = $js_dev_header . ";\n"; | ||||
108 | # overwrite loader with defered head.js loader | ||||
109 | # $prefix .= $headJS if $deferred; | ||||
110 | # prefix the new header to data | ||||
111 | ${$data} = $prefix . ${$data}; | ||||
112 | } | ||||
113 | 1 | 14µs | }; | ||
114 | |||||
115 | ################################################################################################### | ||||
116 | ################################################################################################### | ||||
117 | 1 | 43µs | 1; |