PHP Classes

Execution Time Tracker: Keep track of the time PHP scripts take to execute

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 329 All time: 7,153 This week: 455Up
Version License PHP version Categories
runtimelogger 1.0.0Free for non-comm...5.0PHP 5, Time and Date, Performance and...
Description 

Author

This class can keep track of the time PHP scripts take to execute.

It gets the time in microseconds at each given moment the class is called adding milestones associated to optional text labels.

At the end it returns an array with the times the elapsed between each milestone.

Picture of Md. Shahadat Hossain Khan Razon
  Performance   Level  
Name: Md. Shahadat Hossain ... <contact>
Classes: 14 packages by
Country: Bangladesh Bangladesh
Age: 43
All time rank: 2986 in Bangladesh Bangladesh
Week rank: 276 Up6 in Bangladesh Bangladesh Equal

Example

<?php

ini_set
('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include_once
'RunTimeLogger.php';

class
A{
    public
$timer;
    function
__construct(){
       
$this->timer=new RunTimeLogger();
    }
    public function
runAnyMethod(){
       
$this->timer->milestone(__METHOD__.'.start');
        try{
           
sleep(10);
        }catch (
Exception $e){
           
$this->timer->milestone(__METHOD__.'.sleepfail');
        }
       
$this->timer->milestone(__METHOD__.'.end');
    }
}

$timer=new RunTimeLogger(4, false);
$obj=new A();
## any other script
for($i=0; $i<99999999; $i++) $j='any task!';
$timer('loopdone');
$timer1=new RunTimeLogger(false);
$timer2=new RunTimeLogger('simple timer of shahadat');
$obj->runAnyMethod();
echo
'$obj->runAnyMethod() log: '.$timer('anymethodrundone').'<br />';
echo
'just echo last log: '.$timer.'<br />';
for(
$i=0; $i<999; $i++) $j='another task!';
$timer('task2done');
echo
'<h3>now lets see log!</h3>
        <h5>global timer</h5><pre>'
.print_r($timer(true), true).'</pre>
        <h5>class timer</h5><pre>'
.print_r($obj->timer->get(true), true).'</pre>
        <h5>timer that didnot started</h5><pre>'
.print_r($timer1(true), true).'</pre>
                <p>end of log</p>'
;




  Files folder image Files  
File Role Description
Plain text file RunTimeLogger.php Class RunTimeLogger Class
Accessible without login Plain text file eg1.php Example RunTimeLogger Example

 Version Control Unique User Downloads Download Rankings  
 0%
Total:329
This week:0
All time:7,153
This week:455Up
User Comments (1)
bad bad bad coding
9 years ago (Menahem Begin)
2%Star