This class can use for compute the time elapsed for any process (generation of web page, SQL query, etc.).
Easy use, example:
<?php
$timer = new CTimer(true); //true for start counting time
... any code ...
echo '<BR>Runtime: ' . $timer->GetCounting() . ' seconds';
?>
Easy counting SQL query or any function:
<?php
$timer = new CTimer(true); //true for start counting time
public $sqltimer = new CTimer();
//... any code ...
SQLquery("SELECT * FROM db");
//... any code ...
SQLquery("SELECT * FROM user");
//... any code ...
echo '<BR>Runtime: ' . $timer->GetCounting() . '(SQL: ' . $sqltimer->GetCounting() . ') seconds';
function SQLquery($query)
{
$sqltimer->Start();
//... any function code ...
$sqltimer->Stop();
}
?>
Explain options for rounding the results:
By default GetCounting() return time in seconds with cute rounding precision equal to three.
Example returns GetCounting()
for counting 0.011821031570435:
$timer->GetCounting() return 0.012
$timer->GetCounting(6) return 0.011821
$timer->GetCounting(6, false) return 0.011821
$timer->GetCounting(false) return 0.011821031570435
for counting 165.71492307472:
$timer->GetCounting() return 166
$timer->GetCounting(6) return 165.715
$timer->GetCounting(6, false) return 165.714923
$timer->GetCounting(false) return 165.71492307472
|