note 34934 deleted from function.in-array by danbrown

From: Date: Mon, 08 Jun 2009 21:46:39 +0000
Subject: note 34934 deleted from function.in-array by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-156527@lists.php.net to get a copy of this message
Note Submitter: morten at nilsen dot com ---- either the benchmark I used, or the one used in an earlier comment is flawed, or this function has seen great improvement... on my system (a Duron 1GHz box) the following benchmark script gave me pretty close to 1 second execution time average when used with 355000 runs of in_array() (10 runs) <?php $average = 0; for ($run=0;$run<10;++$run) { $test_with=array( 1=>array(explode(":", ":1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:")), 2=>array(explode(":", ":21:22:23:24:25:26:27:28:29:210:211:212:213:214:215:")), 3=>array(explode(":", ":14:15:23:24:25:26:27:28:29:210:211:212:213:214:215:")) ); $start = microtime(); for($i=0;$i<=355000;++$i) { in_array($i, $test_with); } $end = microtime(); $start = explode(" ",$start); $end = explode(" ",$end); $start = $start[1].trim($start[0],'0'); $end = $end[1].trim($end[0],'0'); $time = $end - $start; $average += $time; echo "run $run: $time<br>"; } $average /= 10; echo "average: $average"; ?>

« previous php.notes (#156527) next »