News Feed
Sections




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

Davey Shafik's Blog:
Faster Arrays
November 07, 2011 @ 08:54:58

In this new post to his blog Davey Shafik looks at an alternative to the traditional arrays most scripts use - something a little faster and more specific: SplFixedArray, part of the Standard PHP Library included with every release.

The SplFixedArray class provides a super-fast, fixed size array implementation. There are some limitations however, first you must use numeric keys and secondly you cannot use anonymous assignment (i.e. $array[] = 'value';). You'll notice one requirement was missing, that it should have a fixed size. While having a fixed size is what will bring you the speed increase it's actually not a requirement that the size be fixed.

Because of these restrictions, the SplFixedArray is faster than its cousin - between 20 and 40 percent faster, depending on the size of the array. He includes a few snippets in the the post - one showing how he benchmarked the differences against simple arrays and another showing a more advanced example with another SPL type, a FilterIterator.

0 comments voice your opinion now!
spl splfixedarray array benchmark filteriterator


blog comments powered by Disqus

Similar Posts

Maarten Balliauw's Blog: LINQ for PHP (Language Integrated Query for PHP)

Paul Jones' Blog: How Fast Is Your Framework?

Paul Jones' Blog: Running The Symfony 2 Benchmarks

Sebastian Bergmann's Blog: Benchmark of PHP Branches 3.0 through 5.3-CVS

Gonzalo Ayuso's Blog: PHP Template Engine Comparison. Part 2 (vs Plain PHP)


Community Events





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


list laravel threedevsandamaybe voicesoftheelephpant framework introduction release code conference series podcast tips symfony interview community bugfix language deployment api zendserver

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