note 57230 added to function.microtime

From: Date: Tue, 27 Sep 2005 18:55:20 +0000
Subject: note 57230 added to function.microtime
Groups: php.notes 
Request: Send a blank email to php-notes+get-95895@lists.php.net to get a copy of this message
For highly accurate performance timing of an algorithm, you'll need to take into account the time it takes to run microtime() and/or a replacement function such as the microtime_float. Make sure to keep all calculations outside the timers. Here's a small sample. Please note that it takes into account the assignment of one variable as well during calibration, since this will happen in the actual test as well. $calibrate_begin = microtime_float(); $calibrate_end = microtime_float(); $overhead_time = $calibrate_end - $calibrate_begin; $performance_begin = microtime_float(); // test $performance_end = microtime_float(); $result_time = ($performance_end - $performance_begin) - $overhead_time; For even more accuracy in testing, loop the ENTIRE code a number of times. If you just loop the calibration and test independantly, you'll get misleading results due to time spent running the loop codes themselves. ---- Manual Page -- http://www.php.net/manual/en/function.microtime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+57230 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57230&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57230&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57230&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57230&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57230&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57230&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57230&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+57230&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#95895) next »