← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/local/src/github.com/foswiki/core/bin/view
  Run on Sun Dec 4 17:17:59 2011
Reported on Sun Dec 4 17:26:34 2011

Filename/usr/local/src/github.com/foswiki/core/lib/CPAN/lib/CGI/Session/Driver/file.pm
StatementsExecuted 86 statements in 3.24ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111795µs973µsCGI::Session::Driver::file::::BEGIN@10CGI::Session::Driver::file::BEGIN@10
211194µs1.11msCGI::Session::Driver::file::::storeCGI::Session::Driver::file::store
321181µs181µsCGI::Session::Driver::file::::CORE:closeCGI::Session::Driver::file::CORE:close (opcode)
211145µs145µsCGI::Session::Driver::file::::CORE:truncateCGI::Session::Driver::file::CORE:truncate (opcode)
321131µs668µsCGI::Session::Driver::file::::_fileCGI::Session::Driver::file::_file
111128µs452µsCGI::Session::Driver::file::::retrieveCGI::Session::Driver::file::retrieve
32197µs97µsCGI::Session::Driver::file::::CORE:sysopenCGI::Session::Driver::file::CORE:sysopen (opcode)
53159µs59µsCGI::Session::Driver::file::::CORE:ftlinkCGI::Session::Driver::file::CORE:ftlink (opcode)
11129µs38µsCGI::Session::Driver::file::::BEGIN@5CGI::Session::Driver::file::BEGIN@5
32125µs25µsCGI::Session::Driver::file::::CORE:flockCGI::Session::Driver::file::CORE:flock (opcode)
11125µs33µsCGI::Session::Driver::file::::initCGI::Session::Driver::file::init
11124µs145µsCGI::Session::Driver::file::::BEGIN@7CGI::Session::Driver::file::BEGIN@7
21124µs24µsCGI::Session::Driver::file::::CORE:printCGI::Session::Driver::file::CORE:print (opcode)
11121µs2.76msCGI::Session::Driver::file::::BEGIN@9CGI::Session::Driver::file::BEGIN@9
32119µs19µsCGI::Session::Driver::file::::CORE:ftisCGI::Session::Driver::file::CORE:ftis (opcode)
11118µs164µsCGI::Session::Driver::file::::BEGIN@11CGI::Session::Driver::file::BEGIN@11
22117µs17µsCGI::Session::Driver::file::::CORE:readlineCGI::Session::Driver::file::CORE:readline (opcode)
11116µs50µsCGI::Session::Driver::file::::BEGIN@16CGI::Session::Driver::file::BEGIN@16
11114µs14µsCGI::Session::Driver::file::::BEGIN@8CGI::Session::Driver::file::BEGIN@8
11111µs11µsCGI::Session::Driver::file::::BEGIN@13CGI::Session::Driver::file::BEGIN@13
3119µs9µsCGI::Session::Driver::file::::CORE:substCGI::Session::Driver::file::CORE:subst (opcode)
1118µs8µsCGI::Session::Driver::file::::CORE:ftdirCGI::Session::Driver::file::CORE:ftdir (opcode)
1117µs7µsCGI::Session::Driver::file::::DESTROYCGI::Session::Driver::file::DESTROY
3116µs6µsCGI::Session::Driver::file::::CORE:matchCGI::Session::Driver::file::CORE:match (opcode)
0000s0sCGI::Session::Driver::file::::removeCGI::Session::Driver::file::remove
0000s0sCGI::Session::Driver::file::::traverseCGI::Session::Driver::file::traverse
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package CGI::Session::Driver::file;
2
3# $Id: file.pm 447 2008-11-01 03:46:08Z markstos $
4
5261µs248µs
# spent 38µs (29+9) within CGI::Session::Driver::file::BEGIN@5 which was called: # once (29µs+9µs) by CGI::Session::_load_pluggables at line 5
use strict;
# spent 38µs making 1 call to CGI::Session::Driver::file::BEGIN@5 # spent 10µs making 1 call to strict::import
6
7249µs2265µs
# spent 145µs (24+120) within CGI::Session::Driver::file::BEGIN@7 which was called: # once (24µs+120µs) by CGI::Session::_load_pluggables at line 7
use Carp;
# spent 145µs making 1 call to CGI::Session::Driver::file::BEGIN@7 # spent 120µs making 1 call to Exporter::import
8250µs114µs
# spent 14µs within CGI::Session::Driver::file::BEGIN@8 which was called: # once (14µs+0s) by CGI::Session::_load_pluggables at line 8
use File::Spec;
# spent 14µs making 1 call to CGI::Session::Driver::file::BEGIN@8
9276µs25.51ms
# spent 2.76ms (21µs+2.74) within CGI::Session::Driver::file::BEGIN@9 which was called: # once (21µs+2.74ms) by CGI::Session::_load_pluggables at line 9
use Fcntl qw( :DEFAULT :flock :mode );
# spent 2.76ms making 1 call to CGI::Session::Driver::file::BEGIN@9 # spent 2.74ms making 1 call to Exporter::import
102243µs1973µs
# spent 973µs (795+179) within CGI::Session::Driver::file::BEGIN@10 which was called: # once (795µs+179µs) by CGI::Session::_load_pluggables at line 10
use CGI::Session::Driver;
# spent 973µs making 1 call to CGI::Session::Driver::file::BEGIN@10
11258µs2310µs
# spent 164µs (18+146) within CGI::Session::Driver::file::BEGIN@11 which was called: # once (18µs+146µs) by CGI::Session::_load_pluggables at line 11
use vars qw( $FileName $NoFlock $UMask $NO_FOLLOW );
# spent 164µs making 1 call to CGI::Session::Driver::file::BEGIN@11 # spent 146µs making 1 call to vars::import
12
13
# spent 11µs within CGI::Session::Driver::file::BEGIN@13 which was called: # once (11µs+0s) by CGI::Session::_load_pluggables at line 19
BEGIN {
14 # keep historical behavior
15
16256µs284µs
# spent 50µs (16+34) within CGI::Session::Driver::file::BEGIN@16 which was called: # once (16µs+34µs) by CGI::Session::_load_pluggables at line 16
no strict 'refs';
# spent 50µs making 1 call to CGI::Session::Driver::file::BEGIN@16 # spent 34µs making 1 call to strict::unimport
17
18113µs *FileName = \$CGI::Session::File::FileName;
1911.52ms111µs}
# spent 11µs making 1 call to CGI::Session::Driver::file::BEGIN@13
20
21111µs@CGI::Session::Driver::file::ISA = ( "CGI::Session::Driver" );
2212µs$CGI::Session::Driver::file::VERSION = '4.38';
2311µs$FileName = "cgisess_%s";
2411µs$NoFlock = 0;
2511µs$UMask = 0660;
2625µs$NO_FOLLOW = eval { O_NOFOLLOW } || 0;
27
28
# spent 33µs (25+8) within CGI::Session::Driver::file::init which was called: # once (25µs+8µs) by CGI::Session::Driver::new at line 38 of /usr/local/src/github.com/foswiki/core/lib/CPAN/lib/CGI/Session/Driver.pm
sub init {
29635µs my $self = shift;
30 $self->{Directory} ||= File::Spec->tmpdir();
31
3218µs unless ( -d $self->{Directory} ) {
# spent 8µs making 1 call to CGI::Session::Driver::file::CORE:ftdir
33 require File::Path;
34 unless ( File::Path::mkpath($self->{Directory}) ) {
35 return $self->set_error( "init(): couldn't create directory path: $!" );
36 }
37 }
38
39 $self->{NoFlock} = $NoFlock unless exists $self->{NoFlock};
40 $self->{UMask} = $UMask unless exists $self->{UMask};
41
42 return 1;
43}
44
45
# spent 668µs (131+538) within CGI::Session::Driver::file::_file which was called 3 times, avg 223µs/call: # 2 times (84µs+346µs) by CGI::Session::Driver::file::store at line 92, avg 215µs/call # once (47µs+192µs) by CGI::Session::Driver::file::retrieve at line 62
sub _file {
4615149µs my ($self,$sid) = @_;
47 my $id = $sid;
4839µs $id =~ s|\\|/|g;
# spent 9µs making 3 calls to CGI::Session::Driver::file::CORE:subst, avg 3µs/call
49
5036µs if ($id =~ m|/|)
# spent 6µs making 3 calls to CGI::Session::Driver::file::CORE:match, avg 2µs/call
51 {
52 return $self->set_error( "_file(): Session ids cannot contain \\ or / chars: $sid" );
53 }
54
553522µs return File::Spec->catfile($self->{Directory}, sprintf( $FileName, $sid ));
# spent 522µs making 3 calls to File::Spec::Unix::catfile, avg 174µs/call
56}
57
58
# spent 452µs (128+324) within CGI::Session::Driver::file::retrieve which was called: # once (128µs+324µs) by CGI::Session::load at line 748 of /usr/local/src/github.com/foswiki/core/lib/CPAN/lib/CGI/Session.pm
sub retrieve {
5913213µs my $self = shift;
60 my ($sid) = @_;
61
621238µs my $path = $self->_file($sid);
# spent 238µs making 1 call to CGI::Session::Driver::file::_file
63
6418µs return 0 unless -e $path;
# spent 8µs making 1 call to CGI::Session::Driver::file::CORE:ftis
65
66 # make certain our filehandle goes away when we fall out of scope
67 local *FH;
68
6919µs if (-l $path) {
# spent 9µs making 1 call to CGI::Session::Driver::file::CORE:ftlink
70 unlink($path) or
71 return $self->set_error("retrieve(): '$path' appears to be a symlink and I couldn't remove it: $!");
72 return 0; # we deleted this so we have no hope of getting back anything
73 }
74134µs sysopen(FH, $path, O_RDONLY | $NO_FOLLOW ) || return $self->set_error( "retrieve(): couldn't open '$path': $!" );
# spent 34µs making 1 call to CGI::Session::Driver::file::CORE:sysopen
75
76111µs $self->{NoFlock} || flock(FH, LOCK_SH) or return $self->set_error( "retrieve(): couldn't lock '$path': $!" );
# spent 11µs making 1 call to CGI::Session::Driver::file::CORE:flock
77
78 my $rv = "";
79114µs while ( <FH> ) {
# spent 14µs making 1 call to CGI::Session::Driver::file::CORE:readline
8013µs $rv .= $_;
# spent 3µs making 1 call to CGI::Session::Driver::file::CORE:readline
81 }
8217µs close(FH);
# spent 7µs making 1 call to CGI::Session::Driver::file::CORE:close
83 return $rv;
84}
85
- -
88
# spent 1.11ms (194µs+911µs) within CGI::Session::Driver::file::store which was called 2 times, avg 553µs/call: # 2 times (194µs+911µs) by CGI::Session::flush at line 262 of /usr/local/src/github.com/foswiki/core/lib/CPAN/lib/CGI/Session.pm, avg 553µs/call
sub store {
8928674µs my $self = shift;
90 my ($sid, $datastr) = @_;
91
922430µs my $path = $self->_file($sid);
# spent 430µs making 2 calls to CGI::Session::Driver::file::_file, avg 215µs/call
93
94 # make certain our filehandle goes away when we fall out of scope
95 local *FH;
96
97 my $mode = O_WRONLY|$NO_FOLLOW;
98
99 # kill symlinks when we spot them
100239µs if (-l $path) {
# spent 39µs making 2 calls to CGI::Session::Driver::file::CORE:ftlink, avg 20µs/call
101 unlink($path) or
102 return $self->set_error("store(): '$path' appears to be a symlink and I couldn't remove it: $!");
103 }
104
105211µs $mode = O_RDWR|O_CREAT|O_EXCL unless -e $path;
# spent 11µs making 2 calls to CGI::Session::Driver::file::CORE:ftis, avg 6µs/call
106
107264µs sysopen(FH, $path, $mode, $self->{UMask}) or return $self->set_error( "store(): couldn't open '$path': $!" );
# spent 64µs making 2 calls to CGI::Session::Driver::file::CORE:sysopen, avg 32µs/call
108
109 # sanity check to make certain we're still ok
110210µs if (-l $path) {
# spent 10µs making 2 calls to CGI::Session::Driver::file::CORE:ftlink, avg 5µs/call
111 return $self->set_error("store(): '$path' is a symlink, check for malicious processes");
112 }
113
114 # prevent race condition (RT#17949)
115214µs $self->{NoFlock} || flock(FH, LOCK_EX) or return $self->set_error( "store(): couldn't lock '$path': $!" );
# spent 14µs making 2 calls to CGI::Session::Driver::file::CORE:flock, avg 7µs/call
1162145µs truncate(FH, 0) or return $self->set_error( "store(): couldn't truncate '$path': $!" );
# spent 145µs making 2 calls to CGI::Session::Driver::file::CORE:truncate, avg 73µs/call
117
118224µs print FH $datastr;
# spent 24µs making 2 calls to CGI::Session::Driver::file::CORE:print, avg 12µs/call
1192175µs close(FH) or return $self->set_error( "store(): couldn't close '$path': $!" );
# spent 175µs making 2 calls to CGI::Session::Driver::file::CORE:close, avg 87µs/call
120 return 1;
121}
122
123
124sub remove {
125 my $self = shift;
126 my ($sid) = @_;
127 my $path = $self -> _file($sid);
128 unlink($path) or return $self->set_error( "remove(): couldn't unlink '$path': $!" );
129 return 1;
130}
131
132
133sub traverse {
134 my $self = shift;
135 my ($coderef) = @_;
136
137 unless ( $coderef && ref($coderef) && (ref $coderef eq 'CODE') ) {
138 croak "traverse(): usage error";
139 }
140
141 opendir( DIRHANDLE, $self->{Directory} )
142 or return $self->set_error( "traverse(): couldn't open $self->{Directory}, " . $! );
143
144 my $filename_pattern = $FileName;
145 $filename_pattern =~ s/\./\\./g;
146 $filename_pattern =~ s/\%s/(\.\+)/g;
147 while ( my $filename = readdir(DIRHANDLE) ) {
148 next if $filename =~ m/^\.\.?$/;
149 my $full_path = File::Spec->catfile($self->{Directory}, $filename);
150 my $mode = (stat($full_path))[2]
151 or return $self->set_error( "traverse(): stat failed for $full_path: " . $! );
152 next if S_ISDIR($mode);
153 if ( $filename =~ /^$filename_pattern$/ ) {
154 $coderef->($1);
155 }
156 }
157 closedir( DIRHANDLE );
158 return 1;
159}
160
161
162
# spent 7µs within CGI::Session::Driver::file::DESTROY which was called: # once (7µs+0s) by Foswiki::LoginManager::finish at line 183 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/LoginManager.pm
sub DESTROY {
163110µs my $self = shift;
164}
165
16619µs1;
167
168__END__;
 
