PHP implements a class instance for calculating execution time, and the PHP instance
The examples in this article describe the classes that PHP implements to calculate execution time. Share to everyone for your reference. Specific as follows:
With this PHP class, the execution time of a calculation function or a piece of code is simple.
<?phpclass 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; } }};? >
The usage examples are as follows:
<?php $timer = new C_timer; $timer->start (); echo ""; $timer->stop (); echo $timer->elapsed ();? >
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/986073.html www.bkjia.com true http://www.bkjia.com/PHPjc/986073.html techarticle PHP implements a class instance for calculating execution time, and the example in this article describes the classes that PHP implements to calculate execution time. Share to everyone for your reference. As follows: With this ...