3v4l.org

run code in 300+ PHP versions simultaneously
<?php function string_shift_left($input, $inputlen, $bits, &$output = null) { $skip = (int) ($bits / 8); $copylen = (int) ($inputlen - $skip); $offset = ($bits % 8) & 0xff; $mask = ~(0xff >> $offset) & 0xff; $output = str_pad('', $inputlen + 1, "\x00"); echo "$skip $copylen $offset $mask\n"; if ($offset == 0) { /* Shifting multiples of 8 allows us to simply copy the relevant bytes */ for ($i = 0; $i < $copylen; $i++) { $output[$i] = $input[$i + $skip]; } return; } for ($i = 0; $i < $copylen; $i++) { $left = (ord($input[$i + $skip]) << $offset) & 0xff; $right = (ord($input[$i + $skip + 1]) & $mask) >> (8 - $offset); printf("%08b %08b\n", $left, $right); $output[$i] = chr(($left | $right) & 0xff); } } function string_shift_right($input, $inputlen, $bits, &$output = null) { $skip = (int) ($bits / 8); $copylen = (int) ($inputlen - $skip); $offsetr = ($bits % 8) & 0xff; $signbits = (ord($input[0]) & 0x80) == 0 ? 0 : 255; echo "$skip $copylen $offsetr $signbits\n"; $output = str_pad('', $inputlen + 1, "\x00"); for ($i = 0; $i < $skip; $i++) { $output[$i] = chr($signbits); } if ($offsetr == 0) { /* Shifting multiples of 8 allows us to simply copy the relevant bytes */ for ($i = $skip, $l = $i + $copylen; $i < $l; $i++) { $output[$i] = $input[$i - $skip]; } return; } $offsetl = 8 - $offsetr; $mask = ~(0xff >> $offsetr) & 0xff; $output[$skip] = chr(($signbits & ~(0xff >> $offsetl)) | (ord($input[0]) >> $offsetr)); for ($i = $skip + 1, $l = $skip + $copylen; $i < $l; $i++) { $left = ord($input[($i - $skip) - 1]) << $offsetl; $right = (ord($input[$i - $skip]) & $mask) >> $offsetr; printf("%08b %08b\n", $left, $right); $output[$i] = chr($left | $right); } } $input = "abc\x00"; $bits = 6; string_shift_right($input, strlen($input) - 1, $bits, $output); for ($i = 0; $i < strlen($input); $i++) { printf("\n%02x: %08b", ord($input[$i]), ord($input[$i])); } for ($i = 0; $i < strlen($output); $i++) { printf("\n%02x: %08b", ord($output[$i]), ord($output[$i])); }

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.0130.00718.30
8.3.50.0120.00921.88
8.3.40.0110.00718.67
8.3.30.0140.00019.09
8.3.20.0080.00020.33
8.3.10.0050.00321.92
8.3.00.0080.00022.43
8.2.180.0110.00716.50
8.2.170.0110.00422.96
8.2.160.0100.00319.20
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0070.00026.16
8.2.120.0030.00517.47
8.2.110.0030.00722.23
8.2.100.0080.00419.57
8.2.90.0040.00819.21
8.2.80.0030.00618.05
8.2.70.0000.00917.75
8.2.60.0030.00718.04
8.2.50.0040.00418.07
8.2.40.0070.00318.34
8.2.30.0060.00618.10
8.2.20.0030.00617.75
8.2.10.0050.00319.41
8.2.00.0030.00517.79
8.1.280.0140.00725.92
8.1.270.0000.00921.98
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0030.00623.79
8.1.230.0080.00419.06
8.1.220.0000.00817.74
8.1.210.0000.00818.77
8.1.200.0000.00917.48
8.1.190.0000.00817.53
8.1.180.0000.00818.10
8.1.170.0040.00418.46
8.1.160.0000.01021.91
8.1.150.0040.00418.59
8.1.140.0000.00717.47
8.1.130.0000.00817.73
8.1.120.0050.00317.41
8.1.110.0000.00717.47
8.1.100.0000.00717.53
8.1.90.0030.00517.35
8.1.80.0040.00417.51
8.1.70.0000.00717.46
8.1.60.0090.00017.57
8.1.50.0030.00617.53
8.1.40.0050.00317.61
8.1.30.0080.00017.54
8.1.20.0030.00617.60
8.1.10.0040.00417.57
8.1.00.0040.00417.52
8.0.300.0030.00618.77
8.0.290.0000.00717.18
8.0.280.0050.00318.37
8.0.270.0040.00417.41
8.0.260.0000.00616.91
8.0.250.0000.00717.02
8.0.240.0000.00716.91
8.0.230.0030.00317.03
8.0.220.0030.00316.96
8.0.210.0030.00316.92
8.0.200.0070.00017.00
8.0.190.0040.00417.02
8.0.180.0040.00416.95
8.0.170.0080.00016.86
8.0.160.0040.00416.95
8.0.150.0000.00816.91
8.0.140.0040.00416.79
8.0.130.0000.00613.34
8.0.120.0040.00416.78
8.0.110.0090.00016.94
8.0.100.0000.00716.80
8.0.90.0030.00516.82
8.0.80.0130.00316.95
8.0.70.0000.00716.93
8.0.60.0040.00416.89
8.0.50.0040.00416.82
8.0.30.0100.01116.96
8.0.20.0110.00717.40
8.0.10.0000.00917.17
8.0.00.0100.01216.76
7.4.330.0000.00615.00
7.4.320.0000.00716.39
7.4.300.0030.00316.55
7.4.290.0030.00316.50
7.4.280.0080.00016.66
7.4.270.0030.00316.53
7.4.260.0030.00316.44
7.4.250.0040.00416.40
7.4.240.0000.00716.57
7.4.230.0030.00316.70
7.4.220.0060.01216.58
7.4.210.0080.00816.63
7.4.200.0070.00016.64
7.4.190.0070.00016.77
7.4.160.0030.01416.31
7.4.150.0150.00317.40
7.4.140.0110.00617.86
7.4.130.0070.01116.47
7.4.120.0080.01316.61
7.4.110.0120.00816.61
7.4.100.0090.00916.62
7.4.90.0130.00316.51
7.4.80.0100.01319.39
7.4.70.0150.00316.65
7.4.60.0110.00516.46
7.4.50.0020.00216.64
7.4.40.0080.00422.77
7.4.30.0100.00816.32
7.4.00.0040.01414.76
7.3.330.0060.00013.36
7.3.320.0050.00013.27
7.3.310.0070.00016.36
7.3.300.0040.00416.28
7.3.290.0070.00716.35
7.3.280.0120.00316.39
7.3.270.0060.01217.40
7.3.260.0090.00916.41
7.3.250.0070.01016.51
7.3.240.0110.00816.40
7.3.230.0170.00316.39
7.3.210.0030.01416.52
7.3.200.0070.01319.39
7.3.190.0090.01216.48
7.3.180.0030.01316.42
7.3.170.0080.00816.55
7.3.160.0080.00816.32
7.3.120.0090.00614.93
7.2.330.0040.01416.92
7.2.320.0140.00416.88
7.2.310.0090.01316.94
7.2.300.0070.01016.89
7.2.290.0110.00716.70
7.2.00.0030.01419.61
7.1.100.0070.00718.23
7.1.70.0070.00317.23
7.1.60.0060.01819.82
7.1.50.0100.01317.15
7.1.00.0030.07722.57
7.0.200.0100.00716.97
7.0.140.0030.07322.09
7.0.60.0100.08020.04
7.0.50.0070.09017.96
7.0.40.0100.06720.13
7.0.30.0330.04720.26
7.0.20.0200.04020.30
7.0.10.0170.04020.07
7.0.00.0170.07320.12
5.6.280.0070.06721.08
5.6.210.0070.08320.71
5.6.200.0100.06718.13
5.6.190.0000.08720.61
5.6.180.4230.04020.51
5.6.170.0300.07320.47
5.6.160.0030.05720.54
5.6.150.0100.07318.29
5.6.140.0070.07318.21
5.6.130.0030.08018.15
5.6.120.0100.06720.99
5.6.110.0100.08321.10
5.6.100.0130.07721.00
5.6.90.0100.06021.12
5.6.80.0100.07020.43
5.6.70.0200.08320.37
5.5.350.0030.08320.41
5.5.340.0100.04317.94
5.5.330.0070.07020.08
5.5.320.0100.05320.35
5.5.310.0200.04720.37
5.5.300.0070.03718.08
5.5.290.0130.07317.93
5.5.280.0070.04020.82
5.5.270.0070.04320.89
5.5.260.0130.04020.75
5.5.250.0030.06020.72
5.5.240.0170.07020.06
5.4.450.0070.06019.68
5.4.440.0630.06019.39
5.4.430.0170.04719.52
5.4.420.0100.06019.44
5.4.410.0070.05719.26
5.4.400.0100.05018.77
5.4.390.0070.07018.58
5.4.380.0330.04318.58
5.4.370.0200.05318.80
5.4.360.0230.04718.84
5.4.350.0170.06018.81
5.4.340.0200.05318.54
5.4.320.0070.03512.52
5.4.310.0050.04612.52
5.4.300.0050.04512.52
5.4.290.0100.04312.52
5.4.280.0100.03612.41
5.4.270.0130.07018.99
5.4.260.0170.06318.92
5.4.250.0070.06319.01
5.4.240.0200.05718.81
5.4.230.0170.06319.02
5.4.220.0130.08318.84
5.4.210.0130.05718.91
5.4.200.0070.06318.80
5.4.190.0130.06018.84
5.4.180.0070.06319.02
5.4.170.0130.05018.99
5.4.160.0100.07019.00
5.4.150.0070.08318.93
5.4.140.0130.06316.45
5.4.130.0100.04716.43
5.4.120.0100.06716.40
5.4.110.0100.06016.55
5.4.100.0130.06716.44
5.4.90.0030.05716.57
5.4.80.0230.05016.66
5.4.70.0070.06016.40
5.4.60.0130.06316.55
5.4.50.0070.06016.46
5.4.40.0170.05016.58
5.4.30.0030.08016.39
5.4.20.0100.05316.49
5.4.10.0070.07716.44
5.4.00.0270.05315.83
5.3.290.0070.04512.80
5.3.280.0070.06014.65
5.3.270.0100.07714.66
5.3.260.0100.06014.63
5.3.250.0070.06314.81
5.3.240.0200.04314.70
5.3.230.0170.04714.54
5.3.220.0130.04714.69
5.3.210.0070.07314.43
5.3.200.0200.04714.68
5.3.190.0170.06314.59
5.3.180.0070.07014.66
5.3.170.0200.06714.61
5.3.160.0100.06014.59
5.3.150.0270.05714.81
5.3.140.0070.05014.80
5.3.130.0100.07014.60
5.3.120.0100.05314.74
5.3.110.0170.05314.80
5.3.100.0230.06314.29
5.3.90.0130.05014.05
5.3.80.0130.06314.21
5.3.70.0070.05314.08
5.3.60.0200.05714.09
5.3.50.0200.06013.95
5.3.40.0100.05014.07
5.3.30.0130.04314.01
5.3.20.0130.06013.71
5.3.10.0230.03713.76
5.3.00.0030.06713.74
5.2.170.0000.06011.17
5.2.160.0170.03711.09
5.2.150.0030.05311.17
5.2.140.0070.04711.18
5.2.130.0000.04711.05
5.2.120.0030.04711.23
5.2.110.0130.04011.11
5.2.100.0100.03311.04
5.2.90.0100.04011.13
5.2.80.0030.04311.34
5.2.70.0070.04011.21
5.2.60.0030.05011.10
5.2.50.0100.04711.12
5.2.40.0100.05711.11
5.2.30.0070.04311.07
5.2.20.0100.05010.94
5.2.10.0070.04710.72
5.2.00.0070.05710.59
5.1.60.0070.0339.88
5.1.50.0070.04010.04
5.1.40.0070.0309.99
5.1.30.0130.04310.44
5.1.20.0200.04010.39
5.1.10.0030.03710.08
5.1.00.0070.05010.30
5.0.50.0100.0308.59
5.0.40.0030.0308.54
5.0.30.0030.0478.26
5.0.20.0070.0338.32
5.0.10.0030.0408.24
5.0.00.0070.0408.46
4.4.90.0100.0206.82
4.4.80.0070.0236.82
4.4.70.0070.0206.82
4.4.60.0000.0236.82
4.4.50.0000.0376.82
4.4.40.0070.0406.82
4.4.30.0030.0236.82
4.4.20.0030.0236.82
4.4.10.0070.0276.82
4.4.00.0070.0376.82
4.3.110.0000.0376.82
4.3.100.0000.0236.82
4.3.90.0030.0306.82
4.3.80.0100.0336.77
4.3.70.0070.0276.77
4.3.60.0070.0206.75
4.3.50.0030.0236.73
4.3.40.0030.0406.68
4.3.30.0000.0276.68
4.3.20.0000.0306.64
4.3.10.0000.0276.64
4.3.00.0070.0307.38

preferences:
86.98 ms | 401 KiB | 5 Q