コード例 #1
0
ファイル: runTime.class.php プロジェクト: beney/php_collect
<?php

//////////////////////////////
// get the program run time //
//////////////////////////////
// example
$runTime = new \runTime();
$runTime->start();
// do some thing
sleep(1);
$runTime->stop();
echo 'spent:', $runTime->spent();
class runTime
{
    private $starTime;
    private $stopTime;
    private function getMicTime()
    {
        $mictime = microtime();
        list($usec, $sec) = explode(' ', $mictime);
        return (double) $usec + (double) $sec;
    }
    public function start()
    {
        $this->starTime = $this->getMicTime();
    }
    public function stop()
    {
        $this->stopTime = $this->getMicTime();
    }
    public function spent()