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; } 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.60.0170.00318.43
8.3.50.0150.00521.98
8.3.40.0040.01118.80
8.3.30.0070.00718.84
8.3.20.0090.00018.65
8.3.10.0060.00320.66
8.3.00.0090.00023.59
8.2.180.0040.01116.75
8.2.170.0150.00022.96
8.2.160.0030.01020.38
8.2.150.0040.00424.18
8.2.140.0070.00324.66
8.2.130.0030.00526.16
8.2.120.0080.00019.36
8.2.110.0100.00020.47
8.2.100.0090.00317.91
8.2.90.0040.00419.17
8.2.80.0000.00817.97
8.2.70.0000.00817.63
8.2.60.0000.00817.93
8.2.50.0040.00818.16
8.2.40.0040.00418.34
8.2.30.0080.00318.13
8.2.20.0080.00017.79
8.2.10.0000.00817.85
8.2.00.0060.00317.92
8.1.280.0110.00425.92
8.1.270.0050.00223.99
8.1.260.0060.00326.35
8.1.250.0080.00028.09
8.1.240.0110.00022.42
8.1.230.0030.00920.87
8.1.220.0030.00618.77
8.1.210.0000.00818.84
8.1.200.0040.00817.35
8.1.190.0000.00917.39
8.1.180.0040.00418.10
8.1.170.0080.00018.96
8.1.160.0070.00018.93
8.1.150.0040.00418.64
8.1.140.0000.00717.52
8.1.130.0030.00317.78
8.1.120.0040.00417.52
8.1.110.0050.00317.52
8.1.100.0000.00717.32
8.1.90.0040.00417.53
8.1.80.0000.00717.36
8.1.70.0050.00217.34
8.1.60.0040.00417.60
8.1.50.0060.00317.47
8.1.40.0000.00817.44
8.1.30.0000.00817.64
8.1.20.0060.00317.73
8.1.10.0060.00317.48
8.1.00.0030.00617.47
8.0.300.0040.00419.99
8.0.290.0000.00717.30
8.0.280.0040.00418.49
8.0.270.0000.00717.29
8.0.260.0070.00016.91
8.0.250.0040.00417.06
8.0.240.0110.00016.90
8.0.230.0000.00717.05
8.0.220.0030.00316.96
8.0.210.0040.00416.92
8.0.200.0000.00716.98
8.0.190.0000.00716.95
8.0.180.0050.00216.96
8.0.170.0030.00616.89
8.0.160.0060.00316.92
8.0.150.0040.00416.92
8.0.140.0120.00016.91
8.0.130.0030.00313.35
8.0.120.0090.00016.93
8.0.110.0000.00716.80
8.0.100.0080.00016.78
8.0.90.0000.00816.80
8.0.80.0090.00616.91
8.0.70.0040.00416.99
8.0.60.0050.00316.76
8.0.50.0000.00717.00
8.0.30.0130.00717.20
8.0.20.0140.00917.40
8.0.10.0050.00316.84
8.0.00.0090.01016.77
7.4.330.0000.00713.43
7.4.320.0030.00316.47
7.4.300.0000.00616.59
7.4.290.0040.00416.63
7.4.280.0050.00316.66
7.4.270.0070.00016.54
7.4.260.0060.00013.26
7.4.250.0030.00616.68
7.4.240.0000.00816.56
7.4.230.0000.00716.61
7.4.220.0120.00616.50
7.4.210.0090.00816.53
7.4.200.0000.00716.57
7.4.190.0000.00716.61
7.4.160.0070.01016.35
7.4.150.0080.01217.40
7.4.140.0120.00617.86
7.4.130.0090.00816.62
7.4.120.0100.00816.42
7.4.110.0070.01716.53
7.4.100.0120.00616.63
7.4.90.0070.01016.68
7.4.80.0080.00919.04
7.4.70.0130.01016.57
7.4.60.0120.00916.60
7.4.50.0070.00016.46
7.4.40.0090.00622.27
7.4.30.0170.00316.49
7.4.00.0050.01314.85
7.3.330.0000.00513.19
7.3.320.0000.00713.34
7.3.310.0040.00416.25
7.3.300.0040.00416.27
7.3.290.0070.00716.45
7.3.280.0080.00716.43
7.3.270.0050.01417.40
7.3.260.0100.00818.24
7.3.250.0080.01016.57
7.3.240.0100.00716.48
7.3.230.0080.00816.57
7.3.210.0070.01016.70
7.3.200.0120.00419.39
7.3.190.0060.01216.61
7.3.180.0100.00716.43
7.3.170.0060.01216.31
7.3.160.0110.00616.47
7.3.120.0070.01114.85
7.3.110.0080.00914.97
7.3.100.0040.01114.85
7.3.90.0080.01014.77
7.3.80.0070.00514.73
7.3.70.0070.00814.88
7.3.60.0100.00514.83
7.3.50.0060.00914.84
7.3.40.0060.00514.95
7.3.30.0030.01115.00
7.3.20.0080.00416.73
7.3.10.0060.00816.70
7.3.00.0040.00916.81
7.2.330.0140.00316.57
7.2.320.0070.01116.46
7.2.310.0100.01016.71
7.2.300.0070.01016.66
7.2.290.0130.00316.46
7.2.250.0060.01214.99
7.2.240.0090.01015.12
7.2.230.0080.00815.20
7.2.220.0030.01215.37
7.2.210.0050.01214.88
7.2.200.0070.00914.91
7.2.190.0090.00515.01
7.2.180.0040.01015.05
7.2.170.0050.00914.99
7.2.00.0000.01119.18
7.1.330.0100.00415.89
7.1.320.0070.00615.73
7.1.310.0100.00315.95
7.1.300.0070.00715.81
7.1.290.0060.00615.73
7.1.280.0050.01115.87
7.1.270.0090.00915.79
7.1.260.0070.00715.81
7.1.100.0000.01418.23
7.1.70.0050.00217.29
7.1.60.0070.01719.40
7.1.50.0060.01616.93
7.1.00.0070.06722.45
7.0.200.0050.00316.70
7.0.140.0030.07322.00
7.0.60.0070.08319.99
7.0.50.0000.05017.91
7.0.40.0100.04720.18
7.0.30.0270.07720.12
7.0.20.0300.07720.22
7.0.10.0200.04720.12
7.0.00.0100.06720.27
5.6.280.0030.07320.91
5.6.210.0100.07320.63
5.6.200.0100.07718.19
5.6.190.0130.05320.46
5.6.180.0300.07720.46
5.6.170.0400.04320.50
5.6.160.0170.08020.46
5.6.150.0100.06318.17
5.6.140.0130.07718.19
5.6.130.0030.04718.11
5.6.120.0030.09321.10
5.6.110.0100.04721.02
5.6.100.0000.09020.91
5.6.90.0030.04021.02
5.6.80.0100.06320.46
5.5.350.3730.04020.48
5.5.340.0070.07717.96
5.5.330.0070.05020.29
5.5.320.0170.07320.38
5.5.310.0330.07320.19
5.5.300.0030.08318.04
5.5.290.0100.08018.09
5.5.280.0030.05020.79
5.5.270.0030.05020.81
5.5.260.0200.06320.89
5.5.250.0170.07020.82
5.5.240.0030.08720.16
5.4.450.2600.04319.47
5.4.440.2970.05719.46
5.4.430.2670.04019.49
5.4.420.2600.04719.52
5.4.410.2830.04019.43
5.4.400.2870.04019.23
5.4.390.2930.04319.09
5.4.380.2800.03719.22
5.4.370.2630.04319.14
5.4.360.3000.05319.31
5.4.350.2570.03718.88
5.4.340.3200.05019.15
5.4.320.2500.04319.07
5.4.310.2700.04019.09
5.4.300.3130.04719.22
5.4.290.2830.03718.84
5.4.280.2700.02719.06
5.4.270.2600.03019.04
5.4.260.0130.03719.23
5.4.250.0070.03318.84
5.4.240.0700.05019.21
5.4.230.2630.03319.19
5.4.220.2570.04018.83
5.4.210.2670.03319.24
5.4.200.2970.03719.16
5.4.190.2470.04719.17
5.4.180.2970.04019.05
5.4.170.3100.04319.17
5.4.160.3230.04319.07
5.4.150.2900.04319.07
5.4.140.3100.04316.51
5.4.130.2630.03716.36
5.4.120.2800.03716.55
5.4.110.2530.04016.50
5.4.100.2670.02716.50
5.4.90.2800.04316.32
5.4.80.2600.03316.48
5.4.70.3030.04016.59
5.4.60.2830.03316.38
5.4.50.2530.03316.51
5.4.40.2830.03316.54
5.4.30.2730.03316.52
5.4.20.2370.03016.32
5.4.10.2730.04316.51
5.4.00.2730.04315.80
5.3.290.2700.04714.80
5.3.280.2730.04014.53
5.3.270.2800.04014.54
5.3.260.2670.03714.86
5.3.250.2800.04014.55
5.3.240.2770.04014.68
5.3.230.2430.04314.77
5.3.220.3000.03714.68
5.3.210.2770.04314.50
5.3.200.2700.03314.64
5.3.190.2770.04014.82
5.3.180.3030.04014.74
5.3.170.2500.04014.82
5.3.160.2930.04314.61
5.3.150.2970.03314.74
5.3.140.2470.04014.56
5.3.130.2770.04014.69
5.3.120.2470.04714.59
5.3.110.2570.03314.72
5.3.100.2530.03714.29
5.3.90.2800.03313.95
5.3.80.3100.04013.97
5.3.70.3000.04014.06
5.3.60.2700.04313.95
5.3.50.2700.03014.03
5.3.40.2570.03713.88
5.3.30.2630.04013.94
5.3.20.2800.03313.64
5.3.10.2630.03013.65
5.3.00.2670.02713.68
5.2.170.2200.02711.25
5.2.160.2200.02711.23
5.2.150.2730.03711.13
5.2.140.2270.03711.23
5.2.130.2070.02711.08
5.2.120.2000.03011.30
5.2.110.1800.02711.04
5.2.100.2370.02711.14
5.2.90.0570.02711.14
5.2.80.0070.06011.22
5.2.70.0030.05311.08
5.2.60.0030.03311.13
5.2.50.1030.04011.27
5.2.40.1970.03011.00
5.2.30.1830.03011.08
5.2.20.1700.03311.13
5.2.10.1970.03310.89
5.2.00.2000.02710.76
5.1.60.1670.02310.15
5.1.50.1730.02010.15
5.1.40.1870.01710.16
5.1.30.2000.02710.34
5.1.20.1930.03010.35
5.1.10.2000.02710.06
5.1.00.1530.02710.23
5.0.50.0330.0208.66
5.0.40.0530.0178.43
5.0.30.0870.0378.25
5.0.20.0630.0208.28
5.0.10.0870.0178.34
5.0.00.0870.0308.37
4.4.90.0600.0137.35
4.4.80.0870.0137.35
4.4.70.0830.0207.35
4.4.60.0800.0177.35
4.4.50.0700.0177.35
4.4.40.0570.0237.35
4.4.30.0770.0177.35
4.4.20.1000.0237.35
4.4.10.0870.0177.35
4.4.00.0870.0207.35
4.3.110.0970.0137.35
4.3.100.1000.0177.35
4.3.90.0770.0237.35
4.3.80.1000.0307.35
4.3.70.0970.0177.35
4.3.60.0730.0207.35
4.3.50.1000.0207.35
4.3.40.1000.0307.35
4.3.30.0230.0177.35
4.3.20.0530.0177.35
4.3.10.0270.0177.35
4.3.00.0430.0137.35

preferences:
45.46 ms | 401 KiB | 5 Q