| Filename | /home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/IO/AtomicFile.pm |
| Statements | Executed 668 statements in 13.3ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 39 | 1 | 1 | 3.04ms | 11.7ms | RTP::IO::AtomicFile::new |
| 39 | 1 | 1 | 2.84ms | 29.2ms | RTP::IO::AtomicFile::DESTROY |
| 39 | 1 | 1 | 2.11ms | 24.2ms | RTP::IO::AtomicFile::open |
| 39 | 1 | 1 | 1.93ms | 25.3ms | RTP::IO::AtomicFile::close |
| 39 | 1 | 1 | 1.86ms | 2.63ms | RTP::IO::AtomicFile::_closed |
| 1 | 1 | 1 | 87µs | 189µs | RTP::IO::AtomicFile::BEGIN@11 |
| 1 | 1 | 1 | 57µs | 48.0ms | RTP::IO::AtomicFile::BEGIN@16 |
| 0 | 0 | 0 | 0s | 0s | RTP::IO::AtomicFile::delete |
| 0 | 0 | 0 | 0s | 0s | RTP::IO::AtomicFile::detach |
| 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::IO::AtomicFile; | ||||
| 6 | ################################################################################################### | ||||
| 7 | # fork safe implementation of IO::AtomicFile | ||||
| 8 | ################################################################################################### | ||||
| 9 | |||||
| 10 | # Be strict: | ||||
| 11 | 2 | 175µs | 2 | 290µs | # spent 189µs (87+102) within RTP::IO::AtomicFile::BEGIN@11 which was called:
# once (87µs+102µs) by RTP::Webmerge::Merge::BEGIN@44 at line 11 # spent 189µs making 1 call to RTP::IO::AtomicFile::BEGIN@11
# spent 102µs making 1 call to strict::import |
| 12 | |||||
| 13 | ################################################################################################### | ||||
| 14 | |||||
| 15 | # External modules: | ||||
| 16 | 2 | 1.81ms | 2 | 96.0ms | # spent 48.0ms (57µs+48.0) within RTP::IO::AtomicFile::BEGIN@16 which was called:
# once (57µs+48.0ms) by RTP::Webmerge::Merge::BEGIN@44 at line 16 # spent 48.0ms making 1 call to RTP::IO::AtomicFile::BEGIN@16
# spent 48.0ms making 1 call to base::import |
| 17 | |||||
| 18 | ################################################################################################### | ||||
| 19 | |||||
| 20 | #------------------------------ | ||||
| 21 | # new ARGS... | ||||
| 22 | #------------------------------ | ||||
| 23 | # Class method, constructor. | ||||
| 24 | # Any arguments are sent to open(). | ||||
| 25 | # | ||||
| 26 | sub new | ||||
| 27 | # spent 11.7ms (3.04+8.67) within RTP::IO::AtomicFile::new which was called 39 times, avg 300µs/call:
# 39 times (3.04ms+8.67ms) by RTP::Webmerge::IO::writefile at line 242 of webmerge/scripts/modules/RTP/Webmerge/IO.pm, avg 300µs/call | ||||
| 28 | 39 | 170µs | my $pckg = shift; | ||
| 29 | 39 | 1.57ms | 39 | 8.67ms | my $self = $pckg->SUPER::new(); # spent 8.67ms making 39 calls to IO::AtomicFile::new, avg 222µs/call |
| 30 | 39 | 441µs | ${*$self}{'io_atomicfile_pid'} = $$; | ||
| 31 | 39 | 75µs | $self->open(@_) if @_; | ||
| 32 | 39 | 609µs | $self; | ||
| 33 | } | ||||
| 34 | |||||
| 35 | #------------------------------ | ||||
| 36 | # DESTROY | ||||
| 37 | #------------------------------ | ||||
| 38 | # Destructor. | ||||
| 39 | # | ||||
| 40 | # spent 29.2ms (2.84+26.3) within RTP::IO::AtomicFile::DESTROY which was called 39 times, avg 748µs/call:
# 39 times (2.84ms+26.3ms) by main::RUNTIME at line 677 of webmerge/scripts/webmerge.pl, avg 748µs/call | ||||
| 41 | 39 | 135µs | my $self = shift; | ||
| 42 | 39 | 617µs | return if ${*$self}{'io_atomicfile_pid'} ne $$; | ||
| 43 | 39 | 1.94ms | 39 | 26.3ms | $self->SUPER::DESTROY(@_); # spent 26.3ms making 39 calls to IO::AtomicFile::DESTROY, avg 675µs/call |
| 44 | } | ||||
| 45 | |||||
| 46 | #------------------------------ | ||||
| 47 | # open PATH, MODE | ||||
| 48 | #------------------------------ | ||||
| 49 | # Class/instance method. | ||||
| 50 | # | ||||
| 51 | sub open | ||||
| 52 | # spent 24.2ms (2.11+22.1) within RTP::IO::AtomicFile::open which was called 39 times, avg 620µs/call:
# 39 times (2.11ms+22.1ms) by RTP::Webmerge::IO::writefile at line 247 of webmerge/scripts/modules/RTP/Webmerge/IO.pm, avg 620µs/call | ||||
| 53 | 39 | 97µs | my $self = shift; | ||
| 54 | 39 | 480µs | if (${*$self}{'io_atomicfile_pid'} ne $$) | ||
| 55 | { die "atomic file operation of foreign pid"; } | ||||
| 56 | 39 | 1.53ms | 39 | 22.1ms | $self->SUPER::open(@_); # spent 22.1ms making 39 calls to IO::AtomicFile::open, avg 566µs/call |
| 57 | } | ||||
| 58 | |||||
| 59 | #------------------------------ | ||||
| 60 | # _closed [YESNO] | ||||
| 61 | #------------------------------ | ||||
| 62 | # Instance method, private. | ||||
| 63 | # Are we already closed? Argument sets new value, returns previous one. | ||||
| 64 | # | ||||
| 65 | sub _closed | ||||
| 66 | # spent 2.63ms (1.86+767µs) within RTP::IO::AtomicFile::_closed which was called 39 times, avg 67µs/call:
# 39 times (1.86ms+767µs) by IO::AtomicFile::close at line 88 of IO/AtomicFile.pm, avg 67µs/call | ||||
| 67 | 39 | 81µs | my $self = shift; | ||
| 68 | 39 | 332µs | if (${*$self}{'io_atomicfile_pid'} ne $$) | ||
| 69 | { die "atomic file operation of foreign pid"; } | ||||
| 70 | 39 | 1.34ms | 39 | 767µs | $self->SUPER::_closed(@_); # spent 767µs making 39 calls to IO::AtomicFile::_closed, avg 20µs/call |
| 71 | } | ||||
| 72 | |||||
| 73 | #------------------------------ | ||||
| 74 | # close | ||||
| 75 | #------------------------------ | ||||
| 76 | # Instance method. | ||||
| 77 | # Close the handle, and rename the temp file to its final name. | ||||
| 78 | # | ||||
| 79 | sub close | ||||
| 80 | # spent 25.3ms (1.93+23.3) within RTP::IO::AtomicFile::close which was called 39 times, avg 648µs/call:
# 39 times (1.93ms+23.3ms) by IO::AtomicFile::DESTROY at line 46 of IO/AtomicFile.pm, avg 648µs/call | ||||
| 81 | 39 | 78µs | my $self = shift; | ||
| 82 | 39 | 357µs | if (${*$self}{'io_atomicfile_pid'} ne $$) | ||
| 83 | { die "atomic file operation of foreign pid"; } | ||||
| 84 | 39 | 1.40ms | 39 | 23.3ms | $self->SUPER::close(@_); # spent 23.3ms making 39 calls to IO::AtomicFile::close, avg 598µs/call |
| 85 | } | ||||
| 86 | |||||
| 87 | #------------------------------ | ||||
| 88 | # delete | ||||
| 89 | #------------------------------ | ||||
| 90 | # Instance method. | ||||
| 91 | # Close the handle, and delete the temp file. | ||||
| 92 | # | ||||
| 93 | sub delete | ||||
| 94 | { | ||||
| 95 | my $self = shift; | ||||
| 96 | if (${*$self}{'io_atomicfile_pid'} ne $$) | ||||
| 97 | { die "atomic file operation of foreign pid"; } | ||||
| 98 | $self->SUPER::delete(@_); | ||||
| 99 | } | ||||
| 100 | |||||
| 101 | #------------------------------ | ||||
| 102 | # detach | ||||
| 103 | #------------------------------ | ||||
| 104 | # Instance method. | ||||
| 105 | # Close the handle, but DO NOT delete the temp file. | ||||
| 106 | # | ||||
| 107 | sub detach | ||||
| 108 | { | ||||
| 109 | my $self = shift; | ||||
| 110 | if (${*$self}{'io_atomicfile_pid'} ne $$) | ||||
| 111 | { die "atomic file operation of foreign pid"; } | ||||
| 112 | $self->SUPER::detach(@_); | ||||
| 113 | } | ||||
| 114 | |||||
| 115 | ################################################################################################### | ||||
| 116 | ################################################################################################### | ||||
| 117 | 1 | 13µs | 1; |