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] = $signbits; } if ($offsetr == 0) { /* Shifting multiples of 8 allows us to simply copy the relevant bytes */ for ($i = $skip, $l = $i + $copylen; $l; $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); } */ } $input = "abc\x00"; $bits = 8; 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.0150.00018.43
8.3.50.0110.00522.10
8.3.40.0070.00718.97
8.3.30.0030.01019.25
8.3.20.0080.00020.25
8.3.10.0040.00422.09
8.3.00.0000.00822.33
8.2.180.0120.00316.63
8.2.170.0070.01122.96
8.2.160.0100.01019.39
8.2.150.0090.00024.18
8.2.140.0080.00024.66
8.2.130.0050.00326.16
8.2.120.0040.00417.75
8.2.110.0060.00322.19
8.2.100.0040.00719.51
8.2.90.0040.00419.20
8.2.80.0050.00518.16
8.2.70.0030.00617.75
8.2.60.0050.00318.05
8.2.50.0040.00418.07
8.2.40.0030.00618.16
8.2.30.0000.01018.13
8.2.20.0070.00017.80
8.2.10.0000.00919.53
8.2.00.0050.00317.93
8.1.280.0030.01325.92
8.1.270.0030.00622.00
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0040.00423.92
8.1.230.0060.00618.98
8.1.220.0040.00417.79
8.1.210.0040.00418.77
8.1.200.0040.00417.13
8.1.190.0000.00817.30
8.1.180.0030.00518.10
8.1.170.0080.00018.51
8.1.160.0040.00721.98
8.1.150.0040.00418.70
8.1.140.0000.00717.34
8.1.130.0000.00717.91
8.1.120.0040.00417.52
8.1.110.0000.00817.38
8.1.100.0000.00817.43
8.1.90.0000.00817.33
8.1.80.0000.00817.38
8.1.70.0000.00717.39
8.1.60.0060.00317.51
8.1.50.0000.00817.50
8.1.40.0020.00517.41
8.1.30.0040.00417.70
8.1.20.0000.00917.68
8.1.10.0040.00417.62
8.1.00.0000.00717.59
8.0.300.0040.00418.77
8.0.290.0000.00717.18
8.0.280.0040.00418.42
8.0.270.0030.00317.29
8.0.260.0070.00016.80
8.0.250.0030.00317.02
8.0.240.0030.00516.97
8.0.230.0070.00017.02
8.0.220.0000.00716.89
8.0.210.0000.00716.84
8.0.200.0030.00317.08
8.0.190.0040.00417.02
8.0.180.0070.00016.88
8.0.170.0060.00316.88
8.0.160.0040.00416.97
8.0.150.0000.00716.90
8.0.140.0000.00716.92
8.0.130.0060.00013.43
8.0.120.0040.00416.84
8.0.110.0000.00716.96
8.0.100.0070.00016.90
8.0.90.0050.00217.02
8.0.80.0100.01017.02
8.0.70.0040.00416.85
8.0.60.0050.00216.85
8.0.50.0050.00216.93
8.0.30.0120.00917.17
8.0.20.0110.00817.40
8.0.10.0040.00417.07
8.0.00.0080.01216.94
7.4.330.0030.00515.02
7.4.320.0020.00516.29
7.4.300.0040.00416.50
7.4.290.0070.00016.48
7.4.280.0040.00416.54
7.4.270.0040.00416.41
7.4.260.0000.00716.52
7.4.250.0030.00616.46
7.4.240.0040.00416.50
7.4.230.0040.00416.49
7.4.220.0140.01116.52
7.4.210.0080.01216.48
7.4.200.0000.00716.49
7.4.190.0040.00416.63
7.4.160.0620.01016.51
7.4.150.0050.01817.40
7.4.140.0110.01317.86
7.4.130.0160.02216.54
7.4.120.0300.00516.38
7.4.110.0400.00316.52
7.4.100.0410.02316.46
7.4.90.0450.01316.46
7.4.80.0780.02219.39
7.4.70.0390.01716.52
7.4.60.0710.01716.40
7.4.50.0030.00316.46
7.4.40.0000.01722.77
7.4.30.0460.00716.52
7.3.330.0030.00313.28
7.3.320.0000.00613.41
7.3.310.0050.00316.42
7.3.300.0040.00416.42
7.3.290.0130.01316.32
7.3.280.0140.01316.37
7.3.270.0360.02917.40
7.3.260.0210.00416.25
7.3.250.0430.02316.53
7.3.240.0110.02016.45
7.3.230.0380.01216.58
7.3.210.0090.01416.35
7.3.200.0110.01219.39
7.3.190.0160.00716.52
7.3.180.0100.00716.38
7.3.170.0090.01516.39
7.3.160.0540.00716.52
7.2.330.0940.03516.79
7.2.320.0780.01916.59
7.2.310.0170.01416.82
7.2.300.0120.00816.76
7.2.290.0230.01616.82
5.4.270.2230.04718.83
5.4.260.2000.03719.03
5.4.250.2300.04319.26
5.4.240.2070.04318.93
5.4.230.2070.04019.26
5.4.220.2000.04319.02
5.4.210.2030.04018.80
5.4.200.2070.04018.79
5.4.190.2500.03719.16
5.4.180.2170.03718.93
5.4.170.2300.04019.17
5.4.160.2070.03719.05
5.4.150.2300.03718.78
5.4.140.2070.03716.25
5.4.130.2230.03016.43
5.4.120.2130.04016.42
5.4.110.2070.04016.56
5.4.100.2270.04716.54
5.4.90.2070.03716.50
5.4.80.2230.04316.52
5.4.70.2370.03716.34
5.4.60.0070.05016.29
5.4.50.2430.04016.53
5.4.40.2300.03316.26
5.4.30.0200.04316.32
5.4.20.2270.03316.41
5.4.10.2070.03016.38
5.4.00.0100.04715.90
5.3.280.2100.04014.45
5.3.270.2300.04014.41
5.3.260.2300.03314.48
5.3.250.2100.03714.36
5.3.240.2230.04014.48
5.3.230.2170.04314.47
5.3.220.2300.04014.51
5.3.210.2300.04014.43
5.3.200.2300.03714.42
5.3.190.2300.04314.34
5.3.180.2330.04014.36
5.3.170.2030.03714.55
5.3.160.2300.04314.32
5.3.150.2270.04014.41
5.3.140.2230.04714.64
5.3.130.2330.05014.41
5.3.120.2270.03714.49
5.3.110.2230.04714.41
5.3.100.0070.05713.89
5.3.90.2100.03713.79
5.3.80.2270.04713.88
5.3.70.2370.04013.75
5.3.60.2200.04313.93
5.3.50.2300.04313.81
5.3.40.2300.04713.97
5.3.30.2030.03713.78
5.3.20.2370.03313.50
5.3.10.1830.03013.53
5.3.00.2530.04013.48

preferences:
43.79 ms | 400 KiB | 5 Q