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; } var_dump($output); 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; } /* 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.70.0150.00618.28
8.3.60.0120.00418.55
8.3.50.0070.01222.13
8.3.40.0090.00618.90
8.3.30.0100.00319.08
8.3.20.0040.00420.21
8.3.10.0040.00421.97
8.3.00.0030.00622.57
8.2.180.0120.00316.75
8.2.170.0110.00422.96
8.2.160.0070.00719.34
8.2.150.0080.00024.18
8.2.140.0060.00324.66
8.2.130.0050.00326.16
8.2.120.0030.00617.63
8.2.110.0090.00022.20
8.2.100.0120.00017.85
8.2.90.0040.00419.01
8.2.80.0040.00418.05
8.2.70.0000.00817.75
8.2.60.0040.00717.66
8.2.50.0000.00918.07
8.2.40.0050.00318.16
8.2.30.0050.00518.16
8.2.20.0000.00717.62
8.2.10.0040.00419.40
8.2.00.0030.00617.76
8.1.280.0070.01025.92
8.1.270.0080.00022.01
8.1.260.0060.00326.35
8.1.250.0060.00328.09
8.1.240.0040.00423.72
8.1.230.0060.00619.00
8.1.220.0000.00917.77
8.1.210.0000.00818.77
8.1.200.0030.00617.38
8.1.190.0040.00817.55
8.1.180.0090.00018.10
8.1.170.0060.00318.56
8.1.160.0040.00421.94
8.1.150.0050.00218.57
8.1.140.0070.00017.47
8.1.130.0000.00717.91
8.1.120.0070.00017.55
8.1.110.0040.00417.51
8.1.100.0040.00417.42
8.1.90.0050.00217.46
8.1.80.0050.00217.37
8.1.70.0000.00717.43
8.1.60.0040.00417.63
8.1.50.0040.00417.60
8.1.40.0040.00417.52
8.1.30.0000.00717.68
8.1.20.0040.00417.57
8.1.10.0040.00417.60
8.1.00.0070.00017.43
8.0.300.0000.00718.77
8.0.290.0090.00017.18
8.0.280.0000.00718.48
8.0.270.0030.00417.27
8.0.260.0000.00616.76
8.0.250.0000.00716.88
8.0.240.0000.00717.01
8.0.230.0000.00816.89
8.0.220.0040.00416.94
8.0.210.0000.00716.82
8.0.200.0030.00316.98
8.0.190.0040.00417.03
8.0.180.0000.00716.84
8.0.170.0040.00417.00
8.0.160.0040.00416.92
8.0.150.0040.00416.79
8.0.140.0030.00316.87
8.0.130.0000.00513.30
8.0.120.0030.00516.91
8.0.110.0000.00716.93
8.0.100.0040.00416.75
8.0.90.0040.00416.74
8.0.80.0090.00616.98
8.0.70.0040.00416.91
8.0.60.0000.00716.79
8.0.50.0020.00516.89
8.0.30.0130.00916.96
8.0.20.0110.01017.40
8.0.10.0030.00517.01
8.0.00.0130.00716.70
7.4.330.0040.00415.00
7.4.320.0030.00316.63
7.4.300.0000.00716.61
7.4.290.0040.00416.62
7.4.280.0000.00716.52
7.4.270.0000.00716.52
7.4.260.0000.00613.30
7.4.250.0040.00416.54
7.4.240.0040.00416.57
7.4.230.0070.00016.41
7.4.220.0080.00916.62
7.4.210.0060.00816.54
7.4.200.0050.00316.62
7.4.190.0040.00416.38
7.4.160.0130.00316.57
7.4.150.0070.01017.40
7.4.140.0100.01017.86
7.4.130.0090.00816.52
7.4.120.0120.00616.56
7.4.110.0120.00416.54
7.4.100.0080.01116.45
7.4.90.0090.00916.54
7.4.80.0090.01519.39
7.4.70.0070.01116.63
7.4.60.0060.01016.43
7.4.50.0000.00416.38
7.4.40.0060.00622.77
7.4.30.0090.00916.59
7.4.00.0070.00715.07
7.3.330.0000.00513.38
7.3.320.0000.00513.20
7.3.310.0050.00216.25
7.3.300.0000.00716.39
7.3.290.0030.01116.38
7.3.280.0050.01116.40
7.3.270.0060.01217.40
7.3.260.0150.00316.66
7.3.250.0100.00816.40
7.3.240.0150.00616.59
7.3.230.0130.00616.39
7.3.210.0170.00016.35
7.3.200.0080.00819.39
7.3.190.0030.01416.47
7.3.180.0070.01016.57
7.3.170.0090.00616.52
7.3.160.0070.01416.45
7.3.120.0030.01014.87
7.2.330.0070.01116.81
7.2.320.0090.00916.57
7.2.310.0070.01016.57
7.2.300.0100.00716.71
7.2.290.0070.01216.92
7.2.80.0070.00716.80
7.2.00.0000.01219.66
7.1.200.0190.00015.44
7.1.100.0040.00418.16
7.1.70.0000.00717.21
7.1.60.0140.01119.82
7.1.50.0040.00716.99
7.1.00.0030.07322.54
7.0.200.1340.00716.79
7.0.140.0100.06721.92
7.0.60.0100.07719.86
7.0.50.0070.08017.93
7.0.40.0100.08020.20
7.0.30.0200.05320.06
7.0.20.0270.05020.22
7.0.10.0230.03320.33
7.0.00.0070.04020.22
5.6.280.0000.07720.80
5.6.210.0130.07320.77
5.6.200.0030.08018.18
5.6.190.0030.06020.33
5.6.180.3530.03320.67
5.6.170.0200.07020.59
5.6.160.0070.07020.66
5.6.150.0100.08018.24
5.6.140.0130.08018.13
5.6.130.0100.07018.15
5.6.120.0070.04721.07
5.6.110.0130.07021.00
5.6.100.0030.07321.14
5.6.90.0070.08020.99
5.6.80.0100.05720.55
5.6.70.0300.07320.54
5.5.350.0100.07720.32
5.5.340.0030.08318.08
5.5.330.0100.04320.32
5.5.320.0270.04720.32
5.5.310.0330.07320.32
5.5.300.0030.04018.01
5.5.290.0130.07318.08
5.5.280.0100.08020.89
5.5.270.0070.06320.86
5.5.260.0200.07320.99
5.5.250.0170.07020.71
5.5.240.0100.08020.29
5.4.450.0700.05719.57
5.4.440.0800.08319.48
5.4.430.0070.06019.54
5.4.420.0170.05019.36
5.4.410.0100.05719.22
5.4.400.0030.06018.79
5.4.390.0030.06018.75
5.4.380.0170.05718.80
5.4.370.0330.03718.80
5.4.360.0230.04718.55
5.4.350.0300.04318.61
5.4.340.0230.04718.52
5.4.320.0070.03412.53
5.4.310.0020.04512.52
5.4.300.0040.03712.52
5.4.290.0040.04512.52
5.4.280.0040.03612.42
5.4.270.0300.05719.01
5.4.260.0230.05718.77
5.4.250.0100.06019.03
5.4.240.0070.05318.95
5.4.230.0170.04718.99
5.4.220.0030.06318.66
5.4.210.0070.06018.65
5.4.200.0130.06718.94
5.4.190.0070.06318.77
5.4.180.0100.05318.74
5.4.170.0100.07019.02
5.4.160.0170.04318.96
5.4.150.0130.05318.99
5.4.140.0070.07016.42
5.4.130.0170.06316.59
5.4.120.0230.05016.44
5.4.110.0100.05316.61
5.4.100.0130.07316.38
5.4.90.0130.06316.46
5.4.80.0100.04716.61
5.4.70.0170.05316.53
5.4.60.0070.06716.40
5.4.50.0030.05716.52
5.4.40.0030.05716.44
5.4.30.0170.04316.34
5.4.20.0100.05316.39
5.4.10.0070.05716.39
5.4.00.0170.04715.77
5.3.290.0070.03912.80
5.3.280.0070.05314.60
5.3.270.0130.06314.72
5.3.260.0130.06014.64
5.3.250.0000.06314.62
5.3.240.0170.06714.65
5.3.230.0070.06014.70
5.3.220.0030.07014.57
5.3.210.0130.05014.68
5.3.200.0100.06714.58
5.3.190.0030.08014.60
5.3.180.0100.07014.61
5.3.170.0070.07314.50
5.3.160.0070.06314.81
5.3.150.0230.06314.57
5.3.140.0100.07014.61
5.3.130.0070.08014.56
5.3.120.0130.06014.57
5.3.110.0100.05714.66
5.3.100.0070.05714.21
5.3.90.0070.05014.09
5.3.80.0100.04714.03
5.3.70.0100.07013.95
5.3.60.0100.05714.01
5.3.50.0100.05013.98
5.3.40.0130.05313.80
5.3.30.0170.04313.93
5.3.20.0200.04713.79
5.3.10.0070.05313.76
5.3.00.0130.04313.71
5.2.170.0030.04711.25
5.2.160.0100.04011.34
5.2.150.0030.04711.39
5.2.140.0100.03711.25
5.2.130.0030.06311.21
5.2.120.0100.04711.10
5.2.110.0070.05711.13
5.2.100.0170.04711.17
5.2.90.0070.04311.03
5.2.80.0130.05011.12
5.2.70.0170.05711.20
5.2.60.0030.05011.15
5.2.50.0070.04011.14
5.2.40.0130.03311.19
5.2.30.0100.04010.99
5.2.20.0130.04710.97
5.2.10.0100.03710.96
5.2.00.0030.04010.73
5.1.60.0070.04710.02
5.1.50.0030.0379.95
5.1.40.0100.0479.92
5.1.30.0030.03710.58
5.1.20.0130.03310.33
5.1.10.0070.03710.08
5.1.00.0130.04010.02
5.0.50.0070.0308.65
5.0.40.0100.0208.43
5.0.30.0070.0578.23
5.0.20.0030.0308.23
5.0.10.0030.0338.17
5.0.00.0000.0638.13
4.4.90.0000.0336.95
4.4.80.0030.0306.95
4.4.70.0030.0276.95
4.4.60.0000.0236.95
4.4.50.0030.0206.95
4.4.40.0100.0376.95
4.4.30.0070.0276.95
4.4.20.0030.0206.95
4.4.10.0000.0236.95
4.4.00.0030.0376.95
4.3.110.0070.0276.95
4.3.100.0030.0276.95
4.3.90.0000.0276.95
4.3.80.0000.0376.95
4.3.70.0030.0236.95
4.3.60.0030.0306.95
4.3.50.0070.0176.95
4.3.40.0000.0336.95
4.3.30.0000.0236.95
4.3.20.0000.0306.95
4.3.10.0030.0206.95
4.3.00.0000.0277.38

preferences:
60.2 ms | 401 KiB | 5 Q