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.40
8.3.50.0110.00722.00
8.3.40.0140.00718.79
8.3.30.0110.00418.82
8.3.20.0070.00020.06
8.3.10.0050.00322.08
8.3.00.0020.00522.40
8.2.180.0130.00316.61
8.2.170.0110.00422.96
8.2.160.0070.01419.21
8.2.150.0060.00324.18
8.2.140.0080.00024.66
8.2.130.0110.00326.16
8.2.120.0080.00017.63
8.2.110.0030.00721.11
8.2.100.0110.00017.91
8.2.90.0060.00319.23
8.2.80.0000.00917.97
8.2.70.0130.00017.62
8.2.60.0060.00317.93
8.2.50.0050.00318.07
8.2.40.0040.00418.28
8.2.30.0030.00718.23
8.2.20.0040.00417.63
8.2.10.0040.00417.59
8.2.00.0030.00517.64
8.1.280.0200.00025.92
8.1.270.0040.00422.14
8.1.260.0050.00326.35
8.1.250.0000.00828.09
8.1.240.0110.01121.44
8.1.230.0070.00417.52
8.1.220.0040.00417.77
8.1.210.0050.00318.77
8.1.200.0050.00517.35
8.1.190.0040.00417.23
8.1.180.0040.00418.10
8.1.170.0060.00318.46
8.1.160.0000.00721.98
8.1.150.0000.00718.58
8.1.140.0040.00417.52
8.1.130.0000.00717.96
8.1.120.0040.00417.53
8.1.110.0000.00817.52
8.1.100.0070.00017.36
8.1.90.0040.00417.45
8.1.80.0040.00417.38
8.1.70.0040.00417.48
8.1.60.0030.00517.61
8.1.50.0030.00517.53
8.1.40.0040.00417.47
8.1.30.0060.00317.65
8.1.20.0040.00417.69
8.1.10.0000.00817.58
8.1.00.0040.00417.41
8.0.300.0060.00318.77
8.0.290.0040.00416.75
8.0.280.0040.00418.51
8.0.270.0050.00216.85
8.0.260.0060.00016.74
8.0.250.0000.00716.88
8.0.240.0040.00416.88
8.0.230.0030.00516.88
8.0.220.0000.00716.95
8.0.210.0070.00016.82
8.0.200.0080.00016.98
8.0.190.0000.00817.00
8.0.180.0050.00316.93
8.0.170.0000.00716.86
8.0.160.0020.00516.84
8.0.150.0040.00416.93
8.0.140.0070.00016.81
8.0.130.0000.00713.29
8.0.120.0040.00416.75
8.0.110.0040.00416.90
8.0.100.0000.00716.73
8.0.90.0000.00816.82
8.0.80.0110.00616.96
8.0.70.0000.00716.86
8.0.60.0030.00516.95
8.0.50.0000.00716.77
8.0.30.0130.01017.00
8.0.20.0120.00817.40
8.0.10.0060.00316.84
8.0.00.0090.00916.81
7.4.330.0040.00415.00
7.4.320.0030.00316.62
7.4.300.0040.00416.59
7.4.290.0030.00316.48
7.4.280.0000.00816.61
7.4.270.0030.00316.52
7.4.260.0000.00716.48
7.4.250.0000.00816.45
7.4.240.0040.00416.57
7.4.230.0050.00316.50
7.4.220.0150.01216.56
7.4.210.0100.00816.54
7.4.200.0000.00816.61
7.4.190.0030.00316.37
7.4.160.0140.00316.46
7.4.150.0060.01217.40
7.4.140.0090.01117.86
7.4.130.0110.00616.51
7.4.120.0150.00516.71
7.4.110.0030.01316.44
7.4.100.0060.01216.52
7.4.90.0140.00316.58
7.4.80.0260.03919.39
7.4.70.0130.00316.65
7.4.60.0070.01116.25
7.4.50.0000.00616.34
7.4.40.0060.00622.77
7.4.30.0030.01316.59
7.4.10.0120.00615.02
7.4.00.0060.01215.04
7.3.330.0020.00213.37
7.3.320.0030.00313.33
7.3.310.0000.00816.38
7.3.300.0030.00316.25
7.3.290.0120.00416.38
7.3.280.0060.01216.35
7.3.270.0070.01017.40
7.3.260.0120.00916.39
7.3.250.0090.00916.43
7.3.240.0030.01916.41
7.3.230.0100.01216.41
7.3.210.0070.01416.42
7.3.200.0140.00419.39
7.3.190.0120.00616.45
7.3.180.0030.01316.67
7.3.170.0090.00616.39
7.3.160.0070.01016.63
7.3.130.0060.01214.88
7.3.120.0110.00815.01
7.3.110.0080.01014.91
7.3.100.0060.00914.82
7.3.90.0040.00914.95
7.3.80.0050.00814.82
7.3.70.0070.00714.76
7.3.60.0050.01014.73
7.3.50.0090.00314.85
7.3.40.0000.01214.92
7.3.30.0040.00914.79
7.3.20.0070.00716.58
7.3.10.0030.01316.74
7.3.00.0050.00716.57
7.2.330.0070.01116.83
7.2.320.0130.01016.79
7.2.310.0140.00916.60
7.2.300.0070.00916.80
7.2.290.0030.01316.65
7.2.260.0130.00615.14
7.2.250.0050.01315.21
7.2.240.0110.00615.07
7.2.230.0080.00715.34
7.2.220.0040.00915.08
7.2.210.0060.00715.31
7.2.200.0030.01015.21
7.2.190.0060.01015.07
7.2.180.0090.00415.02
7.2.170.0060.00815.09
7.2.160.0020.01015.18
7.2.150.0090.00917.02
7.2.140.0070.00816.89
7.2.130.0040.00917.07
7.2.120.0050.00717.00
7.2.110.0080.00516.93
7.2.100.0050.00916.99
7.2.90.0070.00716.93
7.2.80.0060.01017.07
7.2.70.0070.00717.08
7.2.60.0070.00616.99
7.2.50.0080.00217.14
7.2.40.0050.00916.80
7.2.30.0070.00516.94
7.2.20.0040.00716.89
7.2.10.0050.01117.07
7.2.00.0030.01017.59
7.1.330.0060.01015.93
7.1.320.0060.00515.94
7.1.310.0060.00915.90
7.1.300.0070.00715.84
7.1.290.0070.00715.60
7.1.280.0060.00915.77
7.1.270.0010.01115.80
7.1.260.0070.00715.82
7.1.250.0060.00615.60
7.1.240.0000.01315.71
7.1.230.0070.00415.82
7.1.220.0070.00715.77
7.1.210.0030.00915.94
7.1.200.0110.00715.77
7.1.190.0120.00615.95
7.1.180.0000.00815.74
7.1.170.0030.01015.54
7.1.160.0060.00815.97
7.1.150.0060.00615.55
7.1.140.0080.00815.75
7.1.130.0000.01215.69
7.1.120.0030.01015.80
7.1.110.0030.00615.65
7.1.100.0060.00716.84
7.1.90.0060.00615.91
7.1.80.0060.00315.81
7.1.70.0040.00716.23
7.1.60.0060.01117.80
7.1.50.0030.01416.21
7.1.40.0000.00915.83
7.1.30.0030.00915.77
7.1.20.0070.00315.54
7.1.10.0030.00915.80
7.1.00.0080.04519.21
7.0.330.0000.01215.10
7.0.320.0110.00415.48
7.0.310.0080.00815.43
7.0.300.0060.00915.42
7.0.290.0080.00615.41
7.0.280.0040.01115.45
7.0.270.0000.00915.55
7.0.260.0070.00315.26
7.0.250.0120.00015.45
7.0.240.0080.00015.33
7.0.230.0040.00415.47
7.0.220.0000.01015.55
7.0.210.0110.00415.43
7.0.200.0060.00416.20
7.0.190.0040.00715.29
7.0.180.0090.00615.48
7.0.170.0000.01515.66
7.0.160.0000.01015.43
7.0.150.0070.00715.50
7.0.140.0070.03518.60
7.0.130.0060.00615.62
7.0.120.0040.00415.30
7.0.110.0000.01015.51
7.0.100.0070.00415.47
7.0.90.0080.00415.29
7.0.80.0060.00615.36
7.0.70.0000.00815.52
7.0.60.0100.03817.79
7.0.50.0020.02616.77
7.0.40.0050.04016.71
7.0.30.0150.03716.75
7.0.20.0120.02916.91
7.0.10.0080.03716.95
7.0.00.0100.04016.76
5.6.400.0060.00614.69
5.6.390.0090.00614.35
5.6.380.0030.01214.68
5.6.370.0090.00914.18
5.6.360.0070.00714.67
5.6.350.0030.01314.51
5.6.340.0130.00314.29
5.6.330.0060.00314.83
5.6.320.0070.00714.40
5.6.310.0060.01014.43
5.6.300.0000.01614.74
5.6.290.0030.00514.22
5.6.280.0030.04117.91
5.6.270.0040.00814.64
5.6.260.0030.01014.59
5.6.250.0000.00814.39
5.6.240.0040.01114.45
5.6.230.0030.01414.71
5.6.220.0060.00614.44
5.6.210.0080.04217.45
5.6.200.0060.03216.40
5.6.190.0080.04617.55
5.6.180.1770.02317.57
5.6.170.0200.03717.43
5.6.160.0050.04617.55
5.6.150.0060.04516.37
5.6.140.0030.03716.35
5.6.130.0030.02816.36
5.6.120.0040.03917.79
5.6.110.0060.04217.86
5.6.100.0070.02317.85
5.6.90.0050.04817.83
5.6.80.0100.03617.30
5.6.70.0150.04317.38
5.6.60.0070.01014.30
5.6.50.0030.00614.47
5.6.40.0030.01414.09
5.6.30.0100.00314.39
5.6.20.0070.00714.45
5.6.10.0000.01114.50
5.6.00.0030.00714.51
5.5.380.0030.00914.32
5.5.370.0000.01114.46
5.5.360.0030.00614.65
5.5.350.0050.04217.40
5.5.340.0080.04216.27
5.5.330.0070.04617.49
5.5.320.0110.02117.33
5.5.310.0130.02217.52
5.5.300.0020.02516.27
5.5.290.0100.03216.22
5.5.280.0090.03617.65
5.5.270.0020.04817.60
5.5.260.0100.04317.76
5.5.250.0050.04017.55
5.5.240.0050.03817.16
5.5.230.0100.00714.34
5.5.220.0040.00414.36
5.5.210.0000.00814.39
5.5.200.0070.00714.23
5.5.190.0040.00414.41
5.5.180.0060.00614.23
5.5.170.0000.00814.22
5.5.160.0000.01114.52
5.5.150.0060.00914.64
5.5.140.0070.00314.51
5.5.130.0060.00614.47
5.5.120.0060.00914.42
5.5.110.0070.01014.34
5.5.100.0060.00814.28
5.5.90.0000.00914.36
5.5.80.0030.00714.57
5.5.70.0070.00714.34
5.5.60.0030.01414.32
5.5.50.0000.01314.34
5.5.40.0000.01114.47
5.5.30.0000.01214.25
5.5.20.0100.00314.36
5.5.10.0040.00414.50
5.5.00.0070.00714.04
5.4.450.0260.03515.34
5.4.440.0270.03715.47
5.4.430.0070.04215.37
5.4.420.0150.03215.29
5.4.410.0030.04115.36
5.4.400.0060.02814.73
5.4.390.0070.03115.03
5.4.380.0150.03114.94
5.4.370.0120.02914.86
5.4.360.0150.02714.97
5.4.350.0220.02214.79
5.4.340.0120.03114.77
5.4.330.0040.00411.13
5.4.320.0050.02211.64
5.4.310.0060.02211.87
5.4.300.0040.02111.85
5.4.290.0060.02011.99
5.4.280.0020.02511.71
5.4.270.0070.03415.05
5.4.260.0110.02715.14
5.4.250.0080.03814.95
5.4.240.0090.04114.97
5.4.230.0050.03414.99
5.4.220.0100.03715.21
5.4.210.0090.02814.93
5.4.200.0070.03115.05
5.4.190.0090.03815.10
5.4.180.0070.03015.18
5.4.170.0060.03115.03
5.4.160.0110.02515.12
5.4.150.0070.03914.78
5.4.140.0050.03213.82
5.4.130.0120.03313.71
5.4.120.0070.02813.63
5.4.110.0030.03514.00
5.4.100.0120.03313.81
5.4.90.0070.03413.86
5.4.80.0030.03813.72
5.4.70.0070.03613.66
5.4.60.0080.02613.75
5.4.50.0070.02913.86
5.4.40.0140.02913.78
5.4.30.0090.02513.79
5.4.20.0130.02013.80
5.4.10.0160.03613.81
5.4.00.0110.02813.49
5.3.290.0060.02811.69
5.3.280.0070.03512.65
5.3.270.0070.03412.68
5.3.260.0080.03112.51
5.3.250.0070.04012.68
5.3.240.0040.02812.67
5.3.230.0000.03312.63
5.3.220.0070.02912.54
5.3.210.0110.03512.69
5.3.200.0080.03512.71
5.3.190.0070.03212.59
5.3.180.0120.02812.61
5.3.170.0080.03712.62
5.3.160.0040.03312.65
5.3.150.0060.03012.55
5.3.140.0170.03212.71
5.3.130.0110.03612.56
5.3.120.0120.03012.71
5.3.110.0070.03412.56
5.3.100.0090.03112.45
5.3.90.0050.04212.37
5.3.80.0030.03312.27
5.3.70.0070.03812.24
5.3.60.0070.03212.42
5.3.50.0120.02712.26
5.3.40.0090.02812.29
5.3.30.0020.03712.24
5.3.20.0120.03612.17
5.3.10.0060.02612.13
5.3.00.0070.02911.99
5.2.170.0230.04011.08
5.2.160.0000.04711.13
5.2.150.0170.04711.17
5.2.140.0070.05711.16
5.2.130.0000.06711.09
5.2.120.0100.05011.35
5.2.110.0070.05311.31
5.2.100.0130.03710.98
5.2.90.0130.05011.11
5.2.80.0030.05311.19
5.2.70.0030.05011.10
5.2.60.0130.05311.16
5.2.50.0170.03011.00
5.2.40.0100.03710.86
5.2.30.0200.04310.83
5.2.20.0100.05011.14
5.2.10.0070.05310.89
5.2.00.0070.04010.83
5.1.60.0030.05310.22
5.1.50.0100.03710.01
5.1.40.0100.0409.97
5.1.30.0070.04710.33
5.1.20.0030.03710.46
5.1.10.0000.04310.16
5.1.00.0030.04310.25
5.0.50.0070.0338.55
5.0.40.0030.0338.55
5.0.30.0130.0478.36
5.0.20.0100.0238.39
5.0.10.0100.0338.27
5.0.00.0000.0438.36
4.4.90.0030.0276.92
4.4.80.0030.0276.92
4.4.70.0100.0236.92
4.4.60.0000.0236.92
4.4.50.0070.0276.92
4.4.40.0070.0306.92
4.4.30.0070.0236.92
4.4.20.0030.0236.92
4.4.10.0000.0376.92
4.4.00.0030.0336.92
4.3.110.0030.0206.92
4.3.100.0000.0306.92
4.3.90.0030.0206.92
4.3.80.0000.0336.92
4.3.70.0100.0236.92
4.3.60.0030.0276.92
4.3.50.0030.0236.92
4.3.40.0000.0336.92
4.3.30.0070.0176.92
4.3.20.0030.0236.92
4.3.10.0070.0176.92
4.3.00.0100.0207.38

preferences:
46.62 ms | 400 KiB | 5 Q