MediaWiki  1.23.8
Profiler.php
Go to the documentation of this file.
1 <?php
33 function wfProfileIn( $functionname ) {
34  if ( Profiler::$__instance === null ) { // use this directly to reduce overhead
36  }
37  if ( !( Profiler::$__instance instanceof ProfilerStub ) ) {
38  Profiler::$__instance->profileIn( $functionname );
39  }
40 }
41 
46 function wfProfileOut( $functionname = 'missing' ) {
47  if ( Profiler::$__instance === null ) { // use this directly to reduce overhead
49  }
50  if ( !( Profiler::$__instance instanceof ProfilerStub ) ) {
51  Profiler::$__instance->profileOut( $functionname );
52  }
53 }
54 
61  protected $name; // string; method name
62  protected $enabled = false; // boolean; whether profiling is enabled
63 
75  public function __construct( $name ) {
76  $this->name = $name;
77  if ( Profiler::$__instance === null ) { // use this directly to reduce overhead
79  }
80  if ( !( Profiler::$__instance instanceof ProfilerStub ) ) {
81  $this->enabled = true;
82  Profiler::$__instance->profileIn( $this->name );
83  }
84  }
85 
86  function __destruct() {
87  if ( $this->enabled ) {
88  Profiler::$__instance->profileOut( $this->name );
89  }
90  }
91 }
92 
97 class Profiler {
98  protected $mStack = array(), $mWorkStack = array(), $mCollated = array(),
100  protected $mTimeMetric = 'wall';
101  protected $mProfileID = false, $mCollateDone = false, $mTemplated = false;
102 
103  protected $mDBLockThreshold = 5.0; // float; seconds
105  protected $mDBTrxHoldingLocks = array();
107  protected $mDBTrxMethodTimes = array();
108 
110  public static $__instance = null; // do not call this outside Profiler and ProfileSection
111 
112  function __construct( $params ) {
113  if ( isset( $params['timeMetric'] ) ) {
114  $this->mTimeMetric = $params['timeMetric'];
115  }
116  if ( isset( $params['profileID'] ) ) {
117  $this->mProfileID = $params['profileID'];
118  }
119 
120  $this->addInitialStack();
121  }
122 
127  public static function instance() {
128  if ( self::$__instance === null ) {
130  if ( is_array( $wgProfiler ) ) {
131  if ( !isset( $wgProfiler['class'] ) ) {
132  $class = 'ProfilerStub';
133  } else {
134  $class = $wgProfiler['class'];
135  }
136  self::$__instance = new $class( $wgProfiler );
137  } elseif ( $wgProfiler instanceof Profiler ) {
138  self::$__instance = $wgProfiler; // back-compat
139  } else {
140  self::$__instance = new ProfilerStub( $wgProfiler );
141  }
142  }
143  return self::$__instance;
144  }
145 
150  public static function setInstance( Profiler $p ) {
151  self::$__instance = $p;
152  }
153 
159  public function isStub() {
160  return false;
161  }
162 
169  public function isPersistent() {
170  return true;
171  }
172 
173  public function setProfileID( $id ) {
174  $this->mProfileID = $id;
175  }
176 
177  public function getProfileID() {
178  if ( $this->mProfileID === false ) {
179  return wfWikiID();
180  } else {
181  return $this->mProfileID;
182  }
183  }
184 
188  protected function addInitialStack() {
189  // Push an entry for the pre-profile setup time onto the stack
190  $initial = $this->getInitialTime();
191  if ( $initial !== null ) {
192  $this->mWorkStack[] = array( '-total', 0, $initial, 0 );
193  $this->mStack[] = array( '-setup', 1, $initial, 0, $this->getTime(), 0 );
194  } else {
195  $this->profileIn( '-total' );
196  }
197  }
198 
204  public function profileIn( $functionname ) {
205  global $wgDebugFunctionEntry;
206  if ( $wgDebugFunctionEntry ) {
207  $this->debug( str_repeat( ' ', count( $this->mWorkStack ) ) . 'Entering ' . $functionname . "\n" );
208  }
209 
210  $this->mWorkStack[] = array( $functionname, count( $this->mWorkStack ), $this->getTime(), memory_get_usage() );
211  }
212 
218  public function profileOut( $functionname ) {
219  global $wgDebugFunctionEntry;
220  $memory = memory_get_usage();
221  $time = $this->getTime();
222 
223  if ( $wgDebugFunctionEntry ) {
224  $this->debug( str_repeat( ' ', count( $this->mWorkStack ) - 1 ) . 'Exiting ' . $functionname . "\n" );
225  }
226 
227  $bit = array_pop( $this->mWorkStack );
228 
229  if ( !$bit ) {
230  $this->debugGroup( 'profileerror', "Profiling error, !\$bit: $functionname" );
231  } else {
232  if ( $functionname == 'close' ) {
233  if ( $bit[0] != '-total' ) {
234  $message = "Profile section ended by close(): {$bit[0]}";
235  $this->debugGroup( 'profileerror', $message );
236  $this->mStack[] = array( $message, 0, 0.0, 0, 0.0, 0 );
237  }
238  } elseif ( $bit[0] != $functionname ) {
239  $message = "Profiling error: in({$bit[0]}), out($functionname)";
240  $this->debugGroup( 'profileerror', $message );
241  $this->mStack[] = array( $message, 0, 0.0, 0, 0.0, 0 );
242  }
243  $bit[] = $time;
244  $bit[] = $memory;
245  $this->mStack[] = $bit;
246  $this->updateTrxProfiling( $functionname, $time );
247  }
248  }
249 
253  public function close() {
254  while ( count( $this->mWorkStack ) ) {
255  $this->profileOut( 'close' );
256  }
257  }
258 
267  public function transactionWritingIn( $server, $db ) {
268  $name = "{$server} ({$db})";
269  if ( isset( $this->mDBTrxHoldingLocks[$name] ) ) {
270  ++$this->mDBTrxHoldingLocks[$name]['refs'];
271  } else {
272  $this->mDBTrxHoldingLocks[$name] = array( 'refs' => 1, 'start' => microtime( true ) );
273  $this->mDBTrxMethodTimes[$name] = array();
274  }
275  }
276 
283  protected function updateTrxProfiling( $method, $realtime ) {
284  if ( !$this->mDBTrxHoldingLocks ) {
285  return; // short-circuit
286  // @TODO: hardcoded check is a tad janky (what about FOR UPDATE?)
287  } elseif ( !preg_match( '/^query-m: (?!SELECT)/', $method )
288  && $realtime < $this->mDBLockThreshold
289  ) {
290  return; // not a DB master query nor slow enough
291  }
292  $now = microtime( true );
293  foreach ( $this->mDBTrxHoldingLocks as $name => $info ) {
294  // Hacky check to exclude entries from before the first TRX write
295  if ( ( $now - $realtime ) >= $info['start'] ) {
296  $this->mDBTrxMethodTimes[$name][] = array( $method, $realtime );
297  }
298  }
299  }
300 
311  public function transactionWritingOut( $server, $db ) {
312  $name = "{$server} ({$db})";
313  if ( --$this->mDBTrxHoldingLocks[$name]['refs'] <= 0 ) {
314  $slow = false;
315  foreach ( $this->mDBTrxMethodTimes[$name] as $info ) {
316  list( $method, $realtime ) = $info;
317  if ( $realtime >= $this->mDBLockThreshold ) {
318  $slow = true;
319  break;
320  }
321  }
322  if ( $slow ) {
323  $dbs = implode( ', ', array_keys( $this->mDBTrxHoldingLocks ) );
324  $msg = "Sub-optimal transaction on DB(s) {$dbs}:\n";
325  foreach ( $this->mDBTrxMethodTimes[$name] as $i => $info ) {
326  list( $method, $realtime ) = $info;
327  $msg .= sprintf( "%d\t%.6f\t%s\n", $i, $realtime, $method );
328  }
329  $this->debugGroup( 'DBPerformance', $msg );
330  }
331  unset( $this->mDBTrxHoldingLocks[$name] );
332  unset( $this->mDBTrxMethodTimes[$name] );
333  }
334  }
335 
341  function setTemplated( $t ) {
342  $this->mTemplated = $t;
343  }
344 
350  public function getOutput() {
351  global $wgDebugFunctionEntry, $wgProfileCallTree;
352  $wgDebugFunctionEntry = false;
353 
354  if ( !count( $this->mStack ) && !count( $this->mCollated ) ) {
355  return "No profiling output\n";
356  }
357 
358  if ( $wgProfileCallTree ) {
359  return $this->getCallTree();
360  } else {
361  return $this->getFunctionReport();
362  }
363  }
364 
369  function getCallTree() {
370  return implode( '', array_map( array( &$this, 'getCallTreeLine' ), $this->remapCallTree( $this->mStack ) ) );
371  }
372 
379  function remapCallTree( $stack ) {
380  if ( count( $stack ) < 2 ) {
381  return $stack;
382  }
383  $outputs = array();
384  for ( $max = count( $stack ) - 1; $max > 0; ) {
385  /* Find all items under this entry */
386  $level = $stack[$max][1];
387  $working = array();
388  for ( $i = $max -1; $i >= 0; $i-- ) {
389  if ( $stack[$i][1] > $level ) {
390  $working[] = $stack[$i];
391  } else {
392  break;
393  }
394  }
395  $working = $this->remapCallTree( array_reverse( $working ) );
396  $output = array();
397  foreach ( $working as $item ) {
398  array_push( $output, $item );
399  }
400  array_unshift( $output, $stack[$max] );
401  $max = $i;
402 
403  array_unshift( $outputs, $output );
404  }
405  $final = array();
406  foreach ( $outputs as $output ) {
407  foreach ( $output as $item ) {
408  $final[] = $item;
409  }
410  }
411  return $final;
412  }
413 
418  function getCallTreeLine( $entry ) {
419  list( $fname, $level, $start, /* $x */, $end ) = $entry;
420  $delta = $end - $start;
421  $space = str_repeat( ' ', $level );
422  # The ugly double sprintf is to work around a PHP bug,
423  # which has been fixed in recent releases.
424  return sprintf( "%10s %s %s\n", trim( sprintf( "%7.3f", $delta * 1000.0 ) ), $space, $fname );
425  }
426 
438  function getTime( $metric = false ) {
439  if ( $metric === false ) {
440  $metric = $this->mTimeMetric;
441  }
442 
443  if ( $metric === 'cpu' || $this->mTimeMetric === 'user' ) {
444  if ( !function_exists( 'getrusage' ) ) {
445  return 0;
446  }
447  $ru = getrusage();
448  $time = $ru['ru_utime.tv_sec'] + $ru['ru_utime.tv_usec'] / 1e6;
449  if ( $metric === 'cpu' ) {
450  # This is the time of system calls, added to the user time
451  # it gives the total CPU time
452  $time += $ru['ru_stime.tv_sec'] + $ru['ru_stime.tv_usec'] / 1e6;
453  }
454  return $time;
455  } else {
456  return microtime( true );
457  }
458  }
459 
471  protected function getInitialTime( $metric = false ) {
472  global $wgRequestTime, $wgRUstart;
473 
474  if ( $metric === false ) {
475  $metric = $this->mTimeMetric;
476  }
477 
478  if ( $metric === 'cpu' || $this->mTimeMetric === 'user' ) {
479  if ( !count( $wgRUstart ) ) {
480  return null;
481  }
482 
483  $time = $wgRUstart['ru_utime.tv_sec'] + $wgRUstart['ru_utime.tv_usec'] / 1e6;
484  if ( $metric === 'cpu' ) {
485  # This is the time of system calls, added to the user time
486  # it gives the total CPU time
487  $time += $wgRUstart['ru_stime.tv_sec'] + $wgRUstart['ru_stime.tv_usec'] / 1e6;
488  }
489  return $time;
490  } else {
491  if ( empty( $wgRequestTime ) ) {
492  return null;
493  } else {
494  return $wgRequestTime;
495  }
496  }
497  }
498 
499  protected function collateData() {
500  if ( $this->mCollateDone ) {
501  return;
502  }
503  $this->mCollateDone = true;
504 
505  $this->close();
506 
507  $this->mCollated = array();
508  $this->mCalls = array();
509  $this->mMemory = array();
510 
511  # Estimate profiling overhead
512  $profileCount = count( $this->mStack );
513  self::calculateOverhead( $profileCount );
514 
515  # First, subtract the overhead!
516  $overheadTotal = $overheadMemory = $overheadInternal = array();
517  foreach ( $this->mStack as $entry ) {
518  $fname = $entry[0];
519  $start = $entry[2];
520  $end = $entry[4];
521  $elapsed = $end - $start;
522  $memory = $entry[5] - $entry[3];
523 
524  if ( $fname == '-overhead-total' ) {
525  $overheadTotal[] = $elapsed;
526  $overheadMemory[] = $memory;
527  } elseif ( $fname == '-overhead-internal' ) {
528  $overheadInternal[] = $elapsed;
529  }
530  }
531  $overheadTotal = $overheadTotal ? array_sum( $overheadTotal ) / count( $overheadInternal ) : 0;
532  $overheadMemory = $overheadMemory ? array_sum( $overheadMemory ) / count( $overheadInternal ) : 0;
533  $overheadInternal = $overheadInternal ? array_sum( $overheadInternal ) / count( $overheadInternal ) : 0;
534 
535  # Collate
536  foreach ( $this->mStack as $index => $entry ) {
537  $fname = $entry[0];
538  $start = $entry[2];
539  $end = $entry[4];
540  $elapsed = $end - $start;
541 
542  $memory = $entry[5] - $entry[3];
543  $subcalls = $this->calltreeCount( $this->mStack, $index );
544 
545  if ( !preg_match( '/^-overhead/', $fname ) ) {
546  # Adjust for profiling overhead (except special values with elapsed=0
547  if ( $elapsed ) {
548  $elapsed -= $overheadInternal;
549  $elapsed -= ( $subcalls * $overheadTotal );
550  $memory -= ( $subcalls * $overheadMemory );
551  }
552  }
553 
554  if ( !array_key_exists( $fname, $this->mCollated ) ) {
555  $this->mCollated[$fname] = 0;
556  $this->mCalls[$fname] = 0;
557  $this->mMemory[$fname] = 0;
558  $this->mMin[$fname] = 1 << 24;
559  $this->mMax[$fname] = 0;
560  $this->mOverhead[$fname] = 0;
561  $this->mPeriods[$fname] = array();
562  }
563 
564  $this->mCollated[$fname] += $elapsed;
565  $this->mCalls[$fname]++;
566  $this->mMemory[$fname] += $memory;
567  $this->mMin[$fname] = min( $this->mMin[$fname], $elapsed );
568  $this->mMax[$fname] = max( $this->mMax[$fname], $elapsed );
569  $this->mOverhead[$fname] += $subcalls;
570  $this->mPeriods[$fname][] = compact( 'start', 'end', 'memory', 'subcalls' );
571  }
572 
573  $this->mCalls['-overhead-total'] = $profileCount;
574  arsort( $this->mCollated, SORT_NUMERIC );
575  }
576 
582  function getFunctionReport() {
583  $this->collateData();
584 
585  $width = 140;
586  $nameWidth = $width - 65;
587  $format = "%-{$nameWidth}s %6d %13.3f %13.3f %13.3f%% %9d (%13.3f -%13.3f) [%d]\n";
588  $titleFormat = "%-{$nameWidth}s %6s %13s %13s %13s %9s\n";
589  $prof = "\nProfiling data\n";
590  $prof .= sprintf( $titleFormat, 'Name', 'Calls', 'Total', 'Each', '%', 'Mem' );
591 
592  $total = isset( $this->mCollated['-total'] ) ? $this->mCollated['-total'] : 0;
593 
594  foreach ( $this->mCollated as $fname => $elapsed ) {
595  $calls = $this->mCalls[$fname];
596  $percent = $total ? 100. * $elapsed / $total : 0;
597  $memory = $this->mMemory[$fname];
598  $prof .= sprintf( $format,
599  substr( $fname, 0, $nameWidth ),
600  $calls,
601  (float)( $elapsed * 1000 ),
602  (float)( $elapsed * 1000 ) / $calls,
603  $percent,
604  $memory,
605  ( $this->mMin[$fname] * 1000.0 ),
606  ( $this->mMax[$fname] * 1000.0 ),
607  $this->mOverhead[$fname]
608  );
609  }
610  $prof .= "\nTotal: $total\n\n";
611 
612  return $prof;
613  }
614 
618  public function getRawData() {
619  $this->collateData();
620 
621  $profile = array();
622  $total = isset( $this->mCollated['-total'] ) ? $this->mCollated['-total'] : 0;
623  foreach ( $this->mCollated as $fname => $elapsed ) {
624  $periods = array();
625  foreach ( $this->mPeriods[$fname] as $period ) {
626  $period['start'] *= 1000;
627  $period['end'] *= 1000;
628  $periods[] = $period;
629  }
630  $profile[] = array(
631  'name' => $fname,
632  'calls' => $this->mCalls[$fname],
633  'elapsed' => $elapsed * 1000,
634  'percent' => $total ? 100. * $elapsed / $total : 0,
635  'memory' => $this->mMemory[$fname],
636  'min' => $this->mMin[$fname] * 1000,
637  'max' => $this->mMax[$fname] * 1000,
638  'overhead' => $this->mOverhead[$fname],
639  'periods' => $periods,
640  );
641  }
642 
643  return $profile;
644  }
645 
649  protected static function calculateOverhead( $profileCount ) {
650  wfProfileIn( '-overhead-total' );
651  for ( $i = 0; $i < $profileCount; $i++ ) {
652  wfProfileIn( '-overhead-internal' );
653  wfProfileOut( '-overhead-internal' );
654  }
655  wfProfileOut( '-overhead-total' );
656  }
657 
667  function calltreeCount( $stack, $start ) {
668  $level = $stack[$start][1];
669  $count = 0;
670  for ( $i = $start -1; $i >= 0 && $stack[$i][1] > $level; $i-- ) {
671  $count ++;
672  }
673  return $count;
674  }
675 
679  public function logData() {
680  global $wgProfilePerHost, $wgProfileToDatabase;
681 
682  # Do not log anything if database is readonly (bug 5375)
683  if ( wfReadOnly() || !$wgProfileToDatabase ) {
684  return;
685  }
686 
687  $dbw = wfGetDB( DB_MASTER );
688  if ( !is_object( $dbw ) ) {
689  return;
690  }
691 
692  if ( $wgProfilePerHost ) {
693  $pfhost = wfHostname();
694  } else {
695  $pfhost = '';
696  }
697 
698  try {
699  $this->collateData();
700 
701  foreach ( $this->mCollated as $name => $elapsed ) {
702  $eventCount = $this->mCalls[$name];
703  $timeSum = (float)( $elapsed * 1000 );
704  $memorySum = (float)$this->mMemory[$name];
705  $name = substr( $name, 0, 255 );
706 
707  // Kludge
708  $timeSum = $timeSum >= 0 ? $timeSum : 0;
709  $memorySum = $memorySum >= 0 ? $memorySum : 0;
710 
711  $dbw->update( 'profiling',
712  array(
713  "pf_count=pf_count+{$eventCount}",
714  "pf_time=pf_time+{$timeSum}",
715  "pf_memory=pf_memory+{$memorySum}",
716  ),
717  array(
718  'pf_name' => $name,
719  'pf_server' => $pfhost,
720  ),
721  __METHOD__ );
722 
723  $rc = $dbw->affectedRows();
724  if ( $rc == 0 ) {
725  $dbw->insert( 'profiling', array( 'pf_name' => $name, 'pf_count' => $eventCount,
726  'pf_time' => $timeSum, 'pf_memory' => $memorySum, 'pf_server' => $pfhost ),
727  __METHOD__, array( 'IGNORE' ) );
728  }
729  // When we upgrade to mysql 4.1, the insert+update
730  // can be merged into just a insert with this construct added:
731  // "ON DUPLICATE KEY UPDATE ".
732  // "pf_count=pf_count + VALUES(pf_count), ".
733  // "pf_time=pf_time + VALUES(pf_time)";
734  }
735  } catch ( DBError $e ) {}
736  }
737 
742  function getCurrentSection() {
743  $elt = end( $this->mWorkStack );
744  return $elt[0];
745  }
746 
752  function debug( $s ) {
753  if ( function_exists( 'wfDebug' ) ) {
754  wfDebug( $s );
755  }
756  }
757 
764  function debugGroup( $group, $s ) {
765  if ( function_exists( 'wfDebugLog' ) ) {
766  wfDebugLog( $group, $s );
767  }
768  }
769 
775  protected function getContentType() {
776  foreach ( headers_list() as $header ) {
777  if ( preg_match( '#^content-type: (\w+/\w+);?#i', $header, $m ) ) {
778  return $m[1];
779  }
780  }
781  return null;
782  }
783 }
ProfileSection\__construct
__construct( $name)
Begin profiling of a function and return an object that ends profiling of the function when that obje...
Definition: Profiler.php:75
$time
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition: hooks.txt:1358
DB_MASTER
const DB_MASTER
Definition: Defines.php:56
Profiler\setTemplated
setTemplated( $t)
Mark this call as templated or not.
Definition: Profiler.php:341
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
Profiler\isStub
isStub()
Return whether this a stub profiler.
Definition: Profiler.php:159
Profiler\calltreeCount
calltreeCount( $stack, $start)
Counts the number of profiled function calls sitting under the given point in the call graph.
Definition: Profiler.php:667
Profiler\addInitialStack
addInitialStack()
Add the inital item in the stack.
Definition: Profiler.php:188
Profiler\$mCalls
$mCalls
Definition: Profiler.php:99
Profiler\$mCollateDone
$mCollateDone
Definition: Profiler.php:101
Profiler\instance
static instance()
Singleton.
Definition: Profiler.php:127
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3659
ProfileSection\__destruct
__destruct()
Definition: Profiler.php:86
Profiler\$mStack
$mStack
Definition: Profiler.php:98
Profiler\getOutput
getOutput()
Returns a profiling output to be stored in debug file.
Definition: Profiler.php:350
wfDebugLog
wfDebugLog( $logGroup, $text, $dest='all')
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Definition: GlobalFunctions.php:1040
wfProfileIn
wfProfileIn( $functionname)
Begin profiling of a function.
Definition: Profiler.php:33
Profiler\getContentType
getContentType()
Get the content type sent out to the client.
Definition: Profiler.php:775
ProfilerStub
Stub profiler that does nothing.
Definition: ProfilerStub.php:29
Profiler\getCurrentSection
getCurrentSection()
Get the function name of the current profiling section.
Definition: Profiler.php:742
$fname
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
Definition: Setup.php:35
$params
$params
Definition: styleTest.css.php:40
wfHostname
wfHostname()
Fetch server name for use in error reporting etc.
Definition: GlobalFunctions.php:1786
wfReadOnly
wfReadOnly()
Check whether the wiki is in read-only mode.
Definition: GlobalFunctions.php:1313
Profiler\getCallTree
getCallTree()
Returns a tree of function call instead of a list of functions.
Definition: Profiler.php:369
$s
$s
Definition: mergeMessageFileList.php:156
Profiler\getInitialTime
getInitialTime( $metric=false)
Get the initial time of the request, based either on $wgRequestTime or $wgRUstart.
Definition: Profiler.php:471
Profiler\isPersistent
isPersistent()
Return whether this profiler stores data.
Definition: Profiler.php:169
Profiler\transactionWritingIn
transactionWritingIn( $server, $db)
Mark a DB as in a transaction with one or more writes pending.
Definition: Profiler.php:267
Profiler\profileOut
profileOut( $functionname)
Called by wfProfieOut()
Definition: Profiler.php:218
Profiler\getRawData
getRawData()
Definition: Profiler.php:618
Profiler\getCallTreeLine
getCallTreeLine( $entry)
Callback to get a formatted line for the call tree.
Definition: Profiler.php:418
Profiler\$mProfileID
$mProfileID
Definition: Profiler.php:101
Profiler\$mPeriods
$mPeriods
Definition: Profiler.php:99
Profiler\getFunctionReport
getFunctionReport()
Returns a list of profiled functions.
Definition: Profiler.php:582
ProfileSection
Class for handling function-scope profiling.
Definition: Profiler.php:60
$total
$total
Definition: Utf8Test.php:92
Profiler\$mTimeMetric
$mTimeMetric
Definition: Profiler.php:100
Profiler\$mCollated
$mCollated
Definition: Profiler.php:98
Profiler\$mWorkStack
$mWorkStack
Definition: Profiler.php:98
Profiler\profileIn
profileIn( $functionname)
Called by wfProfieIn()
Definition: Profiler.php:204
Profiler\debug
debug( $s)
Add an entry in the debug log file.
Definition: Profiler.php:752
Profiler\close
close()
Close opened profiling sections.
Definition: Profiler.php:253
Profiler\calculateOverhead
static calculateOverhead( $profileCount)
Dummy calls to wfProfileIn/wfProfileOut to calculate its overhead.
Definition: Profiler.php:649
$wgRequestTime
$wgRequestTime
Definition: WebStart.php:68
Profiler
Definition: Profiler.php:97
Profiler\getTime
getTime( $metric=false)
Get the initial time of the request, based either on $wgRequestTime or $wgRUstart.
Definition: Profiler.php:438
wfProfileOut
wfProfileOut( $functionname='missing')
Stop profiling of a function.
Definition: Profiler.php:46
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
Profiler\__construct
__construct( $params)
Definition: Profiler.php:112
Profiler\collateData
collateData()
Definition: Profiler.php:499
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
DBError
Database error base class.
Definition: DatabaseError.php:28
Profiler\$mDBTrxHoldingLocks
$mDBTrxHoldingLocks
Definition: Profiler.php:105
wfDebug
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:933
wfWikiID
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
Definition: GlobalFunctions.php:3613
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
ProfileSection\$name
$name
Definition: Profiler.php:61
Profiler\setInstance
static setInstance(Profiler $p)
Set the profiler to a specific profiler instance.
Definition: Profiler.php:150
Profiler\transactionWritingOut
transactionWritingOut( $server, $db)
Mark a DB as no longer in a transaction.
Definition: Profiler.php:311
Profiler\logData
logData()
Log the whole profiling data into the database.
Definition: Profiler.php:679
Profiler\setProfileID
setProfileID( $id)
Definition: Profiler.php:173
Profiler\$__instance
static $__instance
Definition: Profiler.php:110
ProfileSection\$enabled
$enabled
Definition: Profiler.php:62
Profiler\$mDBTrxMethodTimes
$mDBTrxMethodTimes
Definition: Profiler.php:107
$count
$count
Definition: UtfNormalTest2.php:96
Profiler\$mTotals
$mTotals
Definition: Profiler.php:99
Profiler\$mTemplated
$mTemplated
Definition: Profiler.php:101
$output
& $output
Definition: hooks.txt:375
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
$wgProfiler
$wgProfiler
Definition: WebStart.php:107
Profiler\updateTrxProfiling
updateTrxProfiling( $method, $realtime)
Register the name and time of a method for slow DB trx detection.
Definition: Profiler.php:283
Profiler\remapCallTree
remapCallTree( $stack)
Recursive function the format the current profiling array into a tree.
Definition: Profiler.php:379
Profiler\$mDBLockThreshold
$mDBLockThreshold
Definition: Profiler.php:103
name
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at name
Definition: design.txt:12
$t
$t
Definition: testCompression.php:65
$e
if( $useReadline) $e
Definition: eval.php:66
Profiler\debugGroup
debugGroup( $group, $s)
Add an entry in the debug log group.
Definition: Profiler.php:764
Profiler\getProfileID
getProfileID()
Definition: Profiler.php:177