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_int32("\xFF\xFF\xFF\xFE")); printf("%f\n", unpack_int32("\xFF\xFF\xFF\xFE", INT_SIGNED)); printf("%f\n", unpack_int32("\xFF\xFF\xFF\xFE", INT_LE)); printf("%f\n", unpack_int32("\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.60.0070.01116.75
8.3.50.0100.00816.37
8.3.40.0060.01318.64
8.3.30.0110.00418.68
8.3.20.0030.00618.82
8.3.10.0000.00918.60
8.3.00.0040.00419.38
8.2.180.0090.01216.32
8.2.170.0090.00622.96
8.2.160.0130.00318.97
8.2.150.0030.00624.18
8.2.140.0080.00024.66
8.2.130.0050.00326.16
8.2.120.0000.00820.84
8.2.110.0070.00322.13
8.2.100.0090.00317.91
8.2.90.0040.00417.75
8.2.80.0080.00018.96
8.2.70.0050.00317.59
8.2.60.0080.00017.63
8.2.50.0000.00818.16
8.2.40.0000.00920.07
8.2.30.0030.00617.91
8.2.20.0070.00317.61
8.2.10.0060.00317.91
8.2.00.0110.00017.86
8.1.280.0070.01425.92
8.1.270.0040.00423.99
8.1.260.0030.00626.35
8.1.250.0040.00428.09
8.1.240.0030.00623.97
8.1.230.0030.00920.88
8.1.220.0040.00418.63
8.1.210.0090.00018.77
8.1.200.0040.00417.35
8.1.190.0030.00517.25
8.1.180.0050.00318.10
8.1.170.0000.00817.62
8.1.160.0040.00419.13
8.1.150.0040.00418.79
8.1.140.0050.00317.42
8.1.130.0000.00717.57
8.1.120.0000.00817.49
8.1.110.0000.00717.55
8.1.100.0040.00417.51
8.1.90.0000.00817.52
8.1.80.0000.00717.52
8.1.70.0030.00317.48
8.1.60.0000.00717.66
8.1.50.0030.00517.56
8.1.40.0030.00617.62
8.1.30.0040.00417.64
8.1.20.0100.00017.58
8.1.10.0000.00717.49
8.1.00.0000.00817.47
8.0.300.0030.00618.77
8.0.290.0060.00316.75
8.0.280.0000.00718.68
8.0.270.0050.00217.19
8.0.260.0030.00316.79
8.0.250.0040.00416.90
8.0.240.0080.00017.01
8.0.230.0000.00716.93
8.0.220.0030.00317.02
8.0.210.0030.00516.86
8.0.200.0000.00717.05
8.0.190.0050.00316.96
8.0.180.0090.00317.00
8.0.170.0070.00316.93
8.0.160.0040.00417.03
8.0.150.0000.00916.95
8.0.140.0070.00716.81
8.0.130.0000.00613.36
8.0.120.0060.00316.84
8.0.110.0000.00717.01
8.0.100.0040.00416.83
8.0.90.0000.00716.95
8.0.80.0040.01117.00
8.0.70.0090.00017.02
8.0.60.0040.00416.75
8.0.50.0050.00316.91
8.0.30.0130.00416.95
8.0.20.0080.01217.26
8.0.10.0040.00417.14
8.0.00.0100.01016.85
7.4.330.0000.00613.00
7.4.320.0030.00316.58
7.4.300.0000.00616.68
7.4.290.0070.00016.57
7.4.280.0000.00716.55
7.4.270.0030.00316.59
7.4.260.0000.00613.36
7.4.250.0030.00716.57
7.4.240.0080.00016.64
7.4.230.0070.00016.64
7.4.220.0120.00616.63
7.4.210.0000.02116.57
7.4.200.0000.00816.40
7.4.190.0040.00416.54
7.4.160.0060.00916.69
7.4.150.0200.00016.45
7.4.140.0090.00916.50
7.4.130.0140.01116.48
7.4.120.0130.00316.53
7.4.110.0040.01216.48
7.4.100.0070.01116.70
7.4.90.0120.00616.57
7.4.80.0120.01219.39
7.4.70.0120.00616.53
7.4.60.0100.00716.64
7.4.50.0040.00416.23
7.4.40.0000.01616.38
7.4.30.0100.00716.70
7.4.00.0100.00814.97
7.3.330.0030.00313.37
7.3.320.0040.00413.36
7.3.310.0040.00416.37
7.3.300.0000.00616.34
7.3.290.0070.00816.44
7.3.280.0080.00816.42
7.3.270.0130.00416.32
7.3.260.0110.00616.50
7.3.250.0120.01016.52
7.3.240.0130.01016.77
7.3.230.0080.00816.44
7.3.210.0120.00416.67
7.3.200.0060.00916.56
7.3.190.0030.01916.30
7.3.180.0080.00816.34
7.3.170.0110.00516.54
7.3.160.0080.01316.45
7.3.120.0080.00714.93
7.3.110.0140.00015.11
7.3.100.0080.00414.79
7.3.90.0060.00915.14
7.3.80.0060.00814.62
7.3.70.0070.00315.01
7.3.60.0040.00814.83
7.3.50.0000.01214.83
7.3.40.0070.00414.81
7.3.30.0070.00414.64
7.3.20.0040.01116.67
7.3.10.0030.00616.42
7.3.00.0060.00616.61
7.2.330.0120.00616.94
7.2.320.0070.01016.91
7.2.310.0120.00916.83
7.2.300.0060.01316.70
7.2.290.0030.01516.84
7.2.250.0030.01815.09
7.2.240.0120.00614.99
7.2.230.0030.01315.30
7.2.220.0060.00915.14
7.2.210.0090.00614.72
7.2.200.0060.00615.17
7.2.190.0040.01115.18
7.2.180.0040.01115.01
7.2.170.0070.00715.18
7.2.00.0070.00719.55
7.1.330.0000.01615.71
7.1.320.0000.01416.04
7.1.310.0000.01315.95
7.1.300.0030.01015.67
7.1.290.0040.01115.91
7.1.280.0040.00715.99
7.1.270.0080.00415.84
7.1.260.0060.00615.83
7.1.100.0080.00018.33
7.1.70.0000.01117.25
7.1.60.0100.01419.30
7.1.50.0100.01016.89
7.1.00.0070.07322.54
7.0.200.0050.00516.85
7.0.140.0130.06322.12
7.0.120.0000.04022.25
7.0.60.0000.09720.04
7.0.50.0130.05317.91
7.0.40.0100.10020.15
7.0.30.0230.08320.09
7.0.20.0230.08320.10
7.0.10.0170.07720.16
7.0.00.0070.06320.16
5.6.280.0000.07720.93
5.6.210.0030.09020.50
5.6.200.0170.07318.20
5.6.190.0200.07320.40
5.6.180.0230.07020.47
5.6.170.0270.05020.51
5.6.160.0000.04720.47
5.6.150.0030.08318.25
5.6.140.0100.08018.28
5.6.130.0070.07718.18
5.6.120.0130.08321.14
5.6.110.0070.03721.04
5.6.100.0070.08321.00
5.6.90.0070.08021.12
5.6.80.0070.08320.43
5.6.70.3370.03320.46
5.5.350.0300.07720.44
5.5.340.0100.07718.02
5.5.330.0070.04320.21
5.5.320.0230.06720.31
5.5.310.0270.06020.30
5.5.300.0030.05717.96
5.5.290.0100.06318.07
5.5.280.0100.05320.68
5.5.270.0170.07320.83
5.5.260.0100.04020.75
5.5.250.0000.05020.81
5.5.240.0270.07320.21
5.4.450.0070.07719.41
5.4.440.0100.06719.48
5.4.430.0170.07319.24
5.4.420.0070.04719.53
5.4.410.0070.03719.05
5.4.400.0030.05019.25
5.4.390.0000.08319.07
5.4.380.0070.04018.82
5.4.370.0000.04319.24
5.4.360.0070.08719.28
5.4.350.0100.07019.24
5.4.340.0030.08319.20
5.4.320.0130.06319.16
5.4.310.0030.07719.15
5.4.300.0070.08019.14
5.4.290.0100.05719.14
5.4.280.0000.07719.07
5.4.270.0030.05718.92
5.4.260.0100.07318.85
5.4.250.0100.07019.14
5.4.240.0070.07318.86
5.4.230.0030.04719.01
5.4.220.0100.04719.31
5.4.210.0200.03319.14
5.4.200.0100.06018.87
5.4.190.0200.06018.84
5.4.180.0030.03718.91
5.4.170.0030.05018.86
5.4.160.0130.06719.07
5.4.150.0100.04719.18
5.4.140.0130.04316.35
5.4.130.0030.08016.30
5.4.120.0100.06716.42
5.4.110.0070.05716.50
5.4.100.0100.06316.33
5.4.90.0100.06016.50
5.4.80.0070.04716.51
5.4.70.0100.05716.72
5.4.60.0030.04316.28
5.4.50.0030.07716.38
5.4.40.0100.07316.28
5.4.30.0000.06716.36
5.4.20.0170.06316.37
5.4.10.0070.04016.37
5.4.00.0000.04315.89
5.3.290.0030.08714.86
5.3.280.0000.05014.63
5.3.270.0100.07314.71
5.3.260.0070.04714.53
5.3.250.0070.04714.56
5.3.240.0030.07714.70
5.3.230.0030.07314.69
5.3.220.0030.08014.60
5.3.210.0030.08014.64
5.3.200.0000.04314.61
5.3.190.0070.08014.62
5.3.180.0100.05014.67
5.3.170.0100.06314.67
5.3.160.0000.06014.77
5.3.150.0000.04314.61
5.3.140.0030.05314.75
5.3.130.0100.06714.64
5.3.120.0070.06714.61
5.3.110.0030.07014.59
5.3.100.0070.03714.14
5.3.90.0100.03014.11
5.3.80.0070.07314.07
5.3.70.0100.04013.94
5.3.60.0030.04013.96
5.3.50.0030.03714.06
5.3.40.0000.04014.02
5.3.30.0000.04014.02
5.3.20.0030.03713.81
5.3.10.0030.03713.73
5.3.00.0000.03713.83
5.2.170.0000.03311.11
5.2.160.0030.03011.11
5.2.150.0070.03311.15
5.2.140.0000.03011.24
5.2.130.0000.03711.20
5.2.120.0000.03011.11
5.2.110.0070.02311.20
5.2.100.0000.03711.14
5.2.90.0070.02311.30
5.2.80.0000.03011.14
5.2.70.0030.03311.21
5.2.60.0030.03311.15
5.2.50.0100.02311.00
5.2.40.0030.02711.04
5.2.30.0030.03310.95
5.2.20.0070.02711.02
5.2.10.0070.02310.81
5.2.00.0000.03310.72
5.1.60.0000.0239.94
5.1.50.0000.02710.18
5.1.40.0000.02310.08
5.1.30.0030.03010.38
5.1.20.0030.02310.47
5.1.10.0030.02310.11
5.1.00.0070.02010.27
5.0.50.0000.0208.61
5.0.40.0070.0138.58
5.0.30.0000.0308.36
5.0.20.0000.0208.26
5.0.10.0030.0178.29
5.0.00.0030.0278.36
4.4.90.0000.0177.77
4.4.80.0000.0177.77
4.4.70.0000.0177.77
4.4.60.0000.0177.77
4.4.50.0030.0137.77
4.4.40.0030.0237.77
4.4.30.0000.0177.77
4.4.20.0030.0137.77
4.4.10.0000.0177.77
4.4.00.0000.0237.77
4.3.110.0000.0177.77
4.3.100.0030.0137.77
4.3.90.0000.0137.77
4.3.80.0030.0237.77
4.3.70.0030.0107.77
4.3.60.0000.0137.77
4.3.50.0070.0107.77
4.3.40.0000.0237.77
4.3.30.0030.0137.77
4.3.20.0000.0177.77
4.3.10.0000.0177.77
4.3.00.0000.0177.77

preferences:
56.39 ms | 401 KiB | 5 Q