PX : code

timer by David Sklar
Download this code


<?php

class c_Timer {
    var 
$t_start 0;
    var 
$t_stop 0;
    var 
$t_elapsed 0;
    
    function 
start() { $this->t_start microtime(); }
    function 
stop()  { $this->t_stop  microtime(); }

    function 
elapsed() {
        if (
$this->t_elapsed) {
            return 
$this->t_elapsed;
        } else {
        
$start_mt explode (" "$this->t_start);
        
$stop_mt explode (" "$this->t_stop);
        
$start_total doubleval($start_mt[0]) + $start_mt[1];
        
$stop_total  doubleval($stop_mt[0]) + $stop_mt[1];
            
$this->t_elapsed $stop_total $start_total;
            return 
$this->t_elapsed;
        }
    }
};

/* Here's an example usage:

    $timer = new c_Timer;

    $timer->start();
    echo "<hr>";
    $timer->stop();

    echo $timer->elapsed();

*/
?>
 

Comments or questions?
PX is running PHP 5.2.17
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.