<?php
-# This file is only included if profiling is enabled
-function wfProfileIn( $functionname )
-{
+/**
+ * This file is only included if profiling is enabled
+ * @package MediaWiki
+ */
+
+/**
+ * @param $functioname name of the function we will profile
+ */
+function wfProfileIn( $functionname ) {
global $wgProfiler;
$wgProfiler->profileIn( $functionname );
}
-function wfProfileOut( $functionname = 'missing' )
-{
+/**
+ * @param $functioname name of the function we have profiled
+ */
+function wfProfileOut( $functionname = 'missing' ) {
global $wgProfiler;
$wgProfiler->profileOut( $functionname );
}
return $wgProfiler->getOutput( $start, $elapsed );
}
-function wfProfileClose()
-{
+function wfProfileClose() {
global $wgProfiler;
$wgProfiler->close();
}
}
}
+/**
+ * @todo document
+ * @package MediaWiki
+ */
class Profiler
{
var $mStack = array(), $mWorkStack = array(), $mCollated = array();
}
*/
- function profileIn( $functionname )
- {
+ function profileIn( $functionname ) {
global $wgDebugFunctionEntry;
if ( $wgDebugFunctionEntry && function_exists( 'wfDebug' ) ) {
wfDebug( str_repeat( ' ', count( $this->mWorkStack ) ) . 'Entering '.$functionname."\n" );
array_push( $this->mWorkStack, array($functionname, count( $this->mWorkStack ), microtime(), memory_get_usage() ) );
}
- function profileOut( $functionname )
- {
+ function profileOut( $functionname ) {
$memory = memory_get_usage();
global $wgDebugProfiling, $wgDebugFunctionEntry;
}
}
- function close()
- {
+ function close() {
while ( count( $this->mWorkStack ) ) {
$this->profileOut( 'close' );
}
}
- function getOutput()
- {
+ function getOutput() {
global $wgDebugFunctionEntry;
$wgDebugFunctionEntry = false;
}
- /* static */ function logToDB($name, $timeSum, $eventCount)
- {
+ /**
+ * @static
+ */
+ function logToDB($name, $timeSum, $eventCount) {
$dbw =& wfGetDB( DB_MASTER );
$profiling = $dbw->tableName( 'profiling' );
- $name = $dbw->strencode( $name );
+ $name = substr($name,0,255);
+ $encname = $dbw->strencode($name);
$sql = "UPDATE $profiling ".
"SET pf_count=pf_count+{$eventCount}, ".
"pf_time=pf_time + {$timeSum} ".
- "WHERE pf_name='{$name}'";
+ "WHERE pf_name='{$encname}'";
$dbw->query($sql);
$rc = $dbw->affectedRows();
if( $rc == 0) {
- $dbw->insertArray($profiling,array(
+ $dbw->insert('profiling',array(
'pf_name'=>$name,
'pf_count'=>$eventCount,
'pf_time'=>$timeSum),