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] = chr($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; } $offsetl = 8 - $offsetr; $mask = ~(0xff >> $offsetr) & 0xff; $output[$skip] = chr(($signbits & ~(0xff >> $offsetl)) | (ord($input[0]) >> $offsetl)); /* 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 = "\xe1bc\x00"; $bits = 4; 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.40.0070.01018.74
8.3.30.0110.00419.10
8.3.20.0050.00320.29
8.3.10.0040.00421.84
8.3.00.0050.00222.34
8.2.170.0070.00722.96
8.2.160.0100.00319.21
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0080.00017.63
8.2.110.0060.00322.07
8.2.100.0060.00619.70
8.2.90.0030.00619.17
8.2.80.0030.00517.97
8.2.70.0030.00517.61
8.2.60.0040.00418.04
8.2.50.0000.00818.07
8.2.40.0050.00318.22
8.2.30.0070.00318.15
8.2.20.0080.00017.79
8.2.10.0040.00419.45
8.2.00.0000.00817.77
8.1.270.0000.00822.24
8.1.260.0060.00326.35
8.1.250.0000.00828.09
8.1.240.0060.00323.91
8.1.230.0040.00819.10
8.1.220.0050.00317.74
8.1.210.0050.00318.77
8.1.200.0070.00317.48
8.1.190.0040.00417.66
8.1.180.0060.00318.10
8.1.170.0040.00418.64
8.1.160.0040.00821.99
8.1.150.0000.00818.64
8.1.140.0070.00017.56
8.1.130.0040.00417.89
8.1.120.0000.00717.46
8.1.110.0000.00717.49
8.1.100.0020.00517.49
8.1.90.0000.00817.47
8.1.80.0000.00717.43
8.1.70.0000.00717.46
8.1.60.0080.00017.49
8.1.50.0000.00817.59
8.1.40.0000.00717.52
8.1.30.0040.00417.55
8.1.20.0050.00517.56
8.1.10.0040.00417.57
8.1.00.0000.00817.54
8.0.300.0030.00518.77
8.0.290.0000.00717.18
8.0.280.0040.00418.34
8.0.270.0030.00317.28
8.0.260.0030.00316.84
8.0.250.0000.00716.96
8.0.240.0040.00416.91
8.0.230.0000.00716.98
8.0.220.0000.00816.92
8.0.210.0030.00316.91
8.0.200.0030.00316.85
8.0.190.0040.00416.99
8.0.180.0000.00716.91
8.0.170.0040.00416.91
8.0.160.0000.00716.78
8.0.150.0040.00416.80
8.0.140.0040.00416.89
8.0.130.0030.00313.34
8.0.120.0000.00716.77
8.0.110.0040.00416.80
8.0.100.0040.00416.76
8.0.90.0000.00816.81
8.0.80.0120.00616.90
8.0.70.0020.00516.79
8.0.60.0040.00416.73
8.0.50.0000.00716.94
8.0.30.0100.00717.11
8.0.20.0130.01117.40
8.0.10.0050.00417.15
8.0.00.0090.00816.93
7.4.330.0020.00515.00
7.4.320.0030.00316.60
7.4.300.0030.00316.62
7.4.290.0070.00016.56
7.4.280.0000.00716.54
7.4.270.0000.00716.61
7.4.260.0030.00316.52
7.4.250.0050.00216.50
7.4.240.0060.00116.50
7.4.230.0000.00816.62
7.4.220.0170.00216.61
7.4.210.0040.01116.59
7.4.200.0000.00716.68
7.4.190.0040.00416.70
7.4.160.0000.01516.61
7.4.150.0160.00317.40
7.4.140.0160.00817.86
7.4.130.0050.01216.46
7.4.120.0100.00716.58
7.4.110.0030.01316.36
7.4.100.0110.00716.42
7.4.90.0080.00816.44
7.4.80.0090.00919.39
7.4.70.0120.00616.57
7.4.60.0120.00916.29
7.4.50.0060.00016.44
7.4.40.0040.01422.77
7.4.30.0130.00716.36
7.4.00.0070.01015.08
7.3.330.0030.00313.36
7.3.320.0060.00013.38
7.3.310.0060.00316.20
7.3.300.0040.00416.26
7.3.290.0070.00716.38
7.3.280.0090.00916.40
7.3.270.0120.00817.40
7.3.260.0060.01516.63
7.3.250.0090.00916.53
7.3.240.0060.01216.44
7.3.230.0150.00616.39
7.3.210.0060.01316.56
7.3.200.0000.01619.39
7.3.190.0030.01416.68
7.3.180.0120.00316.51
7.3.170.0100.01016.54
7.3.160.0030.02116.33
7.3.120.0100.00614.78
7.3.110.0000.01415.04
7.3.100.0040.01114.83
7.3.90.0040.01114.85
7.3.80.0000.01414.82
7.3.70.0080.00414.75
7.3.60.0100.00314.98
7.3.50.0070.00714.73
7.3.40.0130.00314.52
7.3.30.0060.01314.94
7.3.20.0040.00416.78
7.3.10.0120.00616.68
7.3.00.0150.00016.55
7.2.330.0070.01016.88
7.2.320.0200.00416.69
7.2.310.0140.00316.48
7.2.300.0090.01316.76
7.2.290.0030.01716.88
7.2.240.0060.00614.92
7.2.230.0030.01214.82
7.2.220.0040.00815.35
7.2.210.0040.01515.29
7.2.200.0070.00415.19
7.2.190.0030.01214.88
7.2.180.0130.00615.21
7.2.170.0070.01115.11
7.2.160.0030.00915.21
7.2.150.0000.00917.02
7.2.140.0070.01016.90
7.2.130.0110.00416.72
7.2.120.0100.01016.70
7.2.110.0030.01316.88
7.2.100.0030.00616.68
7.2.90.0130.00316.98
7.2.80.0100.00717.05
7.2.70.0100.00617.00
7.2.60.0030.00916.80
7.2.50.0080.00817.00
7.2.40.0030.00916.68
7.2.30.0000.01617.03
7.2.20.0090.00917.00
7.2.10.0030.01016.86
7.2.00.0050.00817.94
7.1.330.0070.01115.58
7.1.320.0120.00015.61
7.1.310.0030.01315.95
7.1.300.0030.00615.51
7.1.290.0000.01715.81
7.1.280.0030.01015.73
7.1.270.0040.01215.83
7.1.260.0090.00915.94
7.1.250.0100.00315.83
7.1.200.0080.00415.64
7.1.100.0110.00418.34
7.1.70.0000.00716.95
7.1.60.0140.01019.82
7.1.50.0000.01116.96
7.1.00.0030.07722.40
7.0.200.0000.01116.69
7.0.140.0100.07022.02
7.0.110.0500.03320.09
7.0.100.0530.08719.94
7.0.90.0230.06320.13
7.0.80.0200.05319.90
7.0.70.0400.04319.91
7.0.60.0470.07319.95
7.0.50.0430.03719.97
7.0.40.0070.06719.74
7.0.30.0030.04719.78
7.0.20.0100.07319.87
7.0.10.0000.04019.78
7.0.00.0030.08319.84
5.6.280.0100.06721.06
5.6.260.0000.06020.66
5.6.250.0130.02720.52
5.6.240.0070.04020.50
5.6.230.0030.04720.71
5.6.220.0100.04020.72
5.6.210.0100.03020.60
5.6.200.0000.04020.64
5.6.190.0070.04020.68
5.6.180.0030.04020.57
5.6.170.0100.03720.64
5.6.160.0130.03020.63
5.6.150.0100.07320.61
5.6.140.0100.05020.57
5.6.130.0100.06020.66
5.6.120.0030.03720.57
5.6.110.0100.03020.63
5.6.100.0100.04020.69
5.6.90.0070.05320.85
5.6.80.0030.04019.96
5.6.70.0070.04719.98
5.6.60.0030.05020.00
5.6.50.0130.06320.09
5.6.40.0070.03720.06
5.6.30.0070.04020.07
5.6.20.0030.03720.02
5.6.10.0030.05719.98
5.6.00.0000.04020.01
5.5.380.0030.04017.59
5.5.370.0070.03717.64
5.5.360.0100.03717.54
5.5.350.0100.07017.63
5.5.340.0030.07318.14
5.5.330.0000.04317.91
5.5.320.0000.03717.84
5.5.310.0070.06017.84
5.5.300.0070.04718.11
5.5.290.0030.04017.88
5.5.280.0000.04318.09
5.5.270.0000.06017.90
5.5.260.0070.03318.13
5.5.250.0070.06717.89
5.5.240.0030.06317.30
5.5.230.0130.07317.31
5.5.220.0000.04317.26
5.5.210.0030.04717.48
5.5.200.0000.04317.46
5.5.190.0000.03717.30
5.5.180.0000.06017.24
5.5.160.0030.05017.28
5.5.150.0030.08017.29
5.5.140.0100.05717.27
5.5.130.0000.04717.28
5.5.120.0130.02717.58
5.5.110.0030.07017.47
5.5.100.0100.06017.36
5.5.90.0030.04017.35
5.5.80.0030.06317.16
5.5.70.0000.04017.15
5.5.60.0000.07317.18
5.5.50.0100.04317.47
5.5.40.0070.06717.20
5.5.30.0070.03317.17
5.5.20.0030.04017.46
5.5.10.0000.06717.09
5.5.00.0100.02717.15
5.4.450.0030.04319.36
5.4.440.0030.04019.66
5.4.430.0100.07719.48
5.4.420.0030.03319.64
5.4.410.0070.03719.36
5.4.400.0030.04719.00
5.4.390.0100.06018.98
5.4.380.0030.03719.09
5.4.370.0030.08018.95
5.4.360.0100.05019.33
5.4.350.0130.03319.34
5.4.340.0000.04318.99
5.4.320.0130.06319.14
5.4.310.0070.06019.21
5.4.300.0130.06718.98
5.4.290.0070.06019.16
5.4.280.0030.03318.98
5.4.270.0030.07318.99
5.4.260.0030.04319.15
5.4.250.0070.03019.33
5.4.240.0030.03319.00
5.4.230.0230.06719.17
5.4.220.0070.03019.30
5.4.210.0030.05318.98
5.4.200.0030.06719.30
5.4.190.0030.06718.99
5.4.180.0000.04018.94
5.4.170.0030.04019.32
5.4.160.0170.02719.16
5.4.150.0030.04019.14
5.4.140.0000.04316.59
5.4.130.0100.03316.57
5.4.120.0030.07316.59
5.4.110.0130.05316.52
5.4.100.0070.03316.41
5.4.90.0030.03716.59
5.4.80.0100.03016.43
5.4.70.0000.03716.54
5.4.60.0070.03016.63
5.4.50.0030.04316.63
5.4.40.0000.03316.60
5.4.30.0000.03716.55
5.4.20.0170.05316.53
5.4.10.0130.06016.54
5.4.00.0000.06315.84
5.3.290.0000.06714.71
5.3.280.0030.05014.70
5.3.270.0030.06714.65
5.3.260.0070.03714.59
5.3.250.0070.03314.61
5.3.240.0030.04014.72
5.3.230.0070.04014.71
5.3.220.0000.04014.59
5.3.210.0130.07314.63
5.3.200.0030.03714.61
5.3.190.0070.05014.55
5.3.180.0000.04014.59
5.3.170.0030.05014.55
5.3.160.0000.06014.72
5.3.150.0100.03014.57
5.3.140.0030.03014.71
5.3.130.0030.06714.60
5.3.120.0100.07014.58
5.3.110.0030.03714.72
5.3.100.0030.06714.20
5.3.90.0030.03714.05
5.3.80.0070.05714.18
5.3.70.0070.04714.14
5.3.60.0000.03314.17
5.3.50.0000.06314.10
5.3.40.0000.03313.98
5.3.30.0000.04313.90
5.3.20.0030.03713.72
5.3.10.0000.03713.66
5.3.00.0000.04013.73
5.2.170.0070.05312.39
5.2.160.0070.05312.39
5.2.150.0000.03312.39
5.2.140.0070.02712.39
5.2.130.0030.02312.39
5.2.120.0000.03312.39
5.2.110.0070.02712.39
5.2.100.0070.03312.39
5.2.90.0030.02712.39
5.2.80.0000.03312.39
5.2.70.0000.03312.39
5.2.60.0170.04012.39
5.2.50.0000.02712.39
5.2.40.0100.02012.39
5.2.30.0100.02312.39
5.2.20.0070.05012.39
5.2.10.0030.04712.39
5.2.00.0070.04312.39
5.1.60.0030.03312.39
5.1.50.0030.02712.39
5.1.40.0030.03712.39
5.1.30.0070.03712.39
5.1.20.0000.03012.39
5.1.10.0030.02012.39
5.1.00.0030.02312.39
5.0.50.0000.02012.39
5.0.40.0000.01712.39
5.0.30.0000.02712.39
5.0.20.0000.03712.39
5.0.10.0000.02712.39
5.0.00.0000.03312.39
4.4.90.0030.01312.39
4.4.80.0030.01312.39
4.4.70.0030.01712.39
4.4.60.0030.01312.39
4.4.50.0030.02712.39
4.4.40.0000.03312.39
4.4.30.0000.03012.39
4.4.20.0030.01312.39
4.4.10.0030.01712.39
4.4.00.0000.04312.39
4.3.110.0000.01712.39
4.3.100.0030.03312.39
4.3.90.0030.01712.39
4.3.80.0030.02712.39
4.3.70.0000.02012.39
4.3.60.0000.01712.39
4.3.50.0000.01712.39
4.3.40.0030.02012.39
4.3.30.0000.01712.39
4.3.20.0000.01712.39
4.3.10.0030.01312.39
4.3.00.0000.01712.39

preferences:
41.9 ms | 400 KiB | 5 Q