Skip to content

Instantly share code, notes, and snippets.

@mcuadros
Created April 16, 2014 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcuadros/10937820 to your computer and use it in GitHub Desktop.
Save mcuadros/10937820 to your computer and use it in GitHub Desktop.
pimple-hack vs pimple (HHVM vs PHP)

pimple-hack vs pimple

Just as a learning practice, i made this port of pimple for hack, this are the results of my little benchmarks based on 1 million of iterations.

The code

<?hh

require_once __DIR__.'/src/Pimple.php';

$container = new Pimple();
$container['raw'] = new ArrayObject();
$container['shared'] = function ($c) {
    return new ArrayObject();
};
$container['factory'] = $container->factory(function ($c) {
    return new ArrayObject();
});

for($i=0;$i < 1000000;$i++) {
    $raw = $container['raw'];
    $shared = $container['shared'];
    $factory = $container['factory'];
}

The results

pimple-hack @ HipHop VM 3.0.0-dev+2014.04.02 (rel)

time hhvm bench.php

real	0m1.729s
user	0m1.664s
sys  	0m0.056s

Pimple @ HipHop VM 3.0.0-dev+2014.04.02 (rel)

time hhvm bench.php

real	0m2.458s
user	0m2.412s
sys	    0m0.040s

Pimple @ PHP 5.3.10-1ubuntu3.11

time php bench.php

real	0m4.753s
user	0m4.744s
sys	    0m0.000s
@nbpalomino
Copy link

Could you benchmark with PHP5.4 and PHP5.5 ???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment