News Feed
Jobs 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

Shay Ben Moshe's Blog: PDO Persistent Connection Analysis

Michael Bommarito\'s Blog: Day Three - PHP5 vs PHP6 Benchmark

NetTuts.com: PDO vs. MySQLi: Which Should You Use?

Matt Farina's Blog: SplFixedArray, An Underutilized PHP Gem

Paul Jones' Blog: Comparing Benchmark Tools


Community Events











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


language install package example podcast release database hhvm hack introduction composer facebook unittest performance application framework project component symfony2 security

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