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 = (0x00000000FFFFFFFF << 32) | $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('N*', $str)); $signBit = (bool) ($longs[0] & 0x80000000); $isSigned = (bool) ($flags & INT_SIGNED); if (is32Bit()) { if ($longs[1] & 0x80000000) { $longs[1] = (($longs[1] & 0x7FFFFFFF) * 2) + ~$longs[1] + 1; } if ($isSigned && $signBit) { $result = ($longs[0] * pow(2, 32)) + $longs[1]; } else { if ($signBit) { $longs[0] = (($longs[0] & 0x7FFFFFFF) * 2) + ~$longs[0] + 1; } $result = ($longs[0] * pow(2, 32)) + $longs[1]; } } else { $result = ($longs[0] << 32) | $longs[1]; if ($signBit && !$isSigned) { $result = (($result & 0x7FFFFFFFFFFFFFFF) * 2) + ~$result + 1; } } return $result; } echo "int32:\n"; printf("%f\n", unpack_int64("\xFF\xFF\xFF\xFE")); printf("%f\n", unpack_int64("\xFF\xFF\xFF\xFE", INT_SIGNED)); printf("%f\n", unpack_int64("\xFF\xFF\xFF\xFE", INT_LE)); printf("%f\n", unpack_int64("\xFF\xFF\xFF\xFE", INT_LE | INT_SIGNED)); echo "int64:\n"; printf("%f\n", unpack_int64("\xFF\xFF\xFF\xFE\x00\x00\x00\x00")); printf("%f\n", unpack_int64("\xFF\xFF\xFF\xFE\x00\x00\x00\x00", INT_SIGNED)); printf("%f\n", unpack_int64("\xFF\xFF\xFF\xFE\x00\x00\x00\x00", INT_LE)); printf("%f\n", unpack_int64("\xFF\xFF\xFF\xFE\x00\x00\x00\x00", INT_LE | INT_SIGNED));

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.0040.01118.86
8.3.30.0160.00618.76
8.3.20.0120.00318.57
8.3.10.0000.00820.66
8.3.00.0030.00523.66
8.2.170.0120.00622.96
8.2.160.0070.00720.35
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0020.00526.16
8.2.120.0030.00519.48
8.2.110.0060.00320.82
8.2.100.0000.01217.66
8.2.90.0000.00819.17
8.2.80.0040.00418.04
8.2.70.0040.00417.38
8.2.60.0050.00318.03
8.2.50.0000.00918.16
8.2.40.0040.00418.14
8.2.30.0040.00419.95
8.2.20.0050.00317.83
8.2.10.0080.00017.80
8.2.00.0040.00417.80
8.1.270.0040.00423.99
8.1.260.0000.00926.35
8.1.250.0040.00428.09
8.1.240.0060.00322.61
8.1.230.0000.01121.04
8.1.220.0050.00318.77
8.1.210.0040.00418.97
8.1.200.0030.00617.35
8.1.190.0030.00617.64
8.1.180.0060.00318.10
8.1.170.0000.00818.78
8.1.160.0000.00818.98
8.1.150.0050.00318.60
8.1.140.0080.00017.42
8.1.130.0030.00317.80
8.1.120.0070.00017.55
8.1.110.0040.00417.58
8.1.100.0030.00517.41
8.1.90.0050.00317.52
8.1.80.0040.00417.39
8.1.70.0050.00317.45
8.1.60.0040.00817.66
8.1.50.0000.00817.49
8.1.40.0080.00017.61
8.1.30.0030.00617.68
8.1.20.0090.00017.73
8.1.10.0040.00417.64
8.1.00.0000.00817.58
8.0.300.0070.00020.21
8.0.290.0050.00216.88
8.0.280.0040.00418.50
8.0.270.0000.00717.31
8.0.260.0030.00316.79
8.0.250.0000.00717.07
8.0.240.0060.00317.00
8.0.230.0040.00417.01
8.0.220.0070.00016.99
8.0.210.0070.00016.91
8.0.200.0040.00416.92
8.0.190.0060.00316.96
8.0.180.0000.00716.89
8.0.170.0030.00616.83
8.0.160.0030.00416.85
8.0.150.0040.00416.86
8.0.140.0080.00316.96
8.0.130.0000.00813.42
8.0.120.0040.00416.84
8.0.110.0050.00317.07
8.0.100.0080.00016.77
8.0.90.0030.00517.00
8.0.80.0120.00616.91
8.0.70.0040.00416.98
8.0.60.0030.00516.89
8.0.50.0000.00716.93
8.0.30.0100.00917.17
8.0.20.0100.00817.40
8.0.10.0040.00417.07
8.0.00.0080.01016.80
7.4.330.0000.00514.66
7.4.320.0070.00016.52
7.4.300.0000.00716.68
7.4.290.0070.00016.56
7.4.280.0050.00316.67
7.4.270.0040.00416.59
7.4.260.0030.00313.33
7.4.250.0070.00016.45
7.4.240.0000.00716.57
7.4.230.0040.00416.54
7.4.220.0030.01316.71
7.4.210.0090.00916.62
7.4.200.0030.00316.68
7.4.190.0070.00016.44
7.4.160.0070.01716.35
7.4.150.0060.01217.40
7.4.140.0150.00817.86
7.4.130.0120.00916.62
7.4.120.0120.00916.67
7.4.110.0100.01016.48
7.4.100.0070.01416.48
7.4.90.0080.01216.48
7.4.80.0070.01019.37
7.4.70.0030.01316.54
7.4.60.0030.01616.53
7.4.50.0040.00416.45
7.4.40.0060.00622.27
7.4.30.0200.00316.81
7.4.00.0070.01015.05
7.3.330.0050.00013.23
7.3.320.0000.00513.43
7.3.310.0030.00316.31
7.3.300.0070.00016.42
7.3.290.0040.01116.38
7.3.280.0070.01316.41
7.3.270.0100.01917.40
7.3.260.0070.01418.24
7.3.250.0140.00716.58
7.3.240.0180.00416.38
7.3.230.0080.00916.71
7.3.210.0060.01016.40
7.3.200.0100.01319.39
7.3.190.0030.01316.34
7.3.180.0090.00616.70
7.3.170.0060.01016.49
7.3.160.0060.01016.75
7.3.120.0040.00415.08
7.2.330.0070.01116.79
7.2.320.0120.00616.85
7.2.310.0140.00716.91
7.2.300.0100.01016.50
7.2.290.0110.00616.87
7.1.70.0070.00317.23
7.1.60.0000.02519.40
7.1.50.0090.00616.69
7.1.00.0000.06322.41
7.0.200.0170.00314.90
7.0.140.0030.07322.01
7.0.60.0170.05319.93
7.0.50.0030.08717.93
7.0.40.0100.04317.73
7.0.30.0000.07317.82
7.0.20.0130.07017.81
7.0.10.0070.07717.74
7.0.00.0100.07717.81
5.6.280.0000.06721.10
5.6.210.0100.08320.46
5.6.200.0130.07718.20
5.6.190.0030.09018.15
5.6.180.0030.07018.29
5.6.170.0100.08318.19
5.6.160.0100.07718.29
5.6.150.0200.06018.19
5.6.140.0100.07718.24
5.6.130.0000.08718.25
5.6.120.0030.06018.27
5.6.110.0070.07318.18
5.6.100.0030.08318.18
5.6.90.0030.04718.27
5.6.80.0030.08317.54
5.6.70.0100.07717.57
5.6.60.0130.07017.52
5.6.50.0100.07317.53
5.6.40.0030.07317.64
5.6.30.0100.07317.52
5.6.20.0130.07017.63
5.6.10.0000.04717.53
5.6.00.0030.08017.56
5.5.350.0100.03720.52
5.5.340.0030.06317.96
5.5.330.0030.06018.00
5.5.320.0070.07717.97
5.5.310.0130.07318.04
5.5.300.0000.05717.96
5.5.290.0070.05017.98
5.5.280.0070.06017.97
5.5.270.0030.06318.01
5.5.260.0100.07717.97
5.5.250.0030.08317.77
5.5.240.0070.07717.34
5.5.230.0000.05317.32
5.5.220.0100.07317.45
5.5.210.0070.07717.36
5.5.200.0030.08317.35
5.5.190.0100.05317.32
5.5.180.0030.05717.42
5.5.160.0070.06717.32
5.5.150.0070.07717.31
5.5.140.0070.06717.31
5.5.130.0070.04317.32
5.5.120.0100.03317.29
5.5.110.0030.07717.40
5.5.100.0130.07717.20
5.5.90.0030.04317.20
5.5.80.0100.06717.32
5.5.70.0100.05717.21
5.5.60.0030.04317.21
5.5.50.0030.03717.21
5.5.40.0000.04317.23
5.5.30.0100.07017.21
5.5.20.0030.04317.23
5.5.10.0070.06017.32
5.5.00.0100.03317.18
5.4.450.0070.07719.29
5.4.440.0000.06019.49
5.4.430.0070.05319.42
5.4.420.0130.06019.36
5.4.410.0000.05719.34
5.4.400.0100.06019.05
5.4.390.0030.07319.13
5.4.380.0100.07319.09
5.4.370.0130.05719.14
5.4.360.0070.07718.99
5.4.350.0030.06019.10
5.4.340.0070.04719.11
5.4.320.0100.04019.04
5.4.310.0070.07319.13
5.4.300.0030.05019.12
5.4.290.0030.05019.14
5.4.280.0000.05019.14
5.4.270.0000.04319.05
5.4.260.0000.04319.05
5.4.250.0130.03719.09
5.4.240.0070.04319.01
5.4.230.0030.05719.09
5.4.220.0030.04319.04
5.4.210.0070.07019.04
5.4.200.0100.03719.03
5.4.190.0070.06019.02
5.4.180.0030.04019.03
5.4.170.0170.07019.09
5.4.160.0030.04019.08
5.4.150.0100.06019.12
5.4.140.0070.04716.63
5.4.130.0130.06316.63
5.4.120.0100.06716.59
5.4.110.0030.04016.51
5.4.100.0100.05016.45
5.4.90.0130.07016.45
5.4.80.0030.06716.44
5.4.70.0070.05716.45
5.4.60.0070.07716.30
5.4.50.0070.07316.32
5.4.40.0070.03316.48
5.4.30.0100.07016.42
5.4.20.0030.07316.41
5.4.10.0030.07716.35
5.4.00.0030.07016.02
5.3.290.0070.03714.55
5.3.280.0100.06714.62
5.3.270.0070.04314.71
5.3.260.0230.04714.67
5.3.250.0100.06714.68
5.3.240.0130.04014.69
5.3.230.0070.08014.66
5.3.220.0000.08314.61
5.3.210.0070.06714.56
5.3.200.0030.04014.61
5.3.190.0030.07714.63
5.3.180.0070.07314.65
5.3.170.0070.06314.64
5.3.160.0000.08014.70
5.3.150.0030.06714.64
5.3.140.0070.07314.59
5.3.130.0070.07714.59
5.3.120.0070.06314.60
5.3.110.0030.04714.63
5.3.100.0070.07714.29
5.3.90.0100.03314.09
5.3.80.0130.07014.09
5.3.70.0030.04313.95
5.3.60.0070.07314.06
5.3.50.0000.08714.03
5.3.40.0070.07714.05
5.3.30.0070.06013.80
5.3.20.0000.04313.80
5.3.10.0030.04313.58
5.3.00.0070.05713.88
5.2.170.0000.05711.23
5.2.160.0000.04311.23
5.2.150.0070.06311.21
5.2.140.0030.06311.22
5.2.130.0070.06011.14
5.2.120.0070.06011.13
5.2.110.0030.06711.18
5.2.100.0000.04311.18
5.2.90.0030.03711.14
5.2.80.0070.06311.15
5.2.70.0070.04711.17
5.2.60.0070.04311.18
5.2.50.0100.05711.09
5.2.40.0030.03311.00
5.2.30.0030.04311.05
5.2.20.0000.03711.06
5.2.10.0070.05311.00
5.2.00.0000.06010.77
5.1.60.0000.0479.97
5.1.50.0100.02710.17
5.1.40.0130.03310.11
5.1.30.0000.05010.46
5.1.20.0000.05310.39
5.1.10.0000.05310.13
5.1.00.0100.05010.09
5.0.50.0000.0239.45
5.0.40.0100.0239.45
5.0.30.0030.0439.45
5.0.20.0030.0439.45
5.0.10.0000.0309.45
5.0.00.0070.0379.45
4.4.90.0070.0239.45
4.4.80.0000.0379.45
4.4.70.0030.0339.45
4.4.60.0000.0339.45
4.4.50.0030.0339.45
4.4.40.0100.0279.45
4.4.30.0000.0209.45
4.4.20.0030.0339.45
4.4.10.0030.0379.45
4.4.00.0030.0509.45
4.3.110.0000.0379.45
4.3.100.0000.0339.45
4.3.90.0070.0309.45
4.3.80.0070.0279.45
4.3.70.0070.0309.45
4.3.60.0000.0209.45
4.3.50.0030.0209.45
4.3.40.0000.0609.45
4.3.30.0070.0339.45
4.3.20.0000.0339.45
4.3.10.0000.0409.45
4.3.00.0030.0339.45

preferences:
45.06 ms | 400 KiB | 5 Q