3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('INT_SIGNED', 1); define('INT_LE', 2); function is32Bit() { $test = unpack('N', "\xFF\xFF\xFF\xFF"); return current($test) === -1; } function unpack_int32($str, $flags = 0) { $length = strlen($str); if ($length < 4) { return false; } else if ($length > 4) { $str = substr($str, 0, 4); } if ($flags & INT_LE) { $str = strrev($str); } $result = unpack('N', $str); $result = current($result); $signBit = (bool) ($result & 0x80000000); $isSigned = (bool) ($flags & INT_SIGNED); $is32bit = is32Bit(); if ($signBit && $isSigned && !$is32bit) { $result = 0xFFFFFFFF00000000 | $result; } else if ($signBit && !$isSigned && $is32bit) { $result = (($result & 0x7FFFFFFF) * 2) + ~$result + 1; } return $result; } function unpack_int64($str, $flags = 0) { $length = strlen($str); if ($length < 8) { return false; } else if ($length > 8) { $str = substr($str, 0, 8); } $is32bit = is32Bit(); if ($flags & INT_LE) { $str = strrev($str); } $longs = array_values(unpack('NN', substr($str, 0, 4), substr($str, 4, 4))); $signBit = (bool) ($longs[0] & 0x80000000); if (PHP_INT_MAX > 0x7FFFFFFF) { var_dump($longs); $result = ($longs[0] << 32) | $longs[1]; if ($signBit) { $result = (($result & 0x7FFFFFFFFFFFFFFF) * 2) + ~$result + 1; } } return $result; } var_dump(unpack_int32("\x81\x00\x00\x80", INT_SIGNED | INT_LE));

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.0170.00317.00
8.3.50.0140.00717.53
8.3.40.0110.00718.83
8.3.30.0090.00618.88
8.3.20.0060.00318.91
8.3.10.0080.00020.66
8.3.00.0070.00317.50
8.2.180.0110.00716.50
8.2.170.0100.01022.96
8.2.160.0070.00721.20
8.2.150.0070.00024.18
8.2.140.0040.00424.66
8.2.130.0050.00326.16
8.2.120.0040.00419.95
8.2.110.0040.00721.25
8.2.100.0040.00817.97
8.2.90.0060.00319.30
8.2.80.0060.00319.29
8.2.70.0030.00617.50
8.2.60.0080.00017.93
8.2.50.0110.00418.07
8.2.40.0050.00318.27
8.2.30.0040.00418.02
8.2.20.0040.00417.78
8.2.10.0000.00817.62
8.2.00.0000.00817.81
8.1.280.0070.00725.92
8.1.270.0000.00724.66
8.1.260.0050.00226.35
8.1.250.0000.00728.09
8.1.240.0000.00922.59
8.1.230.0040.00820.96
8.1.220.0040.00417.74
8.1.210.0000.00819.02
8.1.200.0030.00717.23
8.1.190.0030.00517.53
8.1.180.0030.00618.10
8.1.170.0030.00619.02
8.1.160.0000.00718.95
8.1.150.0030.00618.63
8.1.140.0000.00817.57
8.1.130.0070.00017.79
8.1.120.0000.00717.55
8.1.110.0000.00817.41
8.1.100.0040.00417.45
8.1.90.0040.00417.52
8.1.80.0080.00017.44
8.1.70.0070.00017.47
8.1.60.0000.00817.68
8.1.50.0000.00817.59
8.1.40.0030.00517.57
8.1.30.0040.00417.63
8.1.20.0090.00017.59
8.1.10.0000.00817.66
8.1.00.0030.00517.42
8.0.300.0040.00419.85
8.0.290.0040.00416.74
8.0.280.0000.00718.45
8.0.270.0070.00016.95
8.0.260.0030.00316.81
8.0.250.0040.00417.07
8.0.240.0030.00316.91
8.0.230.0040.00417.03
8.0.220.0000.00716.95
8.0.210.0000.00716.93
8.0.200.0030.00316.92
8.0.190.0040.00417.04
8.0.180.0000.00816.99
8.0.170.0000.00716.87
8.0.160.0080.00016.87
8.0.150.0000.00716.93
8.0.140.0090.00316.91
8.0.130.0000.00513.44
8.0.120.0040.00416.99
8.0.110.0080.00016.83
8.0.100.0040.00416.94
8.0.90.0000.00717.00
8.0.80.0130.00616.95
8.0.70.0000.00816.86
8.0.60.0040.00417.02
8.0.50.0030.00517.04
8.0.30.0090.01317.30
8.0.20.0110.00817.18
8.0.10.0070.00017.07
8.0.00.0090.00916.99
7.4.330.0050.00013.09
7.4.320.0000.00716.68
7.4.300.0030.00316.58
7.4.290.0030.00316.60
7.4.280.0000.00816.49
7.4.270.0000.00616.59
7.4.260.0030.00313.34
7.4.250.0000.00816.67
7.4.240.0000.00716.71
7.4.230.0030.00316.68
7.4.220.0070.01116.64
7.4.210.0080.01016.62
7.4.200.0030.00316.40
7.4.190.0040.00416.55
7.4.160.0100.00716.49
7.4.150.0140.00316.57
7.4.140.0090.00916.55
7.4.130.0070.01316.68
7.4.120.0120.00616.57
7.4.110.0060.01216.57
7.4.100.0040.01516.55
7.4.90.0090.00916.68
7.4.80.0130.00916.66
7.4.70.0060.01216.74
7.4.60.0050.01016.70
7.4.50.0030.00316.50
7.4.40.0120.00416.45
7.4.30.0030.01416.54
7.4.00.0060.00614.98
7.3.330.0060.00013.46
7.3.320.0000.00513.32
7.3.310.0030.00316.42
7.3.300.0030.00316.50
7.3.290.0090.00616.47
7.3.280.0080.00816.42
7.3.270.0120.00916.42
7.3.260.0140.00516.52
7.3.250.0070.01116.57
7.3.240.0100.00716.45
7.3.230.0100.00716.54
7.3.210.0130.00716.40
7.3.200.0110.00719.39
7.3.190.0130.00316.54
7.3.180.0100.00516.33
7.3.170.0170.00316.39
7.3.160.0220.00016.60
7.3.120.0040.00815.25
7.3.10.0000.00916.95
7.3.00.0060.00616.90
7.2.330.0060.01216.57
7.2.320.0100.00716.39
7.2.310.0180.00716.50
7.2.300.0180.00616.54
7.2.290.0080.01216.84
7.2.130.0070.00716.97
7.2.120.0060.00616.94
7.2.110.0060.01016.82
7.2.100.0040.01116.93
7.2.90.0030.00917.00
7.2.80.0100.00316.94
7.2.70.0070.00716.80
7.2.60.0040.00816.87
7.2.50.0030.01016.94
7.2.40.0030.01316.90
7.2.30.0040.00716.83
7.2.20.0060.00616.94
7.2.10.0030.00916.94
7.2.00.0060.00616.82
7.1.250.0100.00015.81
7.1.100.0040.00818.37
7.1.70.0000.00717.14
7.1.60.0100.01019.40
7.1.50.0000.02317.16
7.1.00.0030.08722.45
7.0.200.0030.00716.97
7.0.140.0030.07722.21
7.0.120.0070.06322.25
7.0.60.0030.04320.05
7.0.50.0100.07718.08
7.0.40.0030.07320.40
7.0.30.0170.04020.17
7.0.20.0170.04020.12
7.0.10.0170.06020.16
7.0.00.0100.08720.42
5.6.280.0000.07721.03
5.6.210.0030.04020.79
5.6.200.0100.07718.28
5.6.190.0130.03320.67
5.6.180.0300.04320.58
5.6.170.0170.04320.70
5.6.160.0100.08320.66
5.6.150.0130.07318.31
5.6.140.0030.08318.28
5.6.130.0030.06718.31
5.6.120.0000.04721.13
5.6.110.0130.06321.13
5.6.100.0500.03721.22
5.6.90.0100.06021.20
5.6.80.0100.07720.49
5.6.70.0400.05720.45
5.5.350.0200.07720.55
5.5.340.0070.04018.16
5.5.330.0130.06320.27
5.5.320.0230.03020.47
5.5.310.0300.07320.34
5.5.300.0070.04318.07
5.5.290.0000.05318.21
5.5.280.0100.05721.05
5.5.270.0200.07320.88
5.5.260.0100.07720.90
5.5.250.0030.08020.70
5.5.240.0070.07720.40
5.4.450.0070.07719.20
5.4.440.0130.07719.18
5.4.430.0130.07319.46
5.4.420.0130.07319.46
5.4.410.0070.04719.44
5.4.400.0000.07719.19
5.4.390.0000.05718.87
5.4.380.0100.07719.14
5.4.370.0170.07019.15
5.4.360.0070.07718.85
5.4.350.0070.05018.93
5.4.340.0000.06719.19
5.4.320.0070.06319.19
5.4.310.0130.06319.25
5.4.300.0130.07019.15
5.4.290.0070.07718.97
5.4.280.0070.07018.97
5.4.270.0070.07319.14
5.4.260.0100.03719.15
5.4.250.0030.06718.85
5.4.240.0130.07318.93
5.4.230.0030.05019.24
5.4.220.0130.07319.23
5.4.210.0070.06319.25
5.4.200.0170.07018.91
5.4.190.0100.06018.86
5.4.180.0000.04319.14
5.4.170.0070.03718.84
5.4.160.0170.06318.85
5.4.150.0030.05019.14
5.4.140.0000.04016.43
5.4.130.0030.07316.55
5.4.120.0130.06016.42
5.4.110.0100.07016.52
5.4.100.0070.07316.48
5.4.90.0000.07716.39
5.4.80.0030.05716.46
5.4.70.0130.06716.33
5.4.60.0030.04016.38
5.4.50.0100.07016.47
5.4.40.0070.07716.39
5.4.30.0130.05016.50
5.4.20.0100.06316.27
5.4.10.0000.05716.26
5.4.00.0100.07315.95
5.3.290.0070.05014.71
5.3.280.0030.08314.67
5.3.270.0000.05014.63
5.3.260.0130.07314.77
5.3.250.0070.07014.64
5.3.240.0030.07314.63
5.3.230.0030.07714.77
5.3.220.0130.07314.61
5.3.210.0070.04314.59
5.3.200.0030.06714.47
5.3.190.0070.07314.51
5.3.180.0100.07314.46
5.3.170.0100.04314.61
5.3.160.0070.07314.55
5.3.150.0070.04714.59
5.3.140.0070.07314.63
5.3.130.0100.07314.71
5.3.120.0070.05014.48
5.3.110.0170.06014.73
5.3.100.0030.07714.13
5.3.90.0100.04014.08
5.3.80.0030.06314.07
5.3.70.0130.06714.04
5.3.60.0000.05714.03
5.3.50.0070.07313.96
5.3.40.0030.04313.98
5.3.30.0030.04014.08
5.3.20.0000.04313.68
5.3.10.0000.03713.56
5.3.00.0030.03313.57
5.2.170.0000.03711.09
5.2.160.0030.03311.16
5.2.150.0000.03011.13
5.2.140.0000.03011.09
5.2.130.0130.02311.29
5.2.120.0070.02711.02
5.2.110.0000.03011.13
5.2.100.0000.03011.12
5.2.90.0030.02711.27
5.2.80.0030.02711.00
5.2.70.0000.03011.18
5.2.60.0030.03310.97
5.2.50.0000.03311.12
5.2.40.0000.03011.02
5.2.30.0030.02711.04
5.2.20.0000.03010.95
5.2.10.0070.02310.88
5.2.00.0030.02710.76
5.1.60.0000.02710.08
5.1.50.0100.01710.18
5.1.40.0000.02310.03
5.1.30.0000.03010.28
5.1.20.0100.01710.34
5.1.10.0030.02310.16
5.1.00.0070.02710.07
5.0.50.0000.0209.86
5.0.40.0000.0209.86
5.0.30.0070.0239.86
5.0.20.0000.0209.86
5.0.10.0030.0209.86
5.0.00.0000.0309.86
4.4.90.0030.0179.86
4.4.80.0000.0139.86
4.4.70.0000.0179.86
4.4.60.0000.0179.86
4.4.50.0070.0179.86
4.4.40.0000.0239.86
4.4.30.0000.0179.86
4.4.20.0000.0179.86
4.4.10.0030.0139.86
4.4.00.0000.0239.86
4.3.110.0000.0209.86
4.3.100.0000.0179.86
4.3.90.0000.0139.86
4.3.80.0000.0239.86
4.3.70.0000.0139.86
4.3.60.0000.0139.86
4.3.50.0000.0139.86
4.3.40.0000.0279.86
4.3.30.0000.0139.86
4.3.20.0000.0179.86
4.3.10.0030.0139.86
4.3.00.0070.0079.86

preferences:
42.7 ms | 401 KiB | 5 Q