class DBStats

This class keeps track of performance metrics for the database.

Such metrics include read/write query count, and read/write time.

Properties

private $reads
private $writes
private $start_time
private $query_start
private $read_time
private $write_time
private $queries

Methods

__construct()

Constructs a new stats context and logs the current time

void
startQuery()

Begins tracking a query by logging the current time

void
endQuery(string $sql, int $type, bool $count = true)

Ends tracking a query and updates the relevant stats

array
getQueries()

Returns the array of queries issued to the database

array
getStats()

Returns an array of statistics collected

void
Add(DBStats $stats)

Adds another DBStats' stats to this one

Details

at line 19
__construct()

Constructs a new stats context and logs the current time

at line 22
void startQuery()

Begins tracking a query by logging the current time

Return Value

void

at line 30
void endQuery(string $sql, int $type, bool $count = true)

Ends tracking a query and updates the relevant stats

Parameters

string $sql

the query sent to the DB for history

int $type

whether the query was a read or write (or both - bitset)

bool $count

if false, log only the time spent and don't increment the query counters

Return Value

void

at line 49
array getQueries()

Returns the array of queries issued to the database

Return Value

array

at line 55
array getStats()

Returns an array of statistics collected

Return Value

array

{db_reads:int,db_read_time:double,db_writes:int,db_write_time:double,code_time:double,total_time:double}

at line 70
void Add(DBStats $stats)

Adds another DBStats' stats to this one

Parameters

DBStats $stats

Return Value

void