3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Run it: php r30.php * Run it with a custom number of rows: php r30.php <number> * Have fun :) */ function createRows($numRows, $rule) { $getNextRow = function ($currRow) use ($rule) { $nextRow = [0, 0]; for ($i = 1, $iMax = count($currRow) - 1; $i < $iMax; $i++) { $nextRow[] = $rule[$currRow[$i - 1] . $currRow[$i] . $currRow[$i + 1]]; } array_push($nextRow, 0, 0); return $nextRow; }; $rows[0] = [0, 0, 1, 0, 0]; for ($i = 1; $i <= $numRows; $i++) { $rows[$i] = $getNextRow($rows[$i - 1]); } return $rows; } function displayRows($rows, $isDownwards, $micSleep) { $rowCount = count($rows); $getRow = function ($rows, $isDownwards) use ($rowCount) { if ($isDownwards === true) { for ($i = 0; $i < $rowCount; $i++) { yield [$i, $rows[$i]]; } } else { for ($i = $rowCount - 1; $i >= 0; $i--) { yield [$i, $rows[$i]]; } } }; foreach ($getRow($rows, $isDownwards) as [$pad, $row]) { echo str_repeat(' ', $rowCount - $pad); foreach ($row as $cell) { echo $cell === 1 ? '█' : ' '; } echo PHP_EOL; usleep($micSleep); } } // https://en.wikipedia.org/wiki/Rule_30 const RULE_30 = [ '111' => 0, '110' => 0, '101' => 0, '100' => 1, '011' => 1, '010' => 1, '001' => 1, '000' => 0, ]; $numRows = isset($argv[1]) && (int)$argv[1] > 0 && (int)$argv[1] <= 1000 ? (int)$argv[1] : 80; $rows = createRows($numRows, RULE_30); while (true) { displayRows($rows, true, 5000); displayRows($rows, false, 5000); }

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.0260.01517.00
8.3.50.0330.00616.71
8.3.40.0290.01618.88
8.3.30.0260.01518.95
8.3.20.0390.00320.43
8.3.10.0320.01122.02
8.3.00.0290.01317.97
8.2.180.0290.01116.75
8.2.170.0390.01122.96
8.2.160.0170.02620.64
8.2.150.0360.00624.18
8.2.140.0180.01424.66
8.2.130.0380.00721.10
8.2.120.0420.00026.35
8.2.110.0380.01121.12
8.2.100.0280.00018.41
8.2.90.0080.01119.60
8.2.80.0090.00918.29
8.2.70.0180.00417.88
8.2.60.0130.00418.30
8.2.50.0090.01218.18
8.2.40.0080.00822.14
8.2.30.0130.00621.11
8.2.20.0180.00018.54
8.2.10.0100.01018.49
8.2.00.0110.00818.43
8.1.280.0470.00625.92
8.1.270.0300.01323.75
8.1.260.0330.00826.35
8.1.250.0360.00828.09
8.1.240.0440.00422.47
8.1.230.0170.01017.89
8.1.220.0100.00818.02
8.1.210.0110.00718.77
8.1.200.0130.00817.60
8.1.190.0110.00717.73
8.1.180.0110.00818.10
8.1.170.0120.00418.96
8.1.160.0120.00819.46
8.1.150.0120.00720.68
8.1.140.0120.00819.94
8.1.130.0000.02019.21
8.1.120.0140.00517.92
8.1.110.0090.00917.88
8.1.100.0180.00317.88
8.1.90.0140.00517.81
8.1.80.0070.01117.79
8.1.70.0070.01117.92
8.1.60.0110.00617.91
8.1.50.0100.00717.93
8.1.40.0160.00717.93
8.1.30.0060.01217.93
8.1.20.0080.01318.09
8.1.10.0140.00418.04
8.1.00.0050.01417.96
8.0.300.0120.00618.77
8.0.290.0170.00317.00
8.0.280.0040.01318.82
8.0.270.0120.00817.63
8.0.260.0080.01217.21
8.0.250.0080.00817.38
8.0.240.0070.01717.02
8.0.230.0090.00917.17
8.0.220.0120.00317.23
8.0.210.0080.01217.28
8.0.200.0130.00617.36
8.0.190.0120.00917.27
8.0.180.0040.01317.19
8.0.170.0170.00517.31
8.0.160.0140.00417.30
8.0.150.0150.00417.18
8.0.140.0140.00517.11
8.0.130.0090.00713.81
8.0.120.0150.00617.29
8.0.110.0120.00617.26
8.0.100.0090.00917.32
8.0.90.0140.00517.27
8.0.80.0260.02617.17
8.0.70.0080.00817.11
8.0.60.0150.00017.14
8.0.50.0080.00817.27
8.0.30.0800.03517.39
8.0.20.0770.02917.40
8.0.10.0170.00217.21
8.0.00.0730.01417.07
7.4.330.0080.00815.55
7.4.320.0050.01116.67
7.4.300.0040.01416.89
7.4.290.0100.01016.66
7.4.280.0000.01916.81
7.4.270.0130.00516.88
7.4.260.0130.00313.66
7.4.250.0110.01116.80
7.4.240.0130.00716.72
7.4.230.0150.00416.95
7.4.220.0390.03616.80
7.4.210.0310.03016.80
7.4.200.0080.00816.84
7.4.160.0500.02516.80
7.4.150.0510.04017.40
7.4.140.0660.04217.86
7.4.130.0570.04216.84
7.4.120.0820.03816.85
7.4.110.0590.03116.74
7.4.100.0660.02516.73
7.4.90.0440.03416.79
7.4.80.0350.02919.39
7.4.70.0270.04216.81
7.4.60.0270.03516.68
7.4.50.0190.03216.88
7.4.40.0430.02516.98
7.4.30.0450.02916.58
7.4.00.0270.03314.97
7.3.330.0100.00713.65
7.3.320.0040.01313.79
7.3.310.0120.00616.73
7.3.300.0130.00416.64
7.3.290.0040.01216.74
7.3.280.0460.03116.70
7.3.270.0730.02117.40
7.3.260.0560.02716.83
7.3.250.0470.04116.64
7.3.240.0970.03916.77
7.3.230.1000.03016.66
7.3.210.0470.03016.73
7.3.200.0390.02016.75
7.3.190.0330.03316.65
7.3.180.0340.03017.00
7.3.170.0370.03216.77
7.3.160.0300.02916.88
7.2.330.0630.02416.81
7.2.320.0420.03916.79
7.2.310.0490.01717.11
7.2.300.0410.03817.13
7.2.290.0360.03417.07
7.2.60.0180.01816.95
7.2.50.0270.01616.92
7.1.200.0280.01315.91
7.1.70.0340.02016.07
7.1.60.0690.03534.17
7.1.50.0460.03433.96
7.1.40.0840.02233.16
7.1.30.0590.03633.57
7.1.20.0590.03333.87
7.1.10.0480.02115.56
7.1.00.0450.02015.49
7.0.200.0170.01315.42
7.0.190.0220.00915.12
7.0.180.0480.01314.12
7.0.170.0270.00714.84
7.0.160.0200.01114.78
7.0.150.0260.01414.76
7.0.140.0210.00714.79
7.0.130.0180.00915.01
7.0.120.0220.00815.02
7.0.110.0150.01314.93
7.0.100.0160.01014.79
7.0.90.0200.00814.86
7.0.80.0220.00915.03
7.0.70.0180.01114.93
7.0.60.0210.00914.69
7.0.50.0210.01014.91
7.0.40.0220.00915.05
7.0.30.0180.00915.13
7.0.20.0210.00715.05
7.0.10.0160.01315.08
7.0.00.0160.01014.97

preferences:
35.6 ms | 400 KiB | 5 Q