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) { $replace = $compressPos === 0 || $compressPos + $compressLen === 8 ? ['', ''] : ['']; array_splice($shorts, $compressPos, $compressLen, $replace); } return implode(':', array_map(function($short) { return $short === '' ? '' : dechex($short); }, $shorts)); } var_dump(createCompressedString([1, 0, 0, 0, 0, 0, 0, 0]));

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.0200.00018.31
8.3.50.0100.01022.13
8.3.40.0040.01118.79
8.3.30.0110.00419.21
8.3.20.0050.00320.16
8.3.10.0080.00023.54
8.3.00.0050.00320.79
8.2.180.0070.00716.50
8.2.170.0030.01022.96
8.2.160.0100.00321.88
8.2.150.0050.00324.18
8.2.140.0060.00324.66
8.2.130.0050.00226.16
8.2.120.0070.00021.06
8.2.110.0040.00719.33
8.2.100.0000.01217.84
8.2.90.0080.00019.21
8.2.80.0040.00417.97
8.2.70.0030.00617.72
8.2.60.0030.00518.15
8.2.50.0090.00018.07
8.2.40.0000.00818.22
8.2.30.0060.00318.04
8.2.20.0000.00717.66
8.2.10.0000.00717.75
8.2.00.0050.00317.74
8.1.280.0110.00425.92
8.1.270.0060.00323.89
8.1.260.0080.00026.35
8.1.250.0000.00728.09
8.1.240.0060.00321.44
8.1.230.0070.00717.42
8.1.220.0000.00817.78
8.1.210.0040.00418.77
8.1.200.0000.01017.35
8.1.190.0000.00917.22
8.1.180.0000.00818.10
8.1.170.0050.00318.61
8.1.160.0000.00721.94
8.1.150.0040.00418.62
8.1.140.0000.00717.33
8.1.130.0030.00317.84
8.1.120.0040.00417.43
8.1.110.0040.00417.41
8.1.100.0000.00817.48
8.1.90.0030.00417.49
8.1.80.0040.00417.36
8.1.70.0050.00217.45
8.1.60.0030.00617.64
8.1.50.0030.00517.44
8.1.40.0000.00817.47
8.1.30.0000.00817.57
8.1.20.0040.00417.71
8.1.10.0040.00417.54
8.1.00.0090.00017.50
8.0.300.0040.00418.77
8.0.290.0090.00016.63
8.0.280.0030.00318.38
8.0.270.0070.00017.28
8.0.260.0000.00716.70
8.0.250.0030.00316.89
8.0.240.0000.00816.97
8.0.230.0000.00717.00
8.0.220.0070.00016.95
8.0.210.0040.00416.79
8.0.200.0000.00716.85
8.0.190.0030.00316.96
8.0.180.0050.00316.88
8.0.170.0080.00016.97
8.0.160.0050.00316.75
8.0.150.0070.00016.80
8.0.140.0030.00316.86
8.0.130.0000.00513.32
8.0.120.0040.00416.76
8.0.110.0070.00016.76
8.0.100.0040.00416.77
8.0.90.0070.00016.92
8.0.80.0000.02116.84
8.0.70.0050.00216.91
8.0.60.0000.00816.88
8.0.50.0040.00416.94
8.0.30.0100.00817.11
8.0.20.0100.01017.40
8.0.10.0000.00716.86
8.0.00.0100.00816.75
7.4.330.0050.00015.20
7.4.320.0000.00616.50
7.4.300.0000.00616.62
7.4.290.0000.00716.61
7.4.280.0040.00416.55
7.4.270.0000.00716.53
7.4.260.0030.00316.49
7.4.250.0040.00316.48
7.4.240.0020.00516.57
7.4.230.0000.00716.32
7.4.220.0030.01516.70
7.4.210.0130.00716.59
7.4.200.0000.00716.26
7.4.190.0000.00716.77
7.4.160.0130.00616.57
7.4.150.0090.00917.40
7.4.140.0120.01017.86
7.4.130.0080.00816.49
7.4.120.0050.01316.59
7.4.110.0080.00816.56
7.4.100.0070.01016.50
7.4.90.0140.00416.60
7.4.80.0090.00916.59
7.4.70.0030.01416.55
7.4.60.0030.01316.51
7.4.50.0000.00716.50
7.4.40.0070.00722.77
7.4.30.0070.01116.61
7.4.00.0070.01014.96
7.3.330.0050.00013.18
7.3.320.0020.00213.40
7.3.310.0040.00416.41
7.3.300.0020.00516.41
7.3.290.0030.01016.39
7.3.280.0090.00916.38
7.3.270.0100.00717.40
7.3.260.0100.00716.82
7.3.250.0090.00916.68
7.3.240.0100.01016.59
7.3.230.0040.01616.50
7.3.210.0100.00716.44
7.3.200.0070.01119.39
7.3.190.0040.01216.69
7.3.180.0110.00716.54
7.3.170.0030.01416.73
7.3.160.0030.01416.42
7.3.120.0060.01014.66
7.2.330.0060.01316.81
7.2.320.0100.01016.65
7.2.310.0090.00916.71
7.2.300.0060.01016.80
7.2.290.0070.01416.83
7.2.00.0140.01019.07
7.1.200.0000.01216.02
7.1.100.0040.00818.16
7.1.70.0000.01016.94
7.1.60.0160.00619.32
7.1.50.0120.00916.58
7.1.00.0030.07722.40
7.0.200.0030.00616.52
7.0.140.0000.07722.16
7.0.110.0130.05019.98
7.0.100.0030.07319.98
7.0.90.0100.03720.11
7.0.80.0100.03719.93
7.0.70.0030.05719.93
7.0.60.0030.05020.05
7.0.50.0030.04719.93
7.0.40.0100.06319.74
7.0.30.0100.07719.84
7.0.20.0030.06019.70
7.0.10.0000.04019.81
7.0.00.0000.04319.71
5.6.280.0100.06721.08
5.6.260.0100.05320.67
5.6.250.0000.04720.52
5.6.240.0070.05720.68
5.6.230.0000.04320.70
5.6.220.0030.04020.66
5.6.210.0030.05720.74
5.6.200.0070.05020.64
5.6.190.0070.04020.50
5.6.180.0070.03720.60
5.6.170.0000.04020.63
5.6.160.0030.04020.66
5.6.150.0030.08020.65
5.6.140.0000.05720.63
5.6.130.0100.03020.48
5.6.120.0030.07320.63
5.6.110.0000.09020.57
5.6.100.0100.08020.56
5.6.90.0100.08020.55
5.6.80.0100.07719.86
5.6.70.0070.07720.03
5.6.60.0170.06720.01
5.6.50.0070.05720.01
5.6.40.0070.04019.99
5.6.30.0030.08320.06
5.6.20.0130.07319.92
5.6.10.0000.07019.98
5.6.00.0130.07720.01
5.5.380.0030.04017.57
5.5.370.0030.04017.61
5.5.360.0030.05017.60
5.5.350.0070.06717.55
5.5.340.0000.04317.93
5.5.330.0000.04318.05
5.5.320.0030.04718.10
5.5.310.0030.04018.22
5.5.300.0070.04717.93
5.5.290.0030.05017.96
5.5.280.0100.07717.97
5.5.270.0000.04317.93
5.5.260.0100.05018.22
5.5.250.0130.07317.73
5.5.240.0100.07717.50
5.5.230.0130.06017.30
5.5.220.0130.07317.34
5.5.210.0070.07317.61
5.5.200.0030.08017.29
5.5.190.0030.08017.45
5.5.180.0070.08017.27
5.5.160.0030.06317.48
5.5.150.0030.08017.42
5.5.140.0170.07017.46
5.5.130.0070.07717.44
5.5.120.0030.08017.60
5.5.110.0070.07717.45
5.5.100.0100.07317.31
5.5.90.0030.05017.32
5.5.80.0130.07017.34
5.5.70.0100.06717.50
5.5.60.0030.07317.47
5.5.50.0000.04017.51
5.5.40.0130.06017.49
5.5.30.0070.07017.49
5.5.20.0030.05317.34
5.5.10.0070.06317.19
5.5.00.0070.03017.37
5.4.450.0030.05019.51
5.4.440.0070.05019.33
5.4.430.0030.06319.31
5.4.420.0000.08019.34
5.4.410.0100.07319.45
5.4.400.0000.08019.15
5.4.390.0030.08319.18
5.4.380.0100.07318.95
5.4.370.0130.06719.02
5.4.360.0200.06319.01
5.4.350.0030.08019.01
5.4.340.0100.08019.00
5.4.320.0100.07719.03
5.4.310.0130.06318.96
5.4.300.0000.07718.97
5.4.290.0000.08319.00
5.4.280.0130.07019.00
5.4.270.0030.06319.04
5.4.260.0070.06719.00
5.4.250.0130.07318.99
5.4.240.0100.07019.00
5.4.230.0070.07318.98
5.4.220.0030.07319.09
5.4.210.0030.04718.99
5.4.200.0000.06718.98
5.4.190.0130.06019.00
5.4.180.0100.07019.30
5.4.170.0070.07718.99
5.4.160.0000.05019.21
5.4.150.0000.03719.23
5.4.140.0070.03016.43
5.4.130.0000.03316.43
5.4.120.0100.06716.59
5.4.110.0100.07316.61
5.4.100.0000.03316.61
5.4.90.0000.03316.55
5.4.80.0130.06716.46
5.4.70.0070.03716.51
5.4.60.0170.06016.34
5.4.50.0100.03316.44
5.4.40.0030.04316.52
5.4.30.0070.03716.49
5.4.20.0070.07316.54
5.4.10.0070.06016.44
5.4.00.0170.06716.00
5.3.290.0070.04714.75
5.3.280.0070.08014.61
5.3.270.0130.06714.62
5.3.260.0000.07314.74
5.3.250.0030.03314.58
5.3.240.0070.05714.70
5.3.230.0070.03014.46
5.3.220.0030.07314.43
5.3.210.0100.02714.71
5.3.200.0100.05314.66
5.3.190.0030.03314.65
5.3.180.0030.03314.79
5.3.170.0070.07714.60
5.3.160.0030.08014.59
5.3.150.0030.04314.79
5.3.140.0100.06014.57
5.3.130.0070.07314.57
5.3.120.0000.08014.55
5.3.110.0030.04314.68
5.3.100.0070.03714.17
5.3.90.0030.07314.02
5.3.80.0030.07714.11
5.3.70.0070.03714.16
5.3.60.0170.06714.00
5.3.50.0230.06313.98
5.3.40.0170.06714.00
5.3.30.0000.07313.77
5.3.20.0070.07313.65
5.3.10.0100.06313.75
5.3.00.0070.06313.66
5.2.170.0000.04713.02
5.2.160.0030.06313.02
5.2.150.0100.06013.02
5.2.140.0030.05013.02
5.2.130.0070.06013.02
5.2.120.0070.06313.02
5.2.110.0070.05313.02
5.2.100.0100.04013.02
5.2.90.0070.04013.02
5.2.80.0030.06713.02
5.2.70.0000.03713.02
5.2.60.0030.06313.02
5.2.50.0070.04713.02
5.2.40.0130.02713.02
5.2.30.0100.06013.02
5.2.20.0070.03713.02
5.2.10.0030.03013.02
5.2.00.0100.05313.02
5.1.60.0030.04313.02
5.1.50.0070.02313.02
5.1.40.0070.04713.02
5.1.30.0100.05313.02
5.1.20.0030.04013.02
5.1.10.0030.05713.02
5.1.00.0070.04713.02
5.0.50.0000.04713.02
5.0.40.0030.03713.02
5.0.30.0030.03313.02
5.0.20.0030.04713.02
5.0.10.0000.03013.02
5.0.00.0000.06313.02
4.4.90.0000.01713.02
4.4.80.0000.03713.02
4.4.70.0070.02313.02
4.4.60.0030.03313.02
4.4.50.0030.02013.02
4.4.40.0030.04713.02
4.4.30.0070.02313.02
4.4.20.0030.03013.02
4.4.10.0030.01713.02
4.4.00.0000.04013.02
4.3.110.0030.01313.02
4.3.100.0070.02313.02
4.3.90.0000.03013.02
4.3.80.0000.02713.02
4.3.70.0070.02713.02
4.3.60.0070.01713.02
4.3.50.0000.03713.02
4.3.40.0000.05713.02
4.3.30.0070.01013.02
4.3.20.0000.03313.02
4.3.10.0030.03313.02
4.3.00.0000.01313.02

preferences:
33.34 ms | 401 KiB | 5 Q