3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Person { function __construct($c) { $this->count = $c; } function getPrev() { return $this->prev; } function setPrev($pr) { $this->prev = $pr; } function getNext() { return $this->next; } function setNext($nxt) { $this->next = $nxt; } function shout($shout, $nth) { if ($shout < $nth) { return $shout + 1; } $this->getPrev()->setNext($this->getNext()); $this->getNext()->setPrev($this->getPrev()); return 1; } } class Chain { var $first; function __construct($size) { for($i = 0; $i < $size ; $i++) { $current = new Person($i); if ($this->first == null) $this->first = $current; if ($last != null) { $last->setNext($current); $current->setPrev($last); } $last = $current; } $this->first->setPrev($last); $last->setNext($this->first); } function kill($nth) { $current = $this->first; $shout = 1; while($current->getNext() !== $current) { $shout = $current->shout($shout,$nth); $current = $current->getNext(); } $this->first = $current; } } $start = microtime(true); $ITER = 100000; for($i = 0 ; $i < $ITER ; $i++) { $chain = new Chain(40); $chain->kill(3); } $end = microtime(true); printf("Time per iteration = %3.2f microsecondsnr",(($end - $start) * 1000000 / $ITER))

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Note: hhvm uses a JIT which only kicks in after a few runs. Since we run scripts only once, hhvm always runs slower.

VersionSystem time (s)User time (s)Memory (MiB)
5.4.320.0040.03712.53
5.4.310.0080.03512.53
5.4.300.0110.03012.53
5.4.290.0040.03812.52
5.4.280.0070.03412.42
5.4.270.0060.03512.42
5.4.260.0070.03612.42
5.4.250.0050.03812.42
5.4.240.0090.03312.42
5.4.230.0130.03012.41
5.4.220.0100.03212.41
5.4.210.0070.03412.41
5.4.200.0070.03612.41
5.4.190.0040.03712.41
5.4.180.0020.03912.41
5.4.170.0090.03112.42
5.4.160.0100.03212.42
5.4.150.0060.03612.41
5.4.140.0080.03612.10
5.4.130.0090.03312.09
5.4.120.0070.03512.05
5.4.110.0060.03612.04
5.4.100.0070.03512.04
5.4.90.0050.04212.04
5.4.80.0040.04012.04
5.4.70.0070.03512.04
5.4.60.0040.03812.04
5.4.50.0070.03612.04
5.4.40.0040.03712.03
5.4.30.0050.03712.02
5.4.20.0100.03812.02
5.4.10.0070.03912.03
5.4.00.0060.04011.51
5.3.290.0060.05412.80
5.3.280.0070.04012.71
5.3.270.0040.04112.72
5.3.260.0020.04212.72
5.3.250.0070.03512.72
5.3.240.0060.03612.72
5.3.230.0090.03812.71
5.3.220.0090.03412.68
5.3.210.0050.04112.68
5.3.200.0060.03612.68
5.3.190.0120.03112.68
5.3.180.0120.03112.67
5.3.170.0080.04212.67
5.3.160.0090.03612.68
5.3.150.0070.03612.68
5.3.140.0070.03512.66
5.3.130.0050.04012.65
5.3.120.0110.03512.66
5.3.110.0180.02812.66
5.3.100.0080.03412.14
5.3.90.0150.04212.12
5.3.80.0090.03312.11
5.3.70.0100.03212.11
5.3.60.0070.03512.10
5.3.50.0060.04212.04
5.3.40.0070.03912.04
5.3.30.0050.03612.00
5.3.20.0080.03111.78
5.3.10.0000.03911.75
5.3.00.0040.03611.73
5.2.170.0030.0329.25
5.2.160.0050.0299.25
5.2.150.0050.0299.24
5.2.140.0050.0299.24
5.2.130.0040.0299.20
5.2.120.0040.0289.20
5.2.110.0060.0279.21
5.2.100.0050.0279.20
5.2.90.0100.0239.20
5.2.80.0030.0319.20
5.2.70.0030.0319.20
5.2.60.0030.0319.15
5.2.50.0030.0319.12
5.2.40.0030.0309.09
5.2.30.0050.0289.07
5.2.20.0010.0329.06
5.2.10.0030.0298.96
5.2.00.0030.0308.83
5.1.60.0050.0238.11
5.1.50.0040.0248.11
5.1.40.0060.0228.10
5.1.30.0050.0258.45
5.1.20.0050.0258.47
5.1.10.0080.0218.19
5.1.00.0030.0268.19
5.0.50.0040.0196.67
5.0.40.0000.0226.53
5.0.30.0040.0306.34
5.0.20.0040.0186.30
5.0.10.0040.0196.29
5.0.00.0030.0316.28
4.4.90.0040.0144.78
4.4.80.0030.0144.75
4.4.70.0040.0134.75
4.4.60.0020.0164.75
4.4.50.0030.0144.77
4.4.40.0030.0244.71
4.4.30.0010.0174.76
4.4.20.0020.0164.84
4.4.10.0010.0174.85
4.4.00.0040.0234.76
4.3.110.0020.0164.67
4.3.100.0040.0134.66
4.3.90.0020.0144.63
4.3.80.0040.0234.59
4.3.70.0020.0154.63
4.3.60.0020.0154.63
4.3.50.0030.0144.63
4.3.40.0030.0244.54
4.3.30.0020.0163.31
4.3.20.0010.0163.29
4.3.10.0050.0123.25
4.3.00.0130.0207.08