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

Simon Holywell: HHVM vs Zephir vs PHP: The showdown

Chris Shiflett's Blog: Sorting Multi-Dimensional Arrays in PHP

Avent Labs Blog: PHP framework comparison benchmarks

Stoyan Stefanov's Blog: Performance Advent Calendar 2009

Drupal.org: Tuning your server for optimal Drupal performance


Community Events





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


deployment language laravel interview list podcast tips update introduction opinion community install symfony package api series framework zendserver release library

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