note 105358 added to function.microtime

From: Date: Thu, 11 Aug 2011 10:32:30 +0000
Subject: note 105358 added to function.microtime
Groups: php.notes 
Request: Send a blank email to php-notes+get-182422@lists.php.net to get a copy of this message
<?php define("LOOPCOUNT", 1000); define("GRAP", 5); define("TESTCOUNT", 15); function benchmark($func,$out=TRUE){ static $first=TRUE; if($first){$first=FALSE;benchmark($func,FALSE);} //burn first process if($out) echo $func,": <br/>"; $btime=array(); for($i=0;$i<TESTCOUNT;++$i) { $time = microtime(TRUE); for($x=0;$x< LOOPCOUNT;++$x){ $func(); } $time=microtime(TRUE)-$time; if($x > GRAP) { $btime[]=$time; if($out) echo substr($time,0,8)," "; } } if($out) echo "Average: ", substr(array_sum($btime) / count($btime),0,5) ,"<br/><br/>"; } function test(){ crc32("12345679"); } function test2(){ crc32("1234567a"); } benchmark("test"); benchmark("test2"); ?> output : test: 0.003493 0.003639 0.003493 0.003482 0.003551 0.003499 0.003633 0.003554 0.003486 0.003478 0.003556 0.003491 0.003482 0.003468 0.003456 Average: 0.003 test2: 0.003620 0.003538 0.003540 0.003522 0.003520 0.003599 0.003489 0.003489 0.003509 0.003529 0.003596 0.003525 0.003520 0.003522 0.003617 Average: 0.003 ---- Server IP: 69.147.83.197 Probable Submitter: 49.49.36.104 ---- Manual Page -- http://www.php.net/manual/en/function.microtime.php Edit -- https://master.php.net/note/edit/105358 Del: integrated -- https://master.php.net/note/delete/105358/integrated Del: useless -- https://master.php.net/note/delete/105358/useless Del: bad code -- https://master.php.net/note/delete/105358/bad+code Del: spam -- https://master.php.net/note/delete/105358/spam Del: non-english -- https://master.php.net/note/delete/105358/non-english Del: in docs -- https://master.php.net/note/delete/105358/in+docs Del: other reasons-- https://master.php.net/note/delete/105358 Reject -- https://master.php.net/note/reject/105358 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#182422) next »