<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Sat, 18 May 2013 03:28:37 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Davey Shafik's Blog: Faster Arrays]]></title>
      <guid>http://www.phpdeveloper.org/news/17091</guid>
      <link>http://www.phpdeveloper.org/news/17091</link>
      <description><![CDATA[<p>
In <a href="http://daveyshafik.com/archives/30320-faster-arrays.html">this new post</a> to his blog <i>Davey Shafik</i> looks at an alternative to the traditional <a href="http://php.net/arrays">arrays</a> most scripts use - something a little faster and more specific: <a href="http://php.net/splfixedarray">SplFixedArray</a>, part of the <a href="http://php.net/spl">Standard PHP Library</a> included with every release.
</p>
<blockquote>
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.
</blockquote>
<p>
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 <a href="http://php.net/filteriterator">FilterIterator</a>.
</p>]]></description>
      <pubDate>Mon, 07 Nov 2011 08:54:58 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Matt Farina's Blog: SplFixedArray, An Underutilized PHP Gem]]></title>
      <guid>http://www.phpdeveloper.org/news/16838</guid>
      <link>http://www.phpdeveloper.org/news/16838</link>
      <description><![CDATA[<p>
<i>Matt Farina</i> has a new post today looking at an "underutilized gem" he's found in the offerings of the Standard PHP Library (SPL) - the <a href="http://engineeredweb.com/blog/11/9/splfixedarray-underutilized-php-gem">SplFixedArray</a>.
</p>
<blockquote>
Arrays in PHP are not arrays per the typical <a href="http://en.wikipedia.org/wiki/Array_data_type">array data type</a>. Instead, as Matt Butcher recently pointed out <a href="http://technosophos.com/content/php-arrays-are-not-arrays">arrays in PHP are similar to hashes in other languages</a>. This can be a very important point to know when tracking down bugs in code and to programmers coming to PHP from other languages. But, what if we wanted something like a traditional array data type? Maybe something that preserved numeric order. Enter <A href="http://engineeredweb.com/blog/11/9/splfixedarray">SplFixedArray</a>.
</blockquote>
<p>
He gives an example of using the SplFixedArray object versus the normal array variables in a simple PHP snippet showing the preservation of numbering order. He also touches on the memory consumption difference between the two, with the fixed array coming in quite a bit lower than the normal array data type (around 25% based on his basic testing). There are some catches to using it, though including incompatibility with array methods and the fact that it doesn't implement things like Iterator or Countable interfaces.
</p>]]></description>
      <pubDate>Fri, 09 Sep 2011 10:43:11 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Shay Ben Moshe's Blog: PHP's native array vs SplFixedArray performance ]]></title>
      <guid>http://www.phpdeveloper.org/news/16263</guid>
      <link>http://www.phpdeveloper.org/news/16263</link>
      <description><![CDATA[<p>
<i>Shay Ben Moshe</i> has put together a quick post today where he <a href="http://blog.shay.co/phps-native-array-vs-splfixedarray-performance/">benchmarks array handling performance</a> differences between PHP's native array and the newer SplFixedArray data structure that's a part of the <a href="http://php.net/spl">Standard PHP Library</a> that comes with any recent version of the language.
</p>
<blockquote>
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.
</blockquote>
<p>
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:
</p>
<ul>
<li>Writing data to the array
<li>Reading data from the array
<li>Getting a random value from the array
</ul>
<p>
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 <a href="http://blog.shay.co/files/arraybenchmark.rar">download the files</a> needed. I won't cover the results of the tests here, though - you'll need to <a href="http://blog.shay.co/phps-native-array-vs-splfixedarray-performance/">visit the post</a> for that!
</p>]]></description>
      <pubDate>Thu, 28 Apr 2011 09:06:01 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Rafael Dohms' Blog: SPL: a hidden gem]]></title>
      <guid>http://www.phpdeveloper.org/news/12657</guid>
      <link>http://www.phpdeveloper.org/news/12657</link>
      <description><![CDATA[<p>
Earlier this month <i>Rafael Dohms</i> posted <a href="http://www.rafaeldohms.com.br/2009/06/03/spl-a-hidden-gem/en/">a new article</a> to his blog looking at a feature of PHP it seems not every developer knows about - the Standard PHP Library (or SPL).
</p>
<blockquote>
By a show of hands, how many people here ever heard of SPL? How many already used it? Chances are most of you didn't raise your hands, and some might even have a confused look on their faces. Indeed that is the sad reality when it comes to SPL, but What is SPL?
</blockquote>
<p>
He goes on to look at a few different things the SPL has to offer like autoloader overloading, iterators (with an included list of 21 of them) and the SplFixedArray that can be used to help speed up array access and manipulation.
</p>]]></description>
      <pubDate>Wed, 10 Jun 2009 11:19:06 -0500</pubDate>
    </item>
  </channel>
</rss>
