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]) >> $offsetl)); 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.40.0150.00618.84
8.3.30.0040.01119.08
8.3.20.0040.00420.17
8.3.10.0030.00521.98
8.3.00.0080.00022.37
8.2.170.0090.00622.96
8.2.160.0030.01719.20
8.2.150.0000.00824.18
8.2.140.0060.00324.66
8.2.130.0000.00926.16
8.2.120.0050.00317.75
8.2.110.0000.00922.08
8.2.100.0060.00619.60
8.2.90.0060.00319.36
8.2.80.0050.00318.04
8.2.70.0000.00817.50
8.2.60.0060.00318.05
8.2.50.0060.00318.07
8.2.40.0000.00818.16
8.2.30.0100.00318.16
8.2.20.0040.00417.76
8.2.10.0040.00417.88
8.2.00.0080.00017.68
8.1.270.0050.00321.93
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0090.00023.75
8.1.230.0070.00319.14
8.1.220.0080.00017.77
8.1.210.0080.00018.77
8.1.200.0000.00917.35
8.1.190.0000.00817.38
8.1.180.0040.00418.10
8.1.170.0050.00318.63
8.1.160.0030.00522.09
8.1.150.0000.00818.68
8.1.140.0030.00517.44
8.1.130.0000.00717.78
8.1.120.0050.00217.49
8.1.110.0040.00417.37
8.1.100.0000.00717.54
8.1.90.0040.00417.34
8.1.80.0040.00417.46
8.1.70.0030.00317.48
8.1.60.0040.00417.64
8.1.50.0030.00617.57
8.1.40.0060.00317.55
8.1.30.0000.00717.51
8.1.20.0000.00917.59
8.1.10.0060.00317.54
8.1.00.0000.00817.54
8.0.300.0000.00718.77
8.0.290.0040.00417.30
8.0.280.0000.00818.53
8.0.270.0030.00317.20
8.0.260.0030.00516.86
8.0.250.0030.00317.00
8.0.240.0040.00416.96
8.0.230.0040.00417.02
8.0.220.0000.00716.92
8.0.210.0030.00316.82
8.0.200.0030.00317.01
8.0.190.0000.00816.99
8.0.180.0040.00417.01
8.0.170.0050.00316.98
8.0.160.0000.00816.90
8.0.150.0000.00716.92
8.0.140.0000.00716.77
8.0.130.0000.00513.38
8.0.120.0040.00416.76
8.0.110.0050.00316.97
8.0.100.0080.00016.79
8.0.90.0000.00716.84
8.0.80.0060.00916.92
8.0.70.0040.00416.83
8.0.60.0000.00716.79
8.0.50.0040.00416.95
8.0.30.0100.01117.29
8.0.20.0120.00617.44
8.0.10.0060.00317.17
8.0.00.0060.01216.69
7.4.330.0030.00315.00
7.4.320.0030.00316.54
7.4.300.0000.00716.45
7.4.290.0000.00716.50
7.4.280.0060.00016.50
7.4.270.0030.00316.68
7.4.260.0070.00016.51
7.4.250.0050.00316.43
7.4.240.0030.00416.52
7.4.230.0000.00716.53
7.4.220.0160.01016.71
7.4.210.0080.00816.66
7.4.200.0000.00716.71
7.4.190.0000.00716.40
7.4.160.0140.00716.52
7.4.150.0070.01617.40
7.4.140.0140.00517.86
7.4.130.0120.00716.52
7.4.120.0160.00416.54
7.4.110.0120.00416.54
7.4.100.0090.00916.55
7.4.90.0060.01516.62
7.4.80.0120.01219.39
7.4.70.0120.00616.33
7.4.60.0100.00716.58
7.4.50.0000.00416.65
7.4.40.0030.01322.77
7.4.30.0070.01016.30
7.4.00.0080.00715.04
7.3.330.0000.00513.18
7.3.320.0000.00613.25
7.3.310.0000.00716.30
7.3.300.0030.00316.41
7.3.290.0140.00016.40
7.3.280.0100.00916.38
7.3.270.0090.00917.40
7.3.260.0090.00916.62
7.3.250.0120.00816.47
7.3.240.0110.01416.64
7.3.230.0060.01216.66
7.3.210.0110.00716.42
7.3.200.0160.00419.39
7.3.190.0040.01316.66
7.3.180.0060.01016.29
7.3.170.0150.00616.42
7.3.160.0150.00316.66
7.3.120.0110.00615.05
7.3.110.0100.00714.86
7.3.100.0120.00314.84
7.3.90.0120.00614.91
7.3.80.0030.01314.58
7.3.70.0040.00814.91
7.3.60.0030.01315.05
7.3.50.0030.00614.81
7.3.40.0080.00415.03
7.3.30.0090.00614.65
7.3.20.0110.00016.73
7.3.10.0030.00616.70
7.3.00.0070.00716.64
7.2.330.0140.00616.82
7.2.320.0090.00916.82
7.2.310.0100.01016.77
7.2.300.0120.00416.60
7.2.290.0000.01716.94
7.2.250.0100.01015.23
7.2.240.0080.01214.84
7.2.230.0120.00614.96
7.2.220.0070.01115.32
7.2.210.0000.01715.26
7.2.200.0030.00615.29
7.2.190.0040.01115.02
7.2.180.0030.01214.95
7.2.170.0030.01115.05
7.2.00.0030.01419.19
7.1.330.0070.00715.69
7.1.320.0070.00715.91
7.1.310.0060.00615.97
7.1.300.0060.00615.91
7.1.290.0070.00315.58
7.1.280.0090.00615.63
7.1.270.0000.01215.94
7.1.260.0060.01015.78
7.1.100.0000.01218.16
7.1.70.0060.01317.14
7.1.60.0040.00817.32
7.1.50.0070.01416.79
7.1.00.0030.07722.44
7.0.200.0060.00916.79
7.0.140.0070.07022.12
7.0.60.0070.08020.05
7.0.50.0070.05018.03
7.0.40.0030.09720.15
7.0.30.0230.04720.23
7.0.20.0130.04720.07
7.0.10.0230.08320.16
7.0.00.0100.05320.10
5.6.280.0030.07320.91
5.6.210.0070.05720.75
5.6.200.0170.03318.22
5.6.190.0100.08720.33
5.6.180.4070.05020.55
5.6.170.0330.06320.44
5.6.160.0130.07720.57
5.6.150.0030.04318.19
5.6.140.0030.07718.27
5.6.130.0100.04318.28
5.6.120.0070.08021.00
5.6.110.0170.04321.07
5.6.100.0130.06021.03
5.6.90.0030.08321.04
5.6.80.0130.08020.43
5.6.70.0200.07020.54
5.5.350.0000.08720.54
5.5.340.0130.06717.96
5.5.330.0070.07020.23
5.5.320.0130.04720.38
5.5.310.0100.04720.27
5.5.300.0000.08317.98
5.5.290.0130.07017.95
5.5.280.0130.07720.82
5.5.270.0130.07320.89
5.5.260.0100.07720.90
5.5.250.0000.08720.73
5.5.240.0000.09020.30
5.4.450.0700.09719.45
5.4.440.0170.06019.39
5.4.430.0130.05319.42
5.4.420.0100.05719.46
5.4.410.0070.05719.27
5.4.400.0070.05718.80
5.4.390.0100.05018.74
5.4.380.0070.05718.76
5.4.370.0400.06018.84
5.4.360.0100.04718.55
5.4.350.0370.04718.80
5.4.340.0030.05318.79
5.4.320.0050.04112.52
5.4.310.0090.03912.52
5.4.300.0050.03512.52
5.4.290.0020.05112.52
5.4.280.0060.03912.41
5.4.270.0100.05718.81
5.4.260.0100.05718.81
5.4.250.0070.06018.96
5.4.240.0100.05718.99
5.4.230.0100.06718.84
5.4.220.0070.08018.77
5.4.210.0100.07719.10
5.4.200.0170.05319.00
5.4.190.0200.06319.01
5.4.180.0030.07719.09
5.4.170.0030.05719.05
5.4.160.0070.06718.82
5.4.150.0100.07019.00
5.4.140.0130.05716.45
5.4.130.0170.06316.44
5.4.120.0030.07316.50
5.4.110.0130.05716.43
5.4.100.0030.07316.48
5.4.90.0200.06316.46
5.4.80.0130.05316.37
5.4.70.0000.05716.40
5.4.60.0170.05716.60
5.4.50.0170.05016.63
5.4.40.0030.07016.69
5.4.30.0100.04316.49
5.4.20.0030.07716.49
5.4.10.0130.06316.47
5.4.00.0070.05315.77
5.3.290.0090.04112.80
5.3.280.0170.06014.69
5.3.270.0070.07314.63
5.3.260.0130.08014.71
5.3.250.0130.05014.72
5.3.240.0070.06314.46
5.3.230.0230.06314.79
5.3.220.0170.06314.76
5.3.210.0100.07014.68
5.3.200.0100.07714.62
5.3.190.0170.06314.59
5.3.180.0130.06314.77
5.3.170.0170.06014.82
5.3.160.0070.05314.60
5.3.150.0100.05714.58
5.3.140.0130.07014.65
5.3.130.0200.06714.60
5.3.120.0200.06714.66
5.3.110.0130.05314.71
5.3.100.0000.07714.16
5.3.90.0230.04714.05
5.3.80.0130.07014.23
5.3.70.0170.05314.07
5.3.60.0070.06714.21
5.3.50.0200.06014.05
5.3.40.0100.05314.05
5.3.30.0070.04714.02
5.3.20.0230.05013.71
5.3.10.0070.06713.51
5.3.00.0100.05013.67
5.2.170.0100.03711.18
5.2.160.0030.04711.09
5.2.150.0100.04311.09
5.2.140.0100.04311.27
5.2.130.0130.05311.36
5.2.120.0000.04711.14
5.2.110.0100.05011.09
5.2.100.0130.04011.12
5.2.90.0070.05711.18
5.2.80.0170.03711.08
5.2.70.0070.04311.07
5.2.60.0030.04311.09
5.2.50.0130.05011.12
5.2.40.0100.03711.10
5.2.30.0100.03710.91
5.2.20.0070.04311.05
5.2.10.0030.04710.80
5.2.00.0100.04010.74
5.1.60.0100.04010.04
5.1.50.0100.03310.02
5.1.40.0100.0439.96
5.1.30.0030.03710.35
5.1.20.0000.04310.61
5.1.10.0070.03710.08
5.1.00.0070.05010.20
5.0.50.0000.0338.55
5.0.40.0000.0438.42
5.0.30.0130.0478.32
5.0.20.0100.0238.44
5.0.10.0070.0308.32
5.0.00.0030.0578.26
4.4.90.0070.0206.92
4.4.80.0070.0176.92
4.4.70.0100.0176.92
4.4.60.0100.0176.92
4.4.50.0070.0176.92
4.4.40.0030.0336.92
4.4.30.0030.0306.92
4.4.20.0070.0276.92
4.4.10.0000.0236.92
4.4.00.0100.0376.92
4.3.110.0030.0236.92
4.3.100.0100.0236.92
4.3.90.0100.0136.92
4.3.80.0030.0376.92
4.3.70.0030.0306.92
4.3.60.0070.0176.92
4.3.50.0030.0306.92
4.3.40.0100.0406.92
4.3.30.0070.0276.92
4.3.20.0130.0206.92
4.3.10.0030.0236.92
4.3.00.0070.0237.38

preferences:
46.39 ms | 400 KiB | 5 Q