PHP Master SplFixedArray

The PHP Master book claims significant performance benefits for SplFixedArray over conventional arrays, ranging from 4.3x for large arrays up to 20x for very small ones (p.350).

I’ve been benchmarking the functions with the intention of using them, but I’m not seeing anywhere near this level of performance enhancement. Indeed for smaller arrays (up to 16 entires) the cycles needed to instantiate the class makes the approach less efficient. Even for larger arrays (32k+ entries) the benefit seems to level out at between 20-40% improvement, rather than the 300-400% claimed.

I’m wondering how the quoted benchmarked figures were compiled. And also whether anybody else has experience of using these functions and has managed to achieve the performance gains suggested.

Ah. Found benchmarking code used in the book’s code archive, and the results are consist with those quoted in the book.

Alas, the code has an error - the timer is restarted after the fixed array has been loaded, so the comparisons between normal and fixed arrays are invalid. Correcting the error confirms that the benefits of using fixed arrays is way less than the book suggests.

Maybe you should write to post-sales dept. to inform them of the errata… that would be great :slight_smile:

I emailed details of the error immediately after posting it here, but only got a canned (and inappropriate) response. I also tracked down the github repo and added a correction there, but the only response there was to refresh the repo wiping out the correction (so I put it back again). Five week’s later and the book’s errata hasn’t been updated - so I’m getting the sense that Sitepoint have sadly become more interested in selling books than ensuring that they’re accurate. A shame, because they used to take way more care.

Hi there, sorry about this. Did you sent the details to or to another address? I’d like to get to the bottom of it for you.

I followed the link on the book’s corrections page. That led to me a contact form where I selected “Report a bug or typo in a Sitepoint book” as the reason for contact. The canned response came from and was timestamped Wed, 25 Jan 2012 22:57:08 +1100. Hope that helps.

I’ll point an editor in this direction for a response. :slight_smile: