News Feed
Sections




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

Matt Butcher's Blog:
A Set of Objects in PHP Arrays vs. SplObjectStorage
June 19, 2009 @ 13:46:33

The Standard PHP Library offers PHP developers some excellent tools that, in some cases, can make quite a bit of performance difference than some of their normal counterparts in the rest of the language. In this post from Matt Butcher, two features are compared - normal arrays and the SplObjectStorage feature of the SPL.

One of my projects, QueryPath, performs many tasks that require maintaining a set of unique objects. In my quest to optimize QueryPath, I have been looking into various ways of efficiently storing sets of objects in a way that provides expedient containment checks. [...] Recently I narrowed the list of candidates down to two methods: Use good old fashioned arrays to emulate a hash set or use the SPLObjectStorage system present in PHP 5.2 and up.

He works through the comparison, showing how each of them can emulate the hashed set with the goal of being able to easily iterate and simple to search. The result is that PHP's normal arrays best the SplObjectStorage object in his benchmarking (code included).

1 comment voice your opinion now!
hash comparison array splobjectstore


blog comments powered by Disqus

Similar Posts

Zend Developer Zone: Paging Data Sets With PEAR Pager

ProDevTips: Sorting 2D-arrays in PHP - anectodes and reflections

Matt Butcher's Blog: A Set of Objects in PHP: Arrays vs. SplObjectStorage

Zend PHP Certification Blog: PHP Sorting Functions

Freek Lijten's Blog: Currently on PHP's internals...


Community Events

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


symfony2 introduction opinion api laravel community configure podcast series php7 performance framework conference release install language application library example interview

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