News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Shay Ben Moshe's Blog:
PHP's native array vs SplFixedArray performance
April 28, 2011 @ 09:06:01

Shay Ben Moshe has put together a quick post today where he benchmarks array handling performance differences between PHP's native array and the newer SplFixedArray data structure that's a part of the Standard PHP Library that comes with any recent version of the language.

In PHP, arrays are one of the most fundamental data structures. We use them everywhere. They are very flexible, because they are implemented as associative arrays, and therefore let us use both string and integer keys. They are also unlimited in size, in most languages arrays are fixed-sized, but this is not the case in PHP. With that in mind, there still is a drawback. It damages performance. The solution for this problem may be SplFixedArray. But, it is not a perfect solution.

He points out two major differences - the SplFixedArray is, well, a fixed size and the fact that it can only use integer keys (no associative arrays here). He created three tests to compare the performance of the two:

  • Writing data to the array
  • Reading data from the array
  • Getting a random value from the array

Each of these are measured in terms of runtime and/or memory usage. If you'd like to try out the tests for yourself, you can download the files needed. I won't cover the results of the tests here, though - you'll need to visit the post for that!

0 comments voice your opinion now!
native array splfixedarray performance benchmark runtime memory


blog comments powered by Disqus

Similar Posts

Systems Architect Blog: Apache2 vs Nginx for PHP application

Christopher Jones' Blog: Temporary LOBS in PHP's OCI8 Extension. Instant Client.

Ibuildings techPortal: Optimising MHVC Web Applications for Performance

Evert Pot's Blog: PHP: Arrays vs. Objects

ONLamp.com: Microsoft Report: PHP on Windows: Community Involvement Improves Performance


Community Events





Don't see your event here?
Let us know!


security community mvc symfony laravel library series tool framework update version language opinion podcast composer voicesoftheelephpant introduction package release interview

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework