2015-01-26

PHP/HHVM vs Go vs NodeJs BubbleSort Benchmark

So, I wonder about how good HHVM now, the code was taken from this post. My setup is 64-bit Linux 3.18.2-1, AMD A8-6600K, 16 GB RAM, Non-SSD disk, here's the best result of each implementation:

PHP 5.6.4

$ time php bench.php 
Array
(
    [0] => 1
    [1] => 1
    [2] => 2
    [3] => 3
    [4] => 3
    [5] => 4
    [6] => 5
    [7] => 12
    [8] => 52
    [9] => 92
    [10] => 424
    [11] => 4124
)
2.3711581230164
real    0m2.383s
user    0m2.373s
sys     0m0.010s

HHVM 3.5.0

$ time hhvm -v Eval.Jit=true bench.php 
Array
(
    [0] => 1
    [1] => 1
    [2] => 2
    [3] => 3
    [4] => 3
    [5] => 4
    [6] => 5
    [7] => 12
    [8] => 52
    [9] => 92
    [10] => 424
    [11] => 4124
)
0.13958597183228
real    0m0.414s
user    0m0.247s
sys     0m0.033s

Go 1.4.1
And yes, I include the compile time also for fairness.

$ rm bench; time(go build bench.go && ./bench)
removed ‘bench’
[1 1 2 3 3 4 5 12 52 92 424 4124]
23.027575ms
real    0m0.191s
user    0m0.150s
sys     0m0.033s

$ time ./bench 
[1 1 2 3 3 4 5 12 52 92 424 4124]
22.757741ms
real    0m0.024s
user    0m0.023s
sys     0m0.000s

NodeJS 0.10.35

$ time node bench.js
[ 1, 1, 2, 3, 3, 4, 5, 12, 52, 92, 424, 4124 ]
42

real    0m0.065s
user    0m0.060s
sys     0m0.003s

From what we could see (run duration - actual duration):
Go: 22ms - 24ms
NodeJS: 42ms - 65ms
Go (with compile duration included): 23ms - 191ms
HHVM: 139ms - 414ms
PHP2371ms - 2383ms

8 comments :

  1. What is the result if you exclude HHVM compile time?

    ReplyDelete
    Replies
    1. how to measure hhvm compile time? it's JIT, it cannot be separated right?

      Delete
  2. Could you guys do another test? Go 1.5 vs HHVM 3.8.0? Maybe in a months time?

    ReplyDelete
    Replies
    1. yes, probably when 1.5 officially released, but not for this benchmark, there are some other interesting benchmark than just bubblesort

      Delete
    2. Awesome, one thing tho. Could you introduce Elixir? I'd love a comparison. You could probably skip PHP lol

      Delete
  3. 1.5 is out now, looking forward to lots of micro benchmarks between golang 1.5 and hhvm 3.9!

    ReplyDelete

THINK: is it True? is it Helpful? is it Inspiring? is it Necessary? is it Kind?