3v4l.org

run code in 300+ PHP versions simultaneously
<?php function str_compare(string $left, string $right): int { $length = mb_strlen($left, '8bit'); if (mb_strlen($right, '8bit') !== $length) { throw new Exception('ct_select() expects two strings of equal length'); } $gt = 0; $eq = 1; $i = $length; while ($i > 0) { --$i; $leftCharCode = unpack('C', $left[$i])[1]; $rightCharCode = unpack('C', $right[$i])[1]; $gt |= (($rightCharCode - $leftCharCode) >> 8) & $eq; $eq &= (($rightCharCode ^ $leftCharCode) -1) >> 8; } return ($gt + $gt + $eq) - 1; } var_dump( str_compare('baaaaaaaa', 'aaaaaaaaa'), str_compare('aaaaaaaaa', 'aaaaaaaaa'), str_compare('aaaaaaaaa', 'baaaaaaaa') );

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.140.0070.01118.38
8.3.130.0100.01016.69
8.3.120.0030.00620.84
8.3.110.0000.00920.94
8.3.100.0040.01124.06
8.3.90.0170.00326.77
8.3.80.0030.00616.38
8.3.70.0070.01116.58
8.3.60.0040.01118.43
8.3.50.0160.00324.51
8.3.40.0090.00618.98
8.3.30.0100.01018.80
8.3.20.0070.00024.18
8.3.10.0040.00424.66
8.3.00.0040.00426.16
8.2.250.0000.00818.33
8.2.240.0070.01419.11
8.2.230.0030.00722.58
8.2.220.0060.00337.54
8.2.210.0100.00326.77
8.2.200.0040.00418.29
8.2.190.0090.00916.88
8.2.180.0130.01025.92
8.2.170.0090.00618.82
8.2.160.0130.00322.96
8.2.150.0040.00425.66
8.2.140.0000.00824.66
8.2.130.0070.00026.16
8.2.120.0070.00019.66
8.2.110.0060.00320.27
8.2.100.0090.00317.72
8.2.90.0000.00817.91
8.2.80.0040.00418.22
8.2.70.0060.00317.50
8.2.60.0000.00817.63
8.2.50.0000.00717.63
8.2.40.0040.00418.29
8.2.30.0000.00718.09
8.2.20.0040.00418.05
8.2.10.0040.00419.26
8.2.00.0000.00719.11
8.1.300.0030.00518.30
8.1.290.0030.00630.84
8.1.280.0080.00625.92
8.1.270.0040.00423.99
8.1.260.0030.00526.35
8.1.250.0080.00028.09
8.1.240.0090.00023.65
8.1.230.0090.00322.24
8.1.220.0050.00317.79
8.1.210.0080.00018.80
8.1.200.0040.00417.22
8.1.190.0060.00317.09
8.1.180.0030.00618.10
8.1.170.0060.00318.44
8.1.160.0070.00018.88
8.1.150.0050.00218.82
8.1.140.0090.00018.71
8.1.130.0070.00017.35
8.1.120.0000.00817.32
8.1.110.0030.00517.36
8.1.100.0070.00017.30
8.1.90.0040.00417.23
8.1.80.0000.01017.34
8.1.70.0070.00017.32
8.1.60.0040.00417.56
8.1.50.0110.00617.50
8.1.40.0140.00417.52
8.1.30.0100.00617.68
8.1.20.0140.00317.67
8.1.10.0110.00617.55
8.1.00.0120.00417.45
8.0.300.0070.00020.07
8.0.290.0070.00016.63
8.0.280.0000.00718.36
8.0.270.0080.00017.93
8.0.260.0000.00716.88
8.0.250.0000.00716.86
8.0.240.0060.00016.90
8.0.230.0000.00716.86
8.0.220.0050.00316.88
8.0.210.0000.00716.93
8.0.200.0030.00316.91
8.0.190.0080.00016.89
8.0.180.0100.00416.92
8.0.170.0110.00416.89
8.0.160.0130.00316.87
8.0.150.0080.00616.84
8.0.140.0130.00016.76
8.0.130.0110.00315.03
8.0.120.0110.00416.79
8.0.110.0120.00116.91
8.0.100.0110.00316.84
8.0.90.0100.00516.83
8.0.80.0130.00716.87
8.0.70.0080.00616.77
8.0.60.0080.00616.68
8.0.50.0110.00416.84
8.0.30.0160.00517.05
8.0.20.0120.01017.12
8.0.10.0070.00716.84
8.0.00.0070.00916.90
7.4.330.0000.00515.55
7.4.320.0030.00316.61
7.4.300.0000.00916.51
7.4.290.0100.00616.54
7.4.280.0120.00316.51
7.4.270.0150.00216.49
7.4.260.0130.00214.93
7.4.250.0080.00716.49
7.4.240.0060.00716.55
7.4.230.0090.00716.62
7.4.220.0070.00416.56
7.4.210.0110.00616.62
7.4.200.0070.00616.57
7.4.190.0170.00216.63
7.4.180.0250.00316.65
7.4.160.0190.00716.51
7.4.150.0260.00016.42
7.4.140.0140.00916.51
7.4.130.0100.01016.56
7.4.120.0160.00916.48
7.4.110.0170.00216.53
7.4.100.0130.00916.38
7.4.90.0090.01116.32
7.4.80.0090.01116.45
7.4.70.0100.00916.37
7.4.60.0110.01216.42
7.4.50.0120.01116.52
7.4.40.0180.00316.49
7.4.30.0140.00916.44
7.4.20.0150.00616.43
7.4.10.0160.00716.34
7.4.00.0090.00916.40
7.3.330.0080.00516.31
7.3.320.0100.00314.80
7.3.310.0110.00216.32
7.3.300.0080.00516.26
7.3.290.0130.00416.30
7.3.280.0140.00316.23
7.3.270.0160.00316.36
7.3.260.0130.00716.48
7.3.250.0170.00616.20
7.3.240.0200.00016.18
7.3.230.0110.00816.28
7.3.220.0170.00316.08
7.3.210.0110.00916.38
7.3.200.0110.00916.29
7.3.190.0120.00716.22
7.3.180.0170.00516.30
7.3.170.0170.00516.46
7.3.160.0170.00516.40
7.3.150.0130.00816.43
7.3.140.0130.00816.41
7.3.130.0120.01016.26
7.3.120.0130.00916.43
7.3.110.0130.00816.31
7.3.100.0110.01016.29
7.3.90.0150.00816.45
7.3.80.0130.00916.33
7.3.70.0130.00816.42
7.3.60.0170.00616.37
7.3.50.0130.00816.33
7.3.40.0150.00616.38
7.3.30.0140.00716.44
7.3.20.0150.00816.81
7.3.10.0170.00616.82
7.3.00.0140.01016.80
7.2.340.0200.00016.35
7.2.330.0150.00616.64
7.2.320.0130.00616.49
7.2.310.0100.01216.61
7.2.300.0110.01016.58
7.2.290.0160.00716.53
7.2.280.0170.00816.61
7.2.270.0170.00716.57
7.2.260.0140.00916.68
7.2.250.0160.00616.60
7.2.240.0130.00916.47
7.2.230.0130.00916.65
7.2.220.0160.00816.71
7.2.210.0140.00916.47
7.2.200.0180.00616.70
7.2.190.0160.00716.58
7.2.180.0130.00816.59
7.2.170.0160.00616.54
7.2.160.0150.00816.57
7.2.150.0130.01116.97
7.2.140.0130.00917.03
7.2.130.0160.00917.14
7.2.120.0140.00817.13
7.2.110.0160.00917.11
7.2.100.0180.01017.08
7.2.90.0160.00916.97
7.2.80.0150.01016.98
7.2.70.0150.01017.01
7.2.60.0170.01017.08
7.2.50.0140.00917.19
7.2.40.0130.01117.11
7.2.30.0140.00917.16
7.2.20.0190.00717.07
7.2.10.0160.00817.12
7.2.00.0160.00917.09

preferences:
29.4 ms | 403 KiB | 5 Q