← 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 17:10:45 2013
Reported on Tue Oct 15 17:12:08 2013

Filename/usr/share/perl5/CGI/Session/Driver/DBI.pm
StatementsExecuted 48 statements in 4.53ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111551µs654µsCGI::Session::Driver::DBI::::BEGIN@9CGI::Session::Driver::DBI::BEGIN@9
332117µs3.12msCGI::Session::Driver::DBI::::DESTROYCGI::Session::Driver::DBI::DESTROY
31134µs34µsCGI::Session::Driver::DBI::::initCGI::Session::Driver::DBI::init
31123µs23µsCGI::Session::Driver::DBI::::table_nameCGI::Session::Driver::DBI::table_name
11121µs26µsCGI::Session::Driver::DBI::::BEGIN@5CGI::Session::Driver::DBI::BEGIN@5
11118µs43µsCGI::Session::Driver::DBI::::BEGIN@7CGI::Session::Driver::DBI::BEGIN@7
11113µs36µsCGI::Session::Driver::DBI::::BEGIN@48CGI::Session::Driver::DBI::BEGIN@48
1119µs51µ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
5335µs230µs
# spent 26µs (21+4) within CGI::Session::Driver::DBI::BEGIN@5 which was called: # once (21µs+4µs) by CGI::Session::Driver::mysql::BEGIN@7 at line 5
use strict;
# spent 26µs making 1 call to CGI::Session::Driver::DBI::BEGIN@5 # spent 4µs making 1 call to strict::import
6
7335µs268µs
# spent 43µs (18+25) within CGI::Session::Driver::DBI::BEGIN@7 which was called: # once (18µs+25µs) by CGI::Session::Driver::mysql::BEGIN@7 at line 7
use DBI;
# spent 43µs making 1 call to CGI::Session::Driver::DBI::BEGIN@7 # spent 25µs making 1 call to Exporter::import
8328µs293µs
# spent 51µs (9+42) within CGI::Session::Driver::DBI::BEGIN@8 which was called: # once (9µs+42µs) by CGI::Session::Driver::mysql::BEGIN@7 at line 8
use Carp;
# spent 51µs making 1 call to CGI::Session::Driver::DBI::BEGIN@8 # spent 42µs making 1 call to Exporter::import
93371µs2658µs
# spent 654µs (551+104) within CGI::Session::Driver::DBI::BEGIN@9 which was called: # once (551µs+104µs) by CGI::Session::Driver::mysql::BEGIN@7 at line 9
use CGI::Session::Driver;
# spent 654µs making 1 call to CGI::Session::Driver::DBI::BEGIN@9 # spent 3µs making 1 call to UNIVERSAL::import
10
11116µs@CGI::Session::Driver::DBI::ISA = ( "CGI::Session::Driver" );
121600ns$CGI::Session::Driver::DBI::VERSION = '4.38';
13
14
15
# spent 34µs within CGI::Session::Driver::DBI::init which was called 3 times, avg 11µs/call: # 3 times (34µs+0s) by CGI::Session::Driver::mysql::init at line 41 of CGI/Session/Driver/mysql.pm, avg 11µs/call
sub init {
16946µ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 23µs within CGI::Session::Driver::DBI::table_name which was called 3 times, avg 8µs/call: # 3 times (23µs+0s) by CGI::Session::Driver::mysql::table_name at line 61 of CGI/Session/Driver/mysql.pm, avg 8µs/call
sub table_name {
41930µs my $self = shift;
42 my $class = ref( $self ) || $self;
43
44 if ( (@_ == 0) && ref($self) && ($self->{TableName}) ) {
45 return $self->{TableName};
46 }
47
483841µs259µs
# spent 36µs (13+23) within CGI::Session::Driver::DBI::BEGIN@48 which was called: # once (13µs+23µs) by CGI::Session::Driver::mysql::BEGIN@7 at line 48
no strict 'refs';
# spent 36µs making 1 call to CGI::Session::Driver::DBI::BEGIN@48 # spent 23µ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 3.12ms (117µs+3.00) within CGI::Session::Driver::DBI::DESTROY which was called 3 times, avg 1.04ms/call: # once (37µs+1.07ms) by main::RUNTIME at line 690 of /usr/share/koha/opac/cgi-bin/opac/opac-search.pl # once (39µs+989µs) by C4::Auth::checkauth at line 805 of /usr/share/koha/lib/C4/Auth.pm # once (41µs+936µs) by C4::Auth::get_template_and_user at line 365 of /usr/share/koha/lib/C4/Auth.pm
sub DESTROY {
134123.12ms my $self = shift;
135
13632.97ms unless ( defined $self->{Handle} && $self->{Handle} -> ping ) {
# spent 2.97ms making 3 calls to DBI::db::ping, avg 991µs/call
137 $self->set_error(__PACKAGE__ . '::DESTROY(). Database handle has gone away');
138 return;
139 }
140
141328µs unless ( $self->{Handle}->{AutoCommit} ) {
# spent 28µs making 3 calls to DBI::common::FETCH, avg 9µ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
17314µs1;
174
175=pod
176
- -