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\xFC")); printf("%f\n", unpack_int32("\xFF\xFF\xFF\xFC", INT_SIGNED)); printf("%f\n", unpack_int32("\xFF\xFF\xFF\xFC", INT_LE)); printf("%f\n", unpack_int32("\xFF\xFF\xFF\xFC", INT_LE | INT_SIGNED)); echo "int64:\n"; printf("%f\n", unpack_int64("\xFF\xFF\xFF\xFC\x00\x00\x00\x00")); printf("%f\n", unpack_int64("\xFF\xFF\xFF\xFC\x00\x00\x00\x00", INT_SIGNED)); printf("%f\n", unpack_int64("\xFF\xFF\xFF\xFC\x00\x00\x00\x00", INT_LE)); printf("%f\n", unpack_int64("\xFF\xFF\xFF\xFC\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.0040.01116.50
8.3.50.0270.00516.50
8.3.40.0070.01020.39
8.3.30.0140.00018.70
8.3.20.0080.00018.79
8.3.10.0040.00418.90
8.3.00.0080.00417.75
8.2.180.0110.00416.71
8.2.170.0100.01022.96
8.2.160.0120.00318.86
8.2.150.0030.00624.18
8.2.140.0030.00524.66
8.2.130.0030.00626.16
8.2.120.0040.00420.75
8.2.110.0070.00722.07
8.2.100.0080.00417.91
8.2.90.0030.00618.03
8.2.80.0080.00018.16
8.2.70.0090.00017.50
8.2.60.0060.00317.93
8.2.50.0050.00318.10
8.2.40.0050.00318.28
8.2.30.0040.00417.68
8.2.20.0110.00017.67
8.2.10.0050.00317.73
8.2.00.0030.00617.79
8.1.280.0120.00925.92
8.1.270.0040.00423.99
8.1.260.0070.00726.35
8.1.250.0030.00528.09
8.1.240.0000.00922.59
8.1.230.0140.00020.90
8.1.220.0080.00017.78
8.1.210.0040.00418.89
8.1.200.0040.00417.35
8.1.190.0080.00017.35
8.1.180.0040.00418.10
8.1.170.0080.00018.70
8.1.160.0040.00419.07
8.1.150.0040.00418.57
8.1.140.0040.00417.50
8.1.130.0070.00017.89
8.1.120.0000.00717.52
8.1.110.0000.00817.50
8.1.100.0000.00717.42
8.1.90.0030.00617.50
8.1.80.0050.00317.39
8.1.70.0000.00717.41
8.1.60.0040.00917.65
8.1.50.0000.00817.53
8.1.40.0040.00417.54
8.1.30.0030.00517.54
8.1.20.0070.00417.63
8.1.10.0040.00417.51
8.1.00.0050.00517.56
8.0.300.0000.00720.16
8.0.290.0040.00416.88
8.0.280.0040.00418.38
8.0.270.0000.00817.19
8.0.260.0040.00416.80
8.0.250.0000.00817.00
8.0.240.0040.00417.04
8.0.230.0000.00717.08
8.0.220.0000.00716.80
8.0.210.0000.00716.95
8.0.200.0030.00317.01
8.0.190.0070.00416.98
8.0.180.0070.00017.02
8.0.170.0030.00516.94
8.0.160.0040.00416.94
8.0.150.0000.01016.81
8.0.140.0050.00316.95
8.0.130.0050.00013.42
8.0.120.0030.00616.89
8.0.110.0040.00416.96
8.0.100.0070.00016.91
8.0.90.0070.00016.84
8.0.80.0060.00916.83
8.0.70.0050.00317.02
8.0.60.0030.00516.96
8.0.50.0000.00817.01
8.0.30.0140.00317.04
8.0.20.0110.00817.03
8.0.10.0030.00516.86
8.0.00.0100.01316.64
7.4.330.0050.00013.01
7.4.320.0030.00316.63
7.4.300.0030.00316.64
7.4.290.0030.00316.57
7.4.280.0020.00516.58
7.4.270.0000.00716.56
7.4.260.0030.00313.34
7.4.250.0030.00616.50
7.4.240.0000.00816.55
7.4.230.0000.00716.77
7.4.220.0100.01016.75
7.4.210.0070.01016.71
7.4.200.0050.00316.69
7.4.190.0000.00716.56
7.4.160.0040.01316.40
7.4.150.0150.00416.59
7.4.140.0120.01216.60
7.4.130.0140.00316.50
7.4.120.0130.00316.46
7.4.110.0090.01216.50
7.4.100.0120.00616.57
7.4.90.0120.00616.54
7.4.80.0030.01419.39
7.4.70.0030.01416.47
7.4.60.0120.00616.59
7.4.50.0090.00316.35
7.4.40.0090.00616.70
7.4.30.0110.00816.44
7.4.00.0080.00814.65
7.3.330.0030.00313.35
7.3.320.0000.00613.19
7.3.310.0080.00016.50
7.3.300.0030.00316.41
7.3.290.0090.00916.45
7.3.280.0030.01416.35
7.3.270.0090.00916.48
7.3.260.0080.01116.61
7.3.250.0120.00716.48
7.3.240.0120.00916.68
7.3.230.0080.01016.47
7.3.210.0040.01316.57
7.3.200.0100.00716.45
7.3.190.0170.00616.69
7.3.180.0130.00416.44
7.3.170.0160.00316.70
7.3.160.0070.01016.48
7.3.120.0070.01114.89
7.3.110.0150.00415.00
7.3.100.0030.01214.53
7.3.90.0000.01014.54
7.3.80.0090.00014.96
7.3.70.0030.01014.96
7.3.60.0000.01114.69
7.3.50.0080.00614.69
7.3.40.0060.01014.60
7.3.30.0030.00614.95
7.3.20.0000.00916.63
7.3.10.0140.00016.47
7.3.00.0050.00716.47
7.2.330.0030.01516.51
7.2.320.0140.00416.89
7.2.310.0090.01416.40
7.2.300.0080.00816.76
7.2.290.0090.00816.84
7.2.250.0100.01015.13
7.2.240.0100.01014.93
7.2.230.0040.01115.22
7.2.220.0060.00615.02
7.2.210.0060.00315.02
7.2.200.0060.00914.78
7.2.190.0060.00614.81
7.2.180.0090.00014.90
7.2.170.0080.00414.96
7.2.130.0060.00616.81
7.2.120.0030.01016.81
7.2.110.0070.01116.84
7.2.100.0000.01416.92
7.2.90.0050.00516.94
7.2.80.0100.00716.70
7.2.70.0060.01016.68
7.2.60.0050.01116.88
7.2.50.0130.00516.93
7.2.40.0100.00316.85
7.2.30.0040.01116.88
7.2.20.0070.00717.05
7.2.10.0090.00916.74
7.2.00.0040.01116.84
7.1.330.0070.00715.76
7.1.320.0030.00815.69
7.1.310.0060.00315.91
7.1.300.0000.01615.90
7.1.290.0030.00915.67
7.1.280.0000.01315.76
7.1.270.0000.01015.69
7.1.260.0070.00415.61
7.1.250.0150.00415.77
7.1.240.0060.00615.60
7.1.230.0120.00615.99
7.1.220.0100.00615.43
7.1.210.0120.00315.79
7.1.200.0060.00815.80
7.1.190.0030.00915.66
7.1.180.0000.01315.84
7.1.170.0080.00315.88
7.1.160.0000.01115.89
7.1.150.0040.00715.66
7.1.140.0130.00315.93
7.1.130.0120.00315.82
7.1.120.0000.01215.86
7.1.110.0040.00415.85
7.1.100.0030.01015.98
7.1.90.0100.00715.52
7.1.80.0040.00815.62
7.1.70.0060.00516.39
7.1.60.0060.01117.58
7.1.50.0090.01016.38
7.1.40.0030.01015.79
7.1.30.0050.00515.71
7.1.20.0030.01015.54
7.1.10.0000.01315.64
7.1.00.0000.04319.16
7.0.330.0090.00315.16
7.0.320.0150.00315.23
7.0.310.0060.01015.21
7.0.300.0090.00615.39
7.0.290.0020.01015.54
7.0.280.0000.01115.45
7.0.270.0070.00715.15
7.0.260.0060.00315.21
7.0.250.0000.01315.13
7.0.240.0090.00315.38
7.0.230.0000.01215.53
7.0.220.0060.00915.00
7.0.210.0000.01315.39
7.0.200.0070.00516.09
7.0.190.0160.00015.32
7.0.180.0040.00715.09
7.0.170.0090.00915.44
7.0.160.0080.00815.36
7.0.150.0030.01015.05
7.0.140.0050.03818.77
7.0.130.0120.00015.64
7.0.120.0090.03218.78
7.0.110.0090.00315.25
7.0.100.0050.00515.36
7.0.90.0000.01515.47
7.0.80.0080.00615.25
7.0.70.0070.01115.48
7.0.60.0060.04517.57
7.0.50.0060.04816.80
7.0.40.0030.02916.76
7.0.30.0240.03716.81
7.0.20.0190.04216.84
7.0.10.0080.04216.82
7.0.00.0080.04516.78
5.6.380.0090.00314.34
5.6.370.0030.01214.56
5.6.360.0040.00814.20
5.6.350.0030.00914.46
5.6.340.0090.00613.96
5.6.330.0000.01414.23
5.6.320.0030.01014.49
5.6.310.0110.00014.14
5.6.300.0030.01314.70
5.6.290.0030.00714.20
5.6.280.0070.03717.70
5.6.270.0090.00914.16
5.6.260.0000.01314.38
5.6.250.0000.01214.04
5.6.240.0100.00314.20
5.6.230.0050.01014.31
5.6.220.0040.01314.09
5.6.210.0050.04717.52
5.6.200.0090.04116.26
5.6.190.0050.03717.38
5.6.180.0190.03617.48
5.6.170.0110.02517.56
5.6.160.0110.03617.43
5.6.150.0120.04016.20
5.6.140.0130.02216.27
5.6.130.0060.02516.10
5.6.120.0070.04517.77
5.6.110.0120.03817.68
5.6.100.0050.03517.77
5.6.90.0100.02317.72
5.6.80.0080.03217.35
5.6.70.0000.01714.19
5.6.60.0030.01213.99
5.6.50.0040.01213.85
5.6.40.0100.00314.16
5.6.30.0040.01114.14
5.6.20.0060.00614.35
5.6.10.0130.00314.31
5.6.00.0110.00313.88
5.5.380.0050.00511.20
5.5.370.0030.00311.23
5.5.360.0030.00911.18
5.5.350.0170.02015.83
5.5.340.0120.03214.62
5.5.330.0050.03515.79
5.5.320.0100.03815.68
5.5.310.0160.01815.77
5.5.300.0080.03014.57
5.5.290.0000.02914.56
5.5.280.0040.02316.08
5.5.270.0000.04815.92
5.5.260.0130.02015.98
5.5.250.0070.03315.88
5.5.240.0030.04115.73
5.5.230.0030.00511.28
5.5.220.0040.00811.21
5.5.210.0040.00811.21
5.5.200.0000.01211.18
5.5.190.0060.00011.18
5.5.180.0050.00511.18
5.5.170.0060.00611.18
5.5.160.0040.00811.18
5.5.150.0080.00511.18
5.5.140.0000.01411.26
5.5.130.0120.00011.44
5.5.120.0030.00911.18
5.5.110.0080.00411.18
5.5.100.0040.00911.18
5.5.90.0030.00911.18
5.5.80.0080.00411.18
5.5.70.0060.00611.25
5.5.60.0030.00511.18
5.5.50.0000.01211.27
5.5.40.0030.00611.18
5.5.30.0060.00311.18
5.5.20.0000.01111.18
5.5.10.0060.00311.28
5.5.00.0000.01111.18
5.4.450.0030.03115.38
5.4.440.0030.02715.38
5.4.430.0050.02215.29
5.4.420.0080.02215.37
5.4.410.0060.02815.18
5.4.400.0030.03715.18
5.4.390.0050.03615.16
5.4.380.0120.03515.21
5.4.370.0000.02715.13
5.4.360.0090.04115.19
5.4.350.0040.02515.21
5.4.340.0070.04315.01
5.4.330.0030.00611.18
5.4.320.0150.03215.13
5.4.310.0080.03015.11
5.4.300.0070.04115.03
5.4.290.0100.02215.21
5.4.280.0080.02515.16
5.4.270.0080.04015.10
5.4.260.0080.02515.05
5.4.250.0050.03915.01
5.4.240.0070.04015.12
5.4.230.0060.03015.16
5.4.220.0050.03815.16
5.4.210.0070.02015.13
5.4.200.0050.04015.05
5.4.190.0060.03515.06
5.4.180.0060.02215.15
5.4.170.0050.02315.04
5.4.160.0070.02315.15
5.4.150.0000.02515.16
5.4.140.0110.02313.78
5.4.130.0060.03813.82
5.4.120.0020.04113.80
5.4.110.0080.03813.81
5.4.100.0030.02313.82
5.4.90.0060.03613.81
5.4.80.0080.03813.74
5.4.70.0050.01813.94
5.4.60.0050.01913.74
5.4.50.0030.02113.79
5.4.40.0050.02013.79
5.4.30.0050.01913.96
5.4.20.0080.02113.78
5.4.10.0020.02313.78
5.4.00.0040.02213.54
5.3.290.0050.04313.01
5.3.280.0080.02012.93
5.3.270.0070.02012.91
5.3.260.0000.02412.95
5.3.250.0020.02412.89
5.3.240.0050.02212.93
5.3.230.0080.03312.91
5.3.220.0040.04312.83
5.3.210.0090.02512.90
5.3.200.0110.02012.90
5.3.190.0030.04012.89
5.3.180.0010.02412.89
5.3.170.0030.02612.96
5.3.160.0040.02112.89
5.3.150.0050.02212.92
5.3.140.0000.02612.89
5.3.130.0030.02312.84
5.3.120.0050.01812.88
5.3.110.0030.02012.96
5.3.100.0020.02412.58
5.3.90.0070.02012.65
5.3.80.0060.01812.64
5.3.70.0020.02212.62
5.3.60.0030.02012.61
5.3.50.0030.02012.56
5.3.40.0010.02312.61
5.3.30.0000.02312.53
5.3.20.0030.02012.40
5.3.10.0020.02312.44
5.3.00.0020.02012.44
5.2.170.0020.01611.26
5.2.160.0030.01711.26
5.2.150.0020.01811.20
5.2.140.0030.01511.14
5.2.130.0020.01911.24
5.2.120.0020.01611.14
5.2.110.0020.01911.21
5.2.100.0070.01511.18
5.2.90.0020.01811.19
5.2.80.0050.02711.16
5.2.70.0000.01911.13
5.2.60.0020.01811.13
5.2.50.0000.02011.20
5.2.40.0020.01611.14
5.2.30.0050.01311.13
5.2.20.0030.01611.12
5.2.10.0020.01711.04
5.2.00.0040.01710.95
5.1.60.0030.01510.66
5.1.50.0020.01510.60
5.1.40.0000.01610.58
5.1.30.0000.01810.80
5.1.20.0050.01210.78
5.1.10.0020.01510.64
5.1.00.0020.01510.63
5.0.50.0050.0089.92
5.0.40.0040.0109.83
5.0.30.0030.0209.79
5.0.20.0030.0099.74
5.0.10.0020.0139.70
5.0.00.0040.0139.76
4.4.90.0030.0099.43
4.4.80.0000.0099.43
4.4.70.0010.0109.43
4.4.60.0020.0119.43
4.4.50.0040.0089.43
4.4.40.0030.0139.43
4.4.30.0020.0109.43
4.4.20.0000.0129.43
4.4.10.0000.0129.43
4.4.00.0010.0149.43
4.3.110.0020.0109.43
4.3.100.0010.0109.43
4.3.90.0000.0109.43
4.3.80.0010.0259.43
4.3.70.0040.0179.43
4.3.60.0010.0119.43
4.3.50.0020.0199.43
4.3.40.0030.0159.43
4.3.30.0020.0209.43
4.3.20.0020.0089.43
4.3.10.0000.0139.43
4.3.00.0010.0169.43

preferences:
39.23 ms | 401 KiB | 5 Q