3v4l.org

run code in 300+ PHP versions simultaneously
<?php function countUnique($a) { $acv=array_count_values($a); $n=0; foreach ($acv as $f) if ($f==1) $n++; return $n; } function countUniqueTML($a) { return array_reduce( array_count_values($a), function($c, $i) { return ($i === 1) ? $c + 1 : $c; }, 0); } function countUniqueGG($a) { $cardinal=[]; foreach($a as $v) if (isset($cardinal[$v])) $cardinal[$v] = 0; else $cardinal[$v] = 1; return array_sum($cardinal); } $a=[1,1,2,2,2,5,6]; echo countUniqueTML($a); echo "\n"; echo countUnique($a); echo "\n"; echo countUnique($a);

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.4.20.0190.00317.40
8.4.10.0030.00617.79
8.3.150.0160.00316.63
8.3.140.0090.00917.16
8.3.130.0080.00018.20
8.3.120.0070.01118.88
8.3.110.0040.00420.94
8.3.100.0030.00616.61
8.3.90.0140.00026.77
8.3.80.0060.00316.51
8.3.70.0120.00316.58
8.3.60.0180.00016.25
8.3.50.0100.00716.55
8.3.40.0160.00018.44
8.3.30.0070.00718.58
8.3.20.0080.00020.34
8.3.10.0040.00421.97
8.3.00.0070.00023.66
8.2.260.0120.00616.51
8.2.250.0040.00416.84
8.2.240.0040.00418.80
8.2.230.0130.00322.58
8.2.220.0090.00024.06
8.2.210.0080.00026.77
8.2.200.0030.00618.04
8.2.190.0090.00916.63
8.2.180.0070.00725.92
8.2.170.0040.01218.95
8.2.160.0130.00722.96
8.2.150.0000.00825.66
8.2.140.0030.00624.66
8.2.130.0000.00921.00
8.2.120.0080.00026.16
8.2.110.0090.00022.04
8.2.100.0080.00417.72
8.2.90.0080.00017.91
8.2.80.0050.00319.16
8.2.70.0080.00317.50
8.2.60.0030.00617.50
8.2.50.0030.00617.55
8.2.40.0000.00720.46
8.2.30.0040.00419.33
8.2.20.0040.00418.00
8.2.10.0000.00718.16
8.2.00.0000.00718.20
8.1.310.0080.00016.04
8.1.300.0040.00418.51
8.1.290.0000.00930.84
8.1.280.0110.00325.92
8.1.270.0040.00424.66
8.1.260.0060.00326.35
8.1.250.0030.00628.09
8.1.240.0070.00422.14
8.1.230.0070.00422.66
8.1.220.0030.00617.74
8.1.210.0000.00818.77
8.1.200.0080.00017.35
8.1.190.0080.00017.35
8.1.180.0030.00518.10
8.1.170.0040.00418.47
8.1.160.0030.00518.96
8.1.150.0000.00820.12
8.1.140.0050.00219.60
8.1.130.0040.00419.24
8.1.120.0040.00417.47
8.1.110.0080.00017.43
8.1.100.0040.00417.46
8.1.90.0040.00417.43
8.1.80.0000.00717.41
8.1.70.0000.00717.37
8.1.60.0040.00417.60
8.1.50.0000.00817.42
8.1.40.0000.00817.43
8.1.30.0040.00417.63
8.1.20.0070.00017.67
8.1.10.0050.00317.56
8.1.00.0070.00317.46
8.0.300.0040.00420.10
8.0.290.0000.00816.63
8.0.280.0000.00718.50
8.0.270.0000.00717.18
8.0.260.0000.00716.75
8.0.250.0030.00616.98
8.0.240.0070.00316.91
8.0.230.0000.00717.03
8.0.220.0000.00716.90
8.0.210.0030.00316.89
8.0.200.0030.00316.98
8.0.190.0070.00316.88
8.0.180.0030.00616.95
8.0.170.0080.00016.99
8.0.160.0090.00016.92
8.0.150.0030.00516.94
8.0.140.0000.00716.84
8.0.130.0000.00813.34
8.0.120.0050.00316.84
8.0.110.0050.00216.81
8.0.100.0000.00716.95
8.0.90.0070.00016.91
8.0.80.0070.01116.95
8.0.70.0040.00416.90
8.0.60.0000.00716.86
8.0.50.0000.00816.80
8.0.30.0080.00917.05
8.0.20.0110.01117.42
8.0.10.0030.00516.81
8.0.00.0100.00716.61
7.4.330.0080.00015.55
7.4.320.0030.00316.58
7.4.300.0000.00716.61
7.4.290.0070.00016.43
7.4.280.0040.00416.43
7.4.270.0040.00416.48
7.4.260.0030.00316.50
7.4.250.0050.00216.62
7.4.240.0030.00316.52
7.4.230.0030.00316.59
7.4.220.0100.01016.59
7.4.210.0030.01016.68
7.4.200.0080.00016.50
7.4.160.0060.00916.49
7.4.150.0040.01417.40
7.4.140.0120.00917.86
7.4.130.0090.00916.48
7.4.120.0130.00716.47
7.4.110.0090.00916.43
7.4.100.0030.01416.36
7.4.90.0040.01116.53
7.4.80.0060.01119.39
7.4.70.0040.01216.68
7.4.60.0040.01216.53
7.4.50.0080.00816.64
7.4.40.0130.00716.36
7.4.30.0130.00316.66
7.4.00.0040.01115.18
7.3.330.0050.00013.36
7.3.320.0020.00313.33
7.3.310.0000.00716.24
7.3.300.0000.00716.39
7.3.290.0090.00716.37
7.3.280.0080.00916.37
7.3.270.0130.00617.40
7.3.260.0050.01316.57
7.3.250.0120.00816.53
7.3.240.0080.00916.53
7.3.230.0120.01216.57
7.3.210.0040.01516.40
7.3.200.0160.00316.54
7.3.190.0170.00016.58
7.3.180.0080.00816.39
7.3.170.0170.00016.50
7.3.160.0040.01516.56
7.2.330.0120.00616.88
7.2.320.0090.00916.69
7.2.310.0100.00616.69
7.2.300.0190.00016.52
7.2.290.0120.00916.50
7.2.60.0120.00017.04
7.1.200.0050.00515.84
7.1.90.0070.00717.90
7.1.80.0070.00718.09
7.1.70.0120.00317.01
7.1.60.0140.01135.15
7.1.50.0060.01934.88
7.1.40.0220.00334.50
7.1.30.0110.01434.55
7.1.20.0190.00734.45
7.1.10.0060.00616.56
7.1.00.0060.00616.57
7.0.230.0060.00917.62
7.0.220.0100.00317.90
7.0.210.0030.00916.77
7.0.200.0110.00016.92
7.0.190.0030.01016.76
7.0.180.0040.00816.30
7.0.170.0060.00916.45
7.0.160.0040.00716.18
7.0.150.0060.00616.00
7.0.140.0060.00616.25
7.0.130.0100.00416.52
7.0.120.0120.00016.35
7.0.110.0070.00816.23
7.0.100.0030.00916.18
7.0.90.0080.00416.46
7.0.80.0030.00916.40
7.0.70.0000.01416.34
7.0.60.0000.01216.25
7.0.50.0060.00616.29
7.0.40.0000.01216.37
7.0.30.0060.00616.54
7.0.20.0060.00816.34
7.0.10.0070.01016.29
7.0.00.0110.02116.44

preferences:
73.11 ms | 403 KiB | 5 Q