Documentation

rex_timer
in package

Class to stop the script time.

Tags
author

gharlan

Table of Contents

Constants

MICROSEC  = 1000000
MILLISEC  = 1000
SEC  = 1

Methods

__construct()  : mixed
getDelta()  : float
Returns the time difference.
getFormattedDelta()  : string
Returns the formatted time difference.
measure()  : T
Measures the runtime of the given callable.
measured()  : void
Saves the measurement of the given timer.
reset()  : void
Resets the timer.
stop()  : void
Stops the timer.

Constants

MICROSEC

public mixed MICROSEC = 1000000

MILLISEC

public mixed MILLISEC = 1000

Methods

__construct()

public __construct([float $start = null ]) : mixed
Parameters
$start : float = null

Start time

getDelta()

Returns the time difference.

public getDelta([int $precision = self::MILLISEC ]) : float
Parameters
$precision : int = self::MILLISEC

Factor which will be multiplied, for convertion into different units (e.g. 1000 for milli,...)

Return values
float

Time difference

getFormattedDelta()

Returns the formatted time difference.

public getFormattedDelta([int $precision = self::MILLISEC ][, int $decimals = 3 ]) : string
Parameters
$precision : int = self::MILLISEC

Factor which will be multiplied, for convertion into different units (e.g. 1000 for milli,...)

$decimals : int = 3

Number of decimals points

Return values
string

Formatted time difference

measure()

Measures the runtime of the given callable.

public static measure(string $label, callable(): T $callable) : T

On sufficient user permissions - or in debug mode - this timings will be sent over the wire to the browser via server timing api http headers.

Parameters
$label : string
$callable : callable(): T
Tags
template

T

Return values
T

result of callable

measured()

Saves the measurement of the given timer.

public static measured(string $label, self $timer) : void

This method should be used only if the measured code can not be wrapped inside a callable, otherwise use measure().

Parameters
$label : string
$timer : self

reset()

Resets the timer.

public reset() : void

stop()

Stops the timer.

public stop() : void

        
On this page

Search results