MediaWiki REL1_41
Timing Class Reference

An interface to help developers measure the performance of their applications. More...

Inherits LoggerAwareInterface.

Collaboration diagram for Timing:

Public Member Functions

 __construct (array $params=[])
 
 clearMarks ( $markName=null)
 
 getEntries ()
 
 getEntriesByType ( $entryType)
 
 getEntryByName ( $name)
 
 mark ( $markName)
 Store a timestamp with the associated name (a "mark")
 
 measure ( $measureName, $startMark='requestStart', $endMark=null)
 This method stores the duration between two marks along with the associated name (a "measure").
 
 setLogger (LoggerInterface $logger)
 Sets a logger instance on the object.
 

Protected Attributes

LoggerInterface $logger
 

Detailed Description

An interface to help developers measure the performance of their applications.

This interface closely matches the W3C's User Timing specification. The key differences are:

  • The reference point for all measurements which do not explicitly specify a start time is $_SERVER['REQUEST_TIME_FLOAT'], not navigationStart.
  • Successive calls to mark() and measure() with the same entry name cause the previous entry to be overwritten. This ensures that there is a 1:1 mapping between names and entries.
  • Because there is a 1:1 mapping, instead of getEntriesByName(), we have getEntryByName().

The in-line documentation incorporates content from the User Timing Specification https://www.w3.org/TR/user-timing/ Copyright © 2013 World Wide Web Consortium, (MIT, ERCIM, Keio, Beihang). https://www.w3.org/Consortium/Legal/2015/doc-license

Since
1.27

Definition at line 45 of file Timing.php.

Constructor & Destructor Documentation

◆ __construct()

Timing::__construct ( array $params = [])

Definition at line 53 of file Timing.php.

References clearMarks(), and setLogger().

Member Function Documentation

◆ clearMarks()

Timing::clearMarks ( $markName = null)
Parameters
string | null$markNameThe name of the mark that should be cleared. If not specified, all marks will be cleared.

Definition at line 88 of file Timing.php.

Referenced by __construct().

◆ getEntries()

Timing::getEntries ( )
Returns
array[] All entries in chronological order.

Definition at line 164 of file Timing.php.

◆ getEntriesByType()

Timing::getEntriesByType ( $entryType)
Parameters
string$entryType
Returns
array[] Entries (in chronological order) that have the same value for the entryType attribute as the $entryType parameter.

Definition at line 174 of file Timing.php.

◆ getEntryByName()

Timing::getEntryByName ( $name)
Parameters
string$name
Returns
array|null Entry named $name or null if it does not exist.

Definition at line 189 of file Timing.php.

Referenced by measure().

◆ mark()

Timing::mark ( $markName)

Store a timestamp with the associated name (a "mark")

Parameters
string$markNameThe name associated with the timestamp. If there already exists an entry by that name, it is overwritten.
Returns
array The mark that has been created.

Definition at line 74 of file Timing.php.

◆ measure()

Timing::measure ( $measureName,
$startMark = 'requestStart',
$endMark = null )

This method stores the duration between two marks along with the associated name (a "measure").

If neither the startMark nor the endMark argument is specified, measure() will store the duration from $_SERVER['REQUEST_TIME_FLOAT'] to the current time. If the startMark argument is specified, but the endMark argument is not specified, measure() will store the duration from the most recent occurrence of the start mark to the current time. If both the startMark and endMark arguments are specified, measure() will store the duration from the most recent occurrence of the start mark to the most recent occurrence of the end mark.

Parameters
string$measureName
string$startMark
string | null$endMark
Returns
array|bool The measure that has been created, or false if either the start mark or the end mark do not exist.

Definition at line 123 of file Timing.php.

References getEntryByName().

◆ setLogger()

Timing::setLogger ( LoggerInterface $logger)

Sets a logger instance on the object.

Parameters
LoggerInterface$logger

Definition at line 63 of file Timing.php.

Referenced by __construct().

Member Data Documentation

◆ $logger

LoggerInterface Timing::$logger
protected

Definition at line 51 of file Timing.php.


The documentation for this class was generated from the following file: