3v4l.org

run code in 300+ PHP versions simultaneously
<?php function seqCheck(array $arr, int $maxMis): bool { $oos = 0; $mis = 0; foreach ($arr as $k => $v) { if ($k > 0 && $v < $arr[$k - 1]) { $oos++; // number out of sequence } if ($k > 0 && $v !== $arr[$k - 1] + 1) { $mis++; // number missing in sequence } } if ($oos > 0 || $mis > $maxMis) { return false; } else { return true; } } $tests = [ [[2, 3, 5, 6], 0], [[2, 3, 5, 6], 1], [[2, 5, 6, 8], 1], [[3, 6, 10, 16], 1], [[5, 6, 7, 8, 9, 10, 11], 1], [[1, 3, 5], 2], [[1, 5, 3], 2], ]; foreach ($tests as [$array, $timesForgivable]) { printf( "Test: %-17s,\tMax Forgiven: %d,\tOutcome: %s\n", json_encode($array), $timesForgivable, json_encode(seqCheck($array, $timesForgivable)) ); }

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.4.120.0130.00720.65
8.4.110.0100.01018.80
8.4.100.0120.00917.70
8.4.90.0130.00817.91
8.4.80.0110.01018.02
8.4.70.0120.00518.02
8.4.60.0130.00818.94
8.4.50.0090.01117.85
8.4.40.0130.00617.50
8.4.30.0040.01518.77
8.4.20.0130.00621.43
8.4.10.0060.00319.46
8.3.250.0110.00818.75
8.3.240.0140.00516.71
8.3.230.0130.00516.56
8.3.220.0130.00617.17
8.3.210.0100.00916.62
8.3.200.0130.00616.46
8.3.190.0040.00416.97
8.3.180.0100.00818.32
8.3.170.0150.00318.82
8.3.160.0140.00316.95
8.3.150.0070.01117.11
8.3.140.0190.00020.72
8.3.130.0060.00318.60
8.3.120.0040.00418.88
8.3.110.0040.00420.94
8.3.100.0060.00316.50
8.3.90.0040.00426.77
8.3.80.0060.00317.97
8.3.70.0350.01917.97
8.3.60.0350.00417.97
8.3.50.0170.00917.97
8.3.40.0150.00517.97
8.3.30.0210.00317.97
8.3.20.0120.01217.97
8.3.10.0190.00617.97
8.3.00.0320.00517.97
8.2.290.0080.01020.67
8.2.280.0100.01318.57
8.2.270.0030.00517.32
8.2.260.0080.00018.23
8.2.250.0080.00316.69
8.2.240.0090.00018.77
8.2.230.0030.00722.58
8.2.220.0100.00024.06
8.2.210.0040.00426.77
8.2.200.0030.00616.63
8.2.190.0350.00317.97
8.2.180.0160.00717.97
8.2.170.0240.00717.97
8.2.160.0180.00717.97
8.2.150.0230.00017.97
8.2.140.0230.00017.97
8.2.130.0170.00617.97
8.2.120.0190.00517.97
8.2.110.0280.00617.97
8.2.100.0370.01317.97
8.2.90.0460.00917.97
8.2.80.0390.01317.97
8.2.70.0220.01317.97
8.2.60.0280.00617.97
8.2.50.0270.01717.97
8.2.40.0380.00317.97
8.2.30.0290.01317.97
8.2.20.0290.01317.97
8.2.10.0350.00617.97
8.2.00.0350.00717.97
8.1.330.0090.00916.52
8.1.320.0080.01016.21
8.1.310.0060.00916.58
8.1.300.0000.00919.71
8.1.290.0060.00330.84
8.1.280.0310.01417.97
8.1.270.0340.01317.97
8.1.260.0380.00917.97
8.1.250.0300.01317.97
8.1.240.0420.00317.97
8.1.230.0280.01117.97
8.1.220.0350.01217.97
8.1.210.0240.01417.97
8.1.200.0300.00317.97
8.1.190.0220.00417.97
8.1.180.0180.00417.97
8.1.170.0190.00317.97
8.1.160.0270.00017.97
8.1.150.0170.00717.97
8.1.140.0120.00917.97
8.1.130.0120.00917.97
8.1.120.0190.00417.97
8.1.110.0180.00617.97
8.1.100.0200.00617.97
8.1.90.0060.01818.51
8.1.80.0160.00817.97
8.1.70.0170.00817.97
8.1.60.0210.00717.97
8.1.50.0170.01019.03
8.1.40.0210.00617.97
8.1.30.0280.00017.97
8.1.20.0140.01117.97
8.1.10.0190.00617.97
8.1.00.0180.00317.97

preferences:
26.93 ms | 403 KiB | 5 Q