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.0350.01017.00
8.3.50.0390.01016.51
8.3.40.0310.02218.96
8.3.30.0420.00519.04
8.3.20.0160.02120.50
8.3.10.0410.00522.11
8.3.00.0430.00317.88
8.2.180.0430.01316.75
8.2.170.0400.01222.96
8.2.160.0470.00820.60
8.2.150.0260.01024.18
8.2.140.0400.00224.66
8.2.130.0250.01421.03
8.2.120.0290.01426.35
8.2.110.0340.01920.82
8.2.100.0160.01218.24
8.2.90.0090.00919.42
8.2.80.0120.00818.30
8.2.70.0170.00317.88
8.2.60.0000.01718.18
8.2.50.0170.00018.18
8.2.40.0100.00722.27
8.2.30.0090.00921.22
8.2.20.0060.01218.29
8.2.10.0100.01018.48
8.2.00.0120.00618.45
8.1.280.0260.02025.92
8.1.270.0320.01422.29
8.1.260.0320.01226.35
8.1.250.0380.00328.09
8.1.240.0360.01222.58
8.1.230.0320.00017.89
8.1.220.0100.00818.04
8.1.210.0000.01818.77
8.1.200.0160.00517.63
8.1.190.0110.00617.72
8.1.180.0140.00418.10
8.1.170.0070.01118.96
8.1.160.0040.01319.46
8.1.150.0110.00719.34
8.1.140.0060.01120.01
8.1.130.0150.00319.25
8.1.120.0110.00717.80
8.1.110.0050.01317.77
8.1.100.0120.00617.93
8.1.90.0140.00717.91
8.1.80.0090.00917.77
8.1.70.0070.01017.92
8.1.60.0080.01217.93
8.1.50.0080.01117.94
8.1.40.0150.00717.97
8.1.30.0110.01118.02
8.1.20.0150.00318.08
8.1.10.0100.00817.98
8.1.00.0130.01017.99
8.0.300.0160.00418.77
8.0.290.0060.01116.88
8.0.280.0120.00818.77
8.0.270.0120.00717.58
8.0.260.0110.00617.11
8.0.250.0130.00617.28
8.0.240.0040.01317.31
8.0.230.0190.00017.27
8.0.220.0100.00717.20
8.0.210.0120.00417.24
8.0.200.0160.00017.27
8.0.190.0070.01317.33
8.0.180.0150.00617.29
8.0.170.0130.00817.28
8.0.160.0070.01117.35
8.0.150.0190.00017.18
8.0.140.0150.00517.20
8.0.130.0160.00013.82
8.0.120.0120.00617.25
8.0.110.0100.01017.23
8.0.100.0110.00817.20
8.0.90.0120.00417.23
8.0.80.0470.02317.17
8.0.70.0170.00017.09
8.0.60.0060.00917.24
8.0.50.0140.00517.07
8.0.30.0720.03117.43
8.0.20.0750.04317.45
8.0.10.0070.01017.45
8.0.00.0660.03317.09
7.4.330.0170.00015.55
7.4.320.0080.00816.79
7.4.300.0070.00716.87
7.4.290.0100.01016.81
7.4.280.0060.01216.68
7.4.270.0120.00616.89
7.4.260.0160.00616.89
7.4.250.0090.00916.79
7.4.240.0070.01016.77
7.4.230.0090.01116.66
7.4.220.0360.03716.73
7.4.210.0200.03116.82
7.4.200.0110.00416.92
7.4.160.0720.02916.71
7.4.150.0680.03417.40
7.4.140.1000.02917.86
7.4.130.0810.03116.85
7.4.120.0650.03216.86
7.4.110.0520.02116.75
7.4.100.0600.02616.99
7.4.90.0640.01416.72
7.4.80.0340.03619.39
7.4.70.0560.00717.02
7.4.60.0440.02516.94
7.4.50.0360.02116.95
7.4.40.0380.02216.75
7.4.30.0360.03016.91
7.4.00.0370.02515.18
7.3.330.0130.00313.89
7.3.320.0080.00813.68
7.3.310.0060.01216.71
7.3.300.0070.00716.66
7.3.290.0050.01016.57
7.3.280.0260.02916.70
7.3.270.0610.02917.40
7.3.260.0700.02716.83
7.3.250.0610.03416.79
7.3.240.0690.02916.75
7.3.230.0690.02516.86
7.3.210.0740.01617.00
7.3.200.0490.02416.96
7.3.190.0400.02816.79
7.3.180.0430.04516.62
7.3.170.0400.02716.76
7.3.160.0290.03516.64
7.2.330.0620.02816.93
7.2.320.0310.04017.08
7.2.310.0350.03617.10
7.2.300.0500.02917.10
7.2.290.0270.04216.92
7.2.60.0310.01516.97
7.2.00.0200.01119.54
7.1.200.0200.01715.96
7.1.100.0190.01018.24
7.1.70.0250.01817.21
7.1.60.0280.02635.07
7.1.50.0340.03535.03
7.1.40.0430.02434.65
7.1.30.0330.03034.42
7.1.20.0500.01234.82
7.1.10.0170.02516.53
7.1.00.0320.02116.46
7.0.200.0050.01816.64
7.0.190.0110.00616.66
7.0.180.0060.01115.93
7.0.170.0060.01216.29
7.0.160.0010.01616.11
7.0.150.0120.00716.11
7.0.140.0140.00315.98
7.0.130.0070.00916.35
7.0.120.0040.01116.27
7.0.110.0060.01016.34
7.0.100.0100.00716.14
7.0.90.0080.00815.99
7.0.80.0060.01016.20
7.0.70.0070.00715.99
7.0.60.0060.01116.04
7.0.50.0000.01616.16
7.0.40.0080.00616.38
7.0.30.0050.01216.41
7.0.20.0070.00716.39
7.0.10.0030.01016.16
7.0.00.0030.01116.14

preferences:
36.36 ms | 400 KiB | 5 Q