Skip to content

Instantly share code, notes, and snippets.

@mcuadros
Last active July 12, 2018 06:53
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/879cf48540ecd5dec6e6 to your computer and use it in GitHub Desktop.
Save mcuadros/879cf48540ecd5dec6e6 to your computer and use it in GitHub Desktop.
PHP vs PHP-CPP vs HHVM-HNI

#PHP vs PHP-CPP vs HHVM-HNI This is a small benchmark with the objective of compare the performance of PHP-CPP vs HNI.

Code

$a = [
    'key' => 'foo',
    'foo' => null,
    'a' => 2,
    'b' => 2.2,
    'c' => ['foo' => 2],
    'd' => ['foo']
];

for($i=0;$i<100000;$i++) {
    bson_decode(bson_encode($a));
}

Results

The code was executed in three setups at the same system.

PHP

Under PHP 5.5.10 with 1.5.1 mongo extension, the native extension don't use libbson so the implementation is very different from the other two.

real 0m0.214s

Under HHVM 3.01 with bson-hni extension, basicaly is a wrapper of libbson

real 0m0.504s

Under the same PHP version of the native one with the bson-php-cpp extension, the same bson-hni code ported to PHP-CPP

real 0m1.815s

@aftabnaveed
Copy link

Can you please interpret this real 0m0.214s?

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