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 "\n"; 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.70.0090.00616.75
8.3.60.0060.00916.38
8.3.50.0200.00621.89
8.3.40.0080.00818.57
8.3.30.0150.00019.01
8.3.20.0070.00020.34
8.3.10.0040.00423.45
8.3.00.0040.00422.40
8.2.180.0090.00918.13
8.2.170.0090.00522.96
8.2.160.0070.00720.43
8.2.150.0090.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0030.00522.25
8.2.110.0100.00020.35
8.2.100.0040.00717.91
8.2.90.0030.00519.36
8.2.80.0000.00818.04
8.2.70.0040.00417.63
8.2.60.0030.00618.05
8.2.50.0030.00718.07
8.2.40.0040.00419.28
8.2.30.0080.00018.25
8.2.20.0060.00517.76
8.2.10.0070.00017.68
8.2.00.0060.00317.73
8.1.280.0090.00625.92
8.1.270.0000.00823.92
8.1.260.0080.00026.35
8.1.250.0000.00728.09
8.1.240.0080.00421.96
8.1.230.0040.00822.75
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0050.00517.35
8.1.190.0030.00517.66
8.1.180.0030.00618.10
8.1.170.0040.00418.62
8.1.160.0040.00421.95
8.1.150.0000.00718.57
8.1.140.0000.00717.52
8.1.130.0040.00417.82
8.1.120.0070.00017.48
8.1.110.0090.00017.47
8.1.100.0070.00017.56
8.1.90.0000.00717.41
8.1.80.0070.00017.51
8.1.70.0000.00717.49
8.1.60.0060.00317.52
8.1.50.0060.00317.61
8.1.40.0050.00317.47
8.1.30.0030.00517.64
8.1.20.0000.00817.72
8.1.10.0040.00417.55
8.1.00.0060.00317.53
8.0.300.0040.00418.77
8.0.290.0040.00417.18
8.0.280.0030.00318.49
8.0.270.0030.00317.31
8.0.260.0070.00016.87
8.0.250.0070.00016.90
8.0.240.0040.00417.02
8.0.230.0030.00517.00
8.0.220.0000.00716.84
8.0.210.0070.00016.92
8.0.200.0000.00716.91
8.0.190.0020.00516.90
8.0.180.0070.00016.95
8.0.170.0080.00016.98
8.0.160.0040.00417.08
8.0.150.0070.00016.79
8.0.140.0070.00016.91
8.0.130.0070.00013.37
8.0.120.0000.00716.95
8.0.110.0040.00416.98
8.0.100.0030.00516.89
8.0.90.0070.00017.00
8.0.80.0070.01016.99
8.0.70.0040.00416.95
8.0.60.0040.00416.82
8.0.50.0000.00716.91
8.0.30.0060.01617.20
8.0.20.0120.00817.40
8.0.10.0000.00717.00
8.0.00.0110.00816.72
7.4.330.0000.00515.16
7.4.320.0000.00616.61
7.4.300.0040.00416.65
7.4.290.0070.00016.56
7.4.280.0030.00316.45
7.4.270.0070.00016.56
7.4.260.0030.00316.65
7.4.250.0080.00016.54
7.4.240.0050.00316.51
7.4.230.0050.00316.36
7.4.220.0040.01416.70
7.4.210.0040.01216.63
7.4.200.0000.00716.68
7.4.190.0080.00016.82
7.4.160.0150.00616.71
7.4.150.0110.00517.40
7.4.140.0090.00917.86
7.4.130.0100.00816.53
7.4.120.0140.00816.64
7.4.110.0110.01116.67
7.4.100.0110.00716.53
7.4.90.0130.00616.50
7.4.80.0040.01919.39
7.4.70.0170.00716.57
7.4.60.0110.00616.34
7.4.50.0000.00916.39
7.4.40.0030.01322.77
7.4.30.0100.00716.55
7.4.10.0150.00314.75
7.4.00.0100.00815.11
7.3.330.0050.00013.19
7.3.320.0050.00013.41
7.3.310.0000.00816.52
7.3.300.0030.00316.46
7.3.290.0100.00316.42
7.3.280.0100.01016.37
7.3.270.0060.01317.40
7.3.260.0110.00616.54
7.3.250.0120.00916.53
7.3.240.0110.00816.44
7.3.230.0110.00616.66
7.3.210.0110.00716.57
7.3.200.0110.01119.39
7.3.190.0070.01416.69
7.3.180.0070.01016.38
7.3.170.0120.00416.32
7.3.160.0130.00316.38
7.3.130.0060.00915.17
7.3.120.0130.00314.79
7.3.110.0040.01514.82
7.3.100.0090.00615.17
7.3.90.0100.00314.86
7.3.80.0070.01014.95
7.3.70.0120.00315.02
7.3.60.0060.01014.84
7.3.50.0040.00814.71
7.3.40.0090.00014.58
7.3.30.0070.01014.76
7.3.20.0030.01016.71
7.3.10.0070.00716.55
7.3.00.0060.00716.59
7.2.330.0130.00416.46
7.2.320.0030.01516.80
7.2.310.0090.01316.60
7.2.300.0080.01216.82
7.2.290.0050.01116.82
7.2.260.0030.01414.85
7.2.250.0040.01515.39
7.2.240.0030.01015.43
7.2.230.0060.00315.12
7.2.220.0140.00715.13
7.2.210.0100.00714.68
7.2.200.0070.01015.21
7.2.190.0000.01315.17
7.2.180.0030.01215.20
7.2.170.0050.00515.19
7.2.160.0080.00815.01
7.2.150.0090.00916.87
7.2.140.0070.01117.08
7.2.130.0090.00616.77
7.2.120.0080.00816.88
7.2.110.0050.00917.00
7.2.100.0030.01016.92
7.2.90.0020.01116.83
7.2.80.0050.00716.98
7.2.70.0030.01317.11
7.2.60.0040.00816.87
7.2.50.0060.00816.83
7.2.40.0050.00616.88
7.2.30.0080.00716.87
7.2.20.0090.00617.04
7.2.10.0120.00316.81
7.2.00.0060.01217.72
7.1.330.0070.00715.75
7.1.320.0070.00715.71
7.1.310.0000.01315.75
7.1.300.0070.00715.95
7.1.290.0040.01115.63
7.1.280.0040.00915.79
7.1.270.0030.01015.89
7.1.260.0070.01115.92
7.1.250.0050.01015.81
7.1.240.0050.00915.62
7.1.230.0030.01115.89
7.1.220.0060.00615.76
7.1.210.0070.00715.58
7.1.200.0070.00315.68
7.1.190.0100.00515.83
7.1.180.0060.00715.70
7.1.170.0070.00515.86
7.1.160.0060.00815.82
7.1.150.0070.00715.93
7.1.140.0090.00615.71
7.1.130.0050.00715.84
7.1.120.0070.00915.86
7.1.110.0060.00815.74
7.1.100.0060.00616.49
7.1.90.0110.00415.70
7.1.80.0070.00715.80
7.1.70.0070.00516.28
7.1.60.0090.00816.93
7.1.50.0060.01016.18
7.1.40.0050.00715.65
7.1.30.0040.00615.75
7.1.20.0060.00915.80
7.1.10.0060.00915.95
7.1.00.0050.02918.13
7.0.330.0040.00615.38
7.0.320.0090.00515.16
7.0.310.0040.00915.23
7.0.300.0020.01215.39
7.0.290.0080.00715.32
7.0.280.0050.00615.30
7.0.270.0050.00915.26
7.0.260.0060.00915.36
7.0.250.0030.01015.26
7.0.240.0050.00515.38
7.0.230.0100.00515.20
7.0.220.0030.00815.43
7.0.210.0030.00915.26
7.0.200.0050.00515.86
7.0.190.0050.00815.45
7.0.180.0080.00515.54
7.0.170.0050.00715.47
7.0.160.0050.00715.37
7.0.150.0060.00715.39
7.0.140.0060.02517.71
7.0.130.0030.00715.26
7.0.120.0050.00815.45
7.0.110.0050.01215.52
7.0.100.0080.03316.96
7.0.90.0060.03217.04
7.0.80.0080.02417.05
7.0.70.0070.02916.80
7.0.60.0030.03316.95
7.0.50.0070.03416.96
7.0.40.0070.02715.62
7.0.30.0070.03315.64
7.0.20.0060.02115.69
7.0.10.0050.03115.70
7.0.00.0050.01715.63
5.6.400.0060.01314.61
5.6.390.0000.01214.86
5.6.380.0090.00414.57
5.6.370.0030.00814.25
5.6.360.0050.00714.34
5.6.350.0020.01214.16
5.6.340.0050.00914.50
5.6.330.0070.00814.10
5.6.320.0040.00714.48
5.6.310.0050.01014.35
5.6.300.0060.00714.45
5.6.290.0020.01114.33
5.6.280.0060.02616.64
5.6.270.0080.00914.46
5.6.260.0050.01014.48
5.6.250.0080.03216.61
5.6.240.0060.03116.55
5.6.230.0010.04016.56
5.6.220.0070.03316.37
5.6.210.0070.02916.43
5.6.200.0040.03316.69
5.6.190.0050.03416.72
5.6.180.0010.02616.60
5.6.170.0040.02216.50
5.6.160.0120.02716.55
5.6.150.0090.03316.70
5.6.140.0020.02816.66
5.6.130.0040.03316.71
5.6.120.0060.02116.62
5.6.110.0070.01816.46
5.6.100.0040.02016.53
5.6.90.0050.02116.49
5.6.80.0030.02316.33
5.6.70.0100.02016.45
5.6.60.0080.02816.36
5.6.50.0040.03516.37
5.6.40.0070.02016.54
5.6.30.0090.02016.40
5.6.20.0050.02916.22
5.6.10.0080.01716.26
5.6.00.0070.03016.53
5.5.380.0030.02815.40
5.5.370.0040.03215.29
5.5.360.0040.03515.35
5.5.350.0060.03115.51
5.5.340.0030.03315.50
5.5.330.0080.02315.49
5.5.320.0050.03115.49
5.5.310.0030.02115.53
5.5.300.0080.02715.27
5.5.290.0050.01815.44
5.5.280.0050.03315.47
5.5.270.0040.02215.34
5.5.260.0070.03115.47
5.5.250.0080.02815.30
5.5.240.0080.01815.17
5.5.230.0100.02115.21
5.5.220.0040.03115.21
5.5.210.0080.03015.21
5.5.200.0030.02715.20
5.5.190.0040.02915.06
5.5.180.0060.02615.23
5.5.170.0040.00912.68
5.5.160.0090.02115.10
5.5.150.0020.03315.18
5.5.140.0050.02015.21
5.5.130.0060.02815.25
5.5.120.0080.02515.04
5.5.110.0040.02115.21
5.5.100.0070.01815.23
5.5.90.0040.03115.29
5.5.80.0060.02715.15
5.5.70.0060.03215.14
5.5.60.0020.03015.22
5.5.50.0060.02815.09
5.5.40.0070.03115.25
5.5.30.0060.01915.14
5.5.20.0040.01815.17
5.5.10.0070.01715.13
5.5.00.0060.03415.25
5.4.450.0030.01914.01
5.4.440.0020.02914.06
5.4.430.0050.02114.08
5.4.420.0100.02614.03
5.4.410.0120.01814.00
5.4.400.0110.02014.03
5.4.390.0090.02514.00
5.4.380.0020.03214.03
5.4.370.0060.03014.00
5.4.360.0030.02813.79
5.4.350.0080.02413.88
5.4.340.0070.02513.99
5.4.330.0040.00411.19
5.4.320.0050.02614.03
5.4.310.0050.02913.88
5.4.300.0110.02113.79
5.4.290.0040.02713.88
5.4.280.0090.01713.97
5.4.270.0040.01613.78
5.4.260.0050.02913.89
5.4.250.0080.02513.90
5.4.240.0040.03113.81
5.4.230.0050.02013.96
5.4.220.0100.02613.83
5.4.210.0060.02813.99
5.4.200.0010.03213.95
5.4.190.0030.01814.02
5.4.180.0050.02613.93
5.4.170.0030.03013.89
5.4.160.0080.02613.81
5.4.150.0060.03013.90
5.4.140.0050.03013.02
5.4.130.0090.01912.94
5.4.120.0060.02213.15
5.4.110.0040.02912.94
5.4.100.0070.01713.07
5.4.90.0040.02113.01
5.4.80.0090.01613.04
5.4.70.0040.02413.09
5.4.60.0040.01513.07
5.4.50.0110.01012.99
5.4.40.0030.01713.00
5.4.30.0050.02712.98
5.4.20.0040.03013.06
5.4.10.0070.02712.97
5.4.00.0040.02412.87
5.3.290.0040.02112.32
5.3.280.0040.01912.26
5.3.270.0040.02712.36
5.3.260.0020.02012.18
5.3.250.0090.02312.27
5.3.240.0050.02912.22
5.3.230.0040.02012.28
5.3.220.0030.03212.22
5.3.210.0040.03012.22
5.3.200.0070.02212.25
5.3.190.0060.02812.28
5.3.180.0100.02312.26
5.3.170.0080.02312.32
5.3.160.0030.02312.32
5.3.150.0050.03212.34
5.3.140.0070.02612.19
5.3.130.0060.02812.28
5.3.120.0050.01712.28
5.3.110.0070.02812.31
5.3.100.0080.02512.12
5.3.90.0050.02612.13
5.3.80.0040.02912.07
5.3.70.0050.02012.05
5.3.60.0020.01912.07
5.3.50.0030.02312.05
5.3.40.0060.02712.05
5.3.30.0050.01812.04
5.3.20.0030.01911.92
5.3.10.0020.01511.85
5.3.00.0030.01611.89
5.2.170.0020.03211.96
5.2.160.0060.03211.96
5.2.150.0000.03711.96
5.2.140.0030.01811.96
5.2.130.0030.01811.96
5.2.120.0000.01811.96
5.2.110.0050.01811.96
5.2.100.0020.01811.96
5.2.90.0060.01511.96
5.2.80.0000.01811.96
5.2.70.0000.02011.96
5.2.60.0030.01511.96
5.2.50.0010.01811.96
5.2.40.0020.01811.96
5.2.30.0030.01811.96
5.2.20.0030.01511.96
5.2.10.0030.01511.96
5.2.00.0030.01711.96
5.1.60.0040.01311.96
5.1.50.0020.01411.96
5.1.40.0050.02211.96
5.1.30.0010.01411.96
5.1.20.0000.01411.96
5.1.10.0040.01211.96
5.1.00.0020.01411.96
5.0.50.0040.01011.96
5.0.40.0010.01311.96
5.0.30.0000.01711.96
5.0.20.0030.00811.96
5.0.10.0020.00911.96
5.0.00.0030.01711.96
4.4.90.0020.00911.96
4.4.80.0030.00811.96
4.4.70.0020.01011.96
4.4.60.0020.01111.96
4.4.50.0020.01011.96
4.4.40.0000.01411.96
4.4.30.0020.00911.96
4.4.20.0040.00711.96
4.4.10.0040.00511.96
4.4.00.0040.01511.96
4.3.110.0010.01011.96
4.3.100.0050.00711.96
4.3.90.0000.00911.96
4.3.80.0000.01511.96
4.3.70.0000.01111.96
4.3.60.0020.00911.96
4.3.50.0020.00811.96
4.3.40.0000.01411.96
4.3.30.0020.00911.96
4.3.20.0020.01711.96
4.3.10.0020.00711.96
4.3.00.0000.01211.96

preferences:
51.48 ms | 401 KiB | 5 Q