note 124555 added to class.splfixedarray
| From: | herhor67 at interia dot pl | Date: | Tue, 31 Dec 2019 18:23:02 +0000 |
| Subject: | note 124555 added to class.splfixedarray | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-213716@lists.php.net to get a copy of this message | ||
Memory usage for arrays of 1132766 ints (data derived from some 1kx1k img):
Regular: 76453160B (67.5B/int)
SplFixed: 18898744B (16.7B/int)
In my application, SFA uses 75% less RAM, which is a life-saver.
Speed comparison:
Regular: 449ms
SplFixed (resized before every element): 791ms
SplFixed (fully preallocated): 392ms
SplFixed (preall-d to 1M and then resized): 547ms
Pros and cons:
+ much more efficient RAM-wise
+ a bit faster if max size is known
~ a bit slower if max size is only approximated
- much slower if max size is not known
- cannot be used with most array functions
To sum up:
SplFixedArray is a very good choice for storing giant amount of data, though only as long as you at
least roughly know the size and can work without array functions.
----
Server IP: 45.112.84.4
Probable Submitter: 185.85.3.168 (proxied: 83.4.195.47)
----
Manual Page -- http://php.net/manual/en/class.splfixedarray.php
Edit -- https://master.php.net/note/edit/124555
Del: integrated -- https://master.php.net/note/delete/124555/integrated
Del: useless -- https://master.php.net/note/delete/124555/useless
Del: bad code -- https://master.php.net/note/delete/124555/bad+code
Del: spam -- https://master.php.net/note/delete/124555/spam
Del: non-english -- https://master.php.net/note/delete/124555/non-english
Del: in docs -- https://master.php.net/note/delete/124555/in+docs
Del: other reasons-- https://master.php.net/note/delete/124555
Reject -- https://master.php.net/note/reject/124555
Search -- https://master.php.net/manage/user-notes.php