Category Archives: HHVM

HHVM vs PHP vs OPCache vs Go vs Node

Lets start by saying, I was just curious as to how fast Go was compared to PHP. I knew it was faster, but wanted some benchmarks.

I found this great article by @jaxbot:

He then went on to dismiss PHP as it was too slow; so didn’t include it in the Go 1.1 benchmark test he did later:

Fair game I thought. Until a colleague pondered how fast HHVM would be as he’d recently installed it. Given how easy it is to install HHVM these days I decided to do my own benchmarking.

For Node & Go benchmarks, please refer to @jaxbox’s links above.

There is a minor difference in the code – and that is I am using a function to wrap the code. PHP is generally faster to execute code when it’s in a function, plus HHVM ignores code that isn’t in a function.

The code:

PHP 5.5 (opcache.enable_cli=0)
$ php bubble.php
Run 1: 24.121762990952
Run 2: 24.156540155411
Run 3: 24.948321819305
Run 4: 26.411414861679
Run 5: 24.790290117264
Average: 24.882

PHP 5.5 w/OPCache (opcache.enable_cli=1)
$ php bubble.php
Run 1: 24.675834178925
Run 2: 25.641896009445
Run 3: 26.468472003937
Run 4: 24.278208017349
Run 5: 24.843347072601

HHVM (PHP 5.5 OPCache)
$ hhvm -v Eval.Jit=true bubble.php
Run 1: 2.6463210582733
Run 2: 2.6204199790955
Run 3: 2.563747882843
Run 4: 2.9089078903198
Run 5: 2.6408560276031
Average: 2.672
Interesting is that OPcache didn't fair well in this bubblesort...

Now let's compare to the tests from @jaxbot - he had different hardware, so a direct comparison is almost meaningless.. BUT HHVM speaks for itself when compared to the Zend Engine.

  Node.js Go 1.1 PHP 5.5 HHVM jit
Avg of 5 trials 430ms 326.26ms 24.88ms 2.67ms
Best 420ms 290.27ms 24.12ms 2.56ms

Hope that helps someone who wonders how good HHVM is?! 🙂

I finish with a quote from @jaxbox: "the same rules apply here as last time; take these with a lattice of Sodium Chloride, as the benchmarks tell us information, not answers."