Login   Register  
PHP Classes
elePHPant
Icontem

File: readme.txt

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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: 2010-03-02 20:30
Size: 1,429 bytes
 

Contents

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:

<?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