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; $output = str_pad('', $inputlen + 1, "\x00"); for ($i = 0; $i < $skip; $i++) { $output[$i] = $signbits; } if ($offset == 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_left($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.0080.00818.31
8.3.50.0100.00622.11
8.3.40.0090.00618.72
8.3.30.0070.00719.09
8.3.20.0000.00820.31
8.3.10.0080.00022.04
8.3.00.0040.00422.34
8.2.180.0130.01016.88
8.2.170.0070.01022.96
8.2.160.0070.00719.21
8.2.150.0090.00024.18
8.2.140.0030.00524.66
8.2.130.0060.00326.16
8.2.120.0080.00017.75
8.2.110.0000.00922.13
8.2.100.0070.00419.70
8.2.90.0060.00319.35
8.2.80.0050.00317.97
8.2.70.0030.00517.63
8.2.60.0070.00417.80
8.2.50.0060.00318.07
8.2.40.0040.00418.09
8.2.30.0070.00418.09
8.2.20.0040.00417.84
8.2.10.0040.00417.64
8.2.00.0040.00417.76
8.1.280.0060.00925.92
8.1.270.0040.00422.03
8.1.260.0040.00426.35
8.1.250.0030.00528.09
8.1.240.0060.00323.73
8.1.230.0040.00719.16
8.1.220.0040.00417.78
8.1.210.0030.00518.77
8.1.200.0050.00517.36
8.1.190.0080.00017.63
8.1.180.0000.00818.10
8.1.170.0030.00618.53
8.1.160.0050.00321.95
8.1.150.0000.00718.65
8.1.140.0030.00617.38
8.1.130.0040.00417.84
8.1.120.0080.00017.47
8.1.110.0000.00817.37
8.1.100.0000.00717.48
8.1.90.0000.00717.38
8.1.80.0040.00417.46
8.1.70.0030.00317.39
8.1.60.0000.00817.58
8.1.50.0000.00717.56
8.1.40.0000.00817.57
8.1.30.0050.00217.54
8.1.20.0040.00417.65
8.1.10.0030.00617.48
8.1.00.0000.00817.49
8.0.300.0030.00518.77
8.0.290.0040.00417.05
8.0.280.0030.00318.46
8.0.270.0030.00317.19
8.0.260.0000.00616.91
8.0.250.0070.00016.88
8.0.240.0030.00316.92
8.0.230.0000.00816.83
8.0.220.0030.00316.95
8.0.210.0040.00416.95
8.0.200.0000.00617.01
8.0.190.0060.00317.00
8.0.180.0030.00316.90
8.0.170.0080.00016.97
8.0.160.0000.00716.88
8.0.150.0050.00316.82
8.0.140.0050.00216.85
8.0.130.0060.00013.33
8.0.120.0000.00716.75
8.0.110.0070.00016.77
8.0.100.0040.00416.74
8.0.90.0030.00516.96
8.0.80.0090.00616.82
8.0.70.0050.00216.98
8.0.60.0000.00716.91
8.0.50.0000.00716.89
8.0.30.0120.00916.94
8.0.20.0130.00717.40
8.0.10.0030.00616.88
8.0.00.0060.01416.79
7.4.330.0040.00315.00
7.4.320.0030.00316.50
7.4.300.0070.00016.43
7.4.290.0030.00316.62
7.4.280.0000.00716.36
7.4.270.0030.00516.46
7.4.260.0070.00016.54
7.4.250.0000.00816.56
7.4.240.0040.00416.50
7.4.230.0000.00716.68
7.4.220.0090.00916.55
7.4.210.0040.01116.58
7.4.200.0040.00416.69
7.4.190.0000.00716.79
7.4.160.0140.00716.53
7.4.150.0110.00717.40
7.4.140.0180.01317.86
7.4.130.0080.01216.62
7.4.120.0090.01116.47
7.4.110.0150.00316.40
7.4.100.0090.00916.52
7.4.90.0110.00616.66
7.4.80.0100.01319.39
7.4.70.0120.00616.63
7.4.60.0130.00316.52
7.4.50.0080.00016.36
7.4.40.0070.01022.77
7.4.30.0110.00516.52
7.4.00.0030.01014.98
7.3.330.0000.00613.45
7.3.320.0000.00513.24
7.3.310.0070.00016.23
7.3.300.0030.00316.23
7.3.290.0100.01016.29
7.3.280.0100.01016.35
7.3.270.0100.00717.40
7.3.260.0140.00316.42
7.3.250.0160.00716.45
7.3.240.0100.01416.69
7.3.230.0030.01416.66
7.3.210.0090.00916.32
7.3.200.0030.01319.39
7.3.190.0100.00716.55
7.3.180.0060.00916.37
7.3.170.0080.00816.33
7.3.160.0070.01116.67
7.3.120.0040.00814.76
7.3.10.0130.00616.21
7.3.00.0120.00816.36
7.2.330.0070.01016.73
7.2.320.0170.00016.85
7.2.310.0190.00416.56
7.2.300.0060.01016.75
7.2.290.0070.01416.78
7.2.130.0180.00516.59
7.2.120.0090.01516.22
7.2.110.0120.01216.86
7.2.100.0090.01716.35
7.2.90.0110.01816.40
7.2.80.0150.00916.73
7.2.70.0090.00617.02
7.2.60.0150.00716.97
7.2.50.0090.01316.45
7.2.40.0120.01316.60
7.2.30.0190.00016.73
7.2.20.0210.00616.57
7.2.10.0070.01616.75
7.2.00.0130.00718.02
7.1.250.0100.00715.29
7.1.200.0030.01015.80
7.1.100.0060.00918.07
7.1.70.0030.01717.10
7.1.60.0140.01119.82
7.1.50.0070.01416.64
7.1.00.0100.07022.24
7.0.200.0080.00416.64
7.0.140.0000.08021.99
7.0.60.0030.07719.99
7.0.50.0070.03717.97
7.0.40.0100.04320.18
7.0.30.0300.05020.10
7.0.20.0000.05320.33
7.0.10.0230.05720.12
7.0.00.0030.06720.22
5.6.280.0030.07321.04
5.6.210.0100.07720.71
5.6.200.0130.04318.16
5.6.190.0070.08320.60
5.6.180.4100.03320.47
5.6.170.0300.05720.54
5.6.160.0100.05320.46
5.6.150.0070.04018.15
5.6.140.0100.06318.19
5.6.130.0030.08018.17
5.6.120.0100.08721.10
5.6.110.0130.08021.15
5.6.100.0030.04021.02
5.6.90.0100.04320.99
5.6.80.0200.06020.30
5.6.70.0200.07020.39
5.5.350.0000.08020.34
5.5.340.0030.06317.98
5.5.330.0070.04320.57
5.5.320.0100.04720.27
5.5.310.0100.04320.30
5.5.300.0000.04017.98
5.5.290.0000.05017.93
5.5.280.0130.07320.67
5.5.270.0030.08720.75
5.5.260.0000.06020.86
5.5.250.0100.08020.81
5.5.240.0100.07720.20
5.4.450.0530.06319.61
5.4.440.0530.06019.39
5.4.430.0030.06019.42
5.4.420.0200.06019.53
5.4.410.0030.06319.44
5.4.400.0130.05018.82
5.4.390.0170.04718.84
5.4.380.0330.05318.58
5.4.370.0170.05318.64
5.4.360.0200.05018.73
5.4.350.0200.05018.75
5.4.340.0300.04718.77
5.4.320.0060.04112.52
5.4.310.0080.03512.51
5.4.300.0090.03312.51
5.4.290.0020.04612.51
5.4.280.0040.03712.41
5.4.270.0200.06719.00
5.4.260.0230.04018.77
5.4.250.0200.06318.93
5.4.240.0130.05018.77
5.4.230.0070.06319.00
5.4.220.0130.05718.98
5.4.210.0130.07319.00
5.4.200.0170.08318.97
5.4.190.0100.05718.95
5.4.180.0070.05719.10
5.4.170.0130.06318.74
5.4.160.0130.07318.98
5.4.150.0170.06019.07
5.4.140.0100.05016.44
5.4.130.0130.05316.59
5.4.120.0170.05716.59
5.4.110.0300.05016.52
5.4.100.0230.05716.56
5.4.90.0130.04716.52
5.4.80.0030.05316.66
5.4.70.0200.06016.45
5.4.60.0100.06716.49
5.4.50.0230.05716.45
5.4.40.0000.06016.59
5.4.30.0170.05716.33
5.4.20.0000.06016.47
5.4.10.0170.06316.48
5.4.00.0130.05716.03
5.3.290.0070.03912.80
5.3.280.0130.07014.53
5.3.270.0030.06714.72
5.3.260.0170.06014.72
5.3.250.0130.07314.63
5.3.240.0030.08314.63
5.3.230.0100.05014.70
5.3.220.0130.05014.67
5.3.210.0030.06014.66
5.3.200.0130.06014.68
5.3.190.0070.06714.68
5.3.180.0100.06014.49
5.3.170.0130.05014.67
5.3.160.0100.05014.76
5.3.150.0030.06314.58
5.3.140.0070.05314.67
5.3.130.0030.05714.64
5.3.120.0130.06714.73
5.3.110.0170.05014.70
5.3.100.0070.05014.28
5.3.90.0130.07014.22
5.3.80.0070.05013.95
5.3.70.0200.06314.01
5.3.60.0030.07014.23
5.3.50.0130.04714.04
5.3.40.0170.06714.15
5.3.30.0100.05013.93
5.3.20.0100.05713.94
5.3.10.0030.06313.74
5.3.00.0070.05313.68
5.2.170.0070.04011.35
5.2.160.0000.05311.27
5.2.150.0070.04311.25
5.2.140.0200.04311.39
5.2.130.0030.04711.05
5.2.120.0070.05711.15
5.2.110.0130.04311.20
5.2.100.0100.03711.20
5.2.90.0100.04311.21
5.2.80.0070.04311.10
5.2.70.0130.05311.28
5.2.60.0130.04011.17
5.2.50.0070.04311.04
5.2.40.0030.04311.11
5.2.30.0030.04710.95
5.2.20.0030.04711.07
5.2.10.0100.03310.96
5.2.00.0100.04310.65
5.1.60.0030.04310.11
5.1.50.0070.04010.18
5.1.40.0070.04310.20
5.1.30.0100.03310.42
5.1.20.0070.04010.45
5.1.10.0030.04010.18
5.1.00.0070.03710.08
5.0.50.0070.0278.68
5.0.40.0100.0208.46
5.0.30.0030.0608.46
5.0.20.0000.0308.39
5.0.10.0100.0338.28
5.0.00.0100.0578.25
4.4.90.0030.0236.92
4.4.80.0070.0206.92
4.4.70.0030.0236.92
4.4.60.0100.0206.92
4.4.50.0030.0276.92
4.4.40.0030.0476.92
4.4.30.0070.0276.92
4.4.20.0030.0206.92
4.4.10.0030.0236.92
4.4.00.0030.0436.92
4.3.110.0100.0236.92
4.3.100.0070.0206.92
4.3.90.0070.0276.92
4.3.80.0030.0436.92
4.3.70.0130.0106.92
4.3.60.0130.0176.92
4.3.50.0000.0236.92
4.3.40.0070.0376.92
4.3.30.0000.0336.92
4.3.20.0000.0236.92
4.3.10.0070.0236.92
4.3.00.0100.0237.38

preferences:
47.78 ms | 401 KiB | 5 Q