3v4l.org

run code in 300+ PHP versions simultaneously
<?php function createCompressedString($shorts) { $compressLen = $compressPos = $currentLen = $currentPos = 0; $inBlock = false; for ($i = 0; $i < 8; $i++) { if ($shorts[$i] === 0) { if (!$inBlock) { $inBlock = true; $currentPos = $i; } $currentLen++; } else if ($inBlock) { if ($currentLen > $compressLen) { $compressLen = $currentLen; $compressPos = $currentPos; } $inBlock = false; $currentPos = $currentLen = 0; } } if ($inBlock) { $compressLen = $currentLen; $compressPos = $currentPos; } if ($compressLen === 8) { return '::'; } if ($compressLen > 1) { if ($compressPos === 0 || $compressPos + $compressLen === 8) { array_splice($shorts, $compressPos, $compressLen, ['', '']); } } return implode(':', array_map(function($short) { return $short === '' ? '' : dechex($short); }, $shorts)); } var_dump(createCompressedString([1, 0, 0, 0, 1, 2001, 23234, 21]));

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.0110.00416.49
8.3.60.0000.01518.18
8.3.50.0110.00716.45
8.3.40.0070.00718.98
8.3.30.0040.01118.63
8.3.20.0080.00018.74
8.3.10.0090.00020.48
8.3.00.0040.00417.63
8.2.180.0180.00316.75
8.2.170.0100.01022.96
8.2.160.0030.01022.21
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0000.00726.16
8.2.120.0050.00319.96
8.2.110.0080.00320.89
8.2.100.0040.00817.84
8.2.90.0030.00519.09
8.2.80.0000.00817.97
8.2.70.0030.00617.63
8.2.60.0060.00317.93
8.2.50.0000.00818.07
8.2.40.0080.00018.22
8.2.30.0000.00718.02
8.2.20.0040.00417.78
8.2.10.0060.00317.63
8.2.00.0060.00317.79
8.1.280.0060.01225.92
8.1.270.0040.00423.99
8.1.260.0070.00726.35
8.1.250.0000.00828.09
8.1.240.0060.00322.48
8.1.230.0040.00720.91
8.1.220.0080.00018.77
8.1.210.0080.00018.96
8.1.200.0030.00617.25
8.1.190.0000.00917.41
8.1.180.0030.00518.10
8.1.170.0050.00318.63
8.1.160.0000.00718.96
8.1.150.0000.00818.65
8.1.140.0000.00717.37
8.1.130.0040.00417.88
8.1.120.0040.00417.53
8.1.110.0040.00417.45
8.1.100.0000.00817.47
8.1.90.0040.00417.48
8.1.80.0000.00717.37
8.1.70.0000.00717.36
8.1.60.0070.00017.63
8.1.50.0080.00017.35
8.1.40.0000.00817.49
8.1.30.0030.00517.56
8.1.20.0030.00617.64
8.1.10.0040.00417.59
8.1.00.0040.00417.56
8.0.300.0030.00720.05
8.0.290.0000.00716.75
8.0.280.0000.00818.36
8.0.270.0030.00417.31
8.0.260.0030.00316.84
8.0.250.0000.00716.94
8.0.240.0030.00617.00
8.0.230.0000.00716.96
8.0.220.0030.00316.92
8.0.210.0000.00716.92
8.0.200.0030.00316.85
8.0.190.0000.00716.88
8.0.180.0000.00716.94
8.0.170.0040.00416.83
8.0.160.0000.00716.93
8.0.150.0040.00416.73
8.0.140.0030.00716.82
8.0.130.0000.00713.30
8.0.120.0000.00716.75
8.0.110.0000.00716.94
8.0.100.0000.00716.79
8.0.90.0040.00416.80
8.0.80.0030.01316.79
8.0.70.0040.00416.97
8.0.60.0030.00316.88
8.0.50.0030.00516.90
8.0.30.0080.01117.14
8.0.20.0100.00817.12
8.0.10.0050.00216.87
8.0.00.0100.00716.99
7.4.330.0050.00014.76
7.4.320.0030.00316.62
7.4.300.0000.00616.46
7.4.290.0050.00216.52
7.4.280.0030.00616.53
7.4.270.0040.00416.62
7.4.260.0030.00313.27
7.4.250.0040.00416.53
7.4.240.0000.00716.49
7.4.230.0000.00716.64
7.4.220.0080.00816.43
7.4.210.0070.00916.54
7.4.200.0070.00016.45
7.4.190.0000.00716.75
7.4.160.0060.00916.37
7.4.150.0150.00417.07
7.4.140.0140.00617.16
7.4.130.0030.01516.50
7.4.120.0130.00316.52
7.4.110.0160.00816.58
7.4.100.0030.01616.47
7.4.90.0120.00816.40
7.4.80.0060.01218.80
7.4.70.0100.01016.48
7.4.60.0150.00016.60
7.4.50.0060.00316.54
7.4.40.0070.00822.27
7.4.30.0120.00316.64
7.4.10.0100.01014.98
7.4.00.0050.01114.90
7.3.330.0070.00013.23
7.3.320.0050.00013.29
7.3.310.0030.00316.33
7.3.300.0030.00316.41
7.3.290.0060.00816.37
7.3.280.0050.01316.35
7.3.270.0170.00017.07
7.3.260.0110.01018.24
7.3.250.0090.01116.55
7.3.240.0070.01016.56
7.3.230.0080.00816.41
7.3.210.0160.00316.50
7.3.200.0110.01119.39
7.3.190.0150.00316.65
7.3.180.0040.01216.25
7.3.170.0080.00816.56
7.3.160.0100.00716.25
7.3.130.0000.01814.82
7.3.120.0070.00914.98
7.3.110.0130.00315.14
7.3.100.0080.00414.87
7.3.90.0060.00914.64
7.3.80.0100.00314.86
7.3.70.0070.00414.64
7.3.60.0130.00014.73
7.3.50.0030.01314.75
7.3.40.0040.00714.88
7.3.30.0000.01414.81
7.3.20.0110.00416.73
7.3.10.0030.00716.33
7.3.00.0060.00616.38
7.2.330.0110.00716.86
7.2.320.0130.00916.59
7.2.310.0150.00616.53
7.2.300.0100.00716.67
7.2.290.0110.00616.74
7.2.260.0100.01015.09
7.2.250.0070.01115.06
7.2.240.0040.00815.18
7.2.230.0110.00415.25
7.2.220.0110.00414.94
7.2.210.0080.00814.83
7.2.200.0030.01414.77
7.2.190.0030.00915.12
7.2.180.0140.00314.98
7.2.170.0070.00715.07
7.2.160.0140.00015.09
7.2.150.0040.01116.89
7.2.140.0090.00616.86
7.2.130.0060.00316.88
7.2.120.0040.01116.87
7.2.110.0060.01016.88
7.2.100.0070.01116.81
7.2.90.0070.00716.83
7.2.80.0040.00816.75
7.2.70.0100.00316.68
7.2.60.0060.00617.00
7.2.50.0030.00616.97
7.2.40.0000.01416.84
7.2.30.0090.00617.13
7.2.20.0030.01216.84
7.2.10.0100.00716.96
7.2.00.0030.01017.01
7.1.330.0000.01415.88
7.1.320.0100.00615.84
7.1.310.0070.00315.61
7.1.300.0070.01015.56
7.1.290.0060.00615.88
7.1.280.0000.00915.59
7.1.270.0030.00915.79
7.1.260.0040.00715.64
7.1.250.0080.00415.68
7.1.240.0070.00715.70
7.1.230.0060.00615.78
7.1.220.0000.01215.63
7.1.210.0070.00415.93
7.1.200.0090.00715.76
7.1.190.0000.00815.95
7.1.180.0060.00615.59
7.1.170.0060.00615.69
7.1.160.0070.00715.50
7.1.150.0070.01015.86
7.1.140.0090.00615.57
7.1.130.0070.00715.75
7.1.120.0030.00615.70
7.1.110.0030.01415.84
7.1.100.0040.01217.03
7.1.90.0100.00315.89
7.1.80.0040.00715.86
7.1.70.0040.00716.26
7.1.60.0110.00817.65
7.1.50.0030.01316.53
7.1.40.0040.00415.91
7.1.30.0100.00315.69
7.1.20.0070.00715.84
7.1.10.0030.00615.81
7.1.00.0060.03319.08
7.0.330.0100.00315.54
7.0.320.0040.00815.38
7.0.310.0100.00715.36
7.0.300.0070.00615.35
7.0.290.0000.01115.18
7.0.280.0040.00415.60
7.0.270.0100.00315.28
7.0.260.0050.00515.51
7.0.250.0000.01315.43
7.0.240.0080.00615.45
7.0.230.0100.00715.38
7.0.220.0060.01015.45
7.0.210.0000.00815.32
7.0.200.0000.01316.08
7.0.190.0100.00315.38
7.0.180.0030.00515.17
7.0.170.0070.00715.46
7.0.160.0000.01415.47
7.0.150.0030.00715.23
7.0.140.0090.03518.68
7.0.130.0030.00615.30
7.0.120.0000.01315.43
7.0.110.0090.00615.32
7.0.100.0060.00315.22
7.0.90.0090.00315.40
7.0.80.0080.00415.41
7.0.70.0090.00615.49
7.0.60.0120.04217.56
7.0.50.0080.04016.67
7.0.40.0050.04616.86
7.0.30.0180.03016.79
7.0.20.0220.04216.82
7.0.10.0020.02816.90
7.0.00.0010.04716.89
5.6.400.0110.00314.25
5.6.390.0070.00714.23
5.6.380.0030.01014.30
5.6.370.0060.00914.42
5.6.360.0120.00414.49
5.6.350.0070.00314.38
5.6.340.0070.01014.32
5.6.330.0030.01014.31
5.6.320.0090.00614.54
5.6.310.0040.01214.53
5.6.300.0040.00714.41
5.6.290.0070.00314.33
5.6.280.0070.03617.69
5.6.270.0040.00814.44
5.6.260.0000.01414.41
5.6.250.0070.00714.37
5.6.240.0030.01014.21
5.6.230.0000.01614.31
5.6.220.0120.00014.24
5.6.210.0100.04017.40
5.6.200.0050.04716.28
5.6.190.0090.04317.35
5.6.180.1620.02517.47
5.6.170.0170.04417.38
5.6.160.0050.04517.22
5.6.150.0070.03816.52
5.6.140.0110.03816.07
5.6.130.0070.02716.25
5.6.120.0100.02017.59
5.6.110.0060.04417.60
5.6.100.0050.03817.60
5.6.90.0050.04517.78
5.6.80.0110.03317.28
5.6.70.0070.00714.16
5.6.60.0100.00314.19
5.6.50.0030.01314.16
5.6.40.0120.00314.15
5.6.30.0090.00314.29
5.6.20.0060.00614.51
5.6.10.0000.00914.40
5.6.00.0090.00014.28
5.5.380.0090.00014.46
5.5.370.0090.00313.93
5.5.360.0100.00013.99
5.5.350.0200.03317.36
5.5.340.0050.02116.01
5.5.330.0110.03317.31
5.5.320.0100.02617.34
5.5.310.0220.03817.09
5.5.300.0050.04216.14
5.5.290.0030.03116.10
5.5.280.0050.02417.35
5.5.270.0070.04617.35
5.5.260.0030.04017.41
5.5.250.0040.02317.30
5.5.240.0050.04217.09
5.5.230.0080.00614.15
5.5.220.0100.00314.14
5.5.210.0070.00714.16
5.5.200.0140.00314.36
5.5.190.0030.01014.11
5.5.180.0060.00914.34
5.5.170.0000.01414.34
5.5.160.0030.00614.27
5.5.150.0030.00614.25
5.5.140.0100.00314.12
5.5.130.0040.01113.95
5.5.120.0080.00314.10
5.5.110.0110.00314.34
5.5.100.0060.00614.25
5.5.90.0060.00614.20
5.5.80.0040.00813.97
5.5.70.0040.00814.23
5.5.60.0070.00314.02
5.5.50.0070.00713.96
5.5.40.0120.00314.31
5.5.30.0060.00614.32
5.5.20.0100.00314.09
5.5.10.0000.01413.88
5.5.00.0060.00614.11
5.4.450.0000.04815.23
5.4.440.0100.04015.25
5.4.430.0050.04215.39
5.4.420.0070.03515.40
5.4.410.0070.03915.26
5.4.400.0110.03514.84
5.4.390.0020.02515.01
5.4.380.0090.04015.06
5.4.370.0000.03114.96
5.4.360.0060.02315.07
5.4.350.0030.02414.85
5.4.340.0090.01815.17
5.4.330.0030.00810.84
5.4.320.0050.02014.95
5.4.310.0030.02414.96
5.4.300.0080.01714.98
5.4.290.0030.02015.02
5.4.280.0050.02014.92
5.4.270.0020.02714.90
5.4.260.0050.02114.90
5.4.250.0050.01815.03
5.4.240.0020.02414.90
5.4.230.0080.01715.01
5.4.220.0050.01915.10
5.4.210.0050.02014.86
5.4.200.0070.02315.11
5.4.190.0050.02314.95
5.4.180.0020.02414.98
5.4.170.0030.02115.11
5.4.160.0050.02014.93
5.4.150.0050.02114.73
5.4.140.0010.02113.75
5.4.130.0030.02013.78
5.4.120.0050.01813.68
5.4.110.0000.02213.71
5.4.100.0050.01713.61
5.4.90.0040.02013.42
5.4.80.0070.01713.71
5.4.70.0000.04613.72
5.4.60.0100.03213.62
5.4.50.0050.04013.50
5.4.40.0020.02413.84
5.4.30.0050.02313.63
5.4.20.0030.02413.49
5.4.10.0060.03513.62
5.4.00.0050.03513.33
5.3.290.0030.02612.41
5.3.280.0020.02512.30
5.3.270.0020.02112.44
5.3.260.0020.02312.45
5.3.250.0040.02012.47
5.3.240.0030.02112.37
5.3.230.0060.01812.45
5.3.220.0020.02412.42
5.3.210.0020.02312.37
5.3.200.0000.02312.43
5.3.190.0020.02112.34
5.3.180.0020.03012.59
5.3.170.0080.02712.47
5.3.160.0030.03112.57
5.3.150.0050.04212.64
5.3.140.0050.03212.49
5.3.130.0020.03812.49
5.3.120.0060.03912.51
5.3.110.0160.02512.36
5.3.100.0030.02512.16
5.3.90.0030.04412.15
5.3.80.0100.03212.17
5.3.70.0080.03412.08
5.3.60.0100.02012.07
5.3.50.0080.04012.14
5.3.40.0030.02712.00
5.3.30.0080.03112.05
5.3.20.0040.02811.96
5.3.10.0050.02811.70
5.3.00.0050.03611.90
5.2.170.0030.03011.14
5.2.160.0000.03711.06
5.2.150.0070.06011.15
5.2.140.0000.06711.11
5.2.130.0070.05711.03
5.2.120.0000.03710.99
5.2.110.0030.03311.14
5.2.100.0070.06011.16
5.2.90.0070.04311.14
5.2.80.0070.03311.11
5.2.70.0130.04311.15
5.2.60.0030.03011.20
5.2.50.0000.03310.94
5.2.40.0070.03010.90
5.2.30.0030.05010.92
5.2.20.0030.06310.92
5.2.10.0070.05010.86
5.2.00.0100.04710.64
5.1.60.0000.05710.05
5.1.50.0070.03010.01
5.1.40.0030.0279.89
5.1.30.0030.03310.52
5.1.20.0100.03310.35
5.1.10.0070.05010.03
5.1.00.0000.05710.09
5.0.50.0030.0478.57
5.0.40.0070.0378.58
5.0.30.0030.0578.30
5.0.20.0070.0408.12
5.0.10.0070.0208.23
5.0.00.0000.0378.20
4.4.90.0000.0177.23
4.4.80.0030.0177.23
4.4.70.0000.0237.23
4.4.60.0000.0207.23
4.4.50.0000.0337.23
4.4.40.0000.0437.23
4.4.30.0000.0207.23
4.4.20.0000.0407.23
4.4.10.0030.0307.23
4.4.00.0070.0377.23
4.3.110.0000.0237.23
4.3.100.0000.0177.23
4.3.90.0000.0207.23
4.3.80.0030.0307.23
4.3.70.0000.0207.23
4.3.60.0000.0177.23
4.3.50.0000.0377.23
4.3.40.0100.0277.23
4.3.30.0000.0237.23
4.3.20.0000.0237.23
4.3.10.0000.0277.23
4.3.00.0030.0177.23

preferences:
67.69 ms | 401 KiB | 5 Q