Filename | /home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/Prepare.pm |
Statements | Executed 44 statements in 3.82ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
2 | 1 | 1 | 463µs | 3.76ms | prepare | RTP::Webmerge::Prepare::
1 | 1 | 1 | 132µs | 348µs | BEGIN@26 | RTP::Webmerge::Prepare::
1 | 1 | 1 | 92µs | 346µs | BEGIN@8 | RTP::Webmerge::Prepare::
4 | 1 | 1 | 64µs | 64µs | CORE:ftdir (opcode) | RTP::Webmerge::Prepare::
1 | 1 | 1 | 63µs | 346µs | BEGIN@28 | RTP::Webmerge::Prepare::
1 | 1 | 1 | 58µs | 91µs | BEGIN@10 | RTP::Webmerge::Prepare::
1 | 1 | 1 | 56µs | 56µs | BEGIN@18.21 | RTP::Webmerge::Prepare::
1 | 1 | 1 | 53µs | 140µs | BEGIN@9 | RTP::Webmerge::Prepare::
1 | 1 | 1 | 27µs | 27µs | BEGIN@21 | RTP::Webmerge::Prepare::
1 | 1 | 1 | 25µs | 25µs | BEGIN@18 | RTP::Webmerge::Prepare::
1 | 1 | 1 | 23µs | 23µs | BEGIN@15 | RTP::Webmerge::Prepare::
4 | 2 | 1 | 12µs | 12µs | CORE:match (opcode) | RTP::Webmerge::Prepare::
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::Prepare; | ||||
6 | ################################################################################################### | ||||
7 | |||||
8 | 2 | 164µs | 2 | 600µs | # spent 346µs (92+254) within RTP::Webmerge::Prepare::BEGIN@8 which was called:
# once (92µs+254µs) by main::BEGIN@32 at line 8 # spent 346µs making 1 call to RTP::Webmerge::Prepare::BEGIN@8
# spent 254µs making 1 call to Exporter::import |
9 | 2 | 146µs | 2 | 226µs | # spent 140µs (53+87) within RTP::Webmerge::Prepare::BEGIN@9 which was called:
# once (53µs+87µs) by main::BEGIN@32 at line 9 # spent 140µs making 1 call to RTP::Webmerge::Prepare::BEGIN@9
# spent 87µs making 1 call to strict::import |
10 | 2 | 194µs | 2 | 124µs | # spent 91µs (58+33) within RTP::Webmerge::Prepare::BEGIN@10 which was called:
# once (58µs+33µs) by main::BEGIN@32 at line 10 # spent 91µs making 1 call to RTP::Webmerge::Prepare::BEGIN@10
# spent 33µs making 1 call to warnings::import |
11 | |||||
12 | ################################################################################################### | ||||
13 | |||||
14 | # define our version string | ||||
15 | 1 | 183µs | 1 | 23µs | # spent 23µs within RTP::Webmerge::Prepare::BEGIN@15 which was called:
# once (23µs+0s) by main::BEGIN@32 at line 15 # spent 23µs making 1 call to RTP::Webmerge::Prepare::BEGIN@15 |
16 | |||||
17 | # load exporter and inherit from it | ||||
18 | 3 | 370µs | 2 | 82µs | BEGIN { use Exporter qw(); our @ISA = qw(Exporter) } # spent 56µs making 1 call to RTP::Webmerge::Prepare::BEGIN@18.21
# spent 25µs making 1 call to RTP::Webmerge::Prepare::BEGIN@18 |
19 | |||||
20 | # define our functions to be exported | ||||
21 | 1 | 212µs | 1 | 27µs | # spent 27µs within RTP::Webmerge::Prepare::BEGIN@21 which was called:
# once (27µs+0s) by main::BEGIN@32 at line 21 # spent 27µs making 1 call to RTP::Webmerge::Prepare::BEGIN@21 |
22 | |||||
23 | ################################################################################################### | ||||
24 | |||||
25 | # load core io module | ||||
26 | 2 | 202µs | 2 | 565µs | # spent 348µs (132+216) within RTP::Webmerge::Prepare::BEGIN@26 which was called:
# once (132µs+216µs) by main::BEGIN@32 at line 26 # spent 348µs making 1 call to RTP::Webmerge::Prepare::BEGIN@26
# spent 216µs making 1 call to Exporter::import |
27 | # load core path module | ||||
28 | 2 | 1.84ms | 2 | 629µs | # spent 346µs (63+283) within RTP::Webmerge::Prepare::BEGIN@28 which was called:
# once (63µs+283µs) by main::BEGIN@32 at line 28 # spent 346µs making 1 call to RTP::Webmerge::Prepare::BEGIN@28
# spent 283µs making 1 call to Exporter::import |
29 | |||||
30 | ################################################################################################### | ||||
31 | |||||
32 | # prepare various stuff | ||||
33 | # only mkdir is implemented | ||||
34 | sub prepare | ||||
35 | # spent 3.76ms (463µs+3.29) within RTP::Webmerge::Prepare::prepare which was called 2 times, avg 1.88ms/call:
# 2 times (463µs+3.29ms) by main::RUNTIME at line 642 of webmerge/scripts/webmerge.pl, avg 1.88ms/call | ||||
36 | |||||
37 | # get input variables | ||||
38 | 2 | 8µs | my ($config, $prepare) = @_; | ||
39 | |||||
40 | # should we commit filesystem changes? | ||||
41 | 2 | 8µs | my $commit = $prepare->{'commit'} || 0; | ||
42 | |||||
43 | # commit all changes to the filesystem if configured | ||||
44 | 2 | 52µs | 2 | 8µs | $config->{'atomic'} = {} if $commit =~ m/^\s*(?:bo|be)/i; # spent 8µs making 2 calls to RTP::Webmerge::Prepare::CORE:match, avg 4µs/call |
45 | |||||
46 | # do not process if disabled attribute is given and set to true | ||||
47 | 2 | 23µs | unless ($prepare->{'disabled'} && lc $prepare->{'disabled'} eq 'true') | ||
48 | { | ||||
49 | |||||
50 | # change directory (restore previous state after this block) | ||||
51 | 2 | 62µs | 2 | 34µs | my $dir = RTP::Webmerge::Path->chdir($prepare->{'chdir'}); # spent 34µs making 2 calls to RTP::Webmerge::Path::chdir, avg 17µs/call |
52 | |||||
53 | # process all directories to create | ||||
54 | 2 | 31µs | foreach my $mkdir (@{$prepare->{'mkdir'} || []}) | ||
55 | { | ||||
56 | |||||
57 | # skip this if entry has been disabled | ||||
58 | 4 | 26µs | next if ($prepare->{'disabled'} && lc $prepare->{'disabled'} eq 'true'); | ||
59 | |||||
60 | # resolve the path to be created | ||||
61 | 4 | 59µs | 4 | 3.18ms | my $path = check_path $mkdir->{'path'}; # spent 3.18ms making 4 calls to RTP::Webmerge::Path::check_path, avg 796µs/call |
62 | |||||
63 | # allready exists? | ||||
64 | 4 | 136µs | 4 | 64µs | next if -d $path; # spent 64µs making 4 calls to RTP::Webmerge::Prepare::CORE:ftdir, avg 16µs/call |
65 | |||||
66 | # try to create the given directory and give status messages (abort on error) | ||||
67 | if (mkdir $path) { print "created directory ", exportURI($path), "\n"; } | ||||
68 | else { die "could not create directory ", exportURI($path), ": ", $!; } | ||||
69 | |||||
70 | } | ||||
71 | # EO each mkdir | ||||
72 | |||||
73 | # process all directories to create | ||||
74 | 2 | 22µs | foreach my $copy (@{$prepare->{'copy'} || []}) | ||
75 | { | ||||
76 | |||||
77 | # get path for source and destination | ||||
78 | my $src = check_path $copy->{'src'}; | ||||
79 | my $dst = check_path $copy->{'dst'}; | ||||
80 | |||||
81 | print "copying ", exportURI($src), "\n"; | ||||
82 | |||||
83 | # check if we do not copy a text file | ||||
84 | my $bin = ($copy->{'text'} || '') ne "true"; | ||||
85 | |||||
86 | # copy the file binary if text is not set to true | ||||
87 | my $data = readfile($src, $config->{'atomic'}, $bin); | ||||
88 | writefile($dst, $data, $config->{'atomic'}, $bin); | ||||
89 | |||||
90 | print " copied to ", exportURI($dst), "\n"; | ||||
91 | |||||
92 | } | ||||
93 | # EO each copy | ||||
94 | |||||
95 | } | ||||
96 | # EO unless disabled | ||||
97 | |||||
98 | # commit all changes to the filesystem if configured | ||||
99 | 2 | 71µs | 2 | 5µs | $config->{'atomic'} = {} if $commit =~ m/^\s*(?:bo|af)/i; # spent 5µs making 2 calls to RTP::Webmerge::Prepare::CORE:match, avg 2µs/call |
100 | |||||
101 | } | ||||
102 | # EO sub prepare | ||||
103 | |||||
104 | ################################################################################################### | ||||
105 | ################################################################################################### | ||||
106 | 1 | 15µs | 1; | ||
# spent 64µs within RTP::Webmerge::Prepare::CORE:ftdir which was called 4 times, avg 16µs/call:
# 4 times (64µs+0s) by RTP::Webmerge::Prepare::prepare at line 64, avg 16µs/call | |||||
sub RTP::Webmerge::Prepare::CORE:match; # opcode |