3v4l.org

run code in 500+ PHP versions simultaneously
<?php function countUniqueCharacters(string $str): int { static $cache = []; return $cache[$str] ??= count( array_filter( count_chars($str, 1), fn($count) => $count === 1 ) ); } $tests = ['one', 'two', 'three', 'one', 'two']; foreach ($tests as $test) { echo PHP_EOL . "$test : " . countUniqueCharacters($test); }

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.5.70.0100.00816.74
8.5.60.0040.00316.76
8.5.50.0110.00616.39
8.5.30.0080.00921.15
8.5.20.0090.00819.46
8.5.10.0110.00720.23
8.5.00.0150.00720.08
8.4.180.0130.00822.14
8.4.170.0090.01222.17
8.4.160.0130.00823.93
8.4.150.0070.00516.88
8.4.140.0120.00917.64
8.4.130.0050.00417.90
8.4.120.0090.00523.97
8.4.110.0120.00719.34
8.4.100.0120.00819.13
8.4.90.0070.00518.69
8.4.80.0100.00918.72
8.4.70.0100.01118.96
8.4.60.0090.00920.39
8.4.50.0160.00417.55
8.4.40.0000.00819.64
8.4.30.0190.00018.93
8.4.20.0060.00319.86
8.4.10.0050.00523.86
8.3.300.0100.01220.91
8.3.290.0110.01018.61
8.3.280.0080.01218.60
8.3.270.0080.01216.53
8.3.260.0160.00616.66
8.3.250.0070.01218.84
8.3.240.0090.00217.28
8.3.230.0090.01016.81
8.3.220.0120.00618.74
8.3.210.0130.00616.60
8.3.200.0050.00416.83
8.3.190.0100.00816.55
8.3.180.0110.00816.60
8.3.170.0130.00617.00
8.3.160.0160.00316.64
8.3.150.0000.00817.16
8.3.140.0110.00716.74
8.3.130.0030.00516.78
8.3.120.0070.00018.87
8.3.110.0060.00320.94
8.3.100.0000.00924.06
8.3.90.0070.00726.77
8.3.80.0050.00516.63
8.3.70.0170.00318.10
8.3.60.0140.00716.75
8.3.50.0180.00320.11
8.3.40.0120.00320.29
8.3.30.0110.00718.60
8.3.20.0050.00324.18
8.3.10.0040.00424.66
8.3.00.0050.00326.16
8.2.300.0130.00818.49
8.2.290.0080.01020.47
8.2.280.0100.01118.32
8.2.270.0070.01116.91
8.2.260.0070.00716.83
8.2.250.0080.00018.27
8.2.240.0130.00617.04
8.2.230.0030.00722.58
8.2.220.0060.00337.54
8.2.210.0090.00926.77
8.2.200.0080.00316.75
8.2.190.0060.00916.58
8.2.180.0040.01125.92
8.2.170.0100.00719.07
8.2.160.0080.00822.96
8.2.150.0070.00325.66
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0040.00421.01
8.2.110.0070.00421.06
8.2.100.0080.00419.57
8.2.90.0030.00517.75
8.2.80.0040.00418.91
8.2.70.0080.00017.50
8.2.60.0000.00818.05
8.2.50.0090.00018.07
8.2.40.0000.00817.99
8.2.30.0000.00818.04
8.2.20.0040.00422.41
8.2.10.0040.00418.04
8.2.00.0050.00219.32
8.1.340.0100.01017.68
8.1.330.0120.00622.02
8.1.320.0130.00916.43
8.1.310.0110.00416.78
8.1.300.0090.00916.16
8.1.290.0090.00018.88
8.1.280.0110.00425.92
8.1.270.0000.00823.96
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0040.00422.56
8.1.230.0060.00617.82
8.1.220.0000.00817.74
8.1.210.0080.00018.77
8.1.200.0090.00017.25
8.1.190.0040.00417.23
8.1.180.0000.00818.10
8.1.170.0080.00018.62
8.1.160.0040.00418.91
8.1.150.0040.00418.71
8.1.140.0000.00717.54
8.1.130.0040.00419.27
8.1.120.0080.00417.42
8.1.110.0090.00317.39
8.1.100.0050.00617.42
8.1.90.0100.00417.39
8.1.80.0120.00517.44
8.1.70.0130.00417.43
8.1.60.0100.00717.45
8.1.50.0110.00417.49
8.1.40.0090.00617.52
8.1.30.0170.00117.58
8.1.20.0180.00217.61
8.1.10.0130.00517.50
8.1.00.0190.00217.55
8.0.300.0000.00718.77
8.0.290.0000.00916.75
8.0.280.0080.00018.52
8.0.270.0030.00316.76
8.0.260.0030.00316.74
8.0.250.0110.00516.91
8.0.240.0070.00816.94
8.0.230.0070.00916.96
8.0.220.0160.00216.87
8.0.210.0120.00516.89
8.0.200.0120.00516.85
8.0.190.0120.00516.91
8.0.180.0140.00416.85
8.0.170.0130.00416.88
8.0.160.0110.00716.80
8.0.150.0140.00416.80
8.0.140.0150.00116.77
8.0.130.0130.00416.84
8.0.120.0160.00216.83
8.0.110.0090.00716.82
8.0.100.0100.00816.75
8.0.90.0160.00116.92
8.0.80.0130.00416.84
8.0.70.0150.00216.79
8.0.60.0130.00416.82
8.0.50.0170.00216.88
8.0.30.0130.00516.77
8.0.20.0080.00717.01
8.0.10.0070.00616.87
7.4.330.0000.00515.55
7.4.320.0100.00516.41
7.4.300.0030.00416.51
7.4.290.0100.00216.53
7.4.280.0030.00516.48
7.4.270.0090.00116.57
7.4.260.0120.00616.53
7.4.250.0150.00316.53
7.4.240.0130.00316.43
7.4.230.0130.00416.50
7.4.220.0110.00416.51
7.4.210.0070.00816.56
7.4.200.0090.00516.48
7.4.190.0100.00516.62
7.4.180.0070.00816.53
7.4.160.0070.00716.64
7.4.150.0100.00516.56
7.4.140.0080.00616.40
7.4.130.0110.00416.40
7.4.120.0110.00316.44
7.4.110.0110.00316.37
7.4.100.0110.00416.47
7.4.90.0120.00316.47
7.4.80.0110.00416.40
7.4.70.0140.00116.48
7.4.60.0130.00116.44
7.4.50.0070.00816.46
7.4.40.0070.00316.43
7.4.30.0130.00016.40
7.4.20.0070.00416.39
7.4.10.0080.00316.36
7.4.00.0080.00416.51

preferences:
41.7 ms | 1252 KiB | 5 Q