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

Filename/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/Fingerprint.pm
StatementsExecuted 404 statements in 577ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
926212.7ms573msRTP::Webmerge::Fingerprint::::md5sumRTP::Webmerge::Fingerprint::md5sum
21196µs96µsRTP::Webmerge::Fingerprint::::fingerprintRTP::Webmerge::Fingerprint::fingerprint
11189µs343µsRTP::Webmerge::Fingerprint::::BEGIN@8RTP::Webmerge::Fingerprint::BEGIN@8
11167µs632µsRTP::Webmerge::Fingerprint::::BEGIN@26RTP::Webmerge::Fingerprint::BEGIN@26
11166µs66µsRTP::Webmerge::Fingerprint::::__ANON__[:52]RTP::Webmerge::Fingerprint::__ANON__[:52]
11158µs262µsRTP::Webmerge::Fingerprint::::BEGIN@61RTP::Webmerge::Fingerprint::BEGIN@61
11154µs282µsRTP::Webmerge::Fingerprint::::BEGIN@64RTP::Webmerge::Fingerprint::BEGIN@64
11154µs87µsRTP::Webmerge::Fingerprint::::BEGIN@10RTP::Webmerge::Fingerprint::BEGIN@10
11154µs54µsRTP::Webmerge::Fingerprint::::BEGIN@18.14RTP::Webmerge::Fingerprint::BEGIN@18.14
11152µs141µsRTP::Webmerge::Fingerprint::::BEGIN@9RTP::Webmerge::Fingerprint::BEGIN@9
11130µs30µsRTP::Webmerge::Fingerprint::::BEGIN@58RTP::Webmerge::Fingerprint::BEGIN@58
11128µs28µsRTP::Webmerge::Fingerprint::::BEGIN@21RTP::Webmerge::Fingerprint::BEGIN@21
11122µs22µsRTP::Webmerge::Fingerprint::::BEGIN@18RTP::Webmerge::Fingerprint::BEGIN@18
11122µs22µsRTP::Webmerge::Fingerprint::::BEGIN@15RTP::Webmerge::Fingerprint::BEGIN@15
0000s0sRTP::Webmerge::Fingerprint::::md5shortRTP::Webmerge::Fingerprint::md5short
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::Fingerprint;
6###################################################################################################
7
82164µs2596µ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
use Carp;
# spent 343µs making 1 call to RTP::Webmerge::Fingerprint::BEGIN@8 # spent 254µs making 1 call to Exporter::import
92145µs2230µ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
use strict;
# spent 141µs making 1 call to RTP::Webmerge::Fingerprint::BEGIN@9 # spent 89µs making 1 call to strict::import
102193µs2119µ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
use warnings;
# 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
151146µs122µ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
BEGIN { $RTP::Webmerge::Fingerprint::VERSION = "0.70" }
# spent 22µs making 1 call to RTP::Webmerge::Fingerprint::BEGIN@15
16
17# load exporter and inherit from it
183376µs276µs
# spent 54µs within RTP::Webmerge::Fingerprint::BEGIN@18.14 which was called: # once (54µs+0s) by RTP::Webmerge::Merge::BEGIN@37 at line 18 # spent 22µs within RTP::Webmerge::Fingerprint::BEGIN@18 which was called: # once (22µs+0s) by RTP::Webmerge::Merge::BEGIN@37 at line 18
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
211201µs128µ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
BEGIN { our @EXPORT = qw(md5sum md5short fingerprint); }
# spent 28µs making 1 call to RTP::Webmerge::Fingerprint::BEGIN@21
22
23###################################################################################################
24
25# import registered processors
262731µs21.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
use RTP::Webmerge qw(@initers);
# 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
29push @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
3312µs my (@options);
34
35 # get input variables
3613µs my ($config) = @_;
37
38 # file fingerprints
3914µs $config->{'fingerprint'} = 0;
40 # technique used by context
4114µs $config->{'fingerprint-dev'} = 'query';
4213µs $config->{'fingerprint-live'} = 'query';
43
44 # collect all command line options for getopt call
45111µs push(@options, 'fingerprint|fp!', \ $config->{'cmd_fingerprint'} );
4617µs push(@options, 'fingerprint-dev|fp-dev=s', \ $config->{'cmd_fingerprint-dev'} );
4719µs push(@options, 'fingerprint-live|fp-live=s', \ $config->{'cmd_fingerprint-live'} );
48
49 # return additional get options attribute
50151µs return @options;
51
52117µs};
53# EO plugin initer
54
55###################################################################################################
56
57# use md5 digest for checksum
582158µs130µ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
use Digest::MD5 qw();
# spent 30µs making 1 call to RTP::Webmerge::Fingerprint::BEGIN@58
59
60# use core modules for path handling
612189µs2467µ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
use File::Basename qw(dirname basename);
# 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
6421.32ms2509µ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
use RTP::Webmerge::IO qw(readfile);
# spent 282µs making 1 call to RTP::Webmerge::Fingerprint::BEGIN@64 # spent 227µs making 1 call to Exporter::import
65
66###################################################################################################
67
68sub 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 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
7192433µs my ($data) = @_;
72 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
73925.54ms922.29ms my $md5 = Digest::MD5->new;
# spent 2.29ms making 92 calls to Digest::MD5::new, avg 25µs/call
74 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
7592558ms92556ms $md5->add(${$data});
# spent 556ms making 92 calls to Digest::MD5::add, avg 6.04ms/call
76 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
77929.42ms921.50ms return uc($md5->hexdigest);
# spent 1.50ms making 92 calls to Digest::MD5::hexdigest, avg 16µs/call
78 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
79}
80
81sub md5short
82{
83 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
84 return substr(md5sum($_[0]), 0, 12); # 32
85 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
86}
87
88###################################################################################################
89
90sub 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
94215µs my ($config, $context, $path, $data) = @_;
95
96 # get the fingerprint config option if not explicitly given
97215µs my $technique = $config->{join('-', 'fingerprint', $context)};
98
99 # do not add a fingerprint at all if feature is disabled
100261µ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###################################################################################################
123115µs1;