note 92214 added to class.splfixedarray
| From: | chrisstocktonaz at gmail dot com | Date: | Tue, 14 Jul 2009 18:07:21 +0000 |
| Subject: | note 92214 added to class.splfixedarray | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-158291@lists.php.net to get a copy of this message | ||
Note, that this is considerably faster and should be used when the size of the array is known. Here
are some very basic bench marks:
<?php
for($size = 1000; $size < 50000000; $size *= 2) {
echo PHP_EOL . "Testing size: $size" . PHP_EOL;
for($s = microtime(true), $container = Array(), $i = 0; $i < $size; $i++) $container[$i] =
NULL;
echo "Array(): " . (microtime(true) - $s) . PHP_EOL;
for($s = microtime(true), $container = new SplFixedArray($size), $i = 0; $i < $size; $i++)
$container[$i] = NULL;
echo "SplArray(): " . (microtime(true) - $s) . PHP_EOL;
}
// OUTPUT
Testing size: 1000
Array(): 0.00046396255493164
SplArray(): 0.00023293495178223
Testing size: 2000
Array(): 0.00057101249694824
SplArray(): 0.0003058910369873
Testing size: 4000
Array(): 0.0015869140625
SplArray(): 0.00086307525634766
Testing size: 8000
Array(): 0.0024251937866211
SplArray(): 0.00211501121521
Testing size: 16000
Array(): 0.0057680606842041
SplArray(): 0.0041120052337646
Testing size: 32000
Array(): 0.011334896087646
SplArray(): 0.007631778717041
Testing size: 64000
Array(): 0.021990060806274
SplArray(): 0.013560056686401
Testing size: 128000
Array(): 0.053267002105713
SplArray(): 0.030976057052612
Testing size: 256000
Array(): 0.10280108451843
SplArray(): 0.056283950805664
Testing size: 512000
Array(): 0.20657992362976
SplArray(): 0.11510300636292
Testing size: 1024000
Array(): 0.4138810634613
SplArray(): 0.21826505661011
Testing size: 2048000
Array(): 0.85640096664429
SplArray(): 0.46247816085815
Testing size: 4096000
Array(): 1.7242450714111
SplArray(): 0.95304894447327
Testing size: 8192000
Array(): 3.448086977005
SplArray(): 1.96746301651
----
Server IP: 208.69.120.35
Probable Submitter: 64.202.160.65
----
Manual Page -- http://www.php.net/manual/en/class.splfixedarray.php
Edit -- https://master.php.net/note/edit/92214
Del: integrated -- https://master.php.net/note/delete/92214/integrated
Del: useless -- https://master.php.net/note/delete/92214/useless
Del: bad code -- https://master.php.net/note/delete/92214/bad+code
Del: spam -- https://master.php.net/note/delete/92214/spam
Del: non-english -- https://master.php.net/note/delete/92214/non-english
Del: in docs -- https://master.php.net/note/delete/92214/in+docs
Del: other reasons-- https://master.php.net/note/delete/92214
Reject -- https://master.php.net/note/reject/92214
Search -- https://master.php.net/manage/user-notes.php