note 110633 added to function.microtime

From: Date: Thu, 15 Nov 2012 06:44:16 +0000
Subject: note 110633 added to function.microtime
Groups: php.notes 
Request: Send a blank email to php-notes+get-191995@lists.php.net to get a copy of this message
time() and microtime() return consecutive times as obtained from execution engine. Some microseconds elapse between these two events and that's what an observer sees as a different return times. code to test this (although it still has some overhead, i'll assume that it's good enough for demonstration purposes) for ($i = 0; $i < 1000000; $i++) { $time = time()."|".microtime();//these two calls should happen as close as possible, and concatenation might spend some time (consecutive variable value assignment will spend even more time, on my computer, twice as much at best) $parts = explode("|", $time); $parts[1] = implode(".", array(end(explode(" ", $parts[1])), end(explode(".", reset(explode(" ", $parts[1]))))));//making precise microtime if($parts[0] < floor($parts[1])) { echo "time() returned: $parts[0]\n<br/>microtime() returned: $parts[1]\n\n<br/><br/>"; } } ---- Server IP: 69.147.83.199 Probable Submitter: 93.87.96.75 ---- Manual Page -- http://www.php.net/manual/en/function.microtime.php Edit -- https://master.php.net/note/edit/110633 Del: integrated -- https://master.php.net/note/delete/110633/integrated Del: useless -- https://master.php.net/note/delete/110633/useless Del: bad code -- https://master.php.net/note/delete/110633/bad+code Del: spam -- https://master.php.net/note/delete/110633/spam Del: non-english -- https://master.php.net/note/delete/110633/non-english Del: in docs -- https://master.php.net/note/delete/110633/in+docs Del: other reasons-- https://master.php.net/note/delete/110633 Reject -- https://master.php.net/note/reject/110633 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#191995) next »