Filename | /home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/Fingerprint.pm |
Statements | Executed 404 statements in 577ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
92 | 6 | 2 | 12.7ms | 573ms | md5sum | RTP::Webmerge::Fingerprint::
2 | 1 | 1 | 96µs | 96µs | fingerprint | RTP::Webmerge::Fingerprint::
1 | 1 | 1 | 89µs | 343µs | BEGIN@8 | RTP::Webmerge::Fingerprint::
1 | 1 | 1 | 67µs | 632µs | BEGIN@26 | RTP::Webmerge::Fingerprint::
1 | 1 | 1 | 66µs | 66µs | __ANON__[:52] | RTP::Webmerge::Fingerprint::
1 | 1 | 1 | 58µs | 262µs | BEGIN@61 | RTP::Webmerge::Fingerprint::
1 | 1 | 1 | 54µs | 282µs | BEGIN@64 | RTP::Webmerge::Fingerprint::
1 | 1 | 1 | 54µs | 87µs | BEGIN@10 | RTP::Webmerge::Fingerprint::
1 | 1 | 1 | 54µs | 54µs | BEGIN@18.14 | RTP::Webmerge::Fingerprint::
1 | 1 | 1 | 52µs | 141µs | BEGIN@9 | RTP::Webmerge::Fingerprint::
1 | 1 | 1 | 30µs | 30µs | BEGIN@58 | RTP::Webmerge::Fingerprint::
1 | 1 | 1 | 28µs | 28µs | BEGIN@21 | RTP::Webmerge::Fingerprint::
1 | 1 | 1 | 22µs | 22µs | BEGIN@18 | RTP::Webmerge::Fingerprint::
1 | 1 | 1 | 22µs | 22µs | BEGIN@15 | RTP::Webmerge::Fingerprint::
0 | 0 | 0 | 0s | 0s | md5short | RTP::Webmerge::Fingerprint::
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::Fingerprint; | ||||
6 | ################################################################################################### | ||||
7 | |||||
8 | 2 | 164µs | 2 | 596µs | # spent 343µs (89+254) within RTP::Webmerge::Fingerprint::BEGIN@8 which was called:
# once (89µs+254µs) by RTP::Webmerge::Merge::BEGIN@37 at line 8 # spent 343µs making 1 call to RTP::Webmerge::Fingerprint::BEGIN@8
# spent 254µs making 1 call to Exporter::import |
9 | 2 | 145µs | 2 | 230µs | # spent 141µs (52+89) within RTP::Webmerge::Fingerprint::BEGIN@9 which was called:
# once (52µs+89µs) by RTP::Webmerge::Merge::BEGIN@37 at line 9 # spent 141µs making 1 call to RTP::Webmerge::Fingerprint::BEGIN@9
# spent 89µs making 1 call to strict::import |
10 | 2 | 193µs | 2 | 119µs | # spent 87µs (54+32) within RTP::Webmerge::Fingerprint::BEGIN@10 which was called:
# once (54µs+32µs) by RTP::Webmerge::Merge::BEGIN@37 at line 10 # spent 87µs making 1 call to RTP::Webmerge::Fingerprint::BEGIN@10
# spent 32µs making 1 call to warnings::import |
11 | |||||
12 | ################################################################################################### | ||||
13 | |||||
14 | # define our version string | ||||
15 | 1 | 146µs | 1 | 22µs | # spent 22µs within RTP::Webmerge::Fingerprint::BEGIN@15 which was called:
# once (22µs+0s) by RTP::Webmerge::Merge::BEGIN@37 at line 15 # spent 22µs making 1 call to RTP::Webmerge::Fingerprint::BEGIN@15 |
16 | |||||
17 | # load exporter and inherit from it | ||||
18 | 3 | 376µs | 2 | 76µs | BEGIN { use Exporter qw(); our @ISA = qw(Exporter) } # spent 54µs making 1 call to RTP::Webmerge::Fingerprint::BEGIN@18.14
# spent 22µs making 1 call to RTP::Webmerge::Fingerprint::BEGIN@18 |
19 | |||||
20 | # define our functions to be exported | ||||
21 | 1 | 201µs | 1 | 28µs | # spent 28µs within RTP::Webmerge::Fingerprint::BEGIN@21 which was called:
# once (28µs+0s) by RTP::Webmerge::Merge::BEGIN@37 at line 21 # spent 28µs making 1 call to RTP::Webmerge::Fingerprint::BEGIN@21 |
22 | |||||
23 | ################################################################################################### | ||||
24 | |||||
25 | # import registered processors | ||||
26 | 2 | 731µs | 2 | 1.20ms | # spent 632µs (67+564) within RTP::Webmerge::Fingerprint::BEGIN@26 which was called:
# once (67µs+564µs) by RTP::Webmerge::Merge::BEGIN@37 at line 26 # spent 632µs making 1 call to RTP::Webmerge::Fingerprint::BEGIN@26
# spent 564µs making 1 call to Exporter::import |
27 | |||||
28 | # register initializer | ||||
29 | push @initers, sub | ||||
30 | # spent 66µs within RTP::Webmerge::Fingerprint::__ANON__[/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/Fingerprint.pm:52] which was called:
# once (66µs+0s) by RTP::Webmerge::initConfig at line 263 of webmerge/scripts/modules/RTP/Webmerge.pm | ||||
31 | |||||
32 | # getopt config | ||||
33 | 1 | 2µs | my (@options); | ||
34 | |||||
35 | # get input variables | ||||
36 | 1 | 3µs | my ($config) = @_; | ||
37 | |||||
38 | # file fingerprints | ||||
39 | 1 | 4µs | $config->{'fingerprint'} = 0; | ||
40 | # technique used by context | ||||
41 | 1 | 4µs | $config->{'fingerprint-dev'} = 'query'; | ||
42 | 1 | 3µs | $config->{'fingerprint-live'} = 'query'; | ||
43 | |||||
44 | # collect all command line options for getopt call | ||||
45 | 1 | 11µs | push(@options, 'fingerprint|fp!', \ $config->{'cmd_fingerprint'} ); | ||
46 | 1 | 7µs | push(@options, 'fingerprint-dev|fp-dev=s', \ $config->{'cmd_fingerprint-dev'} ); | ||
47 | 1 | 9µs | push(@options, 'fingerprint-live|fp-live=s', \ $config->{'cmd_fingerprint-live'} ); | ||
48 | |||||
49 | # return additional get options attribute | ||||
50 | 1 | 51µs | return @options; | ||
51 | |||||
52 | 1 | 17µs | }; | ||
53 | # EO plugin initer | ||||
54 | |||||
55 | ################################################################################################### | ||||
56 | |||||
57 | # use md5 digest for checksum | ||||
58 | 2 | 158µs | 1 | 30µs | # spent 30µs within RTP::Webmerge::Fingerprint::BEGIN@58 which was called:
# once (30µs+0s) by RTP::Webmerge::Merge::BEGIN@37 at line 58 # spent 30µs making 1 call to RTP::Webmerge::Fingerprint::BEGIN@58 |
59 | |||||
60 | # use core modules for path handling | ||||
61 | 2 | 189µs | 2 | 467µs | # spent 262µs (58+204) within RTP::Webmerge::Fingerprint::BEGIN@61 which was called:
# once (58µs+204µs) by RTP::Webmerge::Merge::BEGIN@37 at line 61 # spent 262µs making 1 call to RTP::Webmerge::Fingerprint::BEGIN@61
# spent 204µs making 1 call to Exporter::import |
62 | |||||
63 | # load core webmerge io functions | ||||
64 | 2 | 1.32ms | 2 | 509µs | # spent 282µs (54+227) within RTP::Webmerge::Fingerprint::BEGIN@64 which was called:
# once (54µs+227µs) by RTP::Webmerge::Merge::BEGIN@37 at line 64 # spent 282µs making 1 call to RTP::Webmerge::Fingerprint::BEGIN@64
# spent 227µs making 1 call to Exporter::import |
65 | |||||
66 | ################################################################################################### | ||||
67 | |||||
68 | sub md5sum | ||||
69 | # spent 573ms (12.7+561) within RTP::Webmerge::Fingerprint::md5sum which was called 92 times, avg 6.23ms/call:
# 18 times (2.39ms+512ms) by RTP::Webmerge::Merge::writer at line 135 of webmerge/scripts/modules/RTP/Webmerge/Merge.pm, avg 28.6ms/call
# 18 times (2.66ms+30.7ms) by RTP::Webmerge::Checksum::crcCheckEntry at line 83 of webmerge/scripts/modules/RTP/Webmerge/Checksum.pm, avg 1.85ms/call
# 18 times (2.42ms+13.7ms) by RTP::Webmerge::Checksum::crcCheckEntry at line 111 of webmerge/scripts/modules/RTP/Webmerge/Checksum.pm, avg 893µs/call
# 18 times (2.58ms+1.13ms) by RTP::Webmerge::Merge::writer at line 129 of webmerge/scripts/modules/RTP/Webmerge/Merge.pm, avg 206µs/call
# 18 times (2.24ms+1.34ms) by RTP::Webmerge::Checksum::crcCheckEntry at line 126 of webmerge/scripts/modules/RTP/Webmerge/Checksum.pm, avg 198µs/call
# 2 times (380µs+1.60ms) by RTP::Webmerge::Merge::collect at line 239 of webmerge/scripts/modules/RTP/Webmerge/Merge.pm, avg 991µs/call | ||||
70 | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | ||||
71 | 92 | 433µs | my ($data) = @_; | ||
72 | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | ||||
73 | 92 | 5.54ms | 92 | 2.29ms | my $md5 = Digest::MD5->new; # spent 2.29ms making 92 calls to Digest::MD5::new, avg 25µs/call |
74 | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | ||||
75 | 92 | 558ms | 92 | 556ms | $md5->add(${$data}); # spent 556ms making 92 calls to Digest::MD5::add, avg 6.04ms/call |
76 | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | ||||
77 | 92 | 9.42ms | 92 | 1.50ms | return uc($md5->hexdigest); # spent 1.50ms making 92 calls to Digest::MD5::hexdigest, avg 16µs/call |
78 | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | ||||
79 | } | ||||
80 | |||||
81 | sub md5short | ||||
82 | { | ||||
83 | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | ||||
84 | return substr(md5sum($_[0]), 0, 12); # 32 | ||||
85 | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | ||||
86 | } | ||||
87 | |||||
88 | ################################################################################################### | ||||
89 | |||||
90 | sub fingerprint | ||||
91 | # spent 96µs within RTP::Webmerge::Fingerprint::fingerprint which was called 2 times, avg 48µs/call:
# 2 times (96µs+0s) by RTP::Webmerge::Include::CSS::includeCSS at line 50 of webmerge/scripts/modules/RTP/Webmerge/Include/CSS.pm, avg 48µs/call | ||||
92 | |||||
93 | # get passed variables | ||||
94 | 2 | 15µs | my ($config, $context, $path, $data) = @_; | ||
95 | |||||
96 | # get the fingerprint config option if not explicitly given | ||||
97 | 2 | 15µs | my $technique = $config->{join('-', 'fingerprint', $context)}; | ||
98 | |||||
99 | # do not add a fingerprint at all if feature is disabled | ||||
100 | 2 | 61µs | return $path unless $config->{'fingerprint'} && $technique; | ||
101 | |||||
102 | # read the file from the disk if a data reference is not passed | ||||
103 | $data = readfile $path, $config->{'atomic'} unless (defined $data); | ||||
104 | |||||
105 | # simply append the fingerprint as a unique query string | ||||
106 | return join('?', $path, md5short($data)) if $technique eq 'q'; | ||||
107 | |||||
108 | # insert the fingerprint as a (virtual) last directory to the given path | ||||
109 | # this will not work out of the box - you'll need to add some rewrite directives | ||||
110 | return join('/', dirname($path), md5short($data), basename($path)) if $technique eq 'd'; | ||||
111 | return join('/', dirname($path), md5short($data) . '-' . basename($path)) if $technique eq 'f'; | ||||
112 | |||||
113 | # exit and give an error message if technique is not known | ||||
114 | die 'fingerprint technique <', $technique, '> not implemented', "\n"; | ||||
115 | |||||
116 | # at least return something | ||||
117 | return $path; | ||||
118 | |||||
119 | } | ||||
120 | |||||
121 | ################################################################################################### | ||||
122 | ################################################################################################### | ||||
123 | 1 | 15µs | 1; |