Changeset 34 for trunk/phpgwapi/inc/adodb/perf/perf-mysql.inc.php
- Timestamp:
- 06/29/07 15:17:46 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpgwapi/inc/adodb/perf/perf-mysql.inc.php
r2 r34 1 1 <?php 2 2 /* 3 V4. 51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.3 V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. 4 4 Released under both BSD license and Lesser GPL library license. 5 5 Whenever there is any discrepancy between the two licenses, … … 133 133 $save = $ADODB_FETCH_MODE; 134 134 $ADODB_FETCH_MODE = ADODB_FETCH_NUM; 135 if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false); 136 135 137 $rs = $this->conn->Execute('show status'); 138 139 if (isset($savem)) $this->conn->SetFetchMode($savem); 136 140 $ADODB_FETCH_MODE = $save; 137 141 … … 158 162 $save = $ADODB_FETCH_MODE; 159 163 $ADODB_FETCH_MODE = ADODB_FETCH_NUM; 164 if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false); 165 160 166 $rs = $this->conn->Execute('show status'); 167 168 if (isset($savem)) $this->conn->SetFetchMode($savem); 161 169 $ADODB_FETCH_MODE = $save; 162 170 … … 186 194 // first find out type of table 187 195 //$this->conn->debug=1; 196 197 global $ADODB_FETCH_MODE; 198 $save = $ADODB_FETCH_MODE; 199 $ADODB_FETCH_MODE = ADODB_FETCH_NUM; 200 if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false); 201 188 202 $rs = $this->conn->Execute('show table status'); 203 204 if (isset($savem)) $this->conn->SetFetchMode($savem); 205 $ADODB_FETCH_MODE = $save; 206 189 207 if (!$rs) return ''; 190 208 $type = strtoupper($rs->fields[1]); … … 210 228 211 229 $total += $hits; 212 if ($total) return ($hits*100)/$total;230 if ($total) return round(($hits*100)/$total,2); 213 231 return 0; 214 232 } … … 228 246 function GetInnoDBHitRatio() 229 247 { 230 global $HTTP_SESSION_VARS; 231 248 global $ADODB_FETCH_MODE; 249 250 $save = $ADODB_FETCH_MODE; 251 $ADODB_FETCH_MODE = ADODB_FETCH_NUM; 252 if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false); 253 232 254 $rs = $this->conn->Execute('show innodb status'); 255 256 if (isset($savem)) $this->conn->SetFetchMode($savem); 257 $ADODB_FETCH_MODE = $save; 258 233 259 if (!$rs || $rs->EOF) return 0; 234 260 $stat = $rs->fields[0]; … … 238 264 if (preg_match('!Buffer pool hit rate\s*([0-9]*) / ([0-9]*)!',$stat,$arr)) { 239 265 $val = 100*$arr[1]/$arr[2]; 240 $ HTTP_SESSION_VARS['INNODB_HIT_PCT'] = $val;241 return $val;266 $_SESSION['INNODB_HIT_PCT'] = $val; 267 return round($val,2); 242 268 } else { 243 if (isset($ HTTP_SESSION_VARS['INNODB_HIT_PCT'])) return $HTTP_SESSION_VARS['INNODB_HIT_PCT'];269 if (isset($_SESSION['INNODB_HIT_PCT'])) return $_SESSION['INNODB_HIT_PCT']; 244 270 return 0; 245 271 } … … 253 279 if ($reqs == 0) return 0; 254 280 255 return ($hits/($reqs+$hits))*100; 256 } 257 281 return round(($hits/($reqs+$hits))*100,2); 282 } 283 284 // start hack 285 var $optimizeTableLow = 'CHECK TABLE %s FAST QUICK'; 286 var $optimizeTableHigh = 'OPTIMIZE TABLE %s'; 287 288 /** 289 * @see adodb_perf#optimizeTable 290 */ 291 function optimizeTable( $table, $mode = ADODB_OPT_LOW) 292 { 293 if ( !is_string( $table)) return false; 294 295 $conn = $this->conn; 296 if ( !$conn) return false; 297 298 $sql = ''; 299 switch( $mode) { 300 case ADODB_OPT_LOW : $sql = $this->optimizeTableLow; break; 301 case ADODB_OPT_HIGH : $sql = $this->optimizeTableHigh; break; 302 default : 303 { 304 // May dont use __FUNCTION__ constant for BC (__FUNCTION__ Added in PHP 4.3.0) 305 ADOConnection::outp( sprintf( "<p>%s: '%s' using of undefined mode '%s'</p>", __CLASS__, __FUNCTION__, $mode)); 306 return false; 307 } 308 } 309 $sql = sprintf( $sql, $table); 310 311 return $conn->Execute( $sql) !== false; 312 } 313 // end hack 258 314 } 259 315 ?>
Note: See TracChangeset
for help on using the changeset viewer.