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); $right = (ord($input[$i + $skip + 1]) & $mask) >> $offset; printf("%02x ", ($left | $right) & 0xff); $output[$i] = chr(($left | $right) & 0xff); } } //0b000100010001000100000000; $input = "abc\x00"; $bits = 2; 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.0090.01218.55
8.3.50.0190.01322.05
8.3.40.0070.00718.46
8.3.30.0140.00019.09
8.3.20.0070.00020.16
8.3.10.0040.00421.80
8.3.00.0080.00022.43
8.2.180.0140.00416.50
8.2.170.0090.00622.96
8.2.160.0100.00719.38
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0000.00826.16
8.2.120.0030.00519.36
8.2.110.0060.00322.19
8.2.100.0080.00318.22
8.2.90.0000.00719.36
8.2.80.0000.00918.04
8.2.70.0000.00917.63
8.2.60.0080.00317.90
8.2.50.0060.00318.07
8.2.40.0060.00318.22
8.2.30.0000.01018.06
8.2.20.0040.00417.61
8.2.10.0000.00817.73
8.2.00.0060.00317.68
8.1.280.0110.00725.92
8.1.270.0040.00422.05
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0060.00323.90
8.1.230.0120.00019.10
8.1.220.0030.00717.76
8.1.210.0000.00818.77
8.1.200.0060.00317.36
8.1.190.0040.00417.55
8.1.180.0000.00818.10
8.1.170.0090.00018.51
8.1.160.0080.00021.97
8.1.150.0030.00518.71
8.1.140.0050.00317.46
8.1.130.0070.00017.82
8.1.120.0000.00717.51
8.1.110.0000.00817.48
8.1.100.0040.00417.46
8.1.90.0000.00717.46
8.1.80.0030.00417.41
8.1.70.0000.00717.32
8.1.60.0030.00517.47
8.1.50.0050.00217.44
8.1.40.0080.00017.51
8.1.30.0040.00417.58
8.1.20.0030.00517.65
8.1.10.0000.00817.60
8.1.00.0000.00717.38
8.0.300.0040.00418.77
8.0.290.0040.00417.16
8.0.280.0000.00718.46
8.0.270.0030.00317.16
8.0.260.0030.00316.86
8.0.250.0030.00316.96
8.0.240.0000.00716.87
8.0.230.0030.00317.01
8.0.220.0040.00416.81
8.0.210.0070.00016.91
8.0.200.0040.00416.96
8.0.190.0040.00416.96
8.0.180.0000.00816.83
8.0.170.0040.00416.93
8.0.160.0070.00016.93
8.0.150.0000.00716.73
8.0.140.0040.00416.76
8.0.130.0060.00013.38
8.0.120.0040.00416.94
8.0.110.0000.00816.94
8.0.100.0000.00816.71
8.0.90.0040.00416.97
8.0.80.0120.00416.90
8.0.70.0030.00516.80
8.0.60.0080.00016.75
8.0.50.0070.00016.73
8.0.30.0080.01517.10
8.0.20.0110.00917.40
8.0.10.0040.00416.89
8.0.00.0080.01016.70
7.4.330.0070.00015.00
7.4.320.0060.00016.46
7.4.300.0000.00616.64
7.4.290.0000.00716.47
7.4.280.0030.00316.52
7.4.270.0000.00716.52
7.4.260.0000.00716.36
7.4.250.0050.00216.56
7.4.240.0020.00616.59
7.4.230.0000.00716.59
7.4.220.0070.01016.64
7.4.210.0050.01016.53
7.4.200.0040.00416.63
7.4.190.0000.00716.42
7.4.160.0100.01316.36
7.4.150.0120.00617.40
7.4.140.0090.01117.86
7.4.130.0080.01016.43
7.4.120.0110.00716.58
7.4.110.0090.00916.49
7.4.100.0060.01216.66
7.4.90.0110.00716.69
7.4.80.0140.00619.39
7.4.70.0060.01216.41
7.4.60.0090.01216.45
7.4.50.0000.00516.29
7.4.40.0040.01522.77
7.4.30.0150.00316.50
7.4.00.0070.01014.93
7.3.330.0030.00313.15
7.3.320.0060.00013.45
7.3.310.0030.00316.41
7.3.300.0040.00416.34
7.3.290.0080.00616.38
7.3.280.0060.01116.35
7.3.270.0060.01117.40
7.3.260.0100.00916.40
7.3.250.0160.00716.48
7.3.240.0110.00716.66
7.3.230.0130.01416.54
7.3.210.0120.00616.61
7.3.200.0040.01219.39
7.3.190.0090.00916.57
7.3.180.0150.00716.38
7.3.170.0070.01116.43
7.3.160.0030.01316.66
7.3.120.0010.01314.81
7.3.110.0070.01114.81
7.3.100.0050.01014.95
7.3.90.0080.00814.71
7.3.80.0020.00914.71
7.3.70.0090.00214.78
7.3.60.0110.00314.81
7.3.50.0080.00714.68
7.3.40.0050.00814.90
7.3.30.0060.00414.71
7.3.20.0070.00716.68
7.3.10.0050.01016.68
7.3.00.0050.00716.68
7.2.330.0060.01116.63
7.2.320.0070.01716.49
7.2.310.0030.01516.90
7.2.300.0100.00716.66
7.2.290.0120.01316.70
7.2.250.0090.00715.10
7.2.240.0040.01515.31
7.2.230.0110.00715.02
7.2.220.0100.00815.34
7.2.210.0060.00615.08
7.2.200.0060.00615.18
7.2.190.0030.01015.12
7.2.180.0100.00315.19
7.2.170.0090.00414.97
7.1.330.0040.01115.74
7.1.320.0030.00815.70
7.1.310.0020.01115.81
7.1.300.0070.00615.80
7.1.290.0060.01015.89
7.1.280.0080.00515.82
7.1.270.0050.00915.57
7.1.260.0050.00515.80
7.1.70.0000.00817.20
7.1.60.0070.01719.82
7.1.50.0120.00917.10
7.1.00.0030.07722.31
7.0.200.0030.00616.52
7.0.140.0000.07721.95
7.0.60.0130.06019.96
7.0.50.0070.08017.91
7.0.40.0100.05319.96
7.0.30.0230.05720.30
7.0.20.0170.04320.27
7.0.10.0170.04020.33
7.0.00.0070.04320.25
5.6.280.0000.07721.00
5.6.210.0100.07020.53
5.6.200.0070.06018.30
5.6.190.0070.08720.41
5.6.180.4070.04720.47
5.6.170.0330.07720.53
5.6.160.0030.04320.55
5.6.150.0100.03718.21
5.6.140.0070.06018.14
5.6.130.0070.08018.19
5.6.120.0030.05721.01
5.6.110.0100.05721.04
5.6.100.0030.08721.15
5.6.90.0070.07721.14
5.6.80.0200.05720.54
5.6.70.0300.07320.52
5.5.350.0000.09320.42
5.5.340.0070.08017.98
5.5.330.0070.08020.32
5.5.320.0270.07020.32
5.5.310.0170.04320.23
5.5.300.0030.04018.08
5.5.290.0100.08018.06
5.5.280.0070.04320.82
5.5.270.0070.05020.65
5.5.260.0070.09320.97
5.5.250.0030.04320.80
5.5.240.0070.08020.27
5.4.450.0500.06319.39
5.4.440.0570.06019.47
5.4.430.0170.05019.50
5.4.420.0100.05719.37
5.4.410.0130.05019.41
5.4.400.0130.04718.55
5.4.390.0030.05718.71
5.4.380.0230.06018.59
5.4.370.0130.06718.48
5.4.360.0130.05718.79
5.4.350.0270.04718.57
5.4.340.0170.05318.58
5.4.320.0100.03512.51
5.4.310.0080.04012.51
5.4.300.0080.03612.51
5.4.290.0070.04812.51
5.4.280.0060.03512.41
5.4.270.0030.07318.75
5.4.260.0070.07718.94
5.4.250.0130.06718.91
5.4.240.0070.06018.93
5.4.230.0070.05718.91
5.4.220.0170.05018.74
5.4.210.0200.04718.60
5.4.200.0030.05718.89
5.4.190.0130.08018.91
5.4.180.0130.05318.84
5.4.170.0200.07018.77
5.4.160.0230.06318.90
5.4.150.0100.05318.68
5.4.140.0130.06716.56
5.4.130.0100.07716.37
5.4.120.0070.05316.54
5.4.110.0070.06316.33
5.4.100.0030.06316.33
5.4.90.0100.05016.51
5.4.80.0070.06716.34
5.4.70.0100.06716.43
5.4.60.0100.04316.42
5.4.50.0070.07316.30
5.4.40.0130.04316.54
5.4.30.0230.05316.41
5.4.20.0070.05016.44
5.4.10.0170.05016.30
5.4.00.0070.05015.81
5.3.290.0080.03712.80
5.3.280.0200.05714.59
5.3.270.0100.06014.84
5.3.260.0070.06014.68
5.3.250.0170.06314.61
5.3.240.0200.06714.70
5.3.230.0100.05714.68
5.3.220.0100.07014.67
5.3.210.0270.05014.67
5.3.200.0070.05314.72
5.3.190.0100.07014.42
5.3.180.0100.04714.80
5.3.170.0130.05714.41
5.3.160.0170.04314.74
5.3.150.0170.06714.48
5.3.140.0100.07314.73
5.3.130.0100.07714.57
5.3.120.0130.06014.74
5.3.110.0130.05014.65
5.3.100.0070.05014.22
5.3.90.0130.04714.25
5.3.80.0030.05314.19
5.3.70.0070.05314.21
5.3.60.0000.07713.91
5.3.50.0100.07313.98
5.3.40.0030.07313.93
5.3.30.0070.06313.89
5.3.20.0130.05313.79
5.3.10.0170.04013.49
5.3.00.0100.05713.89
5.2.170.0170.03311.24
5.2.160.0100.03711.23
5.2.150.0070.05711.22
5.2.140.0030.05011.22
5.2.130.0130.05311.22
5.2.120.0000.04711.19
5.2.110.0030.04011.11
5.2.100.0100.04010.95
5.2.90.0070.04311.08
5.2.80.0030.06011.17
5.2.70.0070.06311.28
5.2.60.0230.06010.90
5.2.50.0030.04311.13
5.2.40.0100.04711.11
5.2.30.0030.04310.98
5.2.20.0130.04710.80
5.2.10.0070.04010.70
5.2.00.0100.05010.84
5.1.60.0030.0509.98
5.1.50.0070.03310.01
5.1.40.0070.0439.95
5.1.30.0130.03010.43
5.1.20.0070.03710.35
5.1.10.0030.03710.04
5.1.00.0030.03710.16
5.0.50.0030.0308.64
5.0.40.0070.0338.46
5.0.30.0070.0538.35
5.0.20.0070.0308.23
5.0.10.0130.0308.25
5.0.00.0000.0578.27
4.4.90.0030.0335.84
4.4.80.0030.0205.86
4.4.70.0070.0205.80
4.4.60.0100.0175.85
4.4.50.0030.0235.85
4.4.40.0000.0375.84
4.4.30.0000.0275.75
4.4.20.0070.0206.02
4.4.10.0030.0305.87
4.4.00.0030.0375.86
4.3.110.0000.0235.83
4.3.100.0070.0275.76
4.3.90.0070.0275.67
4.3.80.0100.0335.75
4.3.70.0000.0235.71
4.3.60.0130.0205.76
4.3.50.0030.0335.73
4.3.40.0000.0405.84
4.3.30.0100.0235.40
4.3.20.0030.0275.40
4.3.10.0030.0305.40
4.3.00.0200.0177.38

preferences:
42.47 ms | 401 KiB | 5 Q