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; $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.60.0000.01518.43
8.3.50.0080.01321.98
8.3.40.0150.00018.90
8.3.30.0070.00719.06
8.3.20.0050.00320.39
8.3.10.0040.00421.77
8.3.00.0040.00422.44
8.2.180.0180.00416.50
8.2.170.0080.00822.96
8.2.160.0100.00319.14
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0000.00726.16
8.2.120.0030.00517.63
8.2.110.0160.00022.30
8.2.100.0080.00417.91
8.2.90.0080.00019.24
8.2.80.0040.00817.97
8.2.70.0080.00017.50
8.2.60.0000.01117.80
8.2.50.0040.00418.07
8.2.40.0090.00018.34
8.2.30.0050.00518.16
8.2.20.0040.00417.79
8.2.10.0040.00419.44
8.2.00.0030.00517.82
8.1.280.0090.00925.92
8.1.270.0040.00422.20
8.1.260.0000.00826.35
8.1.250.0050.00328.09
8.1.240.0000.00923.91
8.1.230.0040.00719.10
8.1.220.0050.00317.74
8.1.210.0040.00418.77
8.1.200.0060.00317.35
8.1.190.0040.00417.53
8.1.180.0040.00418.10
8.1.170.0050.00318.72
8.1.160.0000.00722.07
8.1.150.0070.00018.59
8.1.140.0040.00417.48
8.1.130.0000.00717.95
8.1.120.0000.00717.36
8.1.110.0070.00017.55
8.1.100.0040.00417.44
8.1.90.0030.00617.44
8.1.80.0050.00317.36
8.1.70.0030.00317.41
8.1.60.0040.00417.51
8.1.50.0000.00817.57
8.1.40.0000.00717.54
8.1.30.0020.00517.61
8.1.20.0060.00317.56
8.1.10.0000.00817.55
8.1.00.0000.00817.57
8.0.300.0000.00718.77
8.0.290.0000.00817.02
8.0.280.0080.00018.57
8.0.270.0000.00717.16
8.0.260.0000.00716.80
8.0.250.0040.00417.02
8.0.240.0040.00416.95
8.0.230.0000.00716.93
8.0.220.0030.00316.88
8.0.210.0080.00016.91
8.0.200.0000.00816.85
8.0.190.0050.00216.86
8.0.180.0040.00417.00
8.0.170.0070.00016.96
8.0.160.0080.00016.89
8.0.150.0000.00716.85
8.0.140.0000.00716.77
8.0.130.0000.00613.39
8.0.120.0000.00716.84
8.0.110.0040.00416.96
8.0.100.0040.00416.77
8.0.90.0040.00416.71
8.0.80.0090.00616.87
8.0.70.0080.00016.82
8.0.60.0000.00716.93
8.0.50.0050.00216.95
8.0.30.0090.01017.17
8.0.20.0050.01317.40
8.0.10.0090.00016.86
8.0.00.0120.01216.69
7.4.330.0030.00315.00
7.4.320.0030.00316.62
7.4.300.0030.00316.43
7.4.290.0000.00716.53
7.4.280.0030.00516.50
7.4.270.0000.00716.63
7.4.260.0070.00016.43
7.4.250.0090.00016.51
7.4.240.0020.00616.56
7.4.230.0030.00316.40
7.4.220.0070.01116.59
7.4.210.0070.01116.60
7.4.200.0070.00016.54
7.4.190.0000.00716.65
7.4.160.0100.00716.45
7.4.150.0130.00417.40
7.4.140.0120.00617.86
7.4.130.0090.00816.56
7.4.120.0110.00816.49
7.4.110.0080.00816.35
7.4.100.0060.01316.49
7.4.90.0040.01416.48
7.4.80.0070.01319.39
7.4.70.0030.01416.40
7.4.60.0030.01416.35
7.4.50.0040.00416.30
7.4.40.0070.01022.77
7.4.30.0090.00616.57
7.4.00.0070.01014.75
7.3.330.0000.00613.38
7.3.320.0030.00313.22
7.3.310.0040.00316.27
7.3.300.0070.00016.39
7.3.290.0080.00616.35
7.3.280.0070.00816.38
7.3.270.0090.00917.40
7.3.260.0150.00316.27
7.3.250.0150.00816.54
7.3.240.0160.00616.62
7.3.230.0100.01116.42
7.3.210.0100.00716.46
7.3.200.0130.00719.39
7.3.190.0090.01216.47
7.3.180.0100.00716.37
7.3.170.0080.00816.46
7.3.160.0030.01416.44
7.3.120.0040.01114.79
7.2.330.0060.01216.79
7.2.320.0090.00916.89
7.2.310.0100.01016.83
7.2.300.0130.01016.88
7.2.290.0130.00716.54
7.2.60.0090.00617.02
7.1.200.0060.00615.79
7.1.70.0000.00917.16
7.1.60.0000.02419.82
7.1.50.0040.01816.69
7.1.00.0030.07722.28
7.0.200.0030.00615.16
7.0.140.0130.06321.95
7.0.60.0070.09019.98
7.0.50.0070.08317.95
7.0.40.0130.08019.96
7.0.30.0330.07720.30
7.0.20.0300.07320.33
7.0.10.0000.07720.25
7.0.00.0070.05020.05
5.6.280.0070.07020.80
5.6.210.0130.07320.69
5.6.200.0070.08018.21
5.6.190.0100.03720.67
5.6.180.3570.04320.46
5.6.170.0330.07320.40
5.6.160.0030.06720.39
5.6.150.0070.07318.25
5.6.140.0030.06018.25
5.6.130.0000.09018.29
5.6.120.0070.04020.98
5.6.110.0070.07321.04
5.6.100.0030.06020.98
5.6.90.0070.06321.15
5.6.80.0000.04020.30
5.5.350.0300.04720.46
5.5.340.0030.08318.05
5.5.330.0100.06320.41
5.5.320.0200.04020.29
5.5.310.0100.04720.24
5.5.300.0130.08017.99
5.5.290.0270.03017.95
5.5.280.0030.05320.92
5.5.270.0130.03320.88
5.5.260.0070.07020.78
5.5.250.0170.07020.60
5.5.240.0070.07720.31
5.4.450.0200.04319.33
5.4.440.0370.04019.39
5.4.430.0070.05319.51
5.4.420.0130.05319.39
5.4.410.0530.06019.54
5.4.400.0970.05719.08
5.4.390.0700.05019.11
5.4.380.0130.08318.74
5.4.370.0400.04718.58
5.4.360.0170.05318.83
5.4.350.0230.05318.74
5.4.340.0230.06318.58
5.4.320.0070.03512.52
5.4.310.0050.04012.52
5.4.300.0050.03712.52
5.4.290.0060.04412.51
5.4.280.0040.03912.41
5.4.270.0100.06319.10
5.4.260.0100.07318.96
5.4.250.0100.05718.93
5.4.240.0230.06318.96
5.4.230.0000.08718.75
5.4.220.0200.06318.80
5.4.210.0170.05318.95
5.4.200.0100.05719.01
5.4.190.0130.05318.77
5.4.180.0100.06318.97
5.4.170.0200.05719.02
5.4.160.0070.05718.98
5.4.150.0170.05018.98
5.4.140.0200.05316.48
5.4.130.0100.07016.35
5.4.120.0230.04016.41
5.4.110.0200.06016.58
5.4.100.0130.05316.52
5.4.90.0100.07016.47
5.4.80.0130.04716.55
5.4.70.0130.04316.56
5.4.60.0070.05016.46
5.4.50.0130.06316.35
5.4.40.0030.05316.44
5.4.30.0130.05016.46
5.4.20.0070.06016.48
5.4.10.0130.05716.45
5.4.00.0170.04315.77
5.3.290.0060.03812.80
5.3.280.0100.07314.76
5.3.270.0170.06014.55
5.3.260.0100.07314.47
5.3.250.0230.06014.79
5.3.240.0100.05314.62
5.3.230.0100.05714.61
5.3.220.0230.05714.57
5.3.210.0070.05714.70
5.3.200.0170.06714.57
5.3.190.0130.07014.77
5.3.180.0100.05714.68
5.3.170.0030.05714.59
5.3.160.0000.05714.63
5.3.150.0130.05014.66
5.3.140.0100.05014.41
5.3.130.0170.06714.58
5.3.120.0170.07014.66
5.3.110.0130.05014.65
5.3.100.0100.05714.25
5.3.90.0030.05714.05
5.3.80.0070.05313.94
5.3.70.0000.06713.87
5.3.60.0170.04314.02
5.3.50.0200.04314.06
5.3.40.0070.05014.07
5.3.30.0030.05714.10
5.3.20.0100.06313.80
5.3.10.0030.05313.64
5.3.00.0100.04713.82
5.2.170.0030.05011.00
5.2.160.0170.04711.16
5.2.150.0100.04711.08
5.2.140.0070.06011.16
5.2.130.0100.03311.09
5.2.120.0100.05311.10
5.2.110.0070.04711.21
5.2.100.0070.04311.11
5.2.90.0170.04311.11
5.2.80.0030.06311.20
5.2.70.0170.03711.34
5.2.60.0130.03711.06
5.2.50.0100.05311.00
5.2.40.0170.04711.12
5.2.30.0070.04010.85
5.2.20.0000.06011.05
5.2.10.0100.05010.88
5.2.00.0170.03710.93
5.1.60.0100.04710.18
5.1.50.0100.03010.07
5.1.40.0070.03010.07
5.1.30.0100.05010.43
5.1.20.0070.04710.54
5.1.10.0000.04010.29
5.1.00.0030.04010.19
5.0.50.0030.0408.58
5.0.40.0030.0438.41
5.0.30.0070.0438.37
5.0.20.0070.0238.07
5.0.10.0030.0408.29
5.0.00.0100.0438.30
4.4.90.0030.0276.95
4.4.80.0000.0236.95
4.4.70.0070.0236.95
4.4.60.0030.0236.95
4.4.50.0070.0236.95
4.4.40.0030.0506.95
4.4.30.0000.0236.95
4.4.20.0000.0276.95
4.4.10.0070.0236.95
4.4.00.0030.0336.95
4.3.110.0030.0236.95
4.3.100.0070.0206.95
4.3.90.0000.0276.95
4.3.80.0000.0476.95
4.3.70.0000.0236.95
4.3.60.0030.0206.95
4.3.50.0000.0276.95
4.3.40.0030.0306.95
4.3.30.0000.0236.95
4.3.20.0030.0206.95
4.3.10.0000.0236.95
4.3.00.0230.01715.58

preferences:
46.52 ms | 401 KiB | 5 Q