# spent 181µs within CGI::Session::Driver::file::CORE:close which was called 3 times, avg 60µs/call: # 2 times (175µs+0s) by CGI::Session::Driver::file::store at line 119, avg 87µs/call # once (7µs+0s) by CGI::Session::Driver::file::retrieve at line 82
sub CGI::Session::Driver::file::CORE:close; # opcode
# spent 25µs within CGI::Session::Driver::file::CORE:flock which was called 3 times, avg 8µs/call: # 2 times (14µs+0s) by CGI::Session::Driver::file::store at line 115, avg 7µs/call # once (11µs+0s) by CGI::Session::Driver::file::retrieve at line 76
sub CGI::Session::Driver::file::CORE:flock; # opcode
# spent 8µs within CGI::Session::Driver::file::CORE:ftdir which was called: # once (8µs+0s) by CGI::Session::Driver::file::init at line 32
sub CGI::Session::Driver::file::CORE:ftdir; # opcode
# spent 19µs within CGI::Session::Driver::file::CORE:ftis which was called 3 times, avg 6µs/call: # 2 times (11µs+0s) by CGI::Session::Driver::file::store at line 105, avg 6µs/call # once (8µs+0s) by CGI::Session::Driver::file::retrieve at line 64
sub CGI::Session::Driver::file::CORE:ftis; # opcode
# spent 59µs within CGI::Session::Driver::file::CORE:ftlink which was called 5 times, avg 12µs/call: # 2 times (39µs+0s) by CGI::Session::Driver::file::store at line 100, avg 20µs/call # 2 times (10µs+0s) by CGI::Session::Driver::file::store at line 110, avg 5µs/call # once (9µs+0s) by CGI::Session::Driver::file::retrieve at line 69
sub CGI::Session::Driver::file::CORE:ftlink; # opcode
# spent 6µs within CGI::Session::Driver::file::CORE:match which was called 3 times, avg 2µs/call: # 3 times (6µs+0s) by CGI::Session::Driver::file::_file at line 50, avg 2µs/call
sub CGI::Session::Driver::file::CORE:match; # opcode
# spent 24µs within CGI::Session::Driver::file::CORE:print which was called 2 times, avg 12µs/call: # 2 times (24µs+0s) by CGI::Session::Driver::file::store at line 118, avg 12µs/call
sub CGI::Session::Driver::file::CORE:print; # opcode
# spent 17µs within CGI::Session::Driver::file::CORE:readline which was called 2 times, avg 8µs/call: # once (14µs+0s) by CGI::Session::Driver::file::retrieve at line 79 # once (3µs+0s) by CGI::Session::Driver::file::retrieve at line 80
sub CGI::Session::Driver::file::CORE:readline; # opcode
# spent 9µs within CGI::Session::Driver::file::CORE:subst which was called 3 times, avg 3µs/call: # 3 times (9µs+0s) by CGI::Session::Driver::file::_file at line 48, avg 3µs/call
sub CGI::Session::Driver::file::CORE:subst; # opcode
# spent 97µs within CGI::Session::Driver::file::CORE:sysopen which was called 3 times, avg 32µs/call: # 2 times (64µs+0s) by CGI::Session::Driver::file::store at line 107, avg 32µs/call # once (34µs+0s) by CGI::Session::Driver::file::retrieve at line 74
sub CGI::Session::Driver::file::CORE:sysopen; # opcode
# spent 145µs within CGI::Session::Driver::file::CORE:truncate which was called 2 times, avg 73µs/call: # 2 times (145µs+0s) by CGI::Session::Driver::file::store at line 116, avg 73µs/call
sub CGI::Session::Driver::file::CORE:truncate; # opcode