← 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/usr/lib64/perl5/vendor_perl/5.16.0/IO/AtomicFile.pm
StatementsExecuted 828 statements in 27.6ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
391113.4ms13.4msIO::AtomicFile::::CORE:renameIO::AtomicFile::CORE:rename (opcode)
1114.44ms44.2msIO::AtomicFile::::BEGIN@9IO::AtomicFile::BEGIN@9
39113.60ms23.3msIO::AtomicFile::::closeIO::AtomicFile::close
39112.83ms22.1msIO::AtomicFile::::openIO::AtomicFile::open
39112.51ms8.67msIO::AtomicFile::::newIO::AtomicFile::new
39111.06ms26.3msIO::AtomicFile::::DESTROYIO::AtomicFile::DESTROY
3911767µs767µsIO::AtomicFile::::_closedIO::AtomicFile::_closed
11196µs193µsIO::AtomicFile::::BEGIN@6IO::AtomicFile::BEGIN@6
11160µs284µsIO::AtomicFile::::BEGIN@17IO::AtomicFile::BEGIN@17
0000s0sIO::AtomicFile::::deleteIO::AtomicFile::delete
0000s0sIO::AtomicFile::::detachIO::AtomicFile::detach
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package IO::AtomicFile;
2
3### DOCUMENTATION AT BOTTOM OF FILE
4
5# Be strict:
62164µs2290µs
# spent 193µs (96+97) within IO::AtomicFile::BEGIN@6 which was called: # once (96µs+97µs) by base::import at line 6
use strict;
# spent 193µs making 1 call to IO::AtomicFile::BEGIN@6 # spent 97µs making 1 call to strict::import
7
8# External modules:
92812µs245.2ms
# spent 44.2ms (4.44+39.7) within IO::AtomicFile::BEGIN@9 which was called: # once (4.44ms+39.7ms) by base::import at line 9
use IO::File;
# spent 44.2ms making 1 call to IO::AtomicFile::BEGIN@9 # spent 988µs making 1 call to Exporter::import
10
11
12#------------------------------
13#
14# GLOBALS...
15#
16#------------------------------
1722.10ms2508µs
# spent 284µs (60+224) within IO::AtomicFile::BEGIN@17 which was called: # once (60µs+224µs) by base::import at line 17
use vars qw($VERSION @ISA);
# spent 284µs making 1 call to IO::AtomicFile::BEGIN@17 # spent 224µs making 1 call to vars::import
18
19# The package version, both in 1.23 style *and* usable by MakeMaker:
2014µs$VERSION = "2.110";
21
22# Inheritance:
23146µs@ISA = qw(IO::File);
24
25
26#------------------------------
27# new ARGS...
28#------------------------------
29# Class method, constructor.
30# Any arguments are sent to open().
31#
32
# spent 8.67ms (2.51+6.15) within IO::AtomicFile::new which was called 39 times, avg 222µs/call: # 39 times (2.51ms+6.15ms) by RTP::IO::AtomicFile::new at line 29 of webmerge/scripts/modules/RTP/IO/AtomicFile.pm, avg 222µs/call
sub new {
3339130µs my $class = shift;
34391.32ms396.15ms my $self = $class->SUPER::new();
# spent 6.15ms making 39 calls to IO::File::new, avg 158µs/call
3539436µs ${*$self}{'io_atomicfile_suffix'} = '';
363969µs $self->open(@_) if @_;
3739778µs $self;
38}
39
40#------------------------------
41# DESTROY
42#------------------------------
43# Destructor.
44#
45
# spent 26.3ms (1.06+25.3) within IO::AtomicFile::DESTROY which was called 39 times, avg 675µs/call: # 39 times (1.06ms+25.3ms) by RTP::IO::AtomicFile::DESTROY at line 43 of webmerge/scripts/modules/RTP/IO/AtomicFile.pm, avg 675µs/call
sub DESTROY {
4639976µs3925.3ms shift->close(1); ### like close, but raises fatal exception on failure
# spent 25.3ms making 39 calls to RTP::IO::AtomicFile::close, avg 648µs/call
47}
48
49#------------------------------
50# open PATH, MODE
51#------------------------------
52# Class/instance method.
53#
54
# spent 22.1ms (2.83+19.2) within IO::AtomicFile::open which was called 39 times, avg 566µs/call: # 39 times (2.83ms+19.2ms) by RTP::IO::AtomicFile::open at line 56 of webmerge/scripts/modules/RTP/IO/AtomicFile.pm, avg 566µs/call
sub open {
5539263µs my ($self, $path, $mode) = @_;
5639134µs ref($self) or $self = $self->new; ### now we have an instance!
57
58 ### Create tmp path, and remember this info:
5939486µs my $temp = "${path}..TMP" . ${*$self}{'io_atomicfile_suffix'};
6039240µs ${*$self}{'io_atomicfile_temp'} = $temp;
6139175µs ${*$self}{'io_atomicfile_path'} = $path;
62
63 ### Open the file! Returns filehandle on success, for use as a constructor:
64391.46ms3919.2ms $self->SUPER::open($temp, $mode) ? $self : undef;
# spent 19.2ms making 39 calls to IO::File::open, avg 493µs/call
65}
66
67#------------------------------
68# _closed [YESNO]
69#------------------------------
70# Instance method, private.
71# Are we already closed? Argument sets new value, returns previous one.
72#
73
# spent 767µs within IO::AtomicFile::_closed which was called 39 times, avg 20µs/call: # 39 times (767µs+0s) by RTP::IO::AtomicFile::_closed at line 70 of webmerge/scripts/modules/RTP/IO/AtomicFile.pm, avg 20µs/call
sub _closed {
743984µs my $self = shift;
7539119µs my $oldval = ${*$self}{'io_atomicfile_closed'};
7639176µs ${*$self}{'io_atomicfile_closed'} = shift if @_;
7739687µs $oldval;
78}
79
80#------------------------------
81# close
82#------------------------------
83# Instance method.
84# Close the handle, and rename the temp file to its final name.
85#
86
# spent 23.3ms (3.60+19.7) within IO::AtomicFile::close which was called 39 times, avg 598µs/call: # 39 times (3.60ms+19.7ms) by RTP::IO::AtomicFile::close at line 84 of webmerge/scripts/modules/RTP/IO/AtomicFile.pm, avg 598µs/call
sub close {
8739150µs my ($self, $die) = @_;
8839608µs392.63ms unless ($self->_closed(1)) { ### sentinel...
# spent 2.63ms making 39 calls to RTP::IO::AtomicFile::_closed, avg 67µs/call
89391.00ms393.74ms $self->SUPER::close();
# spent 3.74ms making 39 calls to IO::Handle::close, avg 96µs/call
90 rename(${*$self}{'io_atomicfile_temp'},
913914.5ms3913.4ms ${*$self}{'io_atomicfile_path'})
# spent 13.4ms making 39 calls to IO::AtomicFile::CORE:rename, avg 343µs/call
92 or ($die ? die "close atomic file: $!\n" : return undef);
93 }
9439653µs 1;
95}
96
97#------------------------------
98# delete
99#------------------------------
100# Instance method.
101# Close the handle, and delete the temp file.
102#
103sub delete {
104 my $self = shift;
105 unless ($self->_closed(1)) { ### sentinel...
106 $self->SUPER::close();
107 return unlink(${*$self}{'io_atomicfile_temp'});
108 }
109 1;
110}
111
112#------------------------------
113# detach
114#------------------------------
115# Instance method.
116# Close the handle, but DO NOT delete the temp file.
117#
118sub detach {
119 my $self = shift;
120 $self->SUPER::close() unless ($self->_closed(1));
121 1;
122}
123
124#------------------------------
125118µs1;
126__END__
 
# spent 13.4ms within IO::AtomicFile::CORE:rename which was called 39 times, avg 343µs/call: # 39 times (13.4ms+0s) by IO::AtomicFile::close at line 91, avg 343µs/call
sub IO::AtomicFile::CORE:rename; # opcode