Filename | /home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/Optimize/PNG.pm |
Statements | Executed 22 statements in 2.83ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 89µs | 357µs | BEGIN@11 | RTP::Webmerge::Optimize::PNG::
1 | 1 | 1 | 83µs | 83µs | BEGIN@19 | RTP::Webmerge::Optimize::PNG::
1 | 1 | 1 | 56µs | 89µs | BEGIN@13 | RTP::Webmerge::Optimize::PNG::
1 | 1 | 1 | 54µs | 762µs | BEGIN@34 | RTP::Webmerge::Optimize::PNG::
1 | 1 | 1 | 52µs | 140µs | BEGIN@12 | RTP::Webmerge::Optimize::PNG::
1 | 1 | 1 | 23µs | 23µs | BEGIN@29 | RTP::Webmerge::Optimize::PNG::
1 | 1 | 1 | 22µs | 22µs | __ANON__[:52] | RTP::Webmerge::Optimize::PNG::
1 | 1 | 1 | 20µs | 20µs | __ANON__[:80] | RTP::Webmerge::Optimize::PNG::
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 | # http://optipng.sourceforge.net/pngtech/optipng.html | ||||
6 | # pngrewrite, pngcrush, OptiPNG, AdvanceCOMP (advpng), PNGOut | ||||
7 | ################################################################################################### | ||||
8 | package RTP::Webmerge::Optimize::PNG; | ||||
9 | ################################################################################################### | ||||
10 | |||||
11 | 2 | 161µs | 2 | 625µs | # spent 357µs (89+268) within RTP::Webmerge::Optimize::PNG::BEGIN@11 which was called:
# once (89µs+268µs) by main::BEGIN@49 at line 11 # spent 357µs making 1 call to RTP::Webmerge::Optimize::PNG::BEGIN@11
# spent 268µs making 1 call to Exporter::import |
12 | 2 | 160µs | 2 | 228µs | # spent 140µs (52+88) within RTP::Webmerge::Optimize::PNG::BEGIN@12 which was called:
# once (52µs+88µs) by main::BEGIN@49 at line 12 # spent 140µs making 1 call to RTP::Webmerge::Optimize::PNG::BEGIN@12
# spent 88µs making 1 call to strict::import |
13 | 2 | 351µs | 2 | 122µs | # spent 89µs (56+33) within RTP::Webmerge::Optimize::PNG::BEGIN@13 which was called:
# once (56µs+33µs) by main::BEGIN@49 at line 13 # spent 89µs making 1 call to RTP::Webmerge::Optimize::PNG::BEGIN@13
# spent 33µs making 1 call to warnings::import |
14 | |||||
15 | ################################################################################################### | ||||
16 | |||||
17 | # setup some global settings | ||||
18 | BEGIN | ||||
19 | # spent 83µs within RTP::Webmerge::Optimize::PNG::BEGIN@19 which was called:
# once (83µs+0s) by main::BEGIN@49 at line 24 | ||||
20 | # enable (or disable) different optimizer executables | ||||
21 | 1 | 22µs | $ENV{'WEBMERGE_ADVDEF'} = 1 unless exists $ENV{'WEBMERGE_ADVDEF'}; | ||
22 | 1 | 28µs | $ENV{'WEBMERGE_ADVPNG'} = 1 unless exists $ENV{'WEBMERGE_ADVPNG'}; | ||
23 | 1 | 39µs | $ENV{'WEBMERGE_OPTIPNG'} = 1 unless exists $ENV{'WEBMERGE_OPTIPNG'}; | ||
24 | 1 | 148µs | 1 | 83µs | } # spent 83µs making 1 call to RTP::Webmerge::Optimize::PNG::BEGIN@19 |
25 | |||||
26 | ################################################################################################### | ||||
27 | |||||
28 | # define our version string | ||||
29 | 1 | 151µs | 1 | 23µs | # spent 23µs within RTP::Webmerge::Optimize::PNG::BEGIN@29 which was called:
# once (23µs+0s) by main::BEGIN@49 at line 29 # spent 23µs making 1 call to RTP::Webmerge::Optimize::PNG::BEGIN@29 |
30 | |||||
31 | ################################################################################################### | ||||
32 | |||||
33 | # load webmberge module variables to hook into | ||||
34 | 2 | 1.57ms | 2 | 1.47ms | # spent 762µs (54+708) within RTP::Webmerge::Optimize::PNG::BEGIN@34 which was called:
# once (54µs+708µs) by main::BEGIN@49 at line 34 # spent 762µs making 1 call to RTP::Webmerge::Optimize::PNG::BEGIN@34
# spent 708µs making 1 call to Exporter::import |
35 | |||||
36 | ################################################################################################### | ||||
37 | |||||
38 | # push to initers | ||||
39 | # return for getOpts | ||||
40 | push @initers, sub | ||||
41 | # spent 22µs within RTP::Webmerge::Optimize::PNG::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/Optimize/PNG.pm:52] which was called:
# once (22µs+0s) by RTP::Webmerge::initConfig at line 263 of webmerge/scripts/modules/RTP/Webmerge.pm | ||||
42 | |||||
43 | # get config | ||||
44 | 1 | 3µs | my ($config) = @_; | ||
45 | |||||
46 | # create config variable to be available | ||||
47 | 1 | 4µs | $config->{'optimize-png'} = undef; | ||
48 | |||||
49 | # connect each tmpl variable with the getOpt option | ||||
50 | 1 | 27µs | return ('optimize-png|png!', \ $config->{'cmd_optimize-png'}); | ||
51 | |||||
52 | 1 | 28µs | }; | ||
53 | # EO push initer | ||||
54 | |||||
55 | ################################################################################################### | ||||
56 | |||||
57 | # push to checkers | ||||
58 | push @checkers, sub | ||||
59 | # spent 20µs within RTP::Webmerge::Optimize::PNG::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/Optimize/PNG.pm:80] which was called:
# once (20µs+0s) by RTP::Webmerge::checkConfig at line 290 of webmerge/scripts/modules/RTP/Webmerge.pm | ||||
60 | |||||
61 | # get config | ||||
62 | 1 | 3µs | my ($config) = @_; | ||
63 | |||||
64 | # disable if not optimizing | ||||
65 | 1 | 4µs | unless ($config->{'optimize'}) | ||
66 | { $config->{'optimize-png'} = 0; } | ||||
67 | |||||
68 | # do nothing if feature is disabled | ||||
69 | 1 | 26µs | return unless $config->{'optimize-png'}; | ||
70 | |||||
71 | # get the optimization level (1 to 4/6) | ||||
72 | my $lvl = '-' . range($config->{'level'}, 1, 5, 4); | ||||
73 | my $olvl = '-o' . range($config->{'level'}, 0.5, 6.5, 9); | ||||
74 | |||||
75 | # define executables to optimize pngs | ||||
76 | $executables{'optipng'} = ['pngopt', "$olvl --quiet \"%s\"", 1] if $ENV{'WEBMERGE_OPTIPNG'}; | ||||
77 | $executables{'advpng'} = ['pngopt', "-z $lvl --quiet \"%s\"", 2] if $ENV{'WEBMERGE_ADVPNG'}; | ||||
78 | $executables{'advdef[png]'} = ['pngopt', "-z $lvl --quiet \"%s\"", 2] if $ENV{'WEBMERGE_ADVDEF'}; | ||||
79 | |||||
80 | 1 | 22µs | }; | ||
81 | # EO push checker | ||||
82 | |||||
83 | ################################################################################################### | ||||
84 | |||||
85 | # now create a new file optimizer subroutine and hook it into our optimizers | ||||
86 | 1 | 32µs | 1 | 62µs | $RTP::Webmerge::Optimize::optimizer{'png'} = RTP::Webmerge::Optimize::optimize('png'); # spent 62µs making 1 call to RTP::Webmerge::Optimize::optimize |
87 | |||||
88 | ################################################################################################### | ||||
89 | ################################################################################################### | ||||
90 | 1 | 50µs | 1; |