Etienne Kneuss

Insane

I'm currently working on a scala compiler plugin that performs interprocedural, compositional effect and pointer analysis on arbitrary scala programs!

Feel free to check out Insane on github!

Phantm

In short, Phantm is a type checker for PHP applications, but it does also much more!

PHP

I sporadically contributes to the core of PHP for quite a while now, see my patch repository.

SplFixedArray to speed up your PHP arrays

Sat, 7 June 2008

Antony got the idea to implement a C-like array wrapper in SPL: SplFixedArray. The main advantage of that class is performance, it's indeed faster than PHP arrays. How so? No free lunch: The speedup comes from the fact that non-numeric indexes are not allowed and that the array is of fixed size (which means no hashing and continuous memory storage). That said, here is a quick example:

$a = new SplFixedArray(4); // takes the initial size as first argument

$a[0] = "foo";
$a[2] = "gee";
$a[3] = "plop";

$a->setSize(3);
$a->setSize(5); // increase the size

foreach($a as $k=>$v) {
    var_dump($v);
}
/* Output:
 * string(3) "foo"
 * NULL
 * string(3) "gee"
 * NULL
 * NULL
 */

The speedup seems to vary between different environments, but so far the multiple benchmarks showed that SplFixedArray was 10~30% faster than standard PHP arrays.