note 59213 added to function.microtime

From: Date: Tue, 29 Nov 2005 17:37:53 +0000
Subject: note 59213 added to function.microtime
Groups: php.notes 
Request: Send a blank email to php-notes+get-99304@lists.php.net to get a copy of this message
A simple class in PHP5 allowing to know the execution time of a script : <?php class Timer { private $m_Start; public function __construct() { $this->m_Start = 0.0; } private function GetMicrotime() { list($micro_seconds, $seconds) = explode(" ", microtime()); return ((float)$micro_seconds + (float)$seconds); } public function Init() { $this->m_Start = $this->GetMicrotime(); } public function GetTime($Decimals = 2) { return number_format($this->GetMicrotime() - $this->m_Start, $Decimals, '.', ''); } } $MyTimer = new Timer(); $MyTimer->Init(); sleep(1); echo $MyTimer->GetTime(); // Output result -> 1.00 ?> Nico. ---- Manual Page -- http://www.php.net/manual/en/function.microtime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+59213 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59213&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59213&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59213&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59213&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59213&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59213&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59213&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+59213&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#99304) next »