Yet Another HHVM Benchmark Test

Since my last post comparing Go vs Node vs HHVM, I decided I would do it properly.

First off, the previous test didn’t really sort the array one million times, it merely sorted once then iterated over the sorted array 999,999 times. Also, my previous test focussed on HHVM & PHP with OPCache and trusted the results from @jaxbox for the Go & Node. Given I’ve fixed the sorting of the array loop, I had to go and run the node & go tests myself. Thanks to my colleague at work for providing me a C version for comparison!

The code:







$ time ./a.out

real 0m0.175s
real 0m0.172s
real 0m0.176s
real 0m0.170s
real 0m0.171s


$ time ./bubble

real 0m0.313s
real 0m0.313s
real 0m0.314s
real 0m0.313s
real 0m0.312s


$ time node bubble.js

real 0m0.484s
real 0m0.489s
real 0m0.491s
real 0m0.489s
real 0m0.496s


$ time hhvm -v Eval.Jit=true hhvm.php

real 0m2.622s
real 0m2.657s
real 0m2.615s
real 0m2.662s
real 0m2.599s


PHP 5.5 OPcache

real 0m30.421s
real 0m27.603s
real 0m27.695s
real 0m27.336s
real 0m27.706s



real 0m0.750s
real 0m0.717s
real 0m0.686s
real 0m0.709s
real 0m0.689s

Sorry for the crappy formatting of the results above. Maybe one day I shall put them in a table.

But basically you can see that in terms of bubble sorting; C > Go > Node > HHVM > PHP

However you look at it, I think it’s a no brainer to use HHVM!

Summary of best times:

Lang Best Time
C 00.171s
Go 00.312s
Node 00.484s
Java 00.689s
HHVM 02.590s
PHP 5.5.8 w/OPCache 27.336s

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:

function bubble() {
$array = array(3,4,1,3,5,1,92,2,4124,424,52,12);
for ($c=0;$c<1000000;$c++) {
for ($i=0;$i for ($y=0;$y if ($array[$y+1] < $array[$y]) {
$t = $array[$y];
$array[$y] = $array[$y+1];
$array[$y+1] = $t;

$starttime = microtime(true);
echo microtime(true) - $starttime;

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."


IE8 Self Sign Certificate Issue with Wildcard Domains

At Sky, I came across a problem with my dev virtual machine, so thought I would share my woes.

For whatever reason, IE8 doesn’t like self-signed wildcard ssl certificates. The SSL certificate I had was *.dev (for and – IE8 refused to acknowledge the certificate until I created a new openssl multi-domain certificate. To do that:

  • create the certificate with
  • create the *.csr and the *.key files as usual
  • before generating the *.crt file, create a *.cnf file with the following:,
  • when generating the *.crt file, append the –extfile flag:

  • openssl genrsa -out ca.key 1024

  • openssl req -new -key ca.key -out ca.csr
  • echo “,” > ca.cnf
  • openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt -extfile ca.cnf

  • cp ca.key /etc/pki/tls/private/ca.key

  • cp ca.csr /etc/pki/tls/private/ca.csr
  • cp ca.crt /etc/pki/tls/certs

  • service httpd restart

Hope that helps someone :)


Android Numeric Keypad Password Field

Just discovered something, which may be useful to some of you Googlers!


To get a the numeric keypad up on an iOS device it’s fairly easy. All you do is apply the pattern attribute. At Sky we use ‘pattern=”\d*”‘ in our codebase. The problem is that this doesn’t work on Android. Android requires that the field has a type attribute of either, ‘tel’ or ‘number’. This creates problems, as it means that if you want a numeric password field, you can’t get the numeric keypad up on Android… or can you?

Introducing -webkit-text-security:

The solution (and this also works for iOS) is to create all numeric password fields as ‘number’ (‘tel’ works too), and apply the following CSS property:

input[type=number] {
  -webkit-text-security: disc;

This replaces the text with the asterisk typically found on a password field. This means that you can do away with the ‘pattern’ attribute completely. I’d strongly suggest that you don’t get carried away and use this CSS for all password fields – it should really only be used where you need a numeric keypad for a password!

I’ve confirmed this works on iOS 6.1.2, Android 2.3.3 and Android 4.1.2

Hope that helps someone :)


Installing ZooKeeper for PHP on CentOS 6.3

This post is very short, simply as a reference to anyone out there that would like to install ZooKeeper on CentOS 6.3, and connect via the PHP Bindings.

To download ZooKeeper, you can visit Globocom’s GitHub page for updated versions. Below are the versions I used at the time of writing.

Install ZooKeeper:

curl -O
rpm -ivh zookeeper*
service zookeeper restart

ZooKeeper is now up and running, but you need to install some more stuff before you can connect to it!

curl -O
rpm -ivh libzookeeper*
curl -O
rpm -ivh libzookeeper-devel*

Install php-zookeeper from Andrei Zmievski:

git clone
pear build
make install

add to your php.ini, or create zookeeper.ini and place it in your php.d folder!

Hope that helps someone!