3v4l.org

run code in 300+ PHP versions simultaneously
<?php function roundup(int $v, int $p2): int { /* purely bitwise way to round up */ return ($v + $p2 - 1) & ~($p2 - 1); } function foreach_chunk(string $s, int $chunk, callable $func): void { /* make sure the chunk length is a power of 2 */ assert($chunk & ($chunk - 1) === 0); /* iterate over each chunk and call the callback */ array_walk(str_split(str_pad($s, roundup(strlen($s), $chunk), '0', STR_PAD_LEFT), $chunk), $func); } function bytesToBits(string $bytestring) { $bitstring = ''; foreach_chunk($bytestring, 4, function (string $chunk) use (&$bitstring) { $bitstring .= str_pad(base_convert(unpack('H*', $chunk)[1], 16, 2), strlen($chunk) * 8, '0', STR_PAD_LEFT); }); return $bitstring; } function bitsToBytes(string $bitstring) { $bytestring = ''; foreach_chunk($bitstring, 32, function(string $chunk) use (&$bytestring) { $bytestring .= pack('H*', str_pad(base_convert($chunk, 2, 16), strlen($chunk) / 8, '0', STR_PAD_LEFT)); }); return $bytestring; }

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.70.0120.00816.50
8.3.60.0110.00716.50
8.3.50.0130.00616.07
8.3.40.0160.00018.63
8.3.30.0120.00418.57
8.3.20.0040.00420.30
8.3.10.0080.00023.70
8.3.00.0070.00023.40
8.2.180.0030.01716.38
8.2.170.0120.00322.96
8.2.160.0100.00720.52
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0070.00022.21
8.2.120.0000.00826.35
8.2.110.0030.00722.25
8.2.100.0080.00417.84
8.2.90.0060.00319.11
8.2.80.0040.00418.02
8.2.70.0050.00317.48
8.2.60.0000.00917.91
8.2.50.0050.00318.10
8.2.40.0030.00520.47
8.2.30.0030.00519.20
8.2.20.0000.00918.00
8.2.10.0030.00517.99
8.2.00.0000.00817.96
8.1.280.0060.00925.92
8.1.270.0050.00323.79
8.1.260.0070.00026.35
8.1.250.0060.00328.09
8.1.240.0090.00020.79
8.1.230.0090.00317.58
8.1.220.0040.00417.74
8.1.210.0090.00018.77
8.1.200.0060.00317.23
8.1.190.0060.00317.11
8.1.180.0000.00718.10
8.1.170.0050.00318.30
8.1.160.0000.00718.77
8.1.150.0000.00719.95
8.1.140.0000.00717.24
8.1.130.0000.00818.81
8.1.120.0070.00017.26
8.1.110.0000.00817.30
8.1.100.0040.00417.32
8.1.90.0000.00717.36
8.1.80.0090.00317.34
8.1.70.0030.00317.36
8.1.60.0000.00917.38
8.1.50.0040.00417.43
8.1.40.0080.00017.32
8.1.30.0040.00817.50
8.1.20.0030.00617.49
8.1.10.0000.00817.38
8.1.00.0040.00417.34
8.0.300.0070.00018.77
8.0.290.0060.00316.63
8.0.280.0030.00318.32
8.0.270.0000.00717.16
8.0.260.0030.00716.71
8.0.250.0030.00316.82
8.0.240.0060.00316.80
8.0.230.0040.00416.80
8.0.220.0030.00316.74
8.0.210.0000.00716.74
8.0.200.0030.00316.81
8.0.190.0060.00316.87
8.0.180.0110.00016.81
8.0.170.0070.00016.86
8.0.160.0030.00616.63
8.0.150.0040.00416.80
8.0.140.0030.00316.73
8.0.130.0000.00713.25
8.0.120.0000.00716.78
8.0.110.0000.00716.78
8.0.100.0020.00516.58
8.0.90.0040.00416.63
8.0.80.0090.00616.72
8.0.70.0000.00716.73
8.0.60.0030.00616.63
8.0.50.0000.00716.86
8.0.30.0070.01217.09
8.0.20.0080.01117.40
8.0.10.0030.00516.77
8.0.00.0090.00916.70
7.4.330.0000.00516.74
7.4.320.0030.00316.45
7.4.300.0000.00616.53
7.4.290.0040.00416.49
7.4.280.0030.00616.47
7.4.270.0070.00016.54
7.4.260.0030.00516.33
7.4.250.0050.00216.35
7.4.240.0030.00316.48
7.4.230.0000.00716.56
7.4.220.0120.00916.30
7.4.210.0110.00916.44
7.4.200.0040.00416.39
7.4.160.0130.00516.26
7.4.150.0060.01517.40
7.4.140.0130.00517.86
7.4.130.0070.01716.34
7.4.120.0140.00816.51
7.4.110.0110.00616.63
7.4.100.0120.00916.27
7.4.90.0070.01016.33
7.4.80.0060.01519.39
7.4.70.0060.01216.49
7.4.60.0060.00916.48
7.4.50.0120.00316.39
7.4.40.0170.00316.15
7.4.30.0100.00716.34
7.4.10.0120.00614.88
7.4.00.0100.00514.96
7.3.330.0000.00513.22
7.3.320.0050.00013.12
7.3.310.0000.00716.25
7.3.300.0000.00616.27
7.3.290.0000.00716.13
7.3.280.0130.00316.26
7.3.270.0140.00317.40
7.3.260.0130.00516.35
7.3.250.0090.00916.29
7.3.240.0050.01216.37
7.3.230.0090.01116.23
7.3.210.0060.01016.42
7.3.200.0090.01016.25
7.3.190.0070.00716.23
7.3.180.0060.01016.19
7.3.170.0090.00616.44
7.3.160.0030.01316.23
7.3.130.0000.01614.63
7.3.120.0080.00914.63
7.3.110.0110.00714.88
7.3.100.0130.00314.73
7.3.90.0030.01014.60
7.3.80.0090.00314.92
7.3.70.0090.00614.66
7.3.60.0040.00814.60
7.3.50.0060.00914.50
7.3.40.0100.00314.50
7.3.30.0060.00914.84
7.3.20.0040.01116.42
7.3.10.0050.01016.30
7.3.00.0110.00716.34
7.2.330.0100.01316.27
7.2.320.0110.00716.46
7.2.310.0120.00416.51
7.2.300.0130.00616.52
7.2.290.0070.01016.46
7.2.260.0030.00914.91
7.2.250.0090.00914.71
7.2.240.0030.00815.11
7.2.230.0110.00014.94
7.2.220.0060.00914.62
7.2.210.0110.00714.77
7.2.200.0120.00314.68
7.2.190.0100.00714.79
7.2.180.0000.01114.86
7.2.170.0060.00614.55
7.2.160.0100.00714.67
7.2.150.0070.00416.75
7.2.140.0100.00316.69
7.2.130.0060.00716.24
7.2.120.0040.00916.41
7.2.110.0100.00216.53
7.2.100.0110.00216.50
7.2.90.0080.00816.68
7.2.80.0060.01016.61
7.2.70.0110.00815.99
7.2.60.0180.00716.72
7.2.50.0050.01116.55
7.2.40.0070.01016.43
7.2.30.0130.00616.45
7.2.20.0140.00716.54
7.2.10.0090.01316.25
7.2.00.0110.00616.32
7.1.330.0040.00715.64
7.1.320.0070.00715.59
7.1.310.0030.01015.32
7.1.300.0060.00915.19
7.1.290.0110.00315.52
7.1.280.0060.00915.19
7.1.270.0000.01215.76
7.1.260.0030.00715.61
7.1.250.0050.00615.36
7.1.240.0000.01315.57
7.1.230.0000.01015.73
7.1.220.0030.01115.41
7.1.210.0030.01015.55
7.1.200.0030.01215.64
7.1.190.0000.01315.57
7.1.180.0040.00715.72
7.1.170.0000.01415.54
7.1.160.0030.01015.70
7.1.150.0030.01015.73
7.1.140.0090.00915.47
7.1.130.0070.00715.63
7.1.120.0000.01515.27
7.1.110.2420.00515.99
7.1.100.2230.00715.83
7.1.90.3900.00715.90
7.1.80.0080.00815.51
7.1.70.3770.01115.26
7.1.60.0210.01124.43
7.1.50.0230.00624.11
7.1.40.0130.01224.21
7.1.30.0180.00724.10
7.1.20.0130.01424.19
7.1.10.0150.00615.04
7.1.00.0140.01215.11
7.0.330.0070.00715.16
7.0.320.0030.00615.16
7.0.310.0120.00015.45
7.0.300.0030.01015.22
7.0.290.0030.00615.34
7.0.280.0040.01515.46
7.0.270.0120.00015.24
7.0.260.0060.00615.00
7.0.250.2510.00815.60
7.0.240.2260.00515.59
7.0.230.5180.00315.42
7.0.220.5020.01215.47
7.0.210.0090.00914.96
7.0.200.0130.00615.04
7.0.190.0070.01015.06
7.0.180.0080.00814.79
7.0.170.0100.00714.88
7.0.160.0070.01114.71
7.0.150.0110.00914.74
7.0.140.0070.01214.83
7.0.130.6080.00614.82
7.0.120.0090.00814.94
7.0.110.0090.01314.75
7.0.100.0100.00614.69
7.0.90.1830.00714.77
7.0.80.0150.00314.87
7.0.70.0070.00914.72
7.0.60.0190.01014.78
7.0.50.4650.01114.85
7.0.40.4830.01013.93
7.0.30.4860.00613.91
7.0.20.4720.01014.04
7.0.10.4320.01113.78
7.0.00.3210.00713.68
5.6.400.0080.00614.41
5.6.390.0050.00513.96
5.6.380.0040.01114.26
5.6.370.0040.01114.14
5.6.360.0100.00314.28
5.6.350.0000.00813.79
5.6.340.0070.01013.93
5.6.330.0060.00614.45
5.6.320.0060.00614.11
5.6.310.0000.01314.32
5.6.300.0030.00514.20
5.6.290.0070.00714.05
5.6.280.0110.00314.13
5.6.270.0040.01214.12
5.6.260.0070.00714.16
5.6.250.0070.01014.14
5.6.240.0060.00914.19
5.6.230.0080.00614.27
5.6.220.0040.00414.32
5.6.210.0060.00313.97
5.6.200.0060.00314.02
5.6.190.0060.00914.14
5.6.180.0030.01013.92
5.6.170.0000.01414.02
5.6.160.0030.01014.11
5.6.150.0040.00713.94
5.6.140.0100.00314.16
5.6.130.0070.01014.02
5.6.120.0000.01514.22
5.6.110.0000.01313.86
5.6.100.0070.00414.09
5.6.90.0000.01213.93
5.6.80.0030.01014.15
5.6.70.0060.00313.84
5.6.60.0030.01313.96
5.6.50.0040.01114.13
5.6.40.0070.00714.10
5.6.30.0060.00913.86
5.6.20.0060.00614.25
5.6.10.0060.00314.02
5.6.00.0040.00414.15

preferences:
64.74 ms | 401 KiB | 5 Q