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(); var_dump($signBit, $isSigned, $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); } 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 (!is32Bit()) { $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.70.0290.00616.63
8.3.60.0040.01116.88
8.3.50.0060.01222.05
8.3.40.0090.00618.93
8.3.30.0130.00719.17
8.3.20.0040.00420.33
8.3.10.0000.00823.66
8.3.00.0050.00319.13
8.2.180.0070.01118.42
8.2.170.0180.00422.96
8.2.160.0140.00320.38
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0110.00426.16
8.2.120.0050.00322.38
8.2.110.0060.00322.29
8.2.100.0040.00718.03
8.2.90.0000.00819.14
8.2.80.0000.00817.97
8.2.70.0050.00317.63
8.2.60.0060.00317.93
8.2.50.0060.00318.07
8.2.40.0000.00918.29
8.2.30.0070.00018.16
8.2.20.0000.00817.86
8.2.10.0000.00718.18
8.2.00.0000.00817.77
8.1.280.0150.00325.92
8.1.270.0080.00023.84
8.1.260.0000.00726.35
8.1.250.0110.00428.09
8.1.240.0040.00424.10
8.1.230.0030.00719.23
8.1.220.0000.00817.74
8.1.210.0000.00918.77
8.1.200.0040.00717.23
8.1.190.0000.00817.39
8.1.180.0090.00018.10
8.1.170.0040.00418.52
8.1.160.0040.00422.12
8.1.150.0000.00818.68
8.1.140.0040.00417.48
8.1.130.0030.00317.90
8.1.120.0020.00517.60
8.1.110.0040.00417.51
8.1.100.0040.00417.49
8.1.90.0040.00417.55
8.1.80.0000.00717.55
8.1.70.0000.00717.42
8.1.60.0090.00017.66
8.1.50.0000.00917.53
8.1.40.0040.00417.57
8.1.30.0030.00617.72
8.1.20.0000.00717.75
8.1.10.0050.00217.61
8.1.00.0000.00717.43
8.0.300.0040.00418.77
8.0.290.0040.00417.30
8.0.280.0040.00418.55
8.0.270.0000.00817.36
8.0.260.0070.00016.95
8.0.250.0000.00717.05
8.0.240.0030.00617.02
8.0.230.0030.00316.97
8.0.220.0080.00016.91
8.0.210.0000.00716.86
8.0.200.0030.00317.08
8.0.190.0040.00417.07
8.0.180.0030.00616.98
8.0.170.0040.00416.92
8.0.160.0040.00417.05
8.0.150.0070.00016.97
8.0.140.0040.00416.98
8.0.130.0000.00913.44
8.0.120.0040.00417.02
8.0.110.0040.00417.04
8.0.100.0000.00716.89
8.0.90.0070.00017.01
8.0.80.0120.00317.06
8.0.70.0000.00716.98
8.0.60.0000.00716.88
8.0.50.0000.00716.94
8.0.30.0110.00817.37
8.0.20.0110.00817.40
8.0.10.0030.00517.07
8.0.00.0070.01117.03
7.4.330.0020.00215.07
7.4.320.0070.00016.53
7.4.300.0040.00416.60
7.4.290.0000.00716.62
7.4.280.0000.00716.52
7.4.270.0030.00316.69
7.4.260.0050.00316.68
7.4.250.0050.00316.57
7.4.240.0020.00516.66
7.4.230.0030.00316.73
7.4.220.0120.00616.76
7.4.210.0080.00716.61
7.4.200.0030.00316.81
7.4.190.0000.00716.66
7.4.160.0100.00616.48
7.4.150.0070.01017.40
7.4.140.0110.00717.86
7.4.130.0070.01116.72
7.4.120.0130.00316.82
7.4.110.0100.00616.63
7.4.100.0120.00616.67
7.4.90.0090.00916.62
7.4.80.0060.01319.39
7.4.70.0090.00916.70
7.4.60.0140.00916.60
7.4.50.0000.00516.32
7.4.40.0100.00322.77
7.4.30.0090.00616.48
7.4.10.0140.00315.18
7.4.00.0020.01415.08
7.3.330.0050.00013.29
7.3.320.0050.00013.40
7.3.310.0040.00416.31
7.3.300.0000.00716.46
7.3.290.0030.01216.38
7.3.280.0100.00816.43
7.3.270.0060.01217.40
7.3.260.0300.00016.42
7.3.250.0130.01016.48
7.3.240.0160.00616.36
7.3.230.0090.00816.66
7.3.210.0140.00416.45
7.3.200.0100.01319.39
7.3.190.0110.01016.75
7.3.180.0060.01016.76
7.3.170.0110.00416.63
7.3.160.0130.00316.47
7.3.130.0070.00715.01
7.3.120.0000.01715.03
7.3.110.0030.01514.89
7.3.100.0040.01515.14
7.3.90.0000.01315.10
7.3.80.0090.00314.77
7.3.70.0100.00014.98
7.3.60.0060.00315.03
7.3.50.0000.01515.04
7.3.40.0120.00614.96
7.3.30.0120.00314.98
7.3.20.0030.01016.70
7.3.10.0000.01616.73
7.3.00.0030.01116.76
7.2.330.0030.01516.76
7.2.320.0070.01116.71
7.2.310.0090.00916.90
7.2.300.0100.00616.89
7.2.290.0100.00716.50
7.2.260.0040.01015.31
7.2.250.0070.01015.20
7.2.240.0160.00015.23
7.2.230.0070.01114.77
7.2.220.0030.01315.04
7.2.210.0070.00715.38
7.2.200.0030.01015.00
7.2.190.0060.00615.20
7.2.180.0040.01115.13
7.2.170.0120.00614.82
7.2.160.0000.01015.24
7.2.150.0040.00817.10
7.2.140.0070.00716.91
7.2.130.0080.00717.02
7.2.120.0070.00516.81
7.2.110.0050.00816.88
7.2.100.0050.00716.84
7.2.90.0050.00816.92
7.2.80.0080.00817.09
7.2.70.0070.00417.01
7.2.60.0060.00916.96
7.2.50.0060.00916.91
7.2.40.0050.00817.09
7.2.30.0080.00616.95
7.2.20.0110.00616.90
7.2.10.0050.00816.92
7.2.00.0090.00517.79
7.1.330.0090.00615.77
7.1.320.0120.00315.92
7.1.310.0040.00715.84
7.1.300.0030.00615.65
7.1.290.0040.01415.64
7.1.280.0060.01215.83
7.1.270.0040.00716.02
7.1.260.0000.01415.86
7.1.250.0100.00215.94
7.1.240.0030.00815.77
7.1.230.0040.00815.91
7.1.220.0040.01315.84
7.1.210.0020.01115.85
7.1.200.0050.00715.86
7.1.190.0050.00715.96
7.1.180.0050.01215.81
7.1.170.0060.00615.76
7.1.160.0100.00215.91
7.1.150.0070.01015.92
7.1.140.0080.00615.68
7.1.130.0030.00815.62
7.1.120.0040.01015.97
7.1.110.0080.00615.91
7.1.100.0050.00716.65
7.1.90.0070.00516.00
7.1.80.0050.00915.93
7.1.70.0060.00516.40
7.1.60.0060.00917.07
7.1.50.0050.01016.31
7.1.40.0030.00715.95
7.1.30.0030.00815.82
7.1.20.0060.00615.78
7.1.10.0040.00815.85
7.1.00.0020.03218.05
7.0.330.0080.00415.56
7.0.320.0090.00515.55
7.0.310.0040.00715.56
7.0.300.0090.00515.52
7.0.290.0080.00315.33
7.0.280.0070.00615.53
7.0.270.0060.00615.53
7.0.260.0050.00515.40
7.0.250.0020.01415.58
7.0.240.0090.00515.62
7.0.230.0070.00515.42
7.0.220.0030.00815.31
7.0.210.0020.01015.41
7.0.200.0030.00615.97
7.0.190.0000.01315.52
7.0.180.0070.00515.28
7.0.170.0070.00415.54
7.0.160.0100.00215.35
7.0.150.0110.00515.28
7.0.140.0070.02517.80
7.0.130.0030.00815.45
7.0.120.0090.00315.65
7.0.110.0020.01015.54
7.0.100.0080.01616.93
7.0.90.0080.01416.95
7.0.80.0060.01817.00
7.0.70.0030.01916.95
7.0.60.0110.01416.95
7.0.50.0050.01617.17
7.0.40.0040.01515.74
7.0.30.0050.01915.81
7.0.20.0040.03115.82
7.0.10.0040.03515.77
7.0.00.0040.03315.71
5.6.400.0060.00314.64
5.6.390.0000.01414.44
5.6.380.0060.00714.34
5.6.370.0060.00614.20
5.6.360.0050.00914.49
5.6.350.0030.00814.26
5.6.340.0030.01114.53
5.6.330.0060.00614.61
5.6.320.0070.00714.06
5.6.310.0050.00814.40
5.6.300.0050.00514.54
5.6.290.0060.00514.49
5.6.280.0050.02716.59
5.6.270.0060.00614.39
5.6.260.0050.00614.35
5.6.250.0040.01916.58
5.6.240.0050.02216.49
5.6.230.0060.01416.51
5.6.220.0030.01716.50
5.6.210.0060.01516.37
5.6.200.0030.01916.77
5.6.190.0040.01516.72
5.6.180.0060.01816.64
5.6.170.0050.01816.68
5.6.160.0050.02916.64
5.6.150.0090.01416.64
5.6.140.0050.02516.70
5.6.130.0090.01716.60
5.6.120.0070.03116.57
5.6.110.0060.02416.75
5.6.100.0060.02716.59
5.6.90.0080.01716.61
5.6.80.0040.01716.32
5.6.70.0060.03016.40
5.6.60.0090.02716.43
5.6.50.0060.03216.39
5.6.40.0080.01616.31
5.6.30.0040.03016.24
5.6.20.0090.02516.44
5.6.10.0020.03116.40
5.6.00.0020.02316.36
5.5.380.0070.01715.36
5.5.370.0060.01515.23
5.5.360.0060.01615.42
5.5.350.0050.01515.25
5.5.340.0060.01815.57
5.5.330.0070.01415.59
5.5.320.0020.01915.53
5.5.310.0060.01415.60
5.5.300.0030.03515.40
5.5.290.0040.03015.58
5.5.280.0060.03215.37
5.5.270.0060.02915.60
5.5.260.0030.03315.54
5.5.250.0080.01815.35
5.5.240.0070.02715.30
5.5.230.0090.02315.24
5.5.220.0040.02015.29
5.5.210.0040.03115.38
5.5.200.0110.02315.39
5.5.190.0040.03115.37
5.5.180.0080.01415.36
5.5.170.0090.00212.84
5.5.160.0040.01815.26
5.5.150.0070.02915.30
5.5.140.0030.02115.29
5.5.130.0030.01915.14
5.5.120.0050.01715.16
5.5.110.0070.02615.14
5.5.100.0070.02815.17
5.5.90.0100.03215.17
5.5.80.0080.02715.16
5.5.70.0040.03215.31
5.5.60.0050.02915.10
5.5.50.0060.02815.06
5.5.40.0040.03515.26
5.5.30.0050.02115.29
5.5.20.0080.01715.25
5.5.10.0030.02315.18
5.5.00.0030.03115.12
5.4.450.0070.02614.77
5.4.440.0000.02814.83
5.4.430.0030.03114.73
5.4.420.0080.02714.68
5.4.410.0040.01614.76
5.4.400.0090.02614.51
5.4.390.0060.03014.50
5.4.380.0020.02414.55
5.4.370.0030.01614.57
5.4.360.0030.02614.45
5.4.350.0060.02514.67
5.4.340.0050.02814.65
5.4.330.0050.00312.34
5.4.320.0020.02314.52
5.4.310.0060.02814.48
5.4.300.0030.02814.69
5.4.290.0020.01714.58
5.4.280.0060.02514.66
5.4.270.0070.02814.41
5.4.260.0040.02814.73
5.4.250.0030.02714.45
5.4.240.0080.02614.52
5.4.230.0050.01814.51
5.4.220.0040.02014.61
5.4.210.0070.02514.61
5.4.200.0030.02814.58
5.4.190.0010.02114.63
5.4.180.0050.02514.49
5.4.170.0050.02414.48
5.4.160.0010.03214.51
5.4.150.0040.03014.59
5.4.140.0040.02913.72
5.4.130.0050.02913.70
5.4.120.0080.02313.70
5.4.110.0060.02613.62
5.4.100.0010.02513.67
5.4.90.0070.02213.68
5.4.80.0030.02513.66
5.4.70.0030.02813.61
5.4.60.0040.02813.67
5.4.50.0060.02213.65
5.4.40.0040.02813.71
5.4.30.0080.02613.56
5.4.20.0050.02713.72
5.4.10.0030.01813.62
5.4.00.0060.01513.45
5.3.290.0040.02912.99
5.3.280.0040.02612.93
5.3.270.0030.03012.97
5.3.260.0030.02313.00
5.3.250.0040.01912.90
5.3.240.0040.03012.89
5.3.230.0070.02712.92
5.3.220.0070.02712.85
5.3.210.0040.03312.89
5.3.200.0040.03212.90
5.3.190.0040.02812.84
5.3.180.0020.01912.88
5.3.170.0010.02412.95
5.3.160.0030.03012.93
5.3.150.0020.02812.88
5.3.140.0070.02612.96
5.3.130.0050.03012.90
5.3.120.0030.03112.88
5.3.110.0000.03512.92
5.3.100.0040.01612.77
5.3.90.0060.02712.70
5.3.80.0070.01412.73
5.3.70.0070.02912.67
5.3.60.0070.02412.78
5.3.50.0060.02512.67
5.3.40.0070.02512.70
5.3.30.0040.02812.62
5.3.20.0080.02012.54
5.3.10.0060.02012.55
5.3.00.0000.03312.52
5.2.170.0080.03010.78
5.2.160.0110.02810.78
5.2.150.0050.03210.78
5.2.140.0060.03310.78
5.2.130.0060.02810.78
5.2.120.0130.02610.78
5.2.110.0030.03310.78
5.2.100.0040.02810.78
5.2.90.0040.03310.78
5.2.80.0030.03310.78
5.2.70.0030.02210.78
5.2.60.0060.01710.78
5.2.50.0030.03410.78
5.2.40.0020.03010.78
5.2.30.0050.03310.78
5.2.20.0050.03010.78
5.2.10.0070.02810.78
5.2.00.0050.02710.78
5.1.60.0050.02410.78
5.1.50.0040.01310.78
5.1.40.0070.02210.78
5.1.30.0060.02810.78
5.1.20.0020.03110.78
5.1.10.0020.02810.78
5.1.00.0060.02910.78
5.0.50.0020.02710.78
5.0.40.0040.01210.78
5.0.30.0070.02810.78
5.0.20.0030.01410.78
5.0.10.0050.01810.78
5.0.00.0020.03010.78
4.4.90.0030.01210.78
4.4.80.0030.01810.78
4.4.70.0030.02010.78
4.4.60.0000.01710.78
4.4.50.0020.01810.78
4.4.40.0000.01710.78
4.4.30.0020.01710.78
4.4.20.0000.01210.78
4.4.10.0010.02110.78
4.4.00.0050.02110.78
4.3.110.0030.02010.78
4.3.100.0050.01810.78
4.3.90.0020.01910.78
4.3.80.0000.03110.78
4.3.70.0050.01310.78
4.3.60.0030.01810.78
4.3.50.0030.01810.78
4.3.40.0020.02110.78
4.3.30.0020.01810.78
4.3.20.0020.01310.78
4.3.10.0050.01310.78
4.3.00.0030.01910.78

preferences:
47.27 ms | 401 KiB | 5 Q