note 103271 added to class.splfixedarray

From: Date: Tue, 05 Apr 2011 09:28:46 +0000
Subject: note 103271 added to class.splfixedarray
Groups: php.notes 
Request: Send a blank email to php-notes+get-178506@lists.php.net to get a copy of this message
Fix for benchmark from nairbv AT yahoo DOT com: <?php $elements = 20; for($size = 1000; $size < 50000000; $size *= 2) { echo PHP_EOL . "Testing size: $size" . PHP_EOL; for($s = microtime(true), $i = 0; $i < $size; $i++) { for($j=0,$container=array();$j < $elements; $j++ ) { $container[$j] = NULL; } } echo "Array(): " . (microtime(true) - $s) . PHP_EOL; for($s = microtime(true), $i = 0; $i < $size; $i++) { for( $j=0,$container=new SplFixedArray($elements);$j<$elements;$j++) { $container[$j] = NULL; } } echo "SplArray(): " . (microtime(true) - $s) . PHP_EOL; } ?> Testing size: 1000 Array(): 0.0060701370239258 SplArray(): 0.00553297996521 Testing size: 2000 Array(): 0.012112855911255 SplArray(): 0.011138916015625 Testing size: 4000 Array(): 0.024483919143677 SplArray(): 0.02207088470459 Testing size: 8000 Array(): 0.04853892326355 SplArray(): 0.04426097869873 Testing size: 16000 Array(): 0.096042156219482 SplArray(): 0.087089061737061 Testing size: 32000 Array(): 0.19448709487915 SplArray(): 0.17775988578796 Testing size: 64000 Array(): 0.3905029296875 SplArray(): 0.35034704208374 Testing size: 128000 Array(): 0.77571702003479 SplArray(): 0.71178388595581 Testing size: 256000 Array(): 1.5540537834167 SplArray(): 1.4021430015564 Testing size: 512000 Array(): 3.0827419757843 SplArray(): 2.8024659156799 Testing size: 1024000 Array(): 6.1439890861511 SplArray(): 5.6017310619354 Testing size: 2048000 Array(): 12.37149810791 SplArray(): 11.197249889374 Testing size: 4096000 Array(): 24.562648057938 SplArray(): 22.566251039505 Testing size: 8192000 Array(): 49.470867872238 SplArray(): 44.795397043228 And, if we set 2000 elements (not 20), the results are more clean: Testing size: 1000 Array(): 0.66445899009705 SplArray(): 0.43877983093262 Testing size: 2000 Array(): 1.3532190322876 SplArray(): 0.87716388702393 Testing size: 4000 Array(): 2.7067821025848 SplArray(): 1.7568969726562 Testing size: 8000 Array(): 5.4080109596252 SplArray(): 3.526603937149 ---- Server IP: 82.177.164.100 Probable Submitter: 193.222.135.194 ---- Manual Page -- http://www.php.net/manual/en/class.splfixedarray.php Edit -- https://master.php.net/note/edit/103271 Del: integrated -- https://master.php.net/note/delete/103271/integrated Del: useless -- https://master.php.net/note/delete/103271/useless Del: bad code -- https://master.php.net/note/delete/103271/bad+code Del: spam -- https://master.php.net/note/delete/103271/spam Del: non-english -- https://master.php.net/note/delete/103271/non-english Del: in docs -- https://master.php.net/note/delete/103271/in+docs Del: other reasons-- https://master.php.net/note/delete/103271 Reject -- https://master.php.net/note/reject/103271 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#178506) next »