public class Profiler

class.profiler.php #13

The Profiler class tracks various performance metrics while a Symphony page is being generated. It provides a basic stopwatch functionality and memory usage statistics. Profiling occurs in both the Frontend and Administration execution. The Profiler implements the Singleton interface.

Methods

static Profiler instance()

Returns the Profiler instance, creating one if it does not exist

array retrieve(integer $index)

Given an index, return the sample at that position otherwise just return all samples.

Parameters
  • $index integerThe array index to return the sample for

Returns

If no $index is passed an array of all the sample arrays are returned otherwise just the sample at the given $index will be returned.

array retrieveByMessage(string $msg)

Returns a sample by message, if no sample is found, an empty array is returned

Parameters
  • $msg stringThe name of the sample to return

array retrieveGroup(string $group)

Returns all the samples that belong to a particular group.

static array retrieveLast()

Returns the last record from the $_records array

integer retrieveTotalMemoryUsage()

Returns the total memory usage from all samples taken by comparing each sample to the base memory sample.

Returns

Memory usage in bytes.

integer retrieveTotalRunningTime()

Returns the difference between when the Profiler was initialised (aka $_starttime) and the last record the Profiler has.

void sample(string $msg, integer $type, string $group, integer $queries)

This function creates a new report in the $_samples array where the message is the name of this report. By default, all samples are compared to the $_starttime but if the PROFILE_LAP constant is passed, it will be compared to specific $_seed timestamp. Samples can grouped by type (ie. Datasources, Events), but by default are grouped by 'General'. Optionally, the number of SQL queries that have occurred since either $_starttime or $_seed can be passed. Memory usage is taken with each sample which measures the amount of memory used by this script by PHP at the time of sampling.

Parameters
  • $msg stringA description for this sample

  • $type integerEither PROFILE_RUNNING_TOTAL or PROFILE_LAP

  • $group stringAllows samples to be grouped together, defaults to General.

  • $queries integerThe number of MySQL queries that occurred since the $_starttime or $_seed

static void seed(integer $time)

Sets the seed to be a timestamp so that time profiling will use this as a starting point

Parameters
  • $time integerThe time in seconds

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details