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 = 4; 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.0070.00718.71
8.3.30.0030.01019.14
8.3.20.0040.00420.08
8.3.10.0040.00422.27
8.3.00.0030.00522.46
8.2.170.0040.01122.96
8.2.160.0120.00619.34
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0110.00726.16
8.2.120.0000.00817.63
8.2.110.0090.00022.04
8.2.100.0100.00717.59
8.2.90.0030.00519.04
8.2.80.0000.00817.97
8.2.70.0030.00617.50
8.2.60.0050.00318.05
8.2.50.0050.00318.07
8.2.40.0030.00618.16
8.2.30.0040.00718.16
8.2.20.0080.00017.80
8.2.10.0040.00419.54
8.2.00.0040.00417.78
8.1.270.0000.00822.05
8.1.260.0030.00526.35
8.1.250.0000.00728.09
8.1.240.0050.00523.80
8.1.230.0070.00319.16
8.1.220.0040.00417.74
8.1.210.0000.00918.77
8.1.200.0030.00717.48
8.1.190.0000.00817.65
8.1.180.0030.00618.10
8.1.170.0080.00018.56
8.1.160.0080.00322.10
8.1.150.0040.00418.60
8.1.140.0080.00017.45
8.1.130.0000.00717.71
8.1.120.0000.00717.47
8.1.110.0000.00817.52
8.1.100.0040.00417.50
8.1.90.0040.00417.36
8.1.80.0070.00017.54
8.1.70.0030.00317.47
8.1.60.0030.00617.65
8.1.50.0050.00317.41
8.1.40.0000.00817.47
8.1.30.0000.00717.59
8.1.20.0030.00617.73
8.1.10.0040.00417.54
8.1.00.0040.00417.51
8.0.300.0020.00518.77
8.0.290.0040.00417.18
8.0.280.0000.00718.48
8.0.270.0070.00017.30
8.0.260.0000.00716.87
8.0.250.0000.00717.01
8.0.240.0000.00717.00
8.0.230.0040.00417.01
8.0.220.0000.00716.98
8.0.210.0060.00016.95
8.0.200.0000.00817.00
8.0.190.0050.00316.93
8.0.180.0050.00216.93
8.0.170.0000.00817.00
8.0.160.0040.00416.96
8.0.150.0000.00716.78
8.0.140.0030.00516.92
8.0.130.0000.00513.29
8.0.120.0050.00316.92
8.0.110.0050.00316.90
8.0.100.0040.00416.88
8.0.90.0000.00816.83
8.0.80.0070.01016.96
8.0.70.0050.00316.92
8.0.60.0070.00017.00
8.0.50.0050.00316.73
8.0.30.0050.01517.27
8.0.20.0100.01217.40
8.0.10.0070.00017.00
8.0.00.0040.01316.97
7.4.330.0070.00015.00
7.4.320.0000.00716.64
7.4.300.0030.00316.61
7.4.290.0000.00716.54
7.4.280.0000.00816.43
7.4.270.0050.00316.57
7.4.260.0030.00616.63
7.4.250.0050.00316.42
7.4.240.0020.00516.59
7.4.230.0030.00316.42
7.4.220.0060.01216.70
7.4.210.0070.01116.60
7.4.200.0050.00216.64
7.4.190.0000.00716.60
7.4.160.0040.01216.34
7.4.150.0110.00717.40
7.4.140.0100.00817.86
7.4.130.0160.00616.50
7.4.120.0050.01216.58
7.4.110.0180.00316.50
7.4.100.0070.01016.63
7.4.90.0080.00816.50
7.4.80.0060.01619.39
7.4.70.0060.01216.62
7.4.60.0110.01116.33
7.4.50.0040.00416.20
7.4.40.0030.01322.77
7.4.30.0060.00916.69
7.4.00.0060.00914.90
7.3.330.0040.00413.41
7.3.320.0000.00513.27
7.3.310.0000.00816.45
7.3.300.0030.00316.26
7.3.290.0070.00716.41
7.3.280.0120.00616.39
7.3.270.0140.00317.40
7.3.260.0100.00716.54
7.3.250.0140.00516.53
7.3.240.0100.01316.61
7.3.230.0110.00716.39
7.3.210.0090.00916.44
7.3.200.0120.00619.39
7.3.190.0080.00816.59
7.3.180.0060.00916.75
7.3.170.0070.01016.46
7.3.160.0190.00316.43
7.3.120.0030.01415.14
7.2.330.0150.00316.62
7.2.320.0100.00716.78
7.2.310.0100.00716.54
7.2.300.0100.00716.78
7.2.290.0110.00616.61
7.2.60.0040.01117.00
7.2.00.0070.00719.21
7.1.200.0090.00315.95
7.1.100.0080.00617.86
7.1.70.0060.00317.14
7.1.60.0140.01019.82
7.1.50.0070.01517.05
7.1.00.0070.07022.54
7.0.200.0040.00716.43
7.0.140.0000.07722.15
7.0.60.0000.07019.93
7.0.50.0030.04017.94
7.0.40.0100.04020.40
7.0.30.0370.07720.09
7.0.20.0170.04320.07
7.0.10.0370.08720.24
7.0.00.0070.06320.16
5.6.280.0100.06720.93
5.6.210.0070.08720.64
5.6.200.0030.05018.19
5.6.190.0030.04720.48
5.6.180.3300.04720.68
5.6.170.0300.06020.45
5.6.160.0070.05020.44
5.6.150.0070.05018.19
5.6.140.0100.06018.27
5.6.130.0030.06318.13
5.6.120.0030.04721.01
5.6.110.0300.07020.99
5.6.100.0100.03321.15
5.6.90.0130.08021.03
5.6.80.0130.07320.55
5.6.70.0330.06720.39
5.5.350.0070.07720.35
5.5.340.0070.07018.10
5.5.330.0030.04320.29
5.5.320.0170.03720.24
5.5.310.0070.05020.26
5.5.300.0070.04717.98
5.5.290.0030.08318.08
5.5.280.0000.07320.98
5.5.270.0070.07020.86
5.5.260.0170.07720.89
5.5.250.0100.06720.71
5.5.240.0130.07320.30
5.4.450.2030.04719.46
5.4.440.2030.04019.38
5.4.430.2100.04319.45
5.4.420.1800.04019.54
5.4.410.2070.04319.32
5.4.400.2070.04319.22
5.4.390.2130.04319.22
5.4.380.2100.03718.99
5.4.370.1830.03719.06
5.4.360.1830.03719.16
5.4.350.2000.04019.22
5.4.340.2070.05018.99
5.4.320.2070.05018.88
5.4.310.2130.03019.21
5.4.300.0070.07319.06
5.4.290.0070.07018.85
5.4.280.0800.04718.99
5.4.270.2000.03319.07
5.4.260.1900.03019.16
5.4.250.2130.04318.97
5.4.240.2100.04318.97
5.4.230.2000.04719.15
5.4.220.2070.04719.29
5.4.210.2030.04719.05
5.4.200.1830.04019.12
5.4.190.1930.03019.18
5.4.180.2070.03719.11
5.4.170.2100.03718.96
5.4.160.2130.03718.97
5.4.150.1800.04018.85
5.4.140.2070.04316.72
5.4.130.2070.04016.54
5.4.120.2130.05316.46
5.4.110.1770.04316.23
5.4.100.2070.04016.61
5.4.90.2100.04016.50
5.4.80.1930.03016.48
5.4.70.2000.04016.31
5.4.60.1870.04016.53
5.4.50.2170.03716.51
5.4.40.2100.04016.17
5.4.30.2000.04016.53
5.4.20.1930.03716.43
5.4.10.2000.03316.17
5.4.00.1930.03015.78
5.3.290.1970.03314.78
5.3.280.2100.03714.52
5.3.270.2000.02714.76
5.3.260.1870.04014.64
5.3.250.1900.03314.72
5.3.240.1870.04014.63
5.3.230.1900.03314.53
5.3.220.1830.04714.68
5.3.210.1900.03314.66
5.3.200.1900.03714.59
5.3.190.1830.04014.69
5.3.180.1930.03714.75
5.3.170.1900.03314.61
5.3.160.1900.03314.52
5.3.150.1400.04014.57
5.3.140.0030.07314.50
5.3.130.0030.03714.66
5.3.120.1730.05314.72
5.3.110.2130.05014.49
5.3.100.2130.04014.15
5.3.90.1770.04014.03
5.3.80.2200.04014.05
5.3.70.2070.04714.20
5.3.60.2030.04313.96
5.3.50.2230.03313.91
5.3.40.2070.04714.04
5.3.30.1900.02714.18
5.3.20.0230.05013.81
5.3.10.0200.07013.91
5.3.00.0170.07313.58
5.2.170.0170.05711.19
5.2.160.0200.05711.27
5.2.150.0170.03311.11
5.2.140.0130.05311.09
5.2.130.0170.06011.06
5.2.120.0270.03711.07
5.2.110.0200.03011.21
5.2.100.0170.02711.06
5.2.90.0200.05311.06
5.2.80.0230.02011.04
5.2.70.0200.05711.13
5.2.60.0130.03711.07
5.2.50.0200.03310.97
5.2.40.0230.04311.11
5.2.30.0130.03711.08
5.2.20.0170.03010.90
5.2.10.0100.03010.85
5.2.00.0130.02710.72
5.1.60.0070.0339.96
5.1.50.0170.0539.93
5.1.40.0230.02710.10
5.1.30.0230.03710.45
5.1.20.0130.03710.61
5.1.10.0070.03010.23
5.1.00.0070.03010.09
5.0.50.0100.0208.51
5.0.40.0030.0238.35
5.0.30.0070.0308.25
5.0.20.0070.0178.41
5.0.10.0030.0208.11
5.0.00.0030.0338.21
4.4.90.0070.0138.00
4.4.80.0030.0138.00
4.4.70.0070.0138.00
4.4.60.0100.0178.00
4.4.50.0100.0178.00
4.4.40.0070.0238.00
4.4.30.0070.0138.00
4.4.20.0030.0178.00
4.4.10.0070.0138.00
4.4.00.0070.0238.00
4.3.110.0030.0178.00
4.3.100.0100.0138.00
4.3.90.0070.0138.00
4.3.80.0000.0308.00
4.3.70.0030.0208.00
4.3.60.0070.0178.00
4.3.50.0070.0138.00
4.3.40.0070.0278.00
4.3.30.0000.0208.00
4.3.20.0000.0278.00
4.3.10.0000.0208.00
4.3.00.0030.0238.00

preferences:
41.35 ms | 400 KiB | 5 Q