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); } 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()) { 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.70.0060.00917.00
8.3.60.0120.00617.00
8.3.50.0130.00522.00
8.3.40.0000.01518.94
8.3.30.0090.00619.14
8.3.20.0040.00420.51
8.3.10.0080.00023.64
8.3.00.0170.00319.50
8.2.190.0000.01618.46
8.2.180.0100.01018.29
8.2.170.0160.00322.96
8.2.160.0070.01120.35
8.2.150.0070.01124.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0080.00022.38
8.2.110.0060.00322.20
8.2.100.0000.01117.97
8.2.90.0000.00819.32
8.2.80.0050.00317.97
8.2.70.0060.00317.75
8.2.60.0080.00017.91
8.2.50.0080.00018.07
8.2.40.0030.00618.34
8.2.30.0040.00418.16
8.2.20.0040.00417.87
8.2.10.0040.00418.23
8.2.00.0000.00717.74
8.1.280.0150.00625.92
8.1.270.0060.00623.96
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0030.00623.77
8.1.230.0080.00419.16
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0030.00617.47
8.1.190.0040.00417.30
8.1.180.0050.00318.10
8.1.170.0030.01318.41
8.1.160.0000.00822.13
8.1.150.0040.00418.80
8.1.140.0000.00717.53
8.1.130.0050.00317.86
8.1.120.0040.00417.48
8.1.110.0050.00217.45
8.1.100.0050.00217.48
8.1.90.0000.00717.57
8.1.80.0070.00017.57
8.1.70.0070.00017.47
8.1.60.0030.00617.71
8.1.50.0040.00417.64
8.1.40.0090.00017.63
8.1.30.0040.00417.73
8.1.20.0030.00617.70
8.1.10.0050.00217.58
8.1.00.0060.00317.50
8.0.300.0060.00318.77
8.0.290.0040.00417.29
8.0.280.0050.00218.44
8.0.270.0070.00017.27
8.0.260.0000.00716.91
8.0.250.0030.00316.93
8.0.240.0040.00516.95
8.0.230.0040.00417.06
8.0.220.0030.00316.96
8.0.210.0020.00516.91
8.0.200.0000.00717.12
8.0.190.0000.00717.11
8.0.180.0000.00816.87
8.0.170.0000.00717.02
8.0.160.0000.00717.02
8.0.150.0040.00416.90
8.0.140.0040.00416.87
8.0.130.0000.00513.42
8.0.120.0040.00417.00
8.0.110.0040.00416.93
8.0.100.0080.00016.87
8.0.90.0000.00816.90
8.0.80.0130.00716.91
8.0.70.0030.00516.82
8.0.60.0050.00317.00
8.0.50.0070.00017.07
8.0.30.0150.00717.11
8.0.20.0090.01117.40
8.0.10.0040.00417.15
8.0.00.0080.01016.82
7.4.330.0000.00515.29
7.4.320.0080.00016.76
7.4.300.0030.00316.61
7.4.290.0030.00316.63
7.4.280.0080.00016.69
7.4.270.0000.00716.69
7.4.260.0030.00316.63
7.4.250.0070.00016.68
7.4.240.0030.00416.66
7.4.230.0000.00716.42
7.4.220.0060.01216.65
7.4.210.0070.00816.75
7.4.200.0000.00716.74
7.4.190.0070.00016.74
7.4.160.0110.00416.69
7.4.150.0100.00717.40
7.4.140.0090.01017.86
7.4.130.0120.00816.59
7.4.120.0090.00716.51
7.4.110.0070.01016.71
7.4.100.0150.00316.82
7.4.90.0030.01316.56
7.4.80.0090.00919.39
7.4.70.0080.00816.47
7.4.60.0140.00616.49
7.4.50.0000.00816.73
7.4.40.0040.00822.77
7.4.30.0100.00616.65
7.4.00.0160.00015.16
7.3.330.0050.00013.43
7.3.320.0000.00613.40
7.3.310.0000.00816.35
7.3.300.0000.00716.48
7.3.290.0000.01616.36
7.3.280.0080.00716.47
7.3.270.0070.01017.40
7.3.260.0120.00616.59
7.3.250.0090.01316.55
7.3.240.0150.00416.49
7.3.230.0080.00816.44
7.3.210.0080.00816.49
7.3.200.0100.01319.39
7.3.190.0110.00816.41
7.3.180.0120.00716.48
7.3.170.0120.00316.53
7.3.160.0060.01616.64
7.3.120.0030.01014.95
7.2.330.0100.01016.72
7.2.320.0170.00016.79
7.2.310.0180.00016.53
7.2.300.0030.01716.54
7.2.290.0060.01216.82
7.2.00.0070.00719.29
7.1.100.0030.01118.04
7.1.70.0060.00317.43
7.1.60.0060.01619.33
7.1.50.0120.00917.01
7.1.00.0100.07022.61
7.0.200.0030.00716.75
7.0.140.0070.07321.97
7.0.100.0070.07320.12
7.0.90.0130.08720.05
7.0.80.0170.04720.09
7.0.70.0100.04720.25
7.0.60.0330.06720.14
7.0.50.0030.07720.42
7.0.40.0070.08720.21
7.0.30.0170.07320.11
7.0.20.0000.06720.20
7.0.10.0030.08020.13
7.0.00.0000.08020.13
5.6.280.0000.07721.23
5.6.250.0200.06020.64
5.6.240.0170.03720.72
5.6.230.0130.07020.78
5.6.220.0130.06020.63
5.6.210.0100.05320.77
5.6.200.0000.08321.14
5.6.190.0070.04021.13
5.6.180.0130.07321.19
5.6.170.0030.05021.15
5.6.160.0070.04721.07
5.6.150.0030.07721.25
5.6.140.0070.08721.04
5.6.130.0100.08321.22
5.6.120.0070.08321.12
5.6.110.0170.07721.17
5.6.100.0100.04321.11
5.6.90.0130.04321.21
5.6.80.0130.04720.61
5.6.70.0030.08020.63
5.6.60.0130.05320.63
5.6.50.0130.05720.53
5.6.40.0100.06720.55
5.6.30.0200.06720.60
5.6.20.0000.04320.53
5.6.10.0300.04320.59
5.6.00.0230.06720.48
5.5.380.0030.08020.68
5.5.370.0170.07020.57
5.5.360.0070.06020.50
5.5.350.0100.06020.54
5.5.340.0070.08020.95
5.5.330.0070.07720.97
5.5.320.0030.08321.04
5.5.310.0030.05320.97
5.5.300.0030.04721.05
5.5.290.0070.04720.81
5.5.280.0030.04321.02
5.5.270.0100.07320.83
5.5.260.0200.07021.00
5.5.250.0100.07320.61
5.5.240.0130.04320.38
5.5.230.0130.03720.38
5.5.220.0000.08320.34
5.5.210.0000.05020.34
5.5.200.0030.08020.20
5.5.190.0030.08320.23
5.5.180.0030.08320.22
5.5.160.0070.07720.45
5.5.150.0130.07320.31
5.5.140.0130.07020.19
5.5.130.0100.07720.29
5.5.120.0100.06320.35
5.5.110.0000.06720.16
5.5.100.0100.05020.23
5.5.90.0070.04320.27
5.5.80.0100.07020.13
5.5.70.0130.07020.28
5.5.60.0130.05720.16
5.5.50.0030.07020.21
5.5.40.0100.04720.15
5.5.30.0030.04320.05
5.5.20.0100.06720.17
5.5.10.0170.05020.19
5.5.00.0100.03720.19
5.4.450.0030.06019.47
5.4.440.0130.03319.27
5.4.430.0030.07319.56
5.4.420.0100.05319.37
5.4.410.0000.04719.43
5.4.400.0130.07019.13
5.4.390.0030.07719.04
5.4.380.0000.08019.13
5.4.370.0130.07018.85
5.4.360.0170.03019.13
5.4.350.0170.06018.88
5.4.340.0130.06319.13
5.4.320.0130.05319.18
5.4.310.0100.07719.11
5.4.300.0030.07318.95
5.4.290.0070.06319.04
5.4.280.0100.08019.03
5.4.270.0070.07719.16
5.4.260.0070.07719.12
5.4.250.0170.06719.13
5.4.240.0170.07018.85
5.4.230.0070.07319.03
5.4.220.0030.06319.12
5.4.210.0070.04319.03
5.4.200.0130.05319.12
5.4.190.0030.04019.20
5.4.180.0070.06019.13
5.4.170.0100.06719.02
5.4.160.0030.07019.03
5.4.150.0100.07318.84
5.4.140.0130.06016.50
5.4.130.0030.05716.25
5.4.120.0130.05316.44
5.4.110.0130.06316.48
5.4.100.0100.07016.53
5.4.90.0000.05716.45
5.4.80.0130.06316.48
5.4.70.0030.06716.52
5.4.60.0100.04716.42
5.4.50.0030.04016.36
5.4.40.0030.06716.52
5.4.30.0070.07016.38
5.4.20.0030.05016.43
5.4.10.0030.04716.40
5.4.00.0070.06015.59
5.3.290.0070.07014.75
5.3.280.0070.04314.67
5.3.270.0100.03314.68
5.3.260.0070.05314.71
5.3.250.0100.06714.73
5.3.240.0170.06014.55
5.3.230.0030.08014.68
5.3.220.0000.04714.60
5.3.210.0070.06314.72
5.3.200.0100.04314.56
5.3.190.0130.04714.51
5.3.180.0230.02714.50
5.3.170.0100.06714.69
5.3.160.0030.04014.63
5.3.150.0100.06714.68
5.3.140.0030.04714.61
5.3.130.0000.05314.58
5.3.120.0030.08014.52
5.3.110.0100.06014.52
5.3.100.0070.06014.06
5.3.90.0070.07013.97
5.3.80.0030.06714.15
5.3.70.0030.07714.10
5.3.60.0070.06014.08
5.3.50.0030.07313.91
5.3.40.0030.05314.11
5.3.30.0030.07313.85
5.3.20.0070.06313.75
5.3.10.0070.04313.73
5.3.00.0130.02713.66
5.2.170.0000.06311.23
5.2.160.0100.02711.23
5.2.150.0000.03311.20
5.2.140.0030.06711.15
5.2.130.0000.04711.19
5.2.120.0130.05011.04
5.2.110.0070.06011.25
5.2.100.0100.05311.25
5.2.90.0000.05711.19
5.2.80.0000.03011.10
5.2.70.0030.06011.18
5.2.60.0030.05711.20
5.2.50.0000.04311.11
5.2.40.0030.05010.94
5.2.30.0030.02310.91
5.2.20.0000.04011.09
5.2.10.0030.03310.80
5.2.00.0030.06010.80
5.1.60.0000.02310.12
5.1.50.0030.04710.07
5.1.40.0000.0409.99
5.1.30.0030.02310.37
5.1.20.0000.03310.51
5.1.10.0030.0209.94
5.1.00.0000.02310.11
5.0.50.0000.0238.44
5.0.40.0000.0208.30
5.0.30.0000.0308.33
5.0.20.0000.0208.29
5.0.10.0000.0208.20
5.0.00.0000.0308.28
4.4.90.0030.0138.17
4.4.80.0000.0278.17
4.4.70.0030.0108.17
4.4.60.0000.0238.17
4.4.50.0000.0138.17
4.4.40.0000.0408.17
4.4.30.0000.0208.17
4.4.20.0000.0178.17
4.4.10.0000.0178.17
4.4.00.0030.0238.17
4.3.110.0000.0178.17
4.3.100.0000.0178.17
4.3.90.0030.0138.17
4.3.80.0030.0238.17
4.3.70.0030.0208.17
4.3.60.0000.0138.17
4.3.50.0030.0108.17
4.3.40.0030.0178.17
4.3.30.0000.0178.17
4.3.20.0000.0138.17
4.3.10.0000.0178.17
4.3.00.0000.0138.17

preferences:
41.25 ms | 401 KiB | 5 Q