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 $test[1] === -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) { $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.40.0070.00718.61
8.3.30.0150.00018.79
8.3.20.0080.00018.76
8.3.10.0000.00821.10
8.3.00.0050.00321.85
8.2.170.0140.00722.96
8.2.160.0100.00320.55
8.2.150.0060.00324.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0050.00321.07
8.2.110.0060.00320.65
8.2.100.0040.00718.09
8.2.90.0030.00619.17
8.2.80.0040.00417.97
8.2.70.0040.00417.63
8.2.60.0030.00618.16
8.2.50.0000.00818.07
8.2.40.0040.00418.28
8.2.30.0000.00719.55
8.2.20.0080.00017.93
8.2.10.0000.00817.74
8.2.00.0040.00417.83
8.1.270.0000.00823.99
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0100.00722.20
8.1.230.0080.00317.51
8.1.220.0050.00317.79
8.1.210.0000.00818.77
8.1.200.0030.00617.36
8.1.190.0000.00817.52
8.1.180.0080.00018.10
8.1.170.0000.00818.67
8.1.160.0000.00718.98
8.1.150.0000.00718.62
8.1.140.0030.00617.57
8.1.130.0030.00317.85
8.1.120.0040.00417.61
8.1.110.0040.00417.54
8.1.100.0080.00017.50
8.1.90.0000.00717.62
8.1.80.0040.00417.56
8.1.70.0000.00717.58
8.1.60.0000.00917.70
8.1.50.0080.00017.61
8.1.40.0000.00817.51
8.1.30.0030.00617.75
8.1.20.0030.00517.83
8.1.10.0040.00417.69
8.1.00.0040.00417.50
8.0.300.0040.00418.77
8.0.290.0080.00017.00
8.0.280.0030.00318.46
8.0.270.0040.00417.36
8.0.260.0000.00717.00
8.0.250.0030.00317.05
8.0.240.0050.00517.04
8.0.230.0040.00417.10
8.0.220.0030.00316.89
8.0.210.0030.00317.00
8.0.200.0030.00316.95
8.0.190.0000.00716.95
8.0.180.0040.00416.99
8.0.170.0040.00416.98
8.0.160.0040.00417.06
8.0.150.0000.00716.96
8.0.140.0070.00017.02
8.0.130.0030.00313.51
8.0.120.0040.00416.98
8.0.110.0000.00717.00
8.0.100.0040.00416.95
8.0.90.0000.00716.83
8.0.80.0070.00717.05
8.0.70.0000.00816.83
8.0.60.0000.00817.01
8.0.50.0040.00416.95
8.0.30.0140.00517.07
8.0.20.0030.01617.44
8.0.10.0000.00717.02
8.0.00.0110.00616.77
7.4.330.0000.00516.88
7.4.320.0030.00316.73
7.4.300.0000.00616.56
7.4.290.0030.00316.71
7.4.280.0030.00316.61
7.4.270.0000.00716.63
7.4.260.0060.00313.37
7.4.250.0040.00416.62
7.4.240.0040.00416.70
7.4.230.0000.00716.44
7.4.220.0130.00316.77
7.4.210.0090.00816.70
7.4.200.0040.00416.60
7.4.190.0030.00316.66
7.4.160.0100.01316.34
7.4.150.0110.00617.40
7.4.140.0060.01217.86
7.4.130.0110.00616.62
7.4.120.0100.00716.57
7.4.110.0110.00716.70
7.4.100.0130.00316.52
7.4.90.0060.01016.60
7.4.80.0120.00619.39
7.4.70.0080.00816.46
7.4.60.0100.01316.53
7.4.50.0060.00316.29
7.4.40.0110.00422.77
7.4.30.0040.01516.69
7.4.00.0040.01515.08
7.3.330.0060.00013.42
7.3.320.0080.00013.41
7.3.310.0030.00316.27
7.3.300.0030.00316.26
7.3.290.0040.01216.42
7.3.280.0130.00616.44
7.3.270.0090.01017.40
7.3.260.0060.00918.24
7.3.250.0100.01016.55
7.3.240.0030.01316.61
7.3.230.0030.01416.67
7.3.210.0140.00316.51
7.3.200.0120.00619.39
7.3.190.0070.01016.49
7.3.180.0030.01316.52
7.3.170.0060.01516.67
7.3.160.0120.00816.51
7.3.120.0080.01115.09
7.3.110.0030.01214.93
7.3.100.0120.00314.77
7.3.90.0130.00014.69
7.3.80.0060.00614.87
7.3.70.0090.00315.03
7.3.60.0060.00914.95
7.3.50.0130.00014.90
7.3.40.0040.00914.72
7.3.30.0000.01014.87
7.3.20.0080.00416.74
7.3.10.0140.00316.75
7.3.00.0060.01116.53
7.2.330.0070.01016.84
7.2.320.0070.01316.52
7.2.310.0070.01616.77
7.2.300.0000.01616.53
7.2.290.0050.01116.82
7.2.250.0100.01015.33
7.2.240.0070.01015.16
7.2.230.0070.01014.91
7.2.220.0030.00615.19
7.2.210.0060.01015.32
7.2.200.0060.00915.04
7.2.190.0070.00715.33
7.2.180.0140.00415.12
7.2.170.0130.00315.23
7.2.130.0140.00916.51
7.2.120.0140.00716.36
7.2.110.0110.00816.67
7.2.100.0130.00316.56
7.2.90.0100.01316.46
7.2.80.0130.00616.30
7.2.70.0190.00616.48
7.2.60.0110.01116.69
7.2.50.0180.00416.30
7.2.40.0180.00716.39
7.2.30.0100.00716.62
7.2.20.0130.01416.74
7.2.10.0130.00816.64
7.2.00.0130.00818.25
7.1.330.0110.00416.06
7.1.320.0090.00615.88
7.1.310.0110.00015.60
7.1.300.0080.00415.87
7.1.290.0000.01515.82
7.1.280.0060.00916.06
7.1.270.0070.00415.88
7.1.260.0030.01016.10
7.1.250.0120.00615.60
7.1.100.0050.00518.43
7.1.70.0100.00617.28
7.1.60.0030.02119.40
7.1.50.0040.01416.92
7.1.00.0030.04722.40
7.0.200.0100.00316.76
7.0.140.0000.06722.24
7.0.70.0100.07320.01
7.0.60.0030.09020.05
7.0.50.0030.08320.53
7.0.40.0130.07720.28
7.0.30.0030.05720.09
7.0.20.0030.07720.28
7.0.10.0070.05320.13
7.0.00.0170.07720.11
5.6.280.0130.06021.24
5.6.220.0030.07720.81
5.6.210.0070.08020.85
5.6.200.0100.08321.22
5.6.190.0130.08021.17
5.6.180.0030.08321.04
5.6.170.0100.07321.24
5.6.160.0130.05721.21
5.6.150.0100.08021.12
5.6.140.0070.05021.13
5.6.130.0100.08021.21
5.6.120.0100.08321.25
5.6.110.0300.05721.12
5.6.100.0030.06021.11
5.6.90.0170.07721.27
5.6.80.0200.06720.59
5.6.70.0030.08020.51
5.6.60.0170.07320.50
5.6.50.0200.07020.61
5.6.40.0070.08320.50
5.6.30.0070.07720.58
5.6.20.0000.07020.48
5.6.10.0070.08320.57
5.6.00.0070.08720.62
5.5.360.0130.08020.44
5.5.350.0100.07320.60
5.5.340.0000.06020.95
5.5.330.0030.08320.87
5.5.320.0030.09020.94
5.5.310.0130.07721.10
5.5.300.0170.07020.97
5.5.290.0100.07021.02
5.5.280.0070.07020.82
5.5.270.0130.08321.02
5.5.260.0070.05321.05
5.5.250.0070.08320.61
5.5.240.0070.07320.36
5.5.230.0030.06320.38
5.5.220.0070.05020.39
5.5.210.0130.07020.31
5.5.200.0070.07320.42
5.5.190.0070.07720.38
5.5.180.0100.06020.30
5.5.160.0100.07720.16
5.5.150.0100.06320.31
5.5.140.0100.07720.32
5.5.130.0070.07720.32
5.5.120.0030.08020.44
5.5.110.0070.08720.22
5.5.100.0070.08020.25
5.5.90.0070.08020.23
5.5.80.0130.07720.08
5.5.70.0070.05020.19
5.5.60.0070.04320.28
5.5.50.0130.07020.22
5.5.40.0100.07720.16
5.5.30.0030.08720.19
5.5.20.0070.08020.23
5.5.10.0030.09020.19
5.5.00.0070.05720.14
5.4.450.0100.08019.36
5.4.440.0100.07719.56
5.4.430.0100.04719.46
5.4.420.0070.05019.42
5.4.410.0170.06719.33
5.4.400.0070.04718.91
5.4.390.0030.07719.18
5.4.380.0070.07319.23
5.4.370.0070.03719.05
5.4.360.0100.07018.95
5.4.350.0030.05019.21
5.4.340.0030.06319.14
5.4.320.0100.07718.91
5.4.310.0070.06018.85
5.4.300.0130.07019.04
5.4.290.0170.06719.18
5.4.280.0100.07019.04
5.4.270.0130.07318.89
5.4.260.0030.07319.16
5.4.250.0100.08019.12
5.4.240.0030.08319.12
5.4.230.0070.07318.86
5.4.220.0030.04319.13
5.4.210.0100.07718.88
5.4.200.0070.08019.22
5.4.190.0130.07018.89
5.4.180.0000.06019.02
5.4.170.0100.08019.06
5.4.160.0000.05019.07
5.4.150.0130.07318.86
5.4.140.0000.07316.32
5.4.130.0030.06716.50
5.4.120.0170.06716.51
5.4.110.0070.07316.52
5.4.100.0130.07016.29
5.4.90.0030.08016.56
5.4.80.0070.07716.40
5.4.70.0070.07716.48
5.4.60.0030.05016.33
5.4.50.0030.07016.25
5.4.40.0070.06016.35
5.4.30.0170.06716.24
5.4.20.0030.03716.46
5.4.10.0030.06716.32
5.4.00.0100.03715.87
5.3.290.0100.07314.63
5.3.280.0000.07314.53
5.3.270.0100.07314.58
5.3.260.0030.08314.59
5.3.250.0030.08314.71
5.3.240.0100.07714.74
5.3.230.0070.06014.57
5.3.220.0130.07014.72
5.3.210.0130.07314.61
5.3.200.0000.08314.63
5.3.190.0030.05714.55
5.3.180.0000.05014.59
5.3.170.0100.06014.51
5.3.160.0100.07714.50
5.3.150.0170.06014.64
5.3.140.0030.07714.59
5.3.130.0170.03014.65
5.3.120.0070.03714.64
5.3.110.0130.07014.54
5.3.100.0030.05014.03
5.3.90.0100.04714.05
5.3.80.0130.07014.14
5.3.70.0070.07314.09
5.3.60.0130.07014.16
5.3.50.0130.06013.89
5.3.40.0070.07713.95
5.3.30.0030.05714.04
5.3.20.0100.05713.68
5.3.10.0130.07013.75
5.3.00.0100.07013.71
5.2.170.0000.06711.23
5.2.160.0070.06711.10
5.2.150.0070.06311.23
5.2.140.0000.07011.07
5.2.130.0170.05011.22
5.2.120.0070.06011.19
5.2.110.0100.06011.04
5.2.100.0100.06011.12
5.2.90.0100.05311.11
5.2.80.0070.04011.13
5.2.70.0030.03711.24
5.2.60.0030.06311.01
5.2.50.0030.06310.98
5.2.40.0000.07011.07
5.2.30.0000.06710.93
5.2.20.0170.05310.96
5.2.10.0070.04311.00
5.2.00.0030.05010.86
5.1.60.0030.03310.86
5.1.50.0030.05310.86
5.1.40.0000.04710.86
5.1.30.0070.05010.86
5.1.20.0130.05010.86
5.1.10.0100.03710.86
5.1.00.0100.04710.86
5.0.50.0170.04010.86
5.0.40.0000.04710.86
5.0.30.0200.04310.86
5.0.20.0030.03310.86
5.0.10.0030.04710.86
5.0.00.0070.06310.86
4.4.90.0000.03310.86
4.4.80.0030.02710.86
4.4.70.0000.04010.86
4.4.60.0000.03710.86
4.4.50.0000.03010.86
4.4.40.0030.05710.86
4.4.30.0030.03710.86
4.4.20.0000.04010.86
4.4.10.0030.03310.86
4.4.00.0030.05310.86
4.3.110.0000.04010.86
4.3.100.0000.03710.86
4.3.90.0030.03010.86
4.3.80.0000.06010.86
4.3.70.0070.03310.86
4.3.60.0030.02310.86
4.3.50.0030.02710.86
4.3.40.0030.03710.86
4.3.30.0000.02310.86
4.3.20.0000.03710.86
4.3.10.0000.03310.86
4.3.00.0030.03010.86

preferences:
40.72 ms | 400 KiB | 5 Q