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 = 5; 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.0040.01118.14
8.3.50.0050.01421.91
8.3.40.0070.00718.79
8.3.30.0140.00019.23
8.3.20.0040.00420.16
8.3.10.0050.00322.05
8.3.00.0040.00422.43
8.2.180.0110.01116.63
8.2.170.0180.00422.96
8.2.160.0100.00319.33
8.2.150.0130.00724.18
8.2.140.0000.00824.66
8.2.130.0060.00326.16
8.2.120.0040.00419.36
8.2.110.0030.00622.11
8.2.100.0040.00819.63
8.2.90.0050.00319.22
8.2.80.0060.00317.97
8.2.70.0000.00917.63
8.2.60.0040.00418.03
8.2.50.0040.00418.07
8.2.40.0040.00418.22
8.2.30.0000.00918.14
8.2.20.0020.00517.63
8.2.10.0080.00019.60
8.2.00.0050.00317.84
8.1.280.0100.00725.92
8.1.270.0050.00322.02
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0080.00023.74
8.1.230.0080.00419.06
8.1.220.0000.00817.74
8.1.210.0000.00818.77
8.1.200.0090.00017.35
8.1.190.0040.00417.43
8.1.180.0000.00918.10
8.1.170.0030.00518.50
8.1.160.0030.00722.05
8.1.150.0000.00718.73
8.1.140.0000.00717.45
8.1.130.0070.00017.85
8.1.120.0000.00717.51
8.1.110.0000.00717.48
8.1.100.0000.00717.39
8.1.90.0040.00417.48
8.1.80.0000.00817.57
8.1.70.0030.00517.51
8.1.60.0000.00817.51
8.1.50.0040.00417.57
8.1.40.0040.00417.61
8.1.30.0060.00317.65
8.1.20.0000.00817.71
8.1.10.0000.00717.50
8.1.00.0080.00017.60
8.0.300.0020.00518.77
8.0.290.0040.00417.05
8.0.280.0000.00718.39
8.0.270.0040.00417.23
8.0.260.0000.00616.87
8.0.250.0000.00716.90
8.0.240.0030.00516.99
8.0.230.0000.00817.04
8.0.220.0000.00816.98
8.0.210.0000.00716.91
8.0.200.0070.00016.88
8.0.190.0030.00516.90
8.0.180.0040.00416.93
8.0.170.0000.00716.98
8.0.160.0000.00816.89
8.0.150.0030.00316.94
8.0.140.0050.00216.86
8.0.130.0000.00513.38
8.0.120.0080.00016.91
8.0.110.0040.00416.96
8.0.100.0040.00416.90
8.0.90.0080.00016.82
8.0.80.0060.01216.89
8.0.70.0040.00416.82
8.0.60.0060.00316.73
8.0.50.0020.00516.88
8.0.30.0070.01216.98
8.0.20.0100.01417.40
8.0.10.0050.00516.97
8.0.00.0100.01116.83
7.4.330.0000.00615.00
7.4.320.0000.00616.57
7.4.300.0060.00016.64
7.4.290.0030.00316.58
7.4.280.0000.00716.62
7.4.270.0000.00716.63
7.4.260.0030.00316.48
7.4.250.0040.00416.51
7.4.240.0040.00416.58
7.4.230.0080.00016.70
7.4.220.0110.01416.56
7.4.210.0070.00916.63
7.4.200.0000.00816.34
7.4.190.0000.00716.50
7.4.160.0120.00316.57
7.4.150.0100.00717.40
7.4.140.0120.00917.86
7.4.130.0060.01116.61
7.4.120.0150.00316.59
7.4.110.0080.00816.46
7.4.100.0110.00716.68
7.4.90.0110.00716.52
7.4.80.0040.01619.39
7.4.70.0090.00916.60
7.4.60.0100.00616.39
7.4.50.0000.00516.45
7.4.40.0110.00722.77
7.4.30.0170.00016.49
7.4.00.0090.00614.88
7.3.330.0030.00313.33
7.3.320.0050.00013.36
7.3.310.0000.00716.44
7.3.300.0000.00716.41
7.3.290.0030.01216.41
7.3.280.0070.00916.37
7.3.270.0120.00617.40
7.3.260.0140.00316.55
7.3.250.0120.00616.36
7.3.240.0150.00316.56
7.3.230.0150.00616.59
7.3.210.0070.01016.51
7.3.200.0070.01419.39
7.3.190.0100.01316.69
7.3.180.0150.00416.45
7.3.170.0060.01116.66
7.3.160.0110.01116.38
7.3.120.0070.00714.86
7.3.10.0030.01316.86
7.3.00.0000.01316.85
7.2.330.0120.00616.75
7.2.320.0120.00616.72
7.2.310.0060.01216.76
7.2.300.0100.01016.86
7.2.290.0080.01516.80
7.2.130.0000.01317.02
7.2.120.0080.00817.03
7.2.110.0060.00616.69
7.2.100.0050.00516.92
7.2.90.0070.00717.04
7.2.80.0110.00416.88
7.2.70.0060.00316.84
7.2.60.0040.01217.00
7.2.50.0030.01017.11
7.2.40.0070.00316.89
7.2.30.0040.00816.86
7.2.20.0030.00816.96
7.2.10.0120.00016.99
7.2.00.0020.01018.02
7.1.250.0030.01015.82
7.1.100.0000.01318.05
7.1.70.0040.00416.88
7.1.60.0060.01919.82
7.1.50.0030.01917.07
7.1.00.0030.07722.57
7.0.200.0030.00616.70
7.0.140.0070.07321.96
7.0.60.0100.06320.03
7.0.50.0030.04017.91
7.0.40.0000.09020.09
7.0.30.0270.06720.13
7.0.20.0200.06020.11
7.0.10.0270.07320.09
7.0.00.0070.07720.05
5.6.280.0100.08021.19
5.6.210.0230.07020.56
5.6.200.0100.08318.25
5.6.190.0070.06020.45
5.6.180.3470.04020.48
5.6.170.0300.06720.41
5.6.160.0030.04720.57
5.6.150.0100.04018.24
5.6.140.0030.04318.15
5.6.130.0130.07318.18
5.6.120.0130.07021.01
5.6.110.0070.07021.13
5.6.100.0100.08321.03
5.6.90.0130.07020.87
5.6.80.0100.07720.43
5.6.70.0230.07020.54
5.5.350.0100.08020.39
5.5.340.0100.05018.05
5.5.330.0130.06020.32
5.5.320.0130.04020.34
5.5.310.0230.03320.31
5.5.300.0100.03317.96
5.5.290.0070.05018.05
5.5.280.0070.05720.75
5.5.270.0070.04720.91
5.5.260.0200.05720.99
5.5.250.0170.07720.56
5.5.240.0070.08020.07
5.4.450.0530.06319.18
5.4.440.0530.05719.59
5.4.430.0070.06019.41
5.4.420.0070.06019.65
5.4.410.0070.05719.31
5.4.400.0200.04018.64
5.4.390.0130.04718.79
5.4.380.0400.07018.61
5.4.370.0270.04318.76
5.4.360.0070.06318.58
5.4.350.0200.05318.78
5.4.340.0330.04018.75
5.4.320.0070.03412.53
5.4.310.0050.03912.52
5.4.300.0040.03812.52
5.4.290.0060.03712.52
5.4.280.0030.03712.41
5.4.270.0130.04719.01
5.4.260.0130.04719.01
5.4.250.0130.05019.10
5.4.240.0030.05718.96
5.4.230.0000.07318.65
5.4.220.0030.08018.95
5.4.210.0070.05319.02
5.4.200.0170.04718.90
5.4.190.0070.08318.79
5.4.180.0100.06318.95
5.4.170.0170.08019.09
5.4.160.0070.08018.79
5.4.150.0130.05718.77
5.4.140.0070.07016.48
5.4.130.0170.05316.44
5.4.120.0100.04716.60
5.4.110.0070.05316.38
5.4.100.0130.06016.38
5.4.90.0070.05016.43
5.4.80.0070.05316.37
5.4.70.0130.05716.45
5.4.60.0200.05316.50
5.4.50.0030.05716.51
5.4.40.0130.06316.68
5.4.30.0170.06016.50
5.4.20.0170.04016.39
5.4.10.0400.04716.57
5.4.00.0200.05316.05
5.3.290.0070.03712.80
5.3.280.0000.06314.46
5.3.270.0100.05714.73
5.3.260.0100.07314.72
5.3.250.0100.07314.63
5.3.240.0130.05714.86
5.3.230.0100.06314.60
5.3.220.0070.05714.59
5.3.210.0130.07014.68
5.3.200.0070.05714.69
5.3.190.0070.07314.76
5.3.180.0130.06714.76
5.3.170.0070.05314.66
5.3.160.0130.05714.44
5.3.150.0100.08014.60
5.3.140.0070.07014.61
5.3.130.0100.05014.74
5.3.120.0070.05714.49
5.3.110.0070.06314.75
5.3.100.0030.06014.23
5.3.90.0170.05013.95
5.3.80.0100.05013.88
5.3.70.0130.04713.88
5.3.60.0100.06714.11
5.3.50.0100.05014.14
5.3.40.0230.05714.09
5.3.30.0070.05313.94
5.3.20.0070.07013.74
5.3.10.0100.06013.59
5.3.00.0130.04713.83
5.2.170.0070.04011.25
5.2.160.0100.04011.37
5.2.150.0030.04711.18
5.2.140.0170.03711.17
5.2.130.0170.05011.32
5.2.120.0100.03711.06
5.2.110.0170.04711.11
5.2.100.0000.04711.36
5.2.90.0070.04311.21
5.2.80.0000.05011.21
5.2.70.0100.04311.20
5.2.60.0100.04311.18
5.2.50.0070.04711.24
5.2.40.0070.05011.11
5.2.30.0100.05311.09
5.2.20.0100.05011.12
5.2.10.0100.03310.88
5.2.00.0070.04710.84
5.1.60.0030.03710.23
5.1.50.0030.03710.27
5.1.40.0100.0309.96
5.1.30.0030.04310.43
5.1.20.0070.05010.58
5.1.10.0100.04310.09
5.1.00.0070.04710.17
5.0.50.0130.0338.79
5.0.40.0000.0408.67
5.0.30.0070.0538.52
5.0.20.0030.0378.21
5.0.10.0170.0308.07
5.0.00.0000.0578.07
4.4.90.0000.0306.95
4.4.80.0030.0236.95
4.4.70.0070.0236.95
4.4.60.0070.0276.95
4.4.50.0100.0176.95
4.4.40.0100.0376.95
4.4.30.0100.0236.95
4.4.20.0100.0236.95
4.4.10.0000.0236.95
4.4.00.0030.0476.95
4.3.110.0070.0236.95
4.3.100.0030.0236.95
4.3.90.0030.0306.95
4.3.80.0070.0306.95
4.3.70.0030.0236.95
4.3.60.0000.0236.95
4.3.50.0000.0276.95
4.3.40.0000.0406.95
4.3.30.0030.0276.95
4.3.20.0070.0306.95
4.3.10.0000.0306.95
4.3.00.0130.0277.38

preferences:
45.77 ms | 401 KiB | 5 Q