The examples in this article describe the classes that the PHP implementation uses to compute execution times. Share to everyone for your reference. Specifically as follows:
With this PHP class, the calculation function or a piece of code execution time is simple
<?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 _u = substr ($this->t_start,0,10);
$start _s = substr ($this->t_start,11,10);
$stop _u = substr ($this->t_stop,0,10);
$stop _s = substr ($this->t_stop,11,10);
$start _total = doubleval ($start _u) + $start _s;
$stop _total = doubleval ($stop _u) + $stop _s;
$this->t_elapsed = $stop _total-$start _total;
Return $this->t_elapsed;}}
;
? >
Examples of usage are as follows:
<?php
$timer = new C_timer;
$timer->start ();
echo "
I hope this article will help you with your PHP program design.