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; $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); } */ } $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.0090.00618.20
8.3.50.0150.00622.04
8.3.40.0040.01118.53
8.3.30.0100.00319.04
8.3.20.0000.00720.34
8.3.10.0080.00022.08
8.3.00.0040.00422.58
8.2.180.0090.00616.63
8.2.170.0100.00722.96
8.2.160.0100.00319.16
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0000.00726.16
8.2.120.0030.00517.63
8.2.110.0060.00322.25
8.2.100.0060.00619.57
8.2.90.0060.00319.34
8.2.80.0050.00317.97
8.2.70.0000.00817.50
8.2.60.0000.00818.16
8.2.50.0050.00318.07
8.2.40.0060.00318.22
8.2.30.0030.00718.15
8.2.20.0000.00817.84
8.2.10.0080.00017.64
8.2.00.0030.00617.75
8.1.280.0140.00725.92
8.1.270.0080.00022.21
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0000.00823.89
8.1.230.0110.00019.12
8.1.220.0000.00817.78
8.1.210.0050.00318.77
8.1.200.0090.00017.25
8.1.190.0060.00317.29
8.1.180.0040.00418.10
8.1.170.0000.00818.55
8.1.160.0000.00821.99
8.1.150.0000.00818.57
8.1.140.0050.00317.47
8.1.130.0060.00317.89
8.1.120.0040.00417.38
8.1.110.0040.00417.34
8.1.100.0000.00717.34
8.1.90.0040.00417.41
8.1.80.0000.00717.49
8.1.70.0000.00817.51
8.1.60.0000.00817.47
8.1.50.0040.00417.48
8.1.40.0040.00417.57
8.1.30.0030.00517.64
8.1.20.0040.00417.69
8.1.10.0040.00417.50
8.1.00.0040.00417.38
8.0.300.0040.00418.77
8.0.290.0000.00716.93
8.0.280.0000.00718.46
8.0.270.0000.00717.23
8.0.260.0030.00316.85
8.0.250.0000.00717.03
8.0.240.0040.00316.96
8.0.230.0000.00716.93
8.0.220.0000.00716.88
8.0.210.0030.00516.93
8.0.200.0000.00616.95
8.0.190.0060.00316.95
8.0.180.0040.00416.91
8.0.170.0070.00016.86
8.0.160.0000.00716.89
8.0.150.0000.00816.82
8.0.140.0040.00416.88
8.0.130.0050.00013.34
8.0.120.0040.00416.75
8.0.110.0040.00416.89
8.0.100.0020.00516.77
8.0.90.0040.00416.96
8.0.80.0120.00316.90
8.0.70.0070.00016.97
8.0.60.0030.00516.96
8.0.50.0000.00717.00
8.0.30.0070.01317.21
8.0.20.0090.00817.40
8.0.10.0060.00316.90
8.0.00.0080.01016.83
7.4.330.0060.00015.00
7.4.320.0000.00616.64
7.4.300.0030.00316.58
7.4.290.0030.00316.50
7.4.280.0080.00016.53
7.4.270.0040.00416.66
7.4.260.0070.00016.36
7.4.250.0040.00416.61
7.4.240.0060.00216.47
7.4.230.0030.00416.50
7.4.220.0150.01116.53
7.4.210.0060.00816.53
7.4.200.0000.00716.63
7.4.190.0030.00316.58
7.4.160.0100.00716.59
7.4.150.0100.00617.40
7.4.140.0070.01517.86
7.4.130.0080.01416.57
7.4.120.0120.00616.53
7.4.110.0040.01216.58
7.4.100.0090.00916.60
7.4.90.0060.01216.57
7.4.80.0090.00919.39
7.4.70.0120.00616.46
7.4.60.0000.01716.43
7.4.50.0000.00516.44
7.4.40.0030.01022.77
7.4.30.0090.00616.67
7.4.00.0060.00914.85
7.3.330.0000.00513.34
7.3.320.0030.00313.37
7.3.310.0030.00516.42
7.3.300.0040.00416.34
7.3.290.0030.01116.39
7.3.280.0090.00916.33
7.3.270.0110.00617.40
7.3.260.0120.00616.56
7.3.250.0090.01316.35
7.3.240.0110.00916.38
7.3.230.0090.01516.54
7.3.210.0090.00916.57
7.3.200.0170.00019.39
7.3.190.0120.00616.66
7.3.180.0080.00816.54
7.3.170.0060.00916.57
7.3.160.0120.00616.63
7.3.120.0100.00314.86
7.2.330.0180.00016.91
7.2.320.0090.00816.63
7.2.310.0130.00916.91
7.2.300.0070.01016.52
7.2.290.0140.00316.46
7.2.00.0070.00719.35
7.1.100.0030.00918.07
7.1.70.0060.00317.10
7.1.60.0100.01619.82
7.1.50.0120.00616.70
7.1.00.0030.07322.28
7.0.200.0220.01114.79
7.0.140.0070.07022.15
7.0.60.0070.08020.14
7.0.50.0130.07717.95
7.0.40.0070.05720.14
7.0.30.0300.04320.21
7.0.20.0200.05320.10
7.0.10.0170.07020.12
7.0.00.0070.04320.20
5.6.280.0070.07020.91
5.6.210.0070.08720.52
5.6.200.0070.05018.16
5.6.190.0030.04320.51
5.6.180.0270.04720.61
5.6.170.0270.06720.39
5.6.160.0130.08020.39
5.6.150.0030.08318.15
5.6.140.0130.06318.21
5.6.130.0000.04318.28
5.6.120.0100.04021.15
5.6.110.0100.03720.98
5.6.100.0170.07721.13
5.6.90.0130.07020.89
5.6.80.0030.05720.39
5.5.350.0000.03720.44
5.5.340.0100.08018.04
5.5.330.0030.05020.57
5.5.320.0170.05020.42
5.5.310.0200.04020.27
5.5.300.0130.07017.99
5.5.290.0130.08017.98
5.5.280.0070.08020.89
5.5.270.0170.07020.89
5.5.260.0030.08720.89
5.5.250.0130.07720.80
5.5.240.0270.08320.14
5.4.450.0370.06319.62
5.4.440.0730.08319.61
5.4.430.0100.08719.60
5.4.420.1030.05719.26
5.4.410.0700.06319.28
5.4.400.0900.06719.28
5.4.390.1030.06319.08
5.4.380.0200.06018.81
5.4.370.0200.05018.72
5.4.360.0130.04718.79
5.4.350.0070.05318.63
5.4.340.0130.06018.52
5.4.320.0100.03712.52
5.4.310.0090.03912.51
5.4.300.0040.04012.52
5.4.290.0050.03712.52
5.4.280.0050.03512.41
5.4.270.0130.05318.97
5.4.260.0200.05318.73
5.4.250.0170.05718.79
5.4.240.0200.06319.00
5.4.230.0230.05318.94
5.4.220.0230.05318.84
5.4.210.0030.06018.94
5.4.200.0070.06018.65
5.4.190.0170.06718.76
5.4.180.0100.07319.09
5.4.170.0200.06318.94
5.4.160.0100.07018.79
5.4.150.0030.07718.98
5.4.140.0070.06016.45
5.4.130.0200.05716.48
5.4.120.0130.04716.44
5.4.110.0100.06716.44
5.4.100.0170.06016.47
5.4.90.0030.05716.68
5.4.80.0100.07316.59
5.4.70.0100.07016.46
5.4.60.0070.05316.33
5.4.50.0100.04716.31
5.4.40.0130.06016.51
5.4.30.0100.05316.44
5.4.20.0230.05716.33
5.4.10.0200.04716.39
5.4.00.0200.04715.85
5.3.290.0090.04012.80
5.3.280.0070.06014.63
5.3.270.0070.06314.86
5.3.260.0130.07714.80
5.3.250.0030.05314.79
5.3.240.0130.04714.85
5.3.230.0030.07014.70
5.3.220.0230.05714.61
5.3.210.0030.07314.49
5.3.200.0170.06014.59
5.3.190.0100.07014.60
5.3.180.0100.04714.67
5.3.170.0100.07714.74
5.3.160.0170.06314.67
5.3.150.0070.05314.72
5.3.140.0100.06714.75
5.3.130.0100.05014.65
5.3.120.0100.05314.63
5.3.110.0100.05014.57
5.3.100.0070.06014.15
5.3.90.0070.06013.87
5.3.80.0100.04714.03
5.3.70.0100.05314.20
5.3.60.0100.06014.00
5.3.50.0170.05713.80
5.3.40.0130.06313.80
5.3.30.0130.05313.92
5.3.20.0130.05713.79
5.3.10.0070.06713.68
5.3.00.0200.06013.56
5.2.170.0030.04311.13
5.2.160.0100.04311.26
5.2.150.0170.05011.40
5.2.140.0070.05711.26
5.2.130.0070.05311.09
5.2.120.0100.04311.31
5.2.110.0030.05311.31
5.2.100.0030.05010.96
5.2.90.0130.04711.34
5.2.80.0170.03711.10
5.2.70.0130.05010.96
5.2.60.0100.05711.17
5.2.50.0230.03011.13
5.2.40.0170.03011.10
5.2.30.0070.04311.16
5.2.20.0000.04711.08
5.2.10.0030.05310.87
5.2.00.0070.04010.82
5.1.60.0070.04710.22
5.1.50.0070.03710.00
5.1.40.0100.03010.07
5.1.30.0070.04310.45
5.1.20.0030.04710.45
5.1.10.0100.03310.19
5.1.00.0030.03710.29
5.0.50.0000.0408.60
5.0.40.0000.0308.70
5.0.30.0030.0508.34
5.0.20.0100.0338.30
5.0.10.0070.0308.19
5.0.00.0070.0538.04
4.4.90.0030.0276.92
4.4.80.0130.0406.92
4.4.70.0000.0336.92
4.4.60.0000.0276.92
4.4.50.0030.0336.92
4.4.40.0000.0506.92
4.4.30.0000.0276.92
4.4.20.0070.0236.92
4.4.10.0030.0306.92
4.4.00.0100.0336.92
4.3.110.0000.0276.92
4.3.100.0000.0306.92
4.3.90.0030.0306.92
4.3.80.0100.0376.92
4.3.70.0000.0336.92
4.3.60.0130.0306.92
4.3.50.0000.0376.92
4.3.40.0000.0336.92
4.3.30.0030.0276.92
4.3.20.0100.0176.92
4.3.10.0030.0206.92
4.3.00.0070.0238.13

preferences:
48.09 ms | 401 KiB | 5 Q