3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); function ct_select( bool $returnLeft, string $left, string $right ): string { $length = mb_strlen($left, '8bit'); if (mb_strlen($right, '8bit') !== $length) { throw new Exception('ct_select() expects two strings of equal length'); } // Mask byte $mask = (-$returnLeft) & 0xff; // X $x = (string) ($left ^ $right); // Output = Right XOR (X AND Mask) $output = ''; for ($i = 0; $i < $length; $i++) { $rightCharCode = unpack('C', $right[$i])[1]; $xCharCode = unpack('C', $x[$i])[1]; $output .= pack( 'C', $rightCharCode ^ ($xCharCode & $mask) ); } return $output; } var_dump( ct_select(true, 'apple', 'tiger'), ct_select(false, 'apple', 'tiger'), );

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.130.0040.00718.49
8.3.120.0060.00319.11
8.3.110.0100.00720.94
8.3.100.0030.00618.54
8.3.90.0000.00818.36
8.3.80.0070.00419.36
8.3.70.0040.01116.63
8.3.60.0060.01316.75
8.3.50.0100.00924.43
8.3.40.0080.01118.84
8.3.30.0060.00918.64
8.3.20.0090.00024.18
8.3.10.0030.00524.66
8.3.00.0000.00726.16
8.2.250.0180.00416.57
8.2.240.0060.00318.82
8.2.230.0040.00422.58
8.2.220.0100.00024.06
8.2.210.0000.01426.77
8.2.200.0060.00316.88
8.2.190.0150.00616.63
8.2.180.0000.01525.92
8.2.170.0120.00922.96
8.2.160.0150.00322.96
8.2.150.0030.00525.66
8.2.140.0030.00524.66
8.2.130.0070.00026.16
8.2.120.0040.00420.93
8.2.110.0060.00321.06
8.2.100.0080.00417.84
8.2.90.0030.00519.21
8.2.80.0080.00017.97
8.2.70.0050.00318.03
8.2.60.0000.00817.50
8.2.50.0000.00918.57
8.2.40.0080.00518.93
8.2.30.0080.00518.78
8.2.20.0070.00118.84
8.2.10.0040.00819.35
8.2.00.0080.00419.41
8.1.300.0090.00016.63
8.1.290.0030.00618.88
8.1.280.0030.01225.92
8.1.270.0090.00023.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0090.00024.02
8.1.230.0060.00619.04
8.1.220.0000.00817.74
8.1.210.0080.00018.77
8.1.200.0030.00617.25
8.1.190.0030.00517.22
8.1.180.0070.00518.81
8.1.170.0040.00819.20
8.1.160.0040.00819.25
8.1.150.0070.00419.17
8.1.140.0050.00519.16
8.1.130.0070.00518.48
8.1.120.0060.00718.41
8.1.110.0090.00418.44
8.1.100.0020.01018.49
8.1.90.0050.00818.43
8.1.80.0030.00818.45
8.1.70.0050.00718.43
8.1.60.0030.01118.55
8.1.50.0080.00418.57
8.1.40.0060.00818.56
8.1.30.0120.00418.10
8.1.20.0060.00618.62
8.1.10.0110.00218.58
8.1.00.0060.00818.54
8.0.300.0050.00518.77
8.0.290.0080.00016.75
8.0.280.0090.00319.01
8.0.270.0070.00618.74
8.0.260.0080.00518.21
8.0.250.0100.00218.23
8.0.240.0080.00418.21
8.0.230.0060.00618.28
8.0.220.0060.00618.25
8.0.210.0070.00418.25
8.0.200.0070.00418.26
8.0.190.0090.00518.20
8.0.180.0090.00518.25
8.0.170.0090.00318.24
8.0.160.0100.00418.23
8.0.150.0100.00218.18
8.0.140.0060.00618.11
8.0.130.0100.00316.63
8.0.120.0060.00517.71
8.0.110.0040.00617.74
8.0.100.0080.00317.69
8.0.90.0070.00417.72
8.0.80.0080.00717.48
8.0.70.0080.00217.79
8.0.60.0080.00317.75
8.0.50.0060.00517.68
8.0.30.0070.00817.72
8.0.20.0080.00717.68
8.0.10.0050.00617.82
8.0.00.0080.00717.79
7.4.330.0080.00017.53
7.4.320.0070.00418.00
7.4.300.0070.00617.99
7.4.290.0050.00718.01
7.4.280.0080.00418.06
7.4.270.0070.00618.05
7.4.260.0080.00416.40
7.4.250.0040.00617.49
7.4.240.0020.00817.57
7.4.230.0040.00617.52
7.4.220.0070.00317.48
7.4.210.0040.00917.13
7.4.200.0070.00417.63
7.4.190.0080.00318.09
7.4.180.0100.00218.04
7.4.160.0100.00218.00
7.4.150.0090.00217.95
7.4.140.0070.00518.06
7.4.130.0090.00517.25
7.4.120.0080.00817.59
7.4.110.0080.00717.47
7.4.100.0140.00717.12
7.4.90.0120.00816.96
7.4.80.0120.01016.97
7.4.70.0140.00716.96
7.4.60.0110.00716.94
7.4.50.0120.00716.92
7.4.40.0110.00716.95
7.4.30.0120.00716.93
7.4.20.0120.00816.98
7.4.10.0110.00816.89
7.4.00.0090.00817.01
7.3.330.0100.00117.88
7.3.320.0050.00516.36
7.3.310.0040.00617.42
7.3.300.0050.00517.45
7.3.290.0110.00516.95
7.3.280.0090.00417.31
7.3.270.0080.00417.94
7.3.260.0070.00817.46
7.3.250.0040.00717.93
7.3.240.0070.00417.97
7.3.230.0080.00617.43
7.3.220.0150.00617.08
7.3.210.0130.00916.91
7.3.200.0120.00716.93
7.3.190.0140.00716.90
7.3.180.0100.00916.99
7.3.170.0110.00816.94
7.3.160.0120.00716.97
7.3.150.0130.00616.83
7.3.140.0090.00916.83
7.3.130.0150.00516.89
7.3.120.0130.00516.86
7.3.110.0130.00616.86
7.3.100.0150.00516.91
7.3.90.0130.00716.99
7.3.80.0120.00816.95
7.3.70.0130.00716.88
7.3.60.0110.00816.89
7.3.50.0100.00916.88
7.3.40.0120.00816.92
7.3.30.0120.00716.88
7.3.20.0150.00616.82
7.3.10.0140.00716.84
7.3.00.0100.01116.92
7.2.340.0060.00617.82
7.2.330.0130.00816.81
7.2.320.0130.00716.80
7.2.310.0120.00816.86
7.2.300.0120.00716.80
7.2.290.0100.00916.77
7.2.280.0090.01016.76
7.2.270.0150.00616.83
7.2.260.0130.00716.74
7.2.250.0150.00416.70
7.2.240.0140.00616.78
7.2.230.0120.00616.76
7.2.220.0090.01016.79
7.2.210.0130.00716.75
7.2.200.0120.00916.83
7.2.190.0130.00716.74
7.2.180.0120.00716.67
7.2.170.0120.00916.76
7.2.160.0120.00716.73
7.2.150.0160.00716.74
7.2.140.0110.00916.83
7.2.130.0170.00616.88
7.2.120.0180.00916.81
7.2.110.0120.01016.82
7.2.100.0150.00616.87
7.2.90.0080.01116.70
7.2.80.0110.00816.89
7.2.70.0110.00716.89
7.2.60.0110.00816.76
7.2.50.0110.00816.63
7.2.40.0110.00716.83
7.2.30.0080.01116.89
7.2.20.0120.00716.78
7.2.10.0100.00916.78
7.2.00.0150.00516.78

preferences:
30.15 ms | 406 KiB | 6 Q