Timer
in package

This is the Timer class.

This class allows us to check times on processes or code-blocks.

Table of Contents

END_SUFFIX  = '_End'
START_SUFFIX  = '_Start'
addFlag() Add new flag to the timer  : void
addTag() Add new tag to the timer  : void
checkTimers() Return the defined timers divided on running state and on finished state  : array<string|int, mixed>
getElapsedTime() Returns the time elapsed from start until now, or until the given flag.  : number
getLoggedTime() Return the logged timer time  : float
getTimeBetweenFlags() Return an array with the logged time between flags.  : array<string|int, mixed>
getTimer() Returns a Timer instance.  : Timer
getTimers() Return the defined timers  : array<string|int, Timer>
measureMethod() Function that concentrates the measurement of time for a method  : float
start() Starts the timer  : void
stop() Stops the timer  : void

Constants

END_SUFFIX

public mixed END_SUFFIX = '_End'

START_SUFFIX

public mixed START_SUFFIX = '_Start'

Methods

addFlag()

Add new flag to the timer

public addFlag(string $flag[, bool $overwrite = false ]) : void
Parameters
$flag : string
$overwrite : bool = false
Tags
throws
TimerException
Return values
void

addTag()

Add new tag to the timer

public addTag(string $tag, string $value) : void
Parameters
$tag : string
$value : string
Tags
throws
TimerException
Return values
void

checkTimers()

Return the defined timers divided on running state and on finished state

public static checkTimers() : array<string|int, mixed>
Return values
array<string|int, mixed>

getElapsedTime()

Returns the time elapsed from start until now, or until the given flag.

public getElapsedTime([string $flag = '' ]) : number
Parameters
$flag : string = ''
Tags
throws
TimerException
Return values
number

getLoggedTime()

Return the logged timer time

public getLoggedTime() : float
Return values
float

getTimeBetweenFlags()

Return an array with the logged time between flags.

public getTimeBetweenFlags() : array<string|int, mixed>
Return values
array<string|int, mixed>

getTimer()

Returns a Timer instance.

public static getTimer(string $key) : Timer

If is not setted, this method will set it.

Parameters
$key : string
Return values
Timer

getTimers()

Return the defined timers

public static getTimers() : array<string|int, Timer>
Return values
array<string|int, Timer>

measureMethod()

Function that concentrates the measurement of time for a method

public measureMethod(callable $method[, bool $saveLog = false ]) : float
Parameters
$method : callable
$saveLog : bool = false
Return values
float

stop()

Stops the timer

public stop([bool $saveLog = false ]) : void
Parameters
$saveLog : bool = false
Tags
throws
TimerException
Return values
void

Search results