PHP Classes

File: readme.txt

Recommend this page to a friend!
  Classes of Pavel Astakhov   CTimer   readme.txt   Download  
File: readme.txt
Role: Example script
Content type: text/plain
Description: Example how to use the CTimer class and explain options for rounding the results.
Class: CTimer
Measure the time elapsed during PHP execution
Author: By
Last change:
Date: 13 years ago
Size: 1,429 bytes


Class file image Download
This class can use for compute the time elapsed for any process (generation of web page, SQL query, etc.).
Easy use, example:

= new CTimer(true); //true for start counting time
... any code ...
'<BR>Runtime: ' . $timer->GetCounting() . ' seconds';

Easy counting SQL query or any function:
= 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';

//... any function code ...

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