← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
  Run on Tue Oct 15 11:58:52 2013
Reported on Tue Oct 15 12:01:42 2013

Filename/usr/share/perl5/CGI/Session/Driver/DBI.pm
StatementsExecuted 48 statements in 4.91ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111877µs1.14msCGI::Session::Driver::DBI::::BEGIN@9CGI::Session::Driver::DBI::BEGIN@9
332147µs2.78msCGI::Session::Driver::DBI::::DESTROYCGI::Session::Driver::DBI::DESTROY
31138µs38µsCGI::Session::Driver::DBI::::table_nameCGI::Session::Driver::DBI::table_name
11137µs77µsCGI::Session::Driver::DBI::::BEGIN@7CGI::Session::Driver::DBI::BEGIN@7
11130µs37µsCGI::Session::Driver::DBI::::BEGIN@5CGI::Session::Driver::DBI::BEGIN@5
31130µs30µsCGI::Session::Driver::DBI::::initCGI::Session::Driver::DBI::init
11119µs58µsCGI::Session::Driver::DBI::::BEGIN@48CGI::Session::Driver::DBI::BEGIN@48
11117µs91µsCGI::Session::Driver::DBI::::BEGIN@8CGI::Session::Driver::DBI::BEGIN@8
0000s0sCGI::Session::Driver::DBI::::removeCGI::Session::Driver::DBI::remove
0000s0sCGI::Session::Driver::DBI::::retrieveCGI::Session::Driver::DBI::retrieve
0000s0sCGI::Session::Driver::DBI::::storeCGI::Session::Driver::DBI::store
0000s0sCGI::Session::Driver::DBI::::traverseCGI::Session::Driver::DBI::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::DBI;
2
3# $Id: DBI.pm 447 2008-11-01 03:46:08Z markstos $
4
5357µs245µs
# spent 37µs (30+7) within CGI::Session::Driver::DBI::BEGIN@5 which was called: # once (30µs+7µs) by CGI::Session::Driver::mysql::BEGIN@7 at line 5
use strict;
# spent 37µs making 1 call to CGI::Session::Driver::DBI::BEGIN@5 # spent 7µs making 1 call to strict::import
6
7361µs2118µs
# spent 77µs (37+41) within CGI::Session::Driver::DBI::BEGIN@7 which was called: # once (37µs+41µs) by CGI::Session::Driver::mysql::BEGIN@7 at line 7
use DBI;
# spent 77µs making 1 call to CGI::Session::Driver::DBI::BEGIN@7 # spent 41µs making 1 call to Exporter::import
8350µs2165µs
# spent 91µs (17+74) within CGI::Session::Driver::DBI::BEGIN@8 which was called: # once (17µs+74µs) by CGI::Session::Driver::mysql::BEGIN@7 at line 8
use Carp;
# spent 91µs making 1 call to CGI::Session::Driver::DBI::BEGIN@8 # spent 74µs making 1 call to Exporter::import
93526µs11.14ms
# spent 1.14ms (877µs+262µs) within CGI::Session::Driver::DBI::BEGIN@9 which was called: # once (877µs+262µs) by CGI::Session::Driver::mysql::BEGIN@7 at line 9
use CGI::Session::Driver;
# spent 1.14ms making 1 call to CGI::Session::Driver::DBI::BEGIN@9
10
11122µs@CGI::Session::Driver::DBI::ISA = ( "CGI::Session::Driver" );
1212µs$CGI::Session::Driver::DBI::VERSION = '4.38';
13
14
15
# spent 30µs within CGI::Session::Driver::DBI::init which was called 3 times, avg 10µs/call: # 3 times (30µs+0s) by CGI::Session::Driver::mysql::init at line 41 of CGI/Session/Driver/mysql.pm, avg 10µs/call
sub init {
16940µs my $self = shift;
17 if ( defined $self->{Handle} ) {
18 if (ref $self->{Handle} eq 'CODE') {
19 $self->{Handle} = $self->{Handle}->();
20 }
21 else {
22 # We assume the handle is working, and there is nothing to do.
23 }
24 }
25 else {
26 $self->{Handle} = DBI->connect(
27 $self->{DataSource}, $self->{User}, $self->{Password},
28 { RaiseError=>1, PrintError=>1, AutoCommit=>1 }
29 );
30 unless ( $self->{Handle} ) {
31 return $self->set_error( "init(): couldn't connect to database: " . DBI->errstr );
32 }
33 $self->{_disconnect} = 1;
34 }
35 return 1;
36}
37
38# A setter/accessor method for the table name, defaulting to 'sessions'
39
40
# spent 38µs within CGI::Session::Driver::DBI::table_name which was called 3 times, avg 13µs/call: # 3 times (38µs+0s) by CGI::Session::Driver::mysql::table_name at line 61 of CGI/Session/Driver/mysql.pm, avg 13µs/call
sub table_name {
41946µs my $self = shift;
42 my $class = ref( $self ) || $self;
43
44 if ( (@_ == 0) && ref($self) && ($self->{TableName}) ) {
45 return $self->{TableName};
46 }
47
4831.31ms298µs
# spent 58µs (19+39) within CGI::Session::Driver::DBI::BEGIN@48 which was called: # once (19µs+39µs) by CGI::Session::Driver::mysql::BEGIN@7 at line 48
no strict 'refs';
# spent 58µs making 1 call to CGI::Session::Driver::DBI::BEGIN@48 # spent 39µs making 1 call to strict::unimport
49 if ( @_ ) {
50 $self->{TableName} = shift;
51 }
52
53 unless (defined $self->{TableName}) {
54 $self->{TableName} = "sessions";
55 }
56
57 return $self->{TableName};
58}
59
60
61sub retrieve {
62 my $self = shift;
63 my ($sid) = @_;
64 croak "retrieve(): usage error" unless $sid;
65
66
67 my $dbh = $self->{Handle};
68 my $sth = $dbh->prepare_cached("SELECT $self->{DataColName} FROM " . $self->table_name . " WHERE $self->{IdColName}=?", undef, 3);
69 unless ( $sth ) {
70 return $self->set_error( "retrieve(): DBI->prepare failed with error message " . $dbh->errstr );
71 }
72 $sth->execute( $sid ) or return $self->set_error( "retrieve(): \$sth->execute failed with error message " . $sth->errstr);
73
74 my ($row) = $sth->fetchrow_array();
75
76 $sth->finish;
77
78 return 0 unless $row;
79 return $row;
80}
81
82
83sub store {
84# die;
85 my $self = shift;
86 my ($sid, $datastr) = @_;
87 croak "store(): usage error" unless $sid && $datastr;
88
89
90 my $dbh = $self->{Handle};
91 my $sth = $dbh->prepare_cached("SELECT $self->{IdColName} FROM " . $self->table_name . " WHERE $self->{IdColName}=?", undef, 3);
92 unless ( defined $sth ) {
93 return $self->set_error( "store(): \$dbh->prepare failed with message " . $sth->errstr );
94 }
95
96 $sth->execute( $sid ) or return $self->set_error( "store(): \$sth->execute failed with message " . $sth->errstr );
97 my $rc = $sth->fetchrow_array;
98 $sth->finish;
99
100 my $action_sth;
101 if ( $rc ) {
102 $action_sth = $dbh->prepare_cached("UPDATE " . $self->table_name . " SET $self->{DataColName}=? WHERE $self->{IdColName}=?", undef, 3);
103 } else {
104 $action_sth = $dbh->prepare_cached("INSERT INTO " . $self->table_name . " ($self->{DataColName}, $self->{IdColName}) VALUES(?, ?)", undef, 3);
105 }
106
107 unless ( defined $action_sth ) {
108 return $self->set_error( "store(): \$dbh->prepare failed with message " . $dbh->errstr );
109 }
110 $action_sth->execute($datastr, $sid)
111 or return $self->set_error( "store(): \$action_sth->execute failed " . $action_sth->errstr );
112
113 $action_sth->finish;
114
115 return 1;
116}
117
118
119sub remove {
120 my $self = shift;
121 my ($sid) = @_;
122 croak "remove(): usage error" unless $sid;
123
124 my $rc = $self->{Handle}->do( 'DELETE FROM ' . $self->table_name . " WHERE $self->{IdColName}= ?", {}, $sid );
125 unless ( $rc ) {
126 croak "remove(): \$dbh->do failed!";
127 }
128
129 return 1;
130}
131
132
133
# spent 2.78ms (147µs+2.63) within CGI::Session::Driver::DBI::DESTROY which was called 3 times, avg 926µs/call: # once (58µs+891µs) by C4::Auth::checkauth at line 806 of /usr/share/koha/lib/C4/Auth.pm # once (38µs+894µs) by C4::Auth::get_template_and_user at line 365 of /usr/share/koha/lib/C4/Auth.pm # once (52µs+845µs) by main::RUNTIME at line 690 of /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
sub DESTROY {
134122.79ms my $self = shift;
135
13632.60ms unless ( defined $self->{Handle} && $self->{Handle} -> ping ) {
# spent 2.60ms making 3 calls to DBI::db::ping, avg 866µs/call
137 $self->set_error(__PACKAGE__ . '::DESTROY(). Database handle has gone away');
138 return;
139 }
140
141331µs unless ( $self->{Handle}->{AutoCommit} ) {
# spent 31µs making 3 calls to DBI::common::FETCH, avg 10µs/call
142 $self->{Handle}->commit;
143 }
144 if ( $self->{_disconnect} ) {
145 $self->{Handle}->disconnect;
146 }
147}
148
149
150sub traverse {
151 my $self = shift;
152 my ($coderef) = @_;
153
154 unless ( $coderef && ref( $coderef ) && (ref $coderef eq 'CODE') ) {
155 croak "traverse(): usage error";
156 }
157
158 my $tablename = $self->table_name();
159 my $sth = $self->{Handle}->prepare_cached("SELECT $self->{IdColName} FROM $tablename", undef, 3)
160 or return $self->set_error("traverse(): couldn't prepare SQL statement. " . $self->{Handle}->errstr);
161 $sth->execute() or return $self->set_error("traverse(): couldn't execute statement $sth->{Statement}. " . $sth->errstr);
162
163 while ( my ($sid) = $sth->fetchrow_array ) {
164 $coderef->($sid);
165 }
166
167 $sth->finish;
168
169 return 1;
170}
171
172
17316µs1;
174
175=pod
176
- -