3v4l.org

run code in 300+ PHP versions simultaneously
<?hh /*-------------------------*\ PROGRAMMING WITH NOTHING \*-------------------------*/ /* * A heavily based */ /*-------------------------*\ $PROGRAM \*-------------------------*/ $zero = $f ==> $x ==> $x; $one = $f ==> $x ==> $f($x); $two = $f ==> $x ==> $f($f($x)); $three = $f ==> $x ==> $f($f($f($x))); $five = $f ==> $x ==> $f($f($f($f($f($x))))); $true = $x ==> $y ==> $x; $false = $x ==> $y ==> $y; $if = $f ==> $f; $isZero = $f ==> ($f($x ==> $false))($true); $increment = $n ==> $f ==> $x ==> $f(($n($f))($x)); $decrement = $n ==> $f ==> $x ==> (($n($g ==> $h ==> $h($g($f))))($y ==> $x))($y ==> $y); $add = $m ==> $n ==> ($n($increment))($m); $subtract = $m ==> $n ==> ($n($decrement))($m); $multiply = $m ==> $n ==> ($n($add($m)))($zero); $power = $m ==> $n ==> ($n($multiply($m)))($one); $cons = $x ==> $y ==> $f ==> ($f($x))($y); $car = $p ==> $p($x ==> $y ==> $x); $cdr = $p ==> $p($x ==> $y ==> $y); $flip = $p ==> $p($x ==> $y ==> ($cons($y))($x)); /*-------------------------*\ $HELPERS (not used in program) \*-------------------------*/ $toNum = $f ==> ($f($x ==> $x + 1))(0); $toBool = $f ==> (($if($f))(true))(false); $toTextBool = $f ==> $toBool($f) ? 'true' : 'false'; function it($m,$p){echo ($p?"✔":"✘")." It $m\n"; if(!$p)register_shutdown_function(function(){die(1);});} /*-------------------------*\ $TESTS \*-------------------------*/ it('has zero', $toNum($zero) === 0); it('has one', $toNum($one) === 1); it('has two', $toNum($two) === 2); it('has three', $toNum($three) === 3); it('has five', $toNum($five) === 5); it('has true', $toBool($true) === true); it('has false', $toBool($false) === false); it('can find zero values', $toBool($isZero($zero)) === true); it('can find non zero values', $toBool($isZero($three)) === false); it('can increment values', $toNum($increment($one)) === 2); it('can decrement values', $toNum($decrement($three)) === 2); it('can add numbers', $toNum(($add($three))($one)) === 4); it('can subtract numbers', $toNum(($subtract($five))($two)) === 3); it('can multiply numbers', $toNum(($multiply($five))($three)) === 15); it('can calculate the power of numbers', $toNum(($power($three))($three)) === 27); $pair = ($cons($one))($two); it('can find the car of a pair', $toNum($car($pair)) === 1); it('can find the cdr of a pair', $toNum($cdr($pair)) === 2); $flippedPair = $flip($pair); it('can flip pairs', $toNum($car($pair)) === 2 && $toNum($cdr($pair)) === 1); $list = ($cons($one))(($cons($two))($three)); it('can find the car of a big list', $toNum($car($list)) === 1); it('can find the cdar of a big list', $toNum($car($cdr($list))) === 2); it('can find the cddr of a big list', $toNum($cdr($cdr($list))) === 3);

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

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0100.01016.50
8.3.50.0070.01322.92
8.3.40.0090.00918.76
8.3.30.0070.00718.92
8.3.20.0080.00019.97
8.3.10.0000.00821.90
8.3.00.0030.00519.38
8.2.180.0110.01118.16
8.2.170.0140.00722.96
8.2.160.0110.00720.39
8.2.150.0060.00324.18
8.2.140.0050.00224.66
8.2.130.0040.00426.16
8.2.120.0080.00020.96
8.2.110.0050.00520.52
8.2.100.0040.00717.77
8.2.90.0040.00419.22
8.2.80.0040.00417.97
8.2.70.0000.00817.50
8.2.60.0000.00919.15
8.2.50.0060.00318.10
8.2.40.0040.00422.15
8.2.30.0040.00419.11
8.2.20.0050.00317.54
8.2.10.0000.00717.84
8.2.00.0040.00417.55
8.1.280.0180.00425.92
8.1.270.0080.00023.68
8.1.260.0080.00026.35
8.1.250.0070.00028.09
8.1.240.0090.00022.14
8.1.230.0070.00417.70
8.1.220.0000.00717.74
8.1.210.0000.00818.77
8.1.200.0060.00317.35
8.1.190.0050.00316.88
8.1.180.0070.00018.10
8.1.170.0040.00418.66
8.1.160.0050.00318.71
8.1.150.0060.00319.98
8.1.140.0020.00517.13
8.1.130.0030.00519.56
8.1.120.0030.00317.25
8.1.110.0000.00717.35
8.1.100.0040.00417.29
8.1.90.0000.00717.23
8.1.80.0000.00717.30
8.1.70.0000.00917.18
8.1.60.0070.00017.44
8.1.50.0000.00817.24
8.1.40.0040.00417.41
8.1.30.0040.00417.54
8.1.20.0040.00417.36
8.1.10.0070.00017.44
8.1.00.0040.00417.28
8.0.300.0040.00418.77
8.0.290.0040.00416.75
8.0.280.0070.00018.39
8.0.270.0030.00317.10
8.0.260.0000.00617.06
8.0.250.0000.00716.78
8.0.240.0000.00716.73
8.0.230.0050.00216.76
8.0.220.0030.00316.65
8.0.210.0030.00316.67
8.0.200.0070.00016.82
8.0.190.0040.00416.80
8.0.180.0000.00716.82
8.0.170.0000.00816.79
8.0.160.0030.00316.81
8.0.150.0030.00516.78
8.0.140.0080.00416.74
8.0.130.0060.00013.40
8.0.120.0000.00716.68
8.0.110.0000.00816.75
8.0.100.0040.00416.76
8.0.90.0000.00716.65
8.0.80.0060.00916.75
8.0.70.0000.00716.86
8.0.60.0000.00816.63
8.0.50.0070.00016.74
8.0.30.0120.00716.96
8.0.20.0090.00917.40
8.0.10.0000.00716.83
8.0.00.0060.01116.69
7.4.330.0000.00515.04
7.4.320.0000.00616.39
7.4.300.0060.00016.49
7.4.290.0070.00016.46
7.4.280.0040.00416.46
7.4.270.0000.00816.40
7.4.260.0030.00316.46
7.4.250.0040.00416.45
7.4.240.0020.00516.48
7.4.230.0030.00316.27
7.4.220.0160.00016.49
7.4.210.0070.00716.47
7.4.200.0030.00316.35
7.4.160.0090.00616.45
7.4.150.0120.00617.40
7.4.140.0070.01017.86
7.4.130.0060.01216.38
7.4.120.0060.01016.31
7.4.110.0040.01416.43
7.4.100.0070.01416.38
7.4.90.0160.00316.39
7.4.80.0090.00819.39
7.4.70.0130.00616.29
7.4.60.0100.00616.36
7.4.50.0040.00016.42
7.4.40.0070.01016.34
7.4.30.0120.00316.29
7.3.330.0030.00312.97
7.3.320.0000.00513.07
7.3.310.0030.00416.13
7.3.300.0030.00316.00
7.3.290.0130.00616.13
7.3.280.0100.00716.15
7.3.270.0130.00317.40
7.3.260.0060.01116.20
7.3.240.0160.00016.12
7.3.230.0110.00916.43
7.3.210.0100.01016.25
7.3.200.0060.01219.39
7.3.190.0090.00616.20
7.3.180.0040.01216.42
7.3.170.0090.00616.27
7.3.160.0120.00416.17
7.2.330.0100.01316.57
7.2.320.0100.01316.29
7.2.310.0120.00616.60
7.2.300.0090.00616.61
7.2.290.0110.00416.36
5.5.150.0100.08020.10
5.5.140.0070.07320.22
5.5.130.0000.08320.25
5.5.120.0030.08319.96
5.5.110.0130.06720.20
5.5.100.0100.07020.00
5.5.90.0000.07020.10
5.5.80.0670.06020.15
5.5.70.0000.07720.13
5.5.60.0070.06020.04
5.5.50.0100.07020.07
5.5.40.0030.08720.14
5.5.30.0030.08320.09
5.5.20.0070.07720.08
5.5.10.0100.07720.11
5.5.00.0130.07020.07
5.4.310.0030.07719.04
5.4.300.0000.07719.04
5.4.290.0070.07719.09
5.4.280.0030.07719.25
5.4.270.0130.06318.85
5.4.260.0030.07719.04
5.4.250.0170.06318.88
5.4.240.0070.07019.03
5.4.230.0070.06719.20
5.4.220.0030.07719.11
5.4.210.0170.07019.15
5.4.200.0070.07718.86
5.4.190.0170.06719.16
5.4.180.0070.07718.89
5.4.170.0030.07719.14
5.4.160.0100.07018.88
5.4.150.0030.05318.82
5.4.140.0100.06716.58
5.4.130.0070.06016.58
5.4.120.0030.05716.58
5.4.110.0030.07016.58
5.4.100.0100.06716.58
5.4.90.0030.07316.58
5.4.80.0030.07016.58
5.4.70.0030.06716.58
5.4.60.0030.07016.58
5.4.50.0070.06716.58
5.4.40.0030.06716.58
5.4.30.0070.06016.58
5.4.20.0070.04316.58
5.4.10.0300.05716.58
5.4.00.0070.06316.58

preferences:
49.53 ms | 401 KiB | 5 Q