PHP Benchmarking Script - Timer
Time the execution of your script using this simple script.
I made a small and simple benchmarking script to time a rather processor intensive script I developed lately. I wrapped it inside a class in case I have the need to use it again.
class Timer {
var $start_time = 0;
var $end_time = 0;
function Timer($start=0) {
if($start) $this->start();
}
function start() {
$timeparts = explode(' ',microtime());
$this->start_time = $timeparts[1].substr($timeparts[0],1);
}
function stop($show=1,$decimal_place=8) {
$timeparts = explode(" ",microtime());
$this->end_time = $timeparts[1].substr($timeparts[0],1);
if($show) $this->display($decimal_place);
}
function display($decimal_place=8) {
echo number_format(bcsub($this->end_time,$this->start_time,6),$decimal_place);
echo "s";
}
}
You can call the script like this...
$T = new Timer();
$T->start();
// ... do whatever that must be timed ...
$T->stop();
Execution time for this page : 0.00005889